Changeset 3453606
- Timestamp:
- 02/04/2026 08:33:36 AM (5 weeks ago)
- Location:
- embed-stl/trunk
- Files:
-
- 7 edited
-
block.asset.php (modified) (2 diffs)
-
block.js (modified) (5 diffs)
-
block.json (modified) (3 diffs)
-
index.php (modified) (5 diffs)
-
public/js/stl_viewer.min.asset.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
style.asset.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
embed-stl/trunk/block.asset.php
r2627009 r3453606 3 3 'dependencies' => array( 4 4 'wp-blocks', 5 'wp- editor',5 'wp-block-editor', 6 6 'wp-i18n', 7 7 'wp-element', … … 9 9 'underscore' 10 10 ), 11 'version' => '1.0. 1'11 'version' => '1.0.2' 12 12 ); 13 13 ?> -
embed-stl/trunk/block.js
r2627009 r3453606 94 94 95 95 edit: function( props ) { 96 var ref = element.useRef(); 97 var blockProps = blockEditor.useBlockProps({ref: ref}); 96 98 var attributes = props.attributes; 97 99 if (!attributes.blockID) props.setAttributes({blockID: props.clientId.replaceAll("-","_")}); … … 127 129 if (!stlPreview) { 128 130 if (attributes.blockID) stlPreview = viewers[attributes.blockID]; 129 if (!stlPreview ) {130 var previewElement = document.getElementById('stl-preview-' + attributes.blockID);131 if (!stlPreview && ref.current) { 132 var previewElement = ref.current.getElementsByClassName("embed-stl-target")[0]; 131 133 if (previewElement) { 132 134 stlPreview = new StlViewer(previewElement, {all_loaded_callback: modelsLoadedCallback, zoom: 1, allow_drag_and_drop: false, send_no_model_click_event: true}); … … 225 227 var onOverlayIconChanged = function(newValue) { 226 228 props.setAttributes({hideOverlayIcon: newValue}); 227 228 var e = document.getElementById('stl-preview-' + attributes.blockID).getElementsByClassName("embed-stl-cube-icon")[0]; 229 var e = ref.current.getElementsByClassName("embed-stl-cube-icon")[0]; 229 230 e.classList.toggle("embed-stl-hidden", newValue); 230 231 } … … 233 234 234 235 return [el('div', 235 { className: props.className },236 blockProps, 236 237 el('div', 237 238 { className: 'selected-model' }, … … 286 287 } )( 287 288 window.wp.blocks, 288 window.wp. editor,289 window.wp.blockEditor, 289 290 window.wp.i18n, 290 291 window.wp.element, -
embed-stl/trunk/block.json
r2627009 r3453606 1 1 { 2 2 "$schema": "https://schemas.wp.org/trunk/block.json", 3 "apiVersion": 1,3 "apiVersion": 3, 4 4 "name": "embed-stl/embed-stl", 5 5 "title": "Embed STL", … … 7 7 "description": "Embeds an STL model as an interactive 3D preview", 8 8 "keywords": ["3d", "model", "stl"], 9 "version": "1.0. 1",9 "version": "1.0.2", 10 10 "textdomain": "embed-stl", 11 11 "attributes": { … … 75 75 } 76 76 }, 77 "editorScript": "file:./block.js",78 " script": "file:./public/js/stl_viewer.min.js",77 "editorScript": ["file:./block.js", "embed-stl-viewer"], 78 "viewScript": "embed-stl-viewer", 79 79 "style": "file:./style.css" 80 80 } -
embed-stl/trunk/index.php
r2627009 r3453606 6 6 * Plugin URI: https://github.com/mmdoogie/embed-stl 7 7 * Description: Adds STL as a media type for uploads, provides editor block for embeddable viewer based on viewstl plugin 8 * Version: 1.0. 19 * Requires at least: 5.88 * Version: 1.0.2 9 * Requires at least: 6.3 10 10 * Requires PHP: 7.0 11 11 * Author: mmdoogie … … 27 27 28 28 function embed_stl_register_block() { 29 $script_url = plugins_url('/public/js/stl_viewer.min.js', __FILE__); 30 wp_register_script( 31 'embed-stl-viewer', 32 $script_url, 33 array(), 34 '1.13', 35 true 36 ); 37 38 wp_add_inline_script( 39 'embed-stl-viewer', 40 'var stl_viewer_script_path = "' . esc_js(plugins_url('/public/js/', __FILE__)) . '";', 41 'before' 42 ); 43 29 44 register_block_type(__DIR__, array('render_callback' => 'embed_stl_render_callback')); 30 45 if (function_exists('wp_set_script_translations')) { … … 57 72 ob_start(); 58 73 59 echo('<div class="wp-block-embed-stl-embed-stl">' . PHP_EOL);74 echo('<div ' . get_block_wrapper_attributes() . ' >' . PHP_EOL); 60 75 printf('<div id="stl-preview-%s" class="embed-stl-target embed-stl-size-%s %s">' . PHP_EOL, esc_attr($attrs['blockID']), esc_attr($attrs['blockSize']), esc_attr($attrs['showBorder'] ? 'embed-stl-yes-border' : '')); 61 76 if (!$attrs['hideOverlayIcon']) { … … 63 78 } 64 79 echo('</div>' . PHP_EOL . '<script>' . PHP_EOL); 80 echo('document.addEventListener("DOMContentLoaded", function() {' . PHP_EOL); 65 81 printf('var e = document.getElementById("stl-preview-%1$s"); var stlView_%1$s = new StlViewer(e, %2$s);' . PHP_EOL, esc_attr($attrs['blockID']), wp_json_encode($viewerParams)); 66 82 printf('function stlView_%1$s_recenter(id,evt,dist,ct) { if (ct != 11) return; v=stlView_%1$s; c=v.get_camera_state(); c.position={...c.position, x:0, y:0, z:v.calc_z_for_auto_zoom()}; c.target={...c.target, x:0, y:0, z:0}; v.set_camera_state(c);};' . PHP_EOL, esc_attr($attrs['blockID'])); … … 69 85 printf('stlView_%1$s.set_on_model_mousedown(stlView_%1$s_recenter);' . PHP_EOL, esc_attr($attrs['blockID'])); 70 86 printf('stlView_%1$s.all_loaded_callback=stlView_%1$s_orient;' . PHP_EOL, esc_attr($attrs['blockID'])); 87 echo('});' . PHP_EOL); 71 88 echo('</script>' . PHP_EOL . '</div>' . PHP_EOL); 72 89 -
embed-stl/trunk/public/js/stl_viewer.min.asset.php
r2626872 r3453606 1 1 <?php 2 2 return array( 3 'version' => '1.13' 3 'dependencies' => array(), 4 'version' => '1.13' 4 5 ); 5 6 ?> -
embed-stl/trunk/readme.txt
r2970785 r3453606 3 3 Contributors: mmdoogie 4 4 Tags: stl, 3d, block 5 Requires at least: 5.86 Tested up to: 6. 37 Stable tag: 1.0. 15 Requires at least: 6.3 6 Tested up to: 6.9 7 Stable tag: 1.0.2 8 8 Requires PHP: 7.0 9 9 License: MIT … … 34 34 == Changelog == 35 35 36 = 1.0.2 = 37 38 * Update block to apiVersion 3, fix compatibility with newer versions 39 36 40 = 1.0.1 = 37 41 … … 44 48 == Upgrade Notice == 45 49 50 = 1.0.2 = 51 52 * Compatibility with WP 6.3+ only 53 46 54 = 1.0.1 = 47 55 -
embed-stl/trunk/style.asset.php
r2627009 r3453606 1 1 <?php 2 2 return array( 3 'version' => '1.0. 1'3 'version' => '1.0.2' 4 4 ); 5 5 ?>
Note: See TracChangeset
for help on using the changeset viewer.