Plugin Directory

Changeset 3453606


Ignore:
Timestamp:
02/04/2026 08:33:36 AM (5 weeks ago)
Author:
mmdoogie
Message:

Uploading embed-stl 1.0.2

Location:
embed-stl/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • embed-stl/trunk/block.asset.php

    r2627009 r3453606  
    33        'dependencies' => array(
    44                'wp-blocks',
    5                 'wp-editor',
     5                'wp-block-editor',
    66                'wp-i18n',
    77                'wp-element',
     
    99                'underscore'
    1010        ),
    11         'version' => '1.0.1'
     11        'version' => '1.0.2'
    1212);
    1313?>
  • embed-stl/trunk/block.js

    r2627009 r3453606  
    9494       
    9595        edit: function( props ) {
     96            var ref = element.useRef();
     97            var blockProps = blockEditor.useBlockProps({ref: ref});
    9698            var attributes = props.attributes;
    9799            if (!attributes.blockID) props.setAttributes({blockID: props.clientId.replaceAll("-","_")});
     
    127129                if (!stlPreview) {
    128130                    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];
    131133                        if (previewElement) {
    132134                            stlPreview = new StlViewer(previewElement, {all_loaded_callback: modelsLoadedCallback, zoom: 1, allow_drag_and_drop: false, send_no_model_click_event: true});
     
    225227            var onOverlayIconChanged = function(newValue) {
    226228                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];
    229230                e.classList.toggle("embed-stl-hidden", newValue);
    230231            }
     
    233234
    234235            return [el('div',
    235                 { className: props.className },
     236                blockProps,
    236237                el('div',
    237238                    { className: 'selected-model' },
     
    286287} )(
    287288    window.wp.blocks,
    288     window.wp.editor,
     289    window.wp.blockEditor,
    289290    window.wp.i18n,
    290291    window.wp.element,
  • embed-stl/trunk/block.json

    r2627009 r3453606  
    11{
    22    "$schema": "https://schemas.wp.org/trunk/block.json",
    3     "apiVersion": 1,
     3    "apiVersion": 3,
    44    "name": "embed-stl/embed-stl",
    55    "title": "Embed STL",
     
    77    "description": "Embeds an STL model as an interactive 3D preview",
    88    "keywords": ["3d", "model", "stl"],
    9     "version": "1.0.1",
     9    "version": "1.0.2",
    1010    "textdomain": "embed-stl",
    1111    "attributes": {
     
    7575        }
    7676    },
    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",
    7979    "style": "file:./style.css"
    8080}
  • embed-stl/trunk/index.php

    r2627009 r3453606  
    66 * Plugin URI: https://github.com/mmdoogie/embed-stl
    77 * Description: Adds STL as a media type for uploads, provides editor block for embeddable viewer based on viewstl plugin
    8  * Version: 1.0.1
    9  * Requires at least: 5.8
     8 * Version: 1.0.2
     9 * Requires at least: 6.3
    1010 * Requires PHP: 7.0
    1111 * Author: mmdoogie
     
    2727
    2828function 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
    2944    register_block_type(__DIR__, array('render_callback' => 'embed_stl_render_callback'));
    3045    if (function_exists('wp_set_script_translations')) {
     
    5772    ob_start();
    5873
    59     echo('<div class="wp-block-embed-stl-embed-stl">' . PHP_EOL);
     74    echo('<div ' . get_block_wrapper_attributes() . ' >' . PHP_EOL);
    6075    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' : ''));
    6176    if (!$attrs['hideOverlayIcon']) {
     
    6378    }
    6479    echo('</div>'  . PHP_EOL . '<script>' . PHP_EOL);
     80    echo('document.addEventListener("DOMContentLoaded", function() {' . PHP_EOL);
    6581    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));
    6682    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']));
     
    6985    printf('stlView_%1$s.set_on_model_mousedown(stlView_%1$s_recenter);' . PHP_EOL, esc_attr($attrs['blockID']));
    7086    printf('stlView_%1$s.all_loaded_callback=stlView_%1$s_orient;' . PHP_EOL, esc_attr($attrs['blockID']));
     87    echo('});' . PHP_EOL);
    7188    echo('</script>' . PHP_EOL . '</div>' . PHP_EOL);
    7289
  • embed-stl/trunk/public/js/stl_viewer.min.asset.php

    r2626872 r3453606  
    11<?php
    22return array(
    3         'version' => '1.13'
     3    'dependencies' => array(),
     4    'version' => '1.13'
    45);
    56?>
  • embed-stl/trunk/readme.txt

    r2970785 r3453606  
    33Contributors: mmdoogie
    44Tags: stl, 3d, block
    5 Requires at least: 5.8
    6 Tested up to: 6.3
    7 Stable tag: 1.0.1
     5Requires at least: 6.3
     6Tested up to: 6.9
     7Stable tag: 1.0.2
    88Requires PHP: 7.0
    99License: MIT
     
    3434== Changelog ==
    3535
     36= 1.0.2 =
     37
     38* Update block to apiVersion 3, fix compatibility with newer versions
     39
    3640= 1.0.1 =
    3741
     
    4448== Upgrade Notice ==
    4549
     50= 1.0.2 =
     51
     52* Compatibility with WP 6.3+ only
     53
    4654= 1.0.1 =
    4755
  • embed-stl/trunk/style.asset.php

    r2627009 r3453606  
    11<?php
    22return array(
    3         'version' => '1.0.1'
     3        'version' => '1.0.2'
    44);
    55?>
Note: See TracChangeset for help on using the changeset viewer.