diff --git a/dist/mathml-block.js b/dist/mathml-block.js index 4549daab..1f209f15 100644 --- a/dist/mathml-block.js +++ b/dist/mathml-block.js @@ -1 +1 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",r=t[3];if(!r)return n;if(e&&"function"==typeof btoa){var o=(i=r,c=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(c),"/*# ".concat(u," */")),a=r.sources.map((function(t){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(t," */")}));return[n].concat(a).concat([o]).join("\n")}var i,c,u;return[n].join("\n")}(e,t);return e[2]?"@media ".concat(e[2]," {").concat(n,"}"):n})).join("")},e.i=function(t,n,r){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(r)for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:0,n=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!c(n))throw TypeError("Stringified UUID is invalid");return n};var f=function(t,e,n){var r=(t=t||{}).random||(t.rng||a)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=r[o];return e}return l(r)},d=wp.i18n.__,m=wp.blocks.registerBlockType;m("mathml/mathmlblock",{title:"MathML",icon:"list-view",category:"common",attributes:{formula:{source:"html",selector:"div",type:"string"}},edit:function(t){var e=t.isSelected,n=t.attributes,r=t.setAttributes,o=t.className,a=n.formula,i=f();return function(t){setTimeout((function(){MathJax.Hub.Queue(["Typeset",MathJax.Hub,document.getElementById(t)])}),100)}(i),e?React.createElement("div",{className:o},React.createElement("label",{htmlFor:i},d("MathML formula:","mathml-block")),React.createElement("textarea",{id:i,className:"mathml-formula",tagname:"div",onChange:function(t){r({formula:t.target.value})},value:a,style:{width:"100%"}})):React.createElement("div",{id:i,className:"mathml-block"},a)},save:function(t){var e=t.attributes,n=t.className,r=e.formula;return React.createElement("div",{className:n},r)}})}]); \ No newline at end of file +!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var r=wp.primitives,o=r.SVG,a=r.Path;e.a=React.createElement(o,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},React.createElement(a,{d:"M 5 19.355 L 12.755 12.209 L 5.157 4.464 L 5.157 4 L 18.28 4 L 18.28 8.405 L 17.821 8.405 C 17.701 7.046 17.275 6.125 16.543 5.642 C 15.773 5.181 14.754 4.959 13.484 4.974 L 8.553 4.974 L 14.772 11.677 L 8.115 17.769 L 16.498 17.769 C 17.111 17.754 17.507 17.501 17.686 17.011 C 17.843 16.543 17.921 16.041 17.921 15.505 L 18.381 15.505 L 18.381 20 L 5 20 L 5 19.355 Z"}))},function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",r=t[3];if(!r)return n;if(e&&"function"==typeof btoa){var o=(i=r,c=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(c),"/*# ".concat(u," */")),a=r.sources.map((function(t){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(t," */")}));return[n].concat(a).concat([o]).join("\n")}var i,c,u;return[n].join("\n")}(e,t);return e[2]?"@media ".concat(e[2]," {").concat(n,"}"):n})).join("")},e.i=function(t,n,r){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(r)for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:0,n=(u[t[e+0]]+u[t[e+1]]+u[t[e+2]]+u[t[e+3]]+"-"+u[t[e+4]]+u[t[e+5]]+"-"+u[t[e+6]]+u[t[e+7]]+"-"+u[t[e+8]]+u[t[e+9]]+"-"+u[t[e+10]]+u[t[e+11]]+u[t[e+12]]+u[t[e+13]]+u[t[e+14]]+u[t[e+15]]).toLowerCase();if(!c(n))throw TypeError("Stringified UUID is invalid");return n};var f=function(t,e,n){var r=(t=t||{}).random||(t.rng||a)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=r[o];return e}return l(r)},d=n(0),m=wp.i18n.__,p=wp.blocks.registerBlockType;p("mathml/mathmlblock",{title:"MathML",icon:d.a,category:"common",attributes:{formula:{source:"html",selector:"div",type:"string"}},edit:function(t){var e=t.isSelected,n=t.attributes,r=t.setAttributes,o=t.className,a=n.formula,i=f();return function(t){setTimeout((function(){MathJax.Hub.Queue(["Typeset",MathJax.Hub,document.getElementById(t)])}),100)}(i),e?React.createElement("div",{className:o},React.createElement("label",{htmlFor:i},m("MathML formula:","mathml-block")),React.createElement("textarea",{id:i,className:"mathml-formula",tagname:"div",onChange:function(t){r({formula:t.target.value})},value:a,style:{width:"100%"}})):React.createElement("div",{id:i,className:"mathml-block"},a)},save:function(t){var e=t.attributes,n=t.className,r=e.formula;return React.createElement("div",{className:n},r)}})}]); \ No newline at end of file diff --git a/src/icon.js b/src/icon.js new file mode 100644 index 00000000..1b4a730d --- /dev/null +++ b/src/icon.js @@ -0,0 +1,7 @@ +const { SVG, Path } = wp.primitives; + +export default ( + + + +); diff --git a/src/mathml-block.js b/src/mathml-block.js index 5b56a22c..0ad2321a 100644 --- a/src/mathml-block.js +++ b/src/mathml-block.js @@ -1,4 +1,5 @@ import { v4 as uuid } from 'uuid'; +import icon from './icon'; const { __ } = wp.i18n; const { registerBlockType } = wp.blocks; @@ -11,7 +12,7 @@ const renderMathML = ( id ) => { registerBlockType( 'mathml/mathmlblock', { title: 'MathML', - icon: 'list-view', + icon, category: 'common', attributes: { formula: { diff --git a/src/mathml-inline.js b/src/mathml-inline.js index 916802bf..e32c0b7d 100644 --- a/src/mathml-inline.js +++ b/src/mathml-inline.js @@ -1,3 +1,4 @@ +import icon from './icon'; const { createElement, Fragment } = window.wp.element; const { registerFormatType, toggleFormat } = window.wp.richText; const { RichTextToolbarButton, RichTextShortcut } = window.wp.blockEditor; @@ -34,6 +35,7 @@ import './mathml-block.css'; } ), createElement( RichTextToolbarButton, { title, + icon, onClick: onToggle, isActive, shortcutType: 'primary',