@aquera/nile-elements 1.9.8 → 1.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/{index-249de90a.esm.js → index-289706c7.esm.js} +1 -1
- package/dist/{index-df196058.cjs.js → index-d7e6f1c6.cjs.js} +2 -2
- package/dist/index-d7e6f1c6.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1577 -1275
- package/dist/katex-44476ab4.esm.js +1 -0
- package/dist/katex-f4186f87.cjs.js +2 -0
- package/dist/katex-f4186f87.cjs.js.map +1 -0
- package/dist/nile-color-picker/index.cjs.js +1 -1
- package/dist/nile-color-picker/index.esm.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
- package/dist/nile-color-picker/nile-color-picker.cjs.js.map +1 -1
- package/dist/nile-color-picker/nile-color-picker.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/commands.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/create-state.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/inputrules.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/keymap.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/keymap.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/code-highlight.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embed-view.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/embeds.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/math-view.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/style-block-view.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/plugins/tables.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/sanitize.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/schema.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/engine/selection-state.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/math/katex-renderer.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/math/katex-renderer.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +22 -3
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +7 -6
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.esm.js +33 -54
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.esm.js +83 -95
- package/dist/nile-wysiwyg-editor/types.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/types.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/types.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-item.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-item.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +23 -15
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +3 -3
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.esm.js +2 -2
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.esm.js +0 -3
- package/dist/nile-wysiwyg-editor/ui/preview.cjs.js +2 -0
- package/dist/nile-wysiwyg-editor/ui/preview.cjs.js.map +1 -0
- package/dist/nile-wysiwyg-editor/ui/preview.esm.js +8 -0
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.esm.js +225 -24
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.esm.js +9 -9
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.esm.js +115 -13
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +13 -12
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-color-picker/nile-color-picker.d.ts +1 -0
- package/dist/src/nile-color-picker/nile-color-picker.js +1 -0
- package/dist/src/nile-color-picker/nile-color-picker.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/index.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js +3 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embed-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.d.ts +19 -4
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js +23 -18
- package/dist/src/nile-wysiwyg-editor/engine/plugins/embeds.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.d.ts +8 -3
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js +41 -4
- package/dist/src/nile-wysiwyg-editor/engine/plugins/math-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.d.ts +17 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js +174 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/style-block-view.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js +33 -2
- package/dist/src/nile-wysiwyg-editor/engine/plugins/tables.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js +49 -8
- package/dist/src/nile-wysiwyg-editor/engine/pm.test.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.d.ts +12 -0
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js +76 -8
- package/dist/src/nile-wysiwyg-editor/engine/sanitize.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/engine/schema.d.ts +2 -0
- package/dist/src/nile-wysiwyg-editor/engine/schema.js +154 -2
- package/dist/src/nile-wysiwyg-editor/engine/schema.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/index.d.ts +5 -0
- package/dist/src/nile-wysiwyg-editor/index.js +3 -0
- package/dist/src/nile-wysiwyg-editor/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.d.ts +38 -0
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js +40 -0
- package/dist/src/nile-wysiwyg-editor/math/katex-renderer.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +22 -3
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.d.ts +36 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +125 -8
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js +5 -2
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.d.ts +2 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.d.ts +55 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js +79 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js +33 -54
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.d.ts +50 -2
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js +158 -102
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/types.d.ts +4 -2
- package/dist/src/nile-wysiwyg-editor/types.js +2 -2
- package/dist/src/nile-wysiwyg-editor/types.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.d.ts +48 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js +69 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-item.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.d.ts +17 -2
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js +128 -35
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.d.ts +2 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js +4 -3
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js +0 -3
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/preview.d.ts +20 -0
- package/dist/src/nile-wysiwyg-editor/ui/preview.js +44 -0
- package/dist/src/nile-wysiwyg-editor/ui/preview.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/source-view.d.ts +35 -3
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js +337 -24
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js +9 -0
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.d.ts +13 -2
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js +166 -10
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.d.ts +1 -0
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js +10 -8
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/xml-25c4108a.esm.js +1 -0
- package/dist/xml-90fd974e.cjs.js +2 -0
- package/dist/xml-90fd974e.cjs.js.map +1 -0
- package/package.json +2 -1
- package/rollup.config.js +1 -0
- package/src/index.ts +8 -0
- package/src/nile-color-picker/nile-color-picker.ts +1 -0
- package/src/nile-wysiwyg-editor/engine/index.ts +1 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embed-view.ts +3 -0
- package/src/nile-wysiwyg-editor/engine/plugins/embeds.ts +26 -20
- package/src/nile-wysiwyg-editor/engine/plugins/math-view.ts +45 -4
- package/src/nile-wysiwyg-editor/engine/plugins/style-block-view.ts +178 -0
- package/src/nile-wysiwyg-editor/engine/plugins/tables.ts +34 -2
- package/src/nile-wysiwyg-editor/engine/pm.test.ts +58 -8
- package/src/nile-wysiwyg-editor/engine/sanitize.ts +71 -8
- package/src/nile-wysiwyg-editor/engine/schema.ts +158 -7
- package/src/nile-wysiwyg-editor/index.ts +5 -0
- package/src/nile-wysiwyg-editor/math/katex-renderer.ts +59 -0
- package/src/nile-wysiwyg-editor/math/katex.d.ts +17 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +22 -3
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.test.ts +5 -2
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +142 -7
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.ts +2 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar-item.ts +68 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.ts +33 -54
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.ts +202 -108
- package/src/nile-wysiwyg-editor/types.ts +6 -4
- package/src/nile-wysiwyg-editor/ui/bubble-item.ts +60 -0
- package/src/nile-wysiwyg-editor/ui/bubble-menu.ts +147 -40
- package/src/nile-wysiwyg-editor/ui/embed-panel.ts +4 -3
- package/src/nile-wysiwyg-editor/ui/math-panel.ts +0 -3
- package/src/nile-wysiwyg-editor/ui/preview.ts +42 -0
- package/src/nile-wysiwyg-editor/ui/source-view.ts +339 -31
- package/src/nile-wysiwyg-editor/ui/suggest-list.ts +10 -0
- package/src/nile-wysiwyg-editor/ui/table-grid-picker.ts +160 -10
- package/src/nile-wysiwyg-editor/ui/table-menu.ts +10 -8
- package/vscode-html-custom-data.json +75 -6
- package/dist/index-df196058.cjs.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["./image-view.cjs.js","../../../index-89c520e9.cjs.js"],function(_export,_context){"use strict";var t,i,s;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[function(_imageViewCjsJs){t=_imageViewCjsJs.a;i=_imageViewCjsJs.i;},function(_index00aCjsJs){}],execute:function execute(){_export("E",
|
|
1
|
+
System.register(["./image-view.cjs.js","./embeds.cjs.js","../../../index-89c520e9.cjs.js"],function(_export,_context){"use strict";var t,i,s,e,r;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[function(_imageViewCjsJs){t=_imageViewCjsJs.a;i=_imageViewCjsJs.i;},function(_embedsCjsJs){s=_embedsCjsJs.E;e=_embedsCjsJs.a;},function(_index00aCjsJs){}],execute:function execute(){_export("E",r=/*#__PURE__*/function(){function r(i,_r,a){_classCallCheck(this,r);this.node=i,this.dom=document.createElement("div"),this.dom.className="nile-wysiwyg__embed",this.iframe=document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.iframe.setAttribute("allowfullscreen","true"),this.iframe.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),this.iframe.setAttribute("sandbox",s),this.iframe.setAttribute("referrerpolicy",e),this.dom.appendChild(this.iframe),this.applyAttrs(i),t(this.dom,this.dom,function(t){var i=a();if(void 0===i||!_r.editable)return;var s=_r.state.doc.nodeAt(i);s&&_r.dispatch(_r.state.tr.setNodeMarkup(i,void 0,_objectSpread(_objectSpread({},s.attrs),{},{width:t})));},160);}return _createClass(r,[{key:"applyAttrs",value:function applyAttrs(t){var _t$attrs=t.attrs,i=_t$attrs.src,s=_t$attrs.provider,e=_t$attrs.title,_r2=_t$attrs.width,a=_t$attrs.align;this.iframe.getAttribute("src")!==i&&this.iframe.setAttribute("src",i),this.dom.setAttribute("data-embed-provider",s!==null&&s!==void 0?s:"generic"),e?this.iframe.title=e:this.iframe.removeAttribute("title"),_r2?(this.dom.setAttribute("data-width",String(_r2)),this.dom.style.width="".concat(_r2,"px")):(this.dom.removeAttribute("data-width"),this.dom.style.width=""),a?this.dom.setAttribute("data-align",a):this.dom.removeAttribute("data-align"),this.dom.style.marginLeft="center"===a||"right"===a?"auto":"",this.dom.style.marginRight="center"===a?"auto":"";}},{key:"update",value:function update(t){return t.type===this.node.type&&(this.node=t,this.applyAttrs(t),!0);}},{key:"stopEvent",value:function stopEvent(t){return i(t);}},{key:"ignoreMutation",value:function ignoreMutation(){return!0;}}]);}());}};});
|
|
2
2
|
//# sourceMappingURL=embed-view.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed-view.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/embed-view.ts"],"sourcesContent":["import { Node as PMNode } from 'prosemirror-model';\nimport { EditorView, NodeView } from 'prosemirror-view';\nimport { attachResizeHandles, isResizeEvent } from './image-view';\n\n/** Below this a 16:9 player is unusable and its own controls stop fitting. */\nconst MIN_EMBED_WIDTH = 160;\n\n/**\n * Video embed (YouTube/Vimeo/Loom) with the same corner drag-resize handles\n * as images. Only the width is dragged; the 16:9 aspect ratio comes from CSS,\n * so the height follows automatically.\n */\nexport class EmbedView implements NodeView {\n dom: HTMLDivElement;\n\n private iframe: HTMLIFrameElement;\n\n constructor(\n private node: PMNode,\n view: EditorView,\n getPos: () => number | undefined\n ) {\n this.dom = document.createElement('div');\n this.dom.className = 'nile-wysiwyg__embed';\n this.iframe = document.createElement('iframe');\n this.iframe.setAttribute('frameborder', '0');\n this.iframe.setAttribute('allowfullscreen', 'true');\n this.iframe.setAttribute(\n 'allow',\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'\n );\n this.dom.appendChild(this.iframe);\n this.applyAttrs(node);\n\n attachResizeHandles(\n this.dom,\n this.dom,\n width => {\n const pos = getPos();\n if (pos === undefined || !view.editable) return;\n const current = view.state.doc.nodeAt(pos);\n if (!current) return;\n view.dispatch(\n view.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, width })\n );\n },\n MIN_EMBED_WIDTH\n );\n }\n\n private applyAttrs(node: PMNode): void {\n const { src, provider, title, width, align } = node.attrs;\n if (this.iframe.getAttribute('src') !== src) this.iframe.setAttribute('src', src);\n this.dom.setAttribute('data-embed-provider', provider ?? 'generic');\n if (title) this.iframe.title = title;\n else this.iframe.removeAttribute('title');\n if (width) {\n this.dom.setAttribute('data-width', String(width));\n this.dom.style.width = `${width}px`;\n } else {\n this.dom.removeAttribute('data-width');\n this.dom.style.width = '';\n }\n // Block alignment via auto margins (mirrors the image figure).\n if (align) this.dom.setAttribute('data-align', align);\n else this.dom.removeAttribute('data-align');\n this.dom.style.marginLeft = align === 'center' || align === 'right' ? 'auto' : '';\n this.dom.style.marginRight = align === 'center' ? 'auto' : '';\n }\n\n update(node: PMNode): boolean {\n if (node.type !== this.node.type) return false;\n this.node = node;\n this.applyAttrs(node);\n return true;\n }\n\n stopEvent(event: Event): boolean {\n return isResizeEvent(event);\n }\n\n ignoreMutation(): boolean {\n return true;\n }\n}\n"],"names":["EmbedView","
|
|
1
|
+
{"version":3,"file":"embed-view.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/embed-view.ts"],"sourcesContent":["import { Node as PMNode } from 'prosemirror-model';\nimport { EditorView, NodeView } from 'prosemirror-view';\nimport { attachResizeHandles, isResizeEvent } from './image-view';\nimport { EMBED_SANDBOX, EMBED_REFERRER_POLICY } from './embeds';\n\n/** Below this a 16:9 player is unusable and its own controls stop fitting. */\nconst MIN_EMBED_WIDTH = 160;\n\n/**\n * Video embed (YouTube/Vimeo/Loom) with the same corner drag-resize handles\n * as images. Only the width is dragged; the 16:9 aspect ratio comes from CSS,\n * so the height follows automatically.\n */\nexport class EmbedView implements NodeView {\n dom: HTMLDivElement;\n\n private iframe: HTMLIFrameElement;\n\n constructor(\n private node: PMNode,\n view: EditorView,\n getPos: () => number | undefined\n ) {\n this.dom = document.createElement('div');\n this.dom.className = 'nile-wysiwyg__embed';\n this.iframe = document.createElement('iframe');\n this.iframe.setAttribute('frameborder', '0');\n this.iframe.setAttribute('allowfullscreen', 'true');\n this.iframe.setAttribute(\n 'allow',\n 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'\n );\n this.iframe.setAttribute('sandbox', EMBED_SANDBOX);\n this.iframe.setAttribute('referrerpolicy', EMBED_REFERRER_POLICY);\n this.dom.appendChild(this.iframe);\n this.applyAttrs(node);\n\n attachResizeHandles(\n this.dom,\n this.dom,\n width => {\n const pos = getPos();\n if (pos === undefined || !view.editable) return;\n const current = view.state.doc.nodeAt(pos);\n if (!current) return;\n view.dispatch(\n view.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, width })\n );\n },\n MIN_EMBED_WIDTH\n );\n }\n\n private applyAttrs(node: PMNode): void {\n const { src, provider, title, width, align } = node.attrs;\n if (this.iframe.getAttribute('src') !== src) this.iframe.setAttribute('src', src);\n this.dom.setAttribute('data-embed-provider', provider ?? 'generic');\n if (title) this.iframe.title = title;\n else this.iframe.removeAttribute('title');\n if (width) {\n this.dom.setAttribute('data-width', String(width));\n this.dom.style.width = `${width}px`;\n } else {\n this.dom.removeAttribute('data-width');\n this.dom.style.width = '';\n }\n // Block alignment via auto margins (mirrors the image figure).\n if (align) this.dom.setAttribute('data-align', align);\n else this.dom.removeAttribute('data-align');\n this.dom.style.marginLeft = align === 'center' || align === 'right' ? 'auto' : '';\n this.dom.style.marginRight = align === 'center' ? 'auto' : '';\n }\n\n update(node: PMNode): boolean {\n if (node.type !== this.node.type) return false;\n this.node = node;\n this.applyAttrs(node);\n return true;\n }\n\n stopEvent(event: Event): boolean {\n return isResizeEvent(event);\n }\n\n ignoreMutation(): boolean {\n return true;\n }\n}\n"],"names":["EmbedView","r","node","view","getPos","this","dom","document","createElement","className","iframe","setAttribute","EMBED_SANDBOX","EMBED_REFERRER_POLICY","appendChild","applyAttrs","attachResizeHandles","width","pos","undefined","editable","current","state","doc","nodeAt","dispatch","tr","setNodeMarkup","attrs","t","_createClass","key","value","_t$attrs","src","provider","title","align","getAttribute","removeAttribute","String","style","marginLeft","marginRight","update","type","stopEvent","event","isResizeEvent","ignoreMutation"],"mappings":"2rEAaaA,CAAAA,yBAKX,SAAAC,EACUC,CACRC,CAAAA,EAAAA,CACAC,2BAFQC,IAAIH,CAAAA,IAAAA,CAAJA,CAIRG,CAAAA,IAAAA,CAAKC,GAAMC,CAAAA,QAAAA,CAASC,cAAc,KAClCH,CAAAA,CAAAA,IAAAA,CAAKC,GAAIG,CAAAA,SAAAA,CAAY,qBACrBJ,CAAAA,IAAAA,CAAKK,OAASH,QAASC,CAAAA,aAAAA,CAAc,QACrCH,CAAAA,CAAAA,IAAAA,CAAKK,MAAOC,CAAAA,YAAAA,CAAa,cAAe,GACxCN,CAAAA,C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CAAA,MAAIA,CAAAA,CAAK2C,CAAAA,IAAAA,GAASxC,IAAKH,CAAAA,IAAAA,CAAK2C,OAC5BxC,IAAKH,CAAAA,IAAAA,CAAOA,CACZG,CAAAA,IAAAA,CAAKU,UAAWb,CAAAA,CAAAA,CAAAA,CAAAA,CACT,EACR,EAED,GAAA6B,GAAA,aAAAC,KAAA,UAAAc,SAAAA,CAAUC,CAAAA,CAAAA,CACR,MAAOC,CAAAA,CAAAA,CAAcD,CACtB,CAAA,EAED,GAAAhB,GAAA,kBAAAC,KAAA,UAAAiB,cAAAA,CAAAA,CAAAA,CACE,MAAO,CAAA,CACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,i}from"./image-view.esm.js";import"../../../index-6f3fa4ab.esm.js";class
|
|
1
|
+
import{a as t,i}from"./image-view.esm.js";import{E as s,a as e}from"./embeds.esm.js";import"../../../index-6f3fa4ab.esm.js";class r{constructor(i,r,a){this.node=i,this.dom=document.createElement("div"),this.dom.className="nile-wysiwyg__embed",this.iframe=document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.iframe.setAttribute("allowfullscreen","true"),this.iframe.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),this.iframe.setAttribute("sandbox",s),this.iframe.setAttribute("referrerpolicy",e),this.dom.appendChild(this.iframe),this.applyAttrs(i),t(this.dom,this.dom,(t=>{const i=a();if(void 0===i||!r.editable)return;const s=r.state.doc.nodeAt(i);s&&r.dispatch(r.state.tr.setNodeMarkup(i,void 0,{...s.attrs,width:t}))}),160)}applyAttrs(t){const{src:i,provider:s,title:e,width:r,align:a}=t.attrs;this.iframe.getAttribute("src")!==i&&this.iframe.setAttribute("src",i),this.dom.setAttribute("data-embed-provider",s??"generic"),e?this.iframe.title=e:this.iframe.removeAttribute("title"),r?(this.dom.setAttribute("data-width",String(r)),this.dom.style.width=`${r}px`):(this.dom.removeAttribute("data-width"),this.dom.style.width=""),a?this.dom.setAttribute("data-align",a):this.dom.removeAttribute("data-align"),this.dom.style.marginLeft="center"===a||"right"===a?"auto":"",this.dom.style.marginRight="center"===a?"auto":""}update(t){return t.type===this.node.type&&(this.node=t,this.applyAttrs(t),!0)}stopEvent(t){return i(t)}ignoreMutation(){return!0}}export{r as E};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["../../../index-89c520e9.cjs.js"],function(_export,_context){"use strict";var e;function
|
|
1
|
+
System.register(["../../../index-89c520e9.cjs.js"],function(_export,_context){"use strict";var e,o,t;function r(e){var o;try{o=new URL(e.trim());}catch(_unused){return null;}if("https:"!==o.protocol)return null;var t=o.hostname.replace(/^www\./,"");if("youtube.com"===t||"youtube-nocookie.com"===t||"youtu.be"===t){var _o$searchParams$get;var _e="";if("youtu.be"===t)_e=o.pathname.slice(1).split("/")[0];else if("/watch"===o.pathname)_e=(_o$searchParams$get=o.searchParams.get("v"))!==null&&_o$searchParams$get!==void 0?_o$searchParams$get:"";else{var _t=/^\/(embed|shorts)\/([\w-]+)/.exec(o.pathname);_t&&(_e=_t[2]);}if(/^[\w-]{6,20}$/.test(_e))return{src:"https://www.youtube-nocookie.com/embed/".concat(_e),provider:"youtube"};}else if("vimeo.com"===t||"player.vimeo.com"===t){var _e2=/\/(?:video\/)?(\d{6,12})(?:$|[/?])/.exec(o.pathname);if(_e2)return{src:"https://player.vimeo.com/video/".concat(_e2[1]),provider:"vimeo"};}else if("loom.com"===t){var _e3=/^\/(share|embed)\/([0-9a-f]{16,40})/.exec(o.pathname);if(_e3)return{src:"https://www.loom.com/embed/".concat(_e3[2]),provider:"loom"};}return{src:o.href,provider:"generic"};}function s(e){try{return"https:"===new URL(e.trim()).protocol;}catch(_unused2){return!1;}}function n(){return new e({props:{handlePaste:function handlePaste(e,o){var _o$clipboardData;var t=e.state;if(!t.selection.empty)return!1;var s=(_o$clipboardData=o.clipboardData)===null||_o$clipboardData===void 0||(_o$clipboardData=_o$clipboardData.getData("text/plain"))===null||_o$clipboardData===void 0?void 0:_o$clipboardData.trim();if(!s||/\s/.test(s))return!1;var n=r(s);if(!n)return!1;var i=t.schema.nodes.embed.create({src:n.src,provider:n.provider});return e.dispatch(t.tr.replaceSelectionWith(i).scrollIntoView()),!0;}}});}_export({e:n,i:s,t:r});return{setters:[function(_index00aCjsJs){e=_index00aCjsJs.b;}],execute:function execute(){_export("E",o="allow-scripts allow-same-origin allow-presentation allow-popups"),_export("a",t="strict-origin-when-cross-origin");}};});
|
|
2
2
|
//# sourceMappingURL=embeds.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embeds.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/embeds.ts"],"sourcesContent":["import { Plugin } from 'prosemirror-state';\n\nexport interface EmbedTarget {\n src: string;\n provider: 'youtube' | 'vimeo' | 'loom';\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"embeds.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/embeds.ts"],"sourcesContent":["import { Plugin } from 'prosemirror-state';\n\nexport interface EmbedTarget {\n src: string;\n provider: 'youtube' | 'vimeo' | 'loom' | 'generic';\n}\n\n/**\n * Sandbox tokens applied to every embed iframe. Notably this OMITS\n * `allow-top-navigation`, so a framed page cannot redirect the whole tab\n * (the main clickjacking/phishing vector); scripts and same-origin are\n * allowed so third-party players still run. Kept in sync with the sanitizer.\n */\nexport const EMBED_SANDBOX = 'allow-scripts allow-same-origin allow-presentation allow-popups';\n\n/** Limits the referrer leaked to the embedded third-party host. */\nexport const EMBED_REFERRER_POLICY = 'strict-origin-when-cross-origin';\n\n/**\n * Converts a URL into an embed target. Known providers (YouTube/Vimeo/Loom)\n * are canonicalized to their dedicated embed URLs; any other `https://` URL\n * is accepted as a `generic` embed. The iframe is always sandboxed on render\n * (see EMBED_SANDBOX), so untrusted hosts cannot navigate the top window.\n * Returns null only for non-https or unparseable URLs.\n */\nexport function toEmbedUrl(url: string): EmbedTarget | null {\n let parsed: URL;\n try {\n parsed = new URL(url.trim());\n } catch {\n return null;\n }\n if (parsed.protocol !== 'https:') return null;\n const host = parsed.hostname.replace(/^www\\./, '');\n\n // YouTube: watch?v=ID, youtu.be/ID, shorts/ID, embed/ID\n if (host === 'youtube.com' || host === 'youtube-nocookie.com' || host === 'youtu.be') {\n let id = '';\n if (host === 'youtu.be') id = parsed.pathname.slice(1).split('/')[0];\n else if (parsed.pathname === '/watch') id = parsed.searchParams.get('v') ?? '';\n else {\n const match = /^\\/(embed|shorts)\\/([\\w-]+)/.exec(parsed.pathname);\n if (match) id = match[2];\n }\n if (/^[\\w-]{6,20}$/.test(id)) {\n return { src: `https://www.youtube-nocookie.com/embed/${id}`, provider: 'youtube' };\n }\n }\n\n // Vimeo: vimeo.com/123456789, player.vimeo.com/video/123456789\n else if (host === 'vimeo.com' || host === 'player.vimeo.com') {\n const match = /\\/(?:video\\/)?(\\d{6,12})(?:$|[/?])/.exec(parsed.pathname);\n if (match) {\n return { src: `https://player.vimeo.com/video/${match[1]}`, provider: 'vimeo' };\n }\n }\n\n // Loom: loom.com/share/ID or loom.com/embed/ID\n else if (host === 'loom.com') {\n const match = /^\\/(share|embed)\\/([0-9a-f]{16,40})/.exec(parsed.pathname);\n if (match) {\n return { src: `https://www.loom.com/embed/${match[2]}`, provider: 'loom' };\n }\n }\n\n // Any other https URL: embed as-is, sandboxed.\n return { src: parsed.href, provider: 'generic' };\n}\n\n/**\n * True when a URL is permitted as an embed src (sanitizer check). Any\n * `https://` URL is allowed; the iframe is sandboxed at render time.\n */\nexport function isAllowedEmbedSrc(src: string): boolean {\n try {\n return new URL(src.trim()).protocol === 'https:';\n } catch {\n return false;\n }\n}\n\n/**\n * Pasting a bare provider URL onto an empty selection inserts an embed\n * instead of plain text. (Pasting over selected text still creates a link.)\n */\nexport function embedPastePlugin(): Plugin {\n return new Plugin({\n props: {\n handlePaste(view, event) {\n const { state } = view;\n if (!state.selection.empty) return false;\n const text = event.clipboardData?.getData('text/plain')?.trim();\n if (!text || /\\s/.test(text)) return false;\n const target = toEmbedUrl(text);\n if (!target) return false;\n const embed = state.schema.nodes.embed.create({\n src: target.src,\n provider: target.provider,\n });\n view.dispatch(state.tr.replaceSelectionWith(embed).scrollIntoView());\n return true;\n },\n },\n });\n}\n"],"names":["toEmbedUrl","url","parsed","URL","trim","_unused","protocol","host","hostname","replace","_o$searchParams$get","id","pathname","slice","split","searchParams","get","match","exec","test","src","provider","concat","href","isAllowedEmbedSrc","_unused2","embedPastePlugin","n","Plugin","props","handlePaste","view","event","_o$clipboardData","state","selection","empty","text","clipboardData","getData","target","embed","schema","nodes","create","dispatch","tr","replaceSelectionWith","scrollIntoView","EMBED_SANDBOX","EMBED_REFERRER_POLICY"],"mappings":"qGAyBM,QAAUA,CAAAA,CAAAA,CAAWC,CACzB,CAAA,CAAA,GAAIC,CAAAA,CACJ,CAAA,GAAA,CACEA,EAAS,GAAIC,CAAAA,GAAAA,CAAIF,CAAIG,CAAAA,IAAAA,CAAAA,CAAAA,CACtB,EAAC,MAAAC,OAAA,CAAA,CACA,MAAO,KACR,EACD,GAAwB,QAApBH,GAAAA,CAAAA,CAAOI,QAAuB,CAAA,MAAO,MACzC,GAAMC,CAAAA,CAAAA,CAAOL,CAAOM,CAAAA,QAAAA,CAASC,OAAQ,CAAA,QAAA,CAAU,EAG/C,CAAA,CAAA,GAAa,aAATF,GAAAA,CAAAA,EAAmC,sBAATA,GAAAA,CAAAA,EAA4C,UAATA,GAAAA,CAAAA,CAAqB,KAAAG,mBAAA,CACpF,GAAIC,CAAAA,EAAAA,CAAK,EACT,CAAA,GAAa,UAATJ,GAAAA,CAAAA,CAAqBI,EAAKT,CAAAA,CAAAA,CAAOU,QAASC,CAAAA,KAAAA,CAAM,CAAGC,CAAAA,CAAAA,KAAAA,CAAM,GAAK,CAAA,CAAA,CAAA,CAAA,CAAA,IAC7D,IAAwB,QAApBZ,GAAAA,CAAAA,CAAOU,QAAuBD,CAAAA,EAAAA,EAAAA,mBAAAA,CAA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@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"../../../index-6f3fa4ab.esm.js";function
|
|
1
|
+
import{b as e}from"../../../index-6f3fa4ab.esm.js";const o="allow-scripts allow-same-origin allow-presentation allow-popups",t="strict-origin-when-cross-origin";function r(e){let o;try{o=new URL(e.trim())}catch{return null}if("https:"!==o.protocol)return null;const t=o.hostname.replace(/^www\./,"");if("youtube.com"===t||"youtube-nocookie.com"===t||"youtu.be"===t){let e="";if("youtu.be"===t)e=o.pathname.slice(1).split("/")[0];else if("/watch"===o.pathname)e=o.searchParams.get("v")??"";else{const t=/^\/(embed|shorts)\/([\w-]+)/.exec(o.pathname);t&&(e=t[2])}if(/^[\w-]{6,20}$/.test(e))return{src:`https://www.youtube-nocookie.com/embed/${e}`,provider:"youtube"}}else if("vimeo.com"===t||"player.vimeo.com"===t){const e=/\/(?:video\/)?(\d{6,12})(?:$|[/?])/.exec(o.pathname);if(e)return{src:`https://player.vimeo.com/video/${e[1]}`,provider:"vimeo"}}else if("loom.com"===t){const e=/^\/(share|embed)\/([0-9a-f]{16,40})/.exec(o.pathname);if(e)return{src:`https://www.loom.com/embed/${e[2]}`,provider:"loom"}}return{src:o.href,provider:"generic"}}function s(e){try{return"https:"===new URL(e.trim()).protocol}catch{return!1}}function n(){return new e({props:{handlePaste(e,o){const{state:t}=e;if(!t.selection.empty)return!1;const s=o.clipboardData?.getData("text/plain")?.trim();if(!s||/\s/.test(s))return!1;const n=r(s);if(!n)return!1;const i=t.schema.nodes.embed.create({src:n.src,provider:n.provider});return e.dispatch(t.tr.replaceSelectionWith(i).scrollIntoView()),!0}}})}export{o as E,t as a,n as e,s as i,r as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register([],function(_export,_context){"use strict";var t;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[],execute:function execute(){_export("M",
|
|
1
|
+
System.register([],function(_export,_context){"use strict";var t,i;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}return{setters:[],execute:function execute(){t=null;_export("M",i=/*#__PURE__*/function(){function i(t,_i){_classCallCheck(this,i);this.token=0,this.renderer=_i,this.dom=document.createElement("span"),this.dom.contentEditable="false",this.render(t);}return _createClass(i,[{key:"render",value:function render(_i2){var _i2$attrs$latex,_i2$attrs$display,_this=this;var s=(_i2$attrs$latex=_i2.attrs.latex)!==null&&_i2$attrs$latex!==void 0?_i2$attrs$latex:"",h=(_i2$attrs$display=_i2.attrs.display)!==null&&_i2$attrs$display!==void 0?_i2$attrs$display:"inline";this.dom.className="block"===h?"nile-wysiwyg__math nile-wysiwyg__math--block":"nile-wysiwyg__math",this.dom.setAttribute("data-math",s),this.dom.setAttribute("data-math-display",h),this.dom.title=s;var a=++this.token;if(this.renderer)try{return void(this.dom.innerHTML=this.renderer(s,h));}catch(_unused){}this.dom.textContent=s,(t||(t=_context["import"]("../../../katex-f4186f87.cjs.js").then(function(t){return t["default"];})),t).then(function(t){if(a===_this.token)try{_this.dom.innerHTML=t.renderToString(s,{output:"mathml",displayMode:"block"===h,throwOnError:!1});}catch(_unused2){_this.dom.textContent=s;}})["catch"](function(){});}},{key:"update",value:function update(t){return"math"===t.type.name&&(this.render(t),!0);}},{key:"ignoreMutation",value:function ignoreMutation(){return!0;}}]);}());}};});
|
|
2
2
|
//# sourceMappingURL=math-view.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math-view.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/math-view.ts"],"sourcesContent":["import { Node as PMNode } from 'prosemirror-model';\nimport { NodeView } from 'prosemirror-view';\n\n/** Turns a LaTeX string into HTML (KaTeX/MathJax/MathML). Host-provided. */\nexport type MathRenderer = (latex: string, display: 'inline' | 'block') => string;\n\n/**\n * Inline atom rendering a math formula.
|
|
1
|
+
{"version":3,"file":"math-view.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/math-view.ts"],"sourcesContent":["import { Node as PMNode } from 'prosemirror-model';\nimport { NodeView } from 'prosemirror-view';\n\n/** Turns a LaTeX string into HTML (KaTeX/MathJax/MathML). Host-provided. */\nexport type MathRenderer = (latex: string, display: 'inline' | 'block') => string;\n\n/**\n * Lazy-loaded KaTeX module (loaded once, only when the first formula renders,\n * so editors without math pay nothing). Resolves to the katex default export.\n */\nlet katexPromise: Promise<{ renderToString(tex: string, opts?: Record<string, unknown>): string }> | null =\n null;\nfunction loadKatex() {\n if (!katexPromise) {\n katexPromise = import('katex').then(m => m.default);\n }\n return katexPromise;\n}\n\n/**\n * Inline atom rendering a math formula. Precedence:\n * 1. A host-supplied `mathRenderer` (full control — e.g. KaTeX HTML, MathJax).\n * 2. The built-in default: KaTeX compiled to **MathML**, which browsers render\n * natively with no stylesheet or web fonts (works cleanly inside the\n * editor's shadow root).\n * 3. If KaTeX can't load / parse, the raw LaTeX stays visible.\n */\nexport class MathView implements NodeView {\n dom: HTMLSpanElement;\n\n private renderer?: MathRenderer;\n\n /** Bumps on every render so a slow async KaTeX result for a stale node is dropped. */\n private token = 0;\n\n constructor(node: PMNode, renderer?: MathRenderer) {\n this.renderer = renderer;\n this.dom = document.createElement('span');\n this.dom.contentEditable = 'false';\n this.render(node);\n }\n\n private render(node: PMNode): void {\n const latex = (node.attrs.latex as string) ?? '';\n const display = (node.attrs.display as 'inline' | 'block') ?? 'inline';\n this.dom.className =\n display === 'block'\n ? 'nile-wysiwyg__math nile-wysiwyg__math--block'\n : 'nile-wysiwyg__math';\n this.dom.setAttribute('data-math', latex);\n this.dom.setAttribute('data-math-display', display);\n this.dom.title = latex;\n\n const token = ++this.token;\n\n // 1. Host renderer wins.\n if (this.renderer) {\n try {\n // Host renderer output is trusted (same trust level as uploadHandler).\n this.dom.innerHTML = this.renderer(latex, display);\n return;\n } catch {\n // Fall through to the built-in renderer.\n }\n }\n\n // 2. Built-in KaTeX → MathML. Show raw LaTeX until the (lazy) engine loads.\n this.dom.textContent = latex;\n loadKatex()\n .then(katex => {\n if (token !== this.token) return; // node changed while loading\n try {\n this.dom.innerHTML = katex.renderToString(latex, {\n output: 'mathml',\n displayMode: display === 'block',\n throwOnError: false,\n });\n } catch {\n this.dom.textContent = latex;\n }\n })\n .catch(() => {\n /* KaTeX unavailable — keep the raw LaTeX already shown. */\n });\n }\n\n update(node: PMNode): boolean {\n if (node.type.name !== 'math') return false;\n this.render(node);\n return true;\n }\n\n /** Atom node: ProseMirror owns selection; never read our subtree back. */\n ignoreMutation(): boolean {\n return true;\n }\n}\n"],"names":["katexPromise","_export","MathView","i","node","renderer","this","token","dom","document","createElement","contentEditable","render","_createClass","key","value","_i2$attrs$latex","_i2$attrs$display","_this","latex","attrs","display","className","setAttribute","title","innerHTML","_unused","textContent","import","then","m","default","katex","renderToString","output","displayMode","throwOnError","_unused2","update","type","name","ignoreMutation"],"mappings":"msCAUIA,CACF,CAAA,IAAA,CAAAC,OAAA,KAgBWC,CAAAA,yBAQX,SAAAC,EAAYC,CAAAA,CAAcC,EAFlBC,CAAAA,CAAAA,eAAAA,MAAAA,CAAAA,EAAAA,IAAAA,CAAKC,KAAG,CAAA,CAAA,CAGdD,IAAKD,CAAAA,QAAAA,CAAWA,GAChBC,IAAKE,CAAAA,GAAAA,CAAMC,QAASC,CAAAA,aAAAA,CAAc,MAClCJ,CAAAA,CAAAA,IAAAA,CAAKE,GAAIG,CAAAA,eAAAA,CAAkB,QAC3BL,IAAKM,CAAAA,MAAAA,CAAOR,CACb,CAAA,EAEO,OAAAS,YAAA,CAAAV,CAAA,GAAAW,GAAA,UAAAC,KAAA,UAAAH,MAAAA,CAAOR,GACb,CAAA,KAAAY,eAAA,CAAAC,iBAAA,CAAAC,KAAA,MAAA,GAAMC,CAAAA,mBAASf,GAAKgB,CAAAA,KAAAA,CAAMD,KAAoB,UAAAH,eAAA,UAAAA,eAAA,CAAA,EAAA,CACxCK,CAAWjB,EAAAA,iBAAAA,CAAAA,GAAAA,CAAKgB,KAAMC,CAAAA,OAAAA,UAAAA,iBAAAA,UAAAA,iBAAAA,CAAkC,SAC9Df,IAA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AAnBA,GAAAA,CAAAA,CAAKmC,KAAKC,IACdlC,GAAAA,IAAAA,CAAKM,MAAOR,CAAAA,CAAAA,CAAAA,CAAAA,CACL,EACR,EAGD,GAAAU,GAAA,kBAAAC,KAAA,UAAA0B,cAAAA,CAAAA,CACE,CAAA,MAAA,CAAO,CACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
let t=null;class i{constructor(t,i){this.token=0,this.renderer=i,this.dom=document.createElement("span"),this.dom.contentEditable="false",this.render(t)}render(i){const s=i.attrs.latex??"",h=i.attrs.display??"inline";this.dom.className="block"===h?"nile-wysiwyg__math nile-wysiwyg__math--block":"nile-wysiwyg__math",this.dom.setAttribute("data-math",s),this.dom.setAttribute("data-math-display",h),this.dom.title=s;const a=++this.token;if(this.renderer)try{return void(this.dom.innerHTML=this.renderer(s,h))}catch{}this.dom.textContent=s,(t||(t=import("../../../katex-44476ab4.esm.js").then((t=>t.default))),t).then((t=>{if(a===this.token)try{this.dom.innerHTML=t.renderToString(s,{output:"mathml",displayMode:"block"===h,throwOnError:!1})}catch{this.dom.textContent=s}})).catch((()=>{}))}update(t){return"math"===t.type.name&&(this.render(t),!0)}ignoreMutation(){return!0}}export{i as M};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
System.register([],function(_export,_context){"use strict";var t,r,i;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function n(t,n){var o=t[n];for(n+=1;n<t.length;)if("\\"!==t[n]){if(t[n]===o)return n+1;n+=1;}else n+=2;return n;}function o(t,o){return function(t,o){var r=[];var e=0,s="";for(var _i=0;_i<t.length;_i+=1){var c=t[_i];if('"'!==c&&"'"!==c)"("===c||"["===c?e+=1:")"!==c&&"]"!==c||(e-=1),c!==o||0!==e?s+=c:(r.push(s),s="");else{var _o=n(t,_i);s+=t.slice(_i,_o),_i=_o-1;}}return r.push(s),r;}(t,",").map(function(t){return function(t,n){var o=t.trim();if(!o)return o;if(/^(?:html|body|:root)$/i.test(o))return n;var r=o.match(/^(?:html|body|:root)\b\s*/i);return r?"".concat(n," ").concat(o.slice(r[0].length)).trim():"".concat(n," ").concat(o);}(t,o);}).filter(Boolean).join(", ");}function e(t,s){var i="",c=0;var u=t.length;for(;c<u;){var f=c;for(;f<u;){var _o2=t[f];if('"'!==_o2&&"'"!==_o2){if("{"===_o2||";"===_o2)break;f+=1;}else f=n(t,f);}if(f>=u){i+=t.slice(c);break;}if(";"===t[f]){i+=t.slice(c,f+1),c=f+1;continue;}var l=t.slice(c,f).trim();var h=1,a=f+1;for(;a<u&&h>0;){var _o3=t[a];'"'!==_o3&&"'"!==_o3?("{"===_o3?h+=1:"}"===_o3&&(h-=1),a+=1):a=n(t,a);}var $=t.slice(f+1,a-1);if(l.startsWith("@")){var _l$match$,_l$match;var _t=((_l$match$=(_l$match=l.match(/^@([a-z-]+)/i))===null||_l$match===void 0?void 0:_l$match[1])!==null&&_l$match$!==void 0?_l$match$:"").toLowerCase();i+=r.has(_t)?"".concat(l," {").concat(e($,s),"}"):"".concat(l," {").concat($,"}");}else l&&(i+="".concat(o(l,s)," {").concat($,"}"));c=a;}return i;}function s(t,n){if(!t.trim())return"";try{return e(t,n);}catch(_unused){return t;}}return{setters:[],execute:function execute(){t=".ProseMirror";r=new Set(["media","supports","container","layer","scope"]);_export("S",i=/*#__PURE__*/function(){function i(n){_classCallCheck(this,i);this.node=n,this.dom=document.createElement("div"),this.dom.className="nile-wysiwyg__style-block",this.dom.contentEditable="false",this.styleEl=document.createElement("style"),this.styleEl.textContent=s(n.attrs.css,t),this.dom.append(this.styleEl);}return _createClass(i,[{key:"update",value:function update(n){return n.type===this.node.type&&(n.attrs.css!==this.node.attrs.css&&(this.styleEl.textContent=s(n.attrs.css,t)),this.node=n,!0);}},{key:"ignoreMutation",value:function ignoreMutation(){return!0;}}]);}());}};});
|
|
2
|
+
//# sourceMappingURL=style-block-view.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-block-view.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/style-block-view.ts"],"sourcesContent":["import { Node as PMNode } from 'prosemirror-model';\nimport { NodeView } from 'prosemirror-view';\n\n/** Content root the editor mounts the document under. Author CSS is scoped to\n * it so a rule such as `div { background: green }` styles the content only and\n * can never paint the editor chrome (toolbar, panels, surface) that shares the\n * same shadow root. */\nconst CONTENT_SCOPE = '.ProseMirror';\n\n/** Advances past a quoted string starting at `i` (the opening quote), honoring\n * backslash escapes; returns the index just after the closing quote. */\nfunction skipString(css: string, i: number): number {\n const quote = css[i];\n i += 1;\n while (i < css.length) {\n if (css[i] === '\\\\') {\n i += 2;\n continue;\n }\n if (css[i] === quote) return i + 1;\n i += 1;\n }\n return i;\n}\n\n/** Splits on a top-level separator, ignoring ones inside (), [] or strings. */\nfunction splitTopLevel(str: string, sep: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let buf = '';\n for (let i = 0; i < str.length; i += 1) {\n const c = str[i];\n if (c === '\"' || c === \"'\") {\n const end = skipString(str, i);\n buf += str.slice(i, end);\n i = end - 1;\n continue;\n }\n if (c === '(' || c === '[') depth += 1;\n else if (c === ')' || c === ']') depth -= 1;\n if (c === sep && depth === 0) {\n parts.push(buf);\n buf = '';\n continue;\n }\n buf += c;\n }\n parts.push(buf);\n return parts;\n}\n\n/** Confines one complex selector to the content root. `html`/`body`/`:root`\n * map onto the root itself. */\nfunction scopeSelector(selector: string, scope: string): string {\n const sel = selector.trim();\n if (!sel) return sel;\n if (/^(?:html|body|:root)$/i.test(sel)) return scope;\n const root = sel.match(/^(?:html|body|:root)\\b\\s*/i);\n return root ? `${scope} ${sel.slice(root[0].length)}`.trim() : `${scope} ${sel}`;\n}\n\n/** Confines a comma-separated selector list to the content root. */\nfunction scopeSelectorList(list: string, scope: string): string {\n return splitTopLevel(list, ',')\n .map(part => scopeSelector(part, scope))\n .filter(Boolean)\n .join(', ');\n}\n\nconst NESTED_AT_RULES = new Set(['media', 'supports', 'container', 'layer', 'scope']);\n\n/**\n * Scopes every rule in a CSS block to the content root by prefixing selectors,\n * keeping each declaration block **verbatim**. Declarations are never re-parsed\n * (a CSSOM round-trip drops `var()` inside shorthands, e.g. gradient text), and\n * strings/nested braces are tracked so `content: \"}\"` can't derail it. Nested\n * conditionals (`@media`, `@supports`, …) recurse; other at-rules\n * (`@keyframes`, `@font-face`, …) pass through untouched.\n */\nfunction scopeBlock(css: string, scope: string): string {\n let out = '';\n let i = 0;\n const n = css.length;\n while (i < n) {\n let j = i;\n while (j < n) {\n const c = css[j];\n if (c === '\"' || c === \"'\") {\n j = skipString(css, j);\n continue;\n }\n if (c === '{' || c === ';') break;\n j += 1;\n }\n if (j >= n) {\n out += css.slice(i);\n break;\n }\n if (css[j] === ';') {\n // A statement at-rule (e.g. a stray @charset) — keep verbatim.\n out += css.slice(i, j + 1);\n i = j + 1;\n continue;\n }\n const prelude = css.slice(i, j).trim();\n let depth = 1;\n let k = j + 1;\n while (k < n && depth > 0) {\n const c = css[k];\n if (c === '\"' || c === \"'\") {\n k = skipString(css, k);\n continue;\n }\n if (c === '{') depth += 1;\n else if (c === '}') depth -= 1;\n k += 1;\n }\n const body = css.slice(j + 1, k - 1);\n if (prelude.startsWith('@')) {\n const name = (prelude.match(/^@([a-z-]+)/i)?.[1] ?? '').toLowerCase();\n out += NESTED_AT_RULES.has(name)\n ? `${prelude} {${scopeBlock(body, scope)}}`\n : `${prelude} {${body}}`;\n } else if (prelude) {\n out += `${scopeSelectorList(prelude, scope)} {${body}}`;\n }\n i = k;\n }\n return out;\n}\n\n/** Returns author CSS confined to the content root. */\nfunction scopeCss(css: string, scope: string): string {\n if (!css.trim()) return '';\n try {\n return scopeBlock(css, scope);\n } catch {\n return css;\n }\n}\n\n/**\n * Node view for an author `<style>` block. It injects the CSS live — scoped to\n * the content root — so the styles apply to the document as authored, with no\n * visible chip. The block itself renders nothing (a hidden `<style>` host); it\n * round-trips to `<style>` in the output via the schema's toDOM, and the same\n * raw CSS is what the HTML-source preview renders.\n */\nexport class StyleBlockView implements NodeView {\n dom: HTMLElement;\n\n private styleEl: HTMLStyleElement;\n\n constructor(private node: PMNode) {\n this.dom = document.createElement('div');\n this.dom.className = 'nile-wysiwyg__style-block';\n this.dom.contentEditable = 'false';\n\n // A <style> applies regardless of its (display:none) host, so the block is\n // invisible yet its rules take effect on the content.\n this.styleEl = document.createElement('style');\n this.styleEl.textContent = scopeCss(node.attrs.css, CONTENT_SCOPE);\n this.dom.append(this.styleEl);\n }\n\n update(node: PMNode): boolean {\n if (node.type !== this.node.type) return false;\n if (node.attrs.css !== this.node.attrs.css) {\n this.styleEl.textContent = scopeCss(node.attrs.css, CONTENT_SCOPE);\n }\n this.node = node;\n return true;\n }\n\n ignoreMutation(): boolean {\n return true;\n }\n}\n"],"names":["skipString","css","i","quote","length","scopeSelectorList","list","scope","str","sep","parts","depth","buf","c","push","end","slice","splitTopLevel","map","part","selector","sel","trim","test","root","match","concat","scopeSelector","filter","Boolean","join","scopeBlock","out","n","j","prelude","k","body","startsWith","_l$match$","_l$match","name","toLowerCase","NESTED_AT_RULES","has","scopeCss","_unused","CONTENT_SCOPE","Set","_export","StyleBlockView","node","this","dom","document","createElement","className","contentEditable","styleEl","textContent","attrs","append","_createClass","key","value","update","type","ignoreMutation"],"mappings":"wpCAWA,QAASA,CAAAA,CAAAA,CAAWC,EAAaC,CAC/B,CAAA,CAAA,GAAMC,CAAAA,CAAQF,CAAAA,CAAAA,CAAIC,CAElB,CAAA,CAAA,IADAA,GAAK,CACEA,CAAAA,CAAAA,CAAID,CAAIG,CAAAA,MAAAA,EACb,GAAe,IAAA,GAAXH,EAAIC,CAAR,CAAA,CAAA,CAIA,GAAID,CAAAA,CAAIC,CAAOC,CAAAA,GAAAA,CAAAA,CAAO,MAAOD,CAAAA,CAAI,CAAA,CAAA,CACjCA,GAAK,CAFJ,EAAA,IAFCA,CAAAA,GAAK,CAMT,CAAA,MAAOA,CAAAA,CACT,EAuCA,QAASG,CAAAA,CAAAA,CAAkBC,EAAcC,CACvC,CAAA,CAAA,MArCF,UAAuBC,CAAAA,CAAaC,CAClC,CAAA,CAAA,GAAMC,CAAAA,EAAkB,EACxB,CAAA,GAAIC,CAAAA,CAAQ,CAAA,CAAA,CACRC,CAAM,CAAA,EAAA,CACV,IAAK,GAAIV,CAAAA,EAAAA,CAAI,EAAGA,EAAIM,CAAAA,CAAAA,CAAIJ,OAAQF,EAAK,EAAA,CAAA,CAAG,CACtC,GAAMW,CAAAA,CAAIL,CAAAA,CAAAA,CAAIN,IACd,GAAU,GAAA,GAANW,CAAmB,EAAA,GAAA,GAANA,CAMP,CAAA,GAAA,GAANA,GAAmB,GAANA,GAAAA,CAAAA,CAAWF,CAAS,EAAA,CAAA,CACtB,GAANE,GAAAA,CAAAA,EAAmB,MAANA,CAAWF,GAAAA,CAAAA,EAAS,GACtCE,CAAMJ,GAAAA,CAAAA,EAAiB,IAAVE,CAKjBC,CAAAA,CAAAA,EAAOC,CAJLH,EAAAA,CAAAA,CAAMI,IA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AAA,IAAAA,CAAID,KAAJA,CAClBC,CAAAA,IAAAA,CAAKC,GAAMC,CAAAA,QAAAA,CAASC,aAAc,CAAA,KAAA,CAAA,CAClCH,KAAKC,GAAIG,CAAAA,SAAAA,CAAY,2BACrBJ,CAAAA,IAAAA,CAAKC,GAAII,CAAAA,eAAAA,CAAkB,QAI3BL,IAAKM,CAAAA,OAAAA,CAAUJ,SAASC,aAAc,CAAA,OAAA,CAAA,CACtCH,KAAKM,OAAQC,CAAAA,WAAAA,CAAcd,CAASM,CAAAA,CAAAA,CAAKS,KAAM3D,CAAAA,GAAAA,CAAK8C,GACpDK,IAAKC,CAAAA,GAAAA,CAAIQ,MAAOT,CAAAA,IAAAA,CAAKM,OACtB,CAAA,EAED,OAAAI,YAAA,CAAA5D,CAAA,GAAA6D,GAAA,UAAAC,KAAA,UAAAC,MAAAA,CAAOd,CAAAA,CAAAA,CACL,MAAIA,CAAAA,CAAAA,CAAKe,IAASd,GAAAA,IAAAA,CAAKD,KAAKe,IACxBf,GAAAA,CAAAA,CAAKS,KAAM3D,CAAAA,GAAAA,GAAQmD,IAAKD,CAAAA,IAAAA,CAAKS,MAAM3D,GACrCmD,GAAAA,IAAAA,CAAKM,OAAQC,CAAAA,WAAAA,CAAcd,CAASM,CAAAA,CAAAA,CAAKS,MAAM3D,GAAK8C,CAAAA,CAAAA,CAAAA,CAAAA,CAEtDK,IAAKD,CAAAA,IAAAA,CAAOA,CACL,CAAA,CAAA,CAAA,CACR,EAED,GAAAY,GAAA,kBAAAC,KAAA,UAAAG,cAAAA,CAAAA,CAAAA,CACE,MAAO,CAAA,CACR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=".ProseMirror";function n(t,n){const o=t[n];for(n+=1;n<t.length;)if("\\"!==t[n]){if(t[n]===o)return n+1;n+=1}else n+=2;return n}function o(t,o){return function(t,o){const r=[];let e=0,s="";for(let i=0;i<t.length;i+=1){const c=t[i];if('"'!==c&&"'"!==c)"("===c||"["===c?e+=1:")"!==c&&"]"!==c||(e-=1),c!==o||0!==e?s+=c:(r.push(s),s="");else{const o=n(t,i);s+=t.slice(i,o),i=o-1}}return r.push(s),r}(t,",").map((t=>function(t,n){const o=t.trim();if(!o)return o;if(/^(?:html|body|:root)$/i.test(o))return n;const r=o.match(/^(?:html|body|:root)\b\s*/i);return r?`${n} ${o.slice(r[0].length)}`.trim():`${n} ${o}`}(t,o))).filter(Boolean).join(", ")}const r=new Set(["media","supports","container","layer","scope"]);function e(t,s){let i="",c=0;const u=t.length;for(;c<u;){let f=c;for(;f<u;){const o=t[f];if('"'!==o&&"'"!==o){if("{"===o||";"===o)break;f+=1}else f=n(t,f)}if(f>=u){i+=t.slice(c);break}if(";"===t[f]){i+=t.slice(c,f+1),c=f+1;continue}const l=t.slice(c,f).trim();let h=1,a=f+1;for(;a<u&&h>0;){const o=t[a];'"'!==o&&"'"!==o?("{"===o?h+=1:"}"===o&&(h-=1),a+=1):a=n(t,a)}const $=t.slice(f+1,a-1);if(l.startsWith("@")){const t=(l.match(/^@([a-z-]+)/i)?.[1]??"").toLowerCase();i+=r.has(t)?`${l} {${e($,s)}}`:`${l} {${$}}`}else l&&(i+=`${o(l,s)} {${$}}`);c=a}return i}function s(t,n){if(!t.trim())return"";try{return e(t,n)}catch{return t}}class i{constructor(n){this.node=n,this.dom=document.createElement("div"),this.dom.className="nile-wysiwyg__style-block",this.dom.contentEditable="false",this.styleEl=document.createElement("style"),this.styleEl.textContent=s(n.attrs.css,t),this.dom.append(this.styleEl)}update(n){return n.type===this.node.type&&(n.attrs.css!==this.node.attrs.css&&(this.styleEl.textContent=s(n.attrs.css,t)),this.node=n,!0)}ignoreMutation(){return!0}}export{i as S};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["../../../index-
|
|
1
|
+
function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["../../../index-d7e6f1c6.cjs.js","../../../index-89c520e9.cjs.js","../../../index-cc1385e0.cjs.js","../../../index-178e1e57.cjs.js"],function(_export,_context){"use strict";var s,t,e,i;function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}function r(){return[s({View:i}),t({allowTableNodeSelection:!0})];}_export("t",r);return{setters:[function(_index001CjsJs){s=_index001CjsJs.c;t=_index001CjsJs.t;e=_index001CjsJs.T;},function(_index00aCjsJs){},function(_index009CjsJs){},function(_index007CjsJs){}],execute:function execute(){i=/*#__PURE__*/function(_e){function i(s,t){var _this;_classCallCheck(this,i);_this=_callSuper(this,i,[s,t]),_this.applyHtmlAttrs(s);return _this;}_inherits(i,_e);return _createClass(i,[{key:"applyHtmlAttrs",value:function applyHtmlAttrs(s){var t=s.attrs.htmlClass,e=s.attrs.htmlId;this.table.className=t!==null&&t!==void 0?t:"",e?this.table.id=e:this.table.removeAttribute("id");}},{key:"update",value:function update(s){var t=_superPropGet(i,"update",this,3)([s]);return t&&this.applyHtmlAttrs(s),t;}}]);}(e);}};});
|
|
2
2
|
//# sourceMappingURL=tables.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/tables.ts"],"sourcesContent":["import { Plugin } from 'prosemirror-state';\nimport { tableEditing, columnResizing } from 'prosemirror-tables';\n\n/**\n * prosemirror-tables wiring: cell selections, fix-tables normalization, and\n * draggable column resizing (widths persist as `data-colwidth`). The CSS\n * these plugins rely on (.selectedCell, .column-resize-handle, .resize-cursor)\n * is inlined in nile-wysiwyg-editor.css.ts.\n */\nexport function tablePlugins(): Plugin[] {\n return [columnResizing()
|
|
1
|
+
{"version":3,"file":"tables.cjs.js","sources":["../../../../../src/nile-wysiwyg-editor/engine/plugins/tables.ts"],"sourcesContent":["import { Plugin } from 'prosemirror-state';\nimport { Node as PMNode } from 'prosemirror-model';\nimport { tableEditing, columnResizing, TableView } from 'prosemirror-tables';\n\n/**\n * TableView that also reflects the author's `class`/`id` onto the inner\n * `<table>` element (the base TableView leaves it bare and puts its own class on\n * the wrapper div). The attributes round-trip via the schema's toDOM on export;\n * this makes `table.grid …` style rules match in the live editor too. Passed to\n * `columnResizing` as its `View`, so column resizing keeps working.\n */\nclass HtmlAttrTableView extends TableView {\n constructor(node: PMNode, defaultCellMinWidth: number) {\n super(node, defaultCellMinWidth);\n this.applyHtmlAttrs(node);\n }\n\n private applyHtmlAttrs(node: PMNode): void {\n const htmlClass = node.attrs.htmlClass as string | null;\n const htmlId = node.attrs.htmlId as string | null;\n this.table.className = htmlClass ?? '';\n if (htmlId) this.table.id = htmlId;\n else this.table.removeAttribute('id');\n }\n\n update(node: PMNode): boolean {\n const updated = super.update(node);\n if (updated) this.applyHtmlAttrs(node);\n return updated;\n }\n}\n\n/**\n * prosemirror-tables wiring: cell selections, fix-tables normalization, and\n * draggable column resizing (widths persist as `data-colwidth`). The CSS\n * these plugins rely on (.selectedCell, .column-resize-handle, .resize-cursor)\n * is inlined in nile-wysiwyg-editor.css.ts.\n */\nexport function tablePlugins(): Plugin[] {\n return [\n columnResizing({ View: HtmlAttrTableView }),\n tableEditing({ allowTableNodeSelection: true }),\n ];\n}\n"],"names":["tablePlugins","columnResizing","View","HtmlAttrTableView","tableEditing","allowTableNodeSelection","TableView","i","node","defaultCellMinWidth","super","this","applyHtmlAttrs","_this","_inherits","_e","_createClass","key","value","htmlClass","attrs","htmlId","table","className","id","removeAttribute","update","updated"],"mappings":"qsGAsCgBA,CAAAA,IACd,MAAO,CACLC,CAAe,CAAA,CAAEC,KAAMC,CACvBC,CAAAA,CAAAA,CAAAA,CAAAA,CAAa,CAAEC,uBAAAA,CAAAA,CAAyB,IAE5C,kOAhCMF,CAA0BG,uBAAAA,EAAAA,EAC9B,SAAAC,EAAYC,CAAAA,CAAcC,CACxBC,CAAAA,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,EAAAA,KAAAA,CAAAA,UAAAA,MAAAA,CAAAA,EAAMF,EAAMC,CACZE,GAAAA,KAAAA,CAAKC,cAAeJ,CAAAA,CAAAA,CACrB,QAAAK,KAAA,EAEOC,SAAA,CAAAP,CAAA,CAAAQ,EAAA,SAAAC,YAAA,CAAAT,CAAA,GAAAU,GAAA,kBAAAC,KAAA,UAAAN,cAAAA,CAAeJ,CACrB,CAAA,CAAA,GAAMW,CAAAA,EAAYX,CAAKY,CAAAA,KAAAA,CAAMD,SACvBE,CAAAA,CAAAA,CAASb,EAAKY,KAAMC,CAAAA,MAAAA,CAC1BV,IAAKW,CAAAA,KAAAA,CAAMC,UAAYJ,CAAa,SAAbA,CAAa,UAAbA,CAAa,CAAA,EAAA,CAChCE,CAAQV,CAAAA,IAAAA,CAAKW,KAAME,CAAAA,EAAAA,CAAKH,CACvBV,CAAAA,IAAAA,CAAKW,MAAMG,eAAgB,CAAA,IAAA,CACjC,EAED,GAAAR,GAAA,UAAAC,KAAA,UAAAQ,MAAAA,CAAOlB,CACL,CAAA,CAAA,GAAMmB,CAAAA,CAAUjB,CAAAA,aAAAA,CAAAA,CAAAA,mBAAaF,CAE7B,EAAA,CAAA,MADImB,CAAAA,CAAShB,EAAAA,IAAAA,CAAKC,eAAeJ,CAC1BmB,CAAAA,CAAAA,CACR,QAlB6BrB,CAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as s,t,T as e}from"../../../index-289706c7.esm.js";import"../../../index-6f3fa4ab.esm.js";import"../../../index-353172ed.esm.js";import"../../../index-920675c4.esm.js";class i extends e{constructor(s,t){super(s,t),this.applyHtmlAttrs(s)}applyHtmlAttrs(s){const t=s.attrs.htmlClass,e=s.attrs.htmlId;this.table.className=t??"",e?this.table.id=e:this.table.removeAttribute("id")}update(s){const t=super.update(s);return t&&this.applyHtmlAttrs(s),t}}function r(){return[s({View:i}),t({allowTableNodeSelection:!0})]}export{r as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["./plugins/embeds.cjs.js","../../index-89c520e9.cjs.js"],function(_export,_context){"use strict";var t,e,a,n,
|
|
1
|
+
System.register(["./plugins/embeds.cjs.js","../../index-89c520e9.cjs.js"],function(_export,_context){"use strict";var t,e,a,i,n,r,o,s,l,d,f;function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function c(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var a=t.trim();if(""===a)return!1;if(/^(#|\/|\.\/|\.\.\/)/.test(a))return!0;var i=/^([a-z][a-z0-9+.-]*):/i.exec(a);if(!i)return!0;var n="".concat(i[1].toLowerCase(),":");return!!d.includes(n)||!(!e||"data:"!==n)&&/^data:image\/(png|gif|jpe?g|webp|avif|bmp);/i.test(a);}function g(t,e){var a=f[e];return t.split(";").map(function(t){return t.trim();}).filter(function(t){var e=t.slice(0,t.indexOf(":")).trim().toLowerCase();return!!(l.has(e)||a&&a.has(e))&&!/url\s*\(|expression\s*\(/i.test(t);}).join("; ");}function p(t){var e=t.tagName.toLowerCase(),a=r[e];for(var _i=0,_Array$from=Array.from(t.attributes);_i<_Array$from.length;_i++){var _i2=_Array$from[_i];var _n=_i2.name.toLowerCase();if((o.has(_n)||void 0!==a&&a.has(_n))&&!_n.startsWith("on")){if("style"===_n){var _a=g(_i2.value,e);_a?t.setAttribute("style",_a):t.removeAttribute("style");}else if("class"===_n){var _e=_i2.value.split(/\s+/).filter(function(t){return t&&!s.test(t);}).join(" ");_e?t.setAttribute("class",_e):t.removeAttribute("class");}else"id"===_n?s.test(_i2.value)&&t.removeAttribute("id"):"href"===_n||"src"===_n?c(_i2.value,"img"===e)||t.removeAttribute(_i2.name):"target"===_n&&("_blank"===_i2.value?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("target"));}else t.removeAttribute(_i2.name);}}function m(r){for(var _i3=0,_Array$from2=Array.from(r.children);_i3<_Array$from2.length;_i3++){var _o=_Array$from2[_i3];var _r=_o.tagName.toLowerCase();if(i.has(_r))_o.remove();else{if("iframe"===_r){var _o$getAttribute;if(!t((_o$getAttribute=_o.getAttribute("src"))!==null&&_o$getAttribute!==void 0?_o$getAttribute:"")){_o.remove();continue;}_o.setAttribute("sandbox",e),_o.setAttribute("referrerpolicy",a);}if("style"!==_r)n.has(_r)?(p(_o),m(_o)):(m(_o),_o.replaceWith.apply(_o,_toConsumableArray(Array.from(_o.childNodes))));else{var _o$textContent;_o.textContent=((_o$textContent=_o.textContent)!==null&&_o$textContent!==void 0?_o$textContent:"").replace(/<\/style/gi,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/@import[^;]*;?/gi,"").replace(/expression\s*\(/gi,"blocked(").replace(/(behavior|-moz-binding)(\s*):/gi,"blocked-prop$2:").replace(/url\(\s*(['"]?)([^)]*?)\1\s*\)/gi,function(t,e,a){var i=String(a).trim();return /^#/.test(i)||/^data:image\/(png|gif|jpe?g|webp|avif|bmp);/i.test(i)?t:"url(#)";}).trim();for(var _i4=0,_Array$from3=Array.from(_o.attributes);_i4<_Array$from3.length;_i4++){var _t=_Array$from3[_i4];_o.removeAttribute(_t.name);}}}}}function w(t){var e=new DOMParser().parseFromString("<body>".concat(t,"</body>"),"text/html");return m(e.body),e.body.innerHTML;}_export({i:c,s:w});return{setters:[function(_pluginsEmbedsCjsJs){t=_pluginsEmbedsCjsJs.i;e=_pluginsEmbedsCjsJs.E;a=_pluginsEmbedsCjsJs.a;},function(_index00aCjsJs){}],execute:function execute(){i=new Set(["script","frame","frameset","object","embed","applet","form","input","textarea","select","button","meta","link","base","title","noscript","template","svg","math","canvas","audio","video","dialog","slot"]),n=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","ul","ol","li","br","hr","a","b","strong","i","em","u","s","strike","del","span","code","sub","sup","div","font","pre","figure","figcaption","img","iframe","table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),r={a:new Set(["href","title","target","rel","id","name","data-bookmark"]),table:new Set(["role","data-layout"]),ol:new Set(["start","type","data-list-style"]),ul:new Set(["data-task-list"]),figure:new Set(["data-align"]),li:new Set(["data-task-item","data-checked"]),span:new Set(["data-mention-trigger","data-mention-key","data-mention-label","data-merge-field","data-merge-label","data-math","data-math-display"]),pre:new Set(["data-language"]),img:new Set(["src","alt","title","width","height"]),td:new Set(["colspan","rowspan","data-colwidth"]),th:new Set(["colspan","rowspan","data-colwidth"]),col:new Set(["span","width"]),div:new Set(["data-embed-provider","data-width","data-align"]),iframe:new Set(["src","title","frameborder","allowfullscreen","allow","sandbox","referrerpolicy"])},o=new Set(["style","align","class","id"]),s=/^(?:nile-wysiwyg|ProseMirror)/;l=new Set(["color","background-color","font-family","font-size","font-style","font-weight","text-align","text-decoration","text-decoration-line","vertical-align","margin-left","margin-inline-start","list-style-type","line-height"]),d=["http:","https:","mailto:","tel:","ftp:"];f={img:new Set(["width","height"]),figure:new Set(["width","margin-right"]),div:new Set(["width","max-width"])};}};});
|
|
2
2
|
//# sourceMappingURL=sanitize.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.cjs.js","sources":["../../../../src/nile-wysiwyg-editor/engine/sanitize.ts"],"sourcesContent":["/**\n * HTML sanitization pre-pass. The ProseMirror schema is the real whitelist —\n * anything it can't parse is dropped — but this pass removes actively\n * dangerous content (scripts, event handlers, javascript: URLs) before the\n * string ever touches a live DOM, and strips style declarations down to the\n * set the schema understands.\n */\n\nimport { isAllowedEmbedSrc } from './plugins/embeds';\n\n/** Elements removed together with their content. */\nconst DROP_WITH_CONTENT = new Set([\n 'script', 'style', 'frame', 'frameset', 'object', 'embed',\n 'applet', 'form', 'input', 'textarea', 'select', 'button', 'meta', 'link',\n 'base', 'title', 'noscript', 'template', 'svg', 'math', 'canvas', 'audio',\n 'video', 'dialog', 'slot',\n]);\n\n/** Elements kept as-is (with filtered attributes). Extended in later phases. */\nconst ALLOWED_TAGS = new Set([\n 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'ul', 'ol', 'li',\n 'br', 'hr', 'a', 'b', 'strong', 'i', 'em', 'u', 's', 'strike', 'del',\n 'span', 'code', 'sub', 'sup', 'div', 'font',\n 'pre', 'figure', 'figcaption', 'img', 'iframe',\n 'table', 'thead', 'tbody', 'tfoot', 'tr', 'td', 'th', 'colgroup', 'col',\n]);\n\n/** Attributes allowed per tag (on top of GLOBAL_ATTRS). */\nconst TAG_ATTRS: Record<string, Set<string>> = {\n a: new Set(['href', 'title', 'target', 'rel', 'id', 'name', 'data-bookmark']),\n table: new Set(['role', 'data-layout']),\n ol: new Set(['start', 'type', 'data-list-style']),\n ul: new Set(['data-task-list']),\n figure: new Set(['data-align']),\n li: new Set(['data-task-item', 'data-checked']),\n span: new Set([\n 'data-mention-trigger', 'data-mention-key', 'data-mention-label',\n 'data-merge-field', 'data-merge-label', 'data-math', 'data-math-display',\n ]),\n pre: new Set(['data-language']),\n img: new Set(['src', 'alt', 'title', 'width', 'height']),\n td: new Set(['colspan', 'rowspan', 'data-colwidth']),\n th: new Set(['colspan', 'rowspan', 'data-colwidth']),\n col: new Set(['span', 'width']),\n div: new Set(['data-embed-provider', 'data-width', 'data-align']),\n iframe: new Set(['src', 'title', 'frameborder', 'allowfullscreen', 'allow']),\n};\n\nconst GLOBAL_ATTRS = new Set(['style', 'align']);\n\n/** Style declarations the schema can represent. Everything else is noise. */\nconst ALLOWED_STYLES = new Set([\n 'color', 'background-color', 'font-family', 'font-size', 'font-style',\n 'font-weight', 'text-align', 'text-decoration', 'text-decoration-line',\n 'vertical-align', 'margin-left', 'margin-inline-start', 'list-style-type',\n 'line-height',\n]);\n\nconst SAFE_URL_PROTOCOLS = ['http:', 'https:', 'mailto:', 'tel:', 'ftp:'];\n\nexport function isSafeUrl(url: string, allowDataImage = false): boolean {\n const trimmed = url.trim();\n if (trimmed === '') return false;\n // Relative URLs and fragments have no protocol — safe.\n if (/^(#|\\/|\\.\\/|\\.\\.\\/)/.test(trimmed)) return true;\n const match = /^([a-z][a-z0-9+.-]*):/i.exec(trimmed);\n if (!match) return true;\n const protocol = `${match[1].toLowerCase()}:`;\n if (SAFE_URL_PROTOCOLS.includes(protocol)) return true;\n if (allowDataImage && protocol === 'data:') {\n // Raster images only — data:image/svg+xml can carry scripts.\n return /^data:image\\/(png|gif|jpe?g|webp|avif|bmp);/i.test(trimmed);\n }\n return false;\n}\n\n/** Size styles allowed only where they are part of the document model. */\nconst SIZED_TAGS: Record<string, Set<string>> = {\n img: new Set(['width', 'height']),\n figure: new Set(['width', 'margin-right']),\n div: new Set(['width', 'max-width']),\n};\n\nfunction filterStyle(value: string, tag: string): string {\n const extra = SIZED_TAGS[tag];\n return value\n .split(';')\n .map(decl => decl.trim())\n .filter(decl => {\n const name = decl.slice(0, decl.indexOf(':')).trim().toLowerCase();\n if (!ALLOWED_STYLES.has(name) && !(extra && extra.has(name))) return false;\n // Defense in depth: CSS url()/expression() smuggling.\n return !/url\\s*\\(|expression\\s*\\(/i.test(decl);\n })\n .join('; ');\n}\n\nfunction sanitizeElement(el: Element): void {\n const tag = el.tagName.toLowerCase();\n const allowed = TAG_ATTRS[tag];\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name.toLowerCase();\n const keep =\n (GLOBAL_ATTRS.has(name) || (allowed !== undefined && allowed.has(name))) &&\n !name.startsWith('on');\n if (!keep) {\n el.removeAttribute(attr.name);\n continue;\n }\n if (name === 'style') {\n const filtered = filterStyle(attr.value, tag);\n if (filtered) el.setAttribute('style', filtered);\n else el.removeAttribute('style');\n } else if (name === 'href' || name === 'src') {\n // Raster data: URLs are allowed on images only.\n if (!isSafeUrl(attr.value, tag === 'img')) el.removeAttribute(attr.name);\n } else if (name === 'target') {\n if (attr.value === '_blank') el.setAttribute('rel', 'noopener noreferrer');\n else el.removeAttribute('target');\n }\n }\n}\n\nfunction walk(node: Element): void {\n for (const child of Array.from(node.children)) {\n const tag = child.tagName.toLowerCase();\n if (DROP_WITH_CONTENT.has(tag)) {\n child.remove();\n continue;\n }\n // iframes are allowed ONLY for allowlisted embed providers.\n if (tag === 'iframe' && !isAllowedEmbedSrc(child.getAttribute('src') ?? '')) {\n child.remove();\n continue;\n }\n if (!ALLOWED_TAGS.has(tag)) {\n // Unknown wrapper (article, section, table for now, …): keep its\n // content, drop the element itself.\n walk(child);\n child.replaceWith(...Array.from(child.childNodes));\n continue;\n }\n sanitizeElement(child);\n walk(child);\n }\n}\n\n/**\n * Sanitizes an HTML string. Parsing happens in an inert document created by\n * DOMParser, so embedded scripts never execute and images never load.\n */\nexport function sanitizeHtml(html: string): string {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n walk(doc.body);\n return doc.body.innerHTML;\n}\n"],"names":["isSafeUrl","url","allowDataImage","arguments","length","undefined","trimmed","trim","test","match","exec","protocol","toLowerCase","SAFE_URL_PROTOCOLS","includes","filterStyle","value","tag","extra","SIZED_TAGS","split","map","decl","filter","name","slice","indexOf","ALLOWED_STYLES","has","join","sanitizeElement","el","tagName","allowed","TAG_ATTRS","_i","_Array$from","Array","from","attributes","attr","GLOBAL_ATTRS","startsWith","filtered","setAttribute","removeAttribute","walk","node","_i2","_Array$from2","children","_i3$getAttribute","child","DROP_WITH_CONTENT","remove","isAllowedEmbedSrc","getAttribute","ALLOWED_TAGS","replaceWith","childNodes","sanitizeHtml","html","doc","DOMParser","parseFromString","body","innerHTML","_export","i","Set","a","table","ol","ul","figure","li","span","pre","img","td","th","col","div","iframe"],"mappings":"qmCA4DgBA,CAAAA,CAAUC,CAAAA,CAAAA,CAA8B,IAAjBC,CAAAA,CAAiB,CAAAC,SAAA,CAAAC,MAAA,IAAAD,SAAA,MAAAE,SAAA,CAAAF,SAAA,IAAA,CAAA,CAAA,CACtD,GAAMG,CAAAA,CAAAA,CAAUL,CAAIM,CAAAA,IAAAA,CAAAA,CAAAA,CACpB,GAAgB,EAAZD,GAAAA,CAAAA,CAAgB,MAAO,CAAA,CAAA,CAE3B,GAAI,qBAAA,CAAsBE,IAAKF,CAAAA,CAAAA,CAAAA,CAAU,MAAO,CAAA,CAAA,CAChD,GAAMG,CAAAA,CAAAA,CAAQ,wBAAyBC,CAAAA,IAAAA,CAAKJ,GAC5C,GAAKG,CAAAA,CAAAA,CAAO,MAAO,CAAA,CAAA,CACnB,GAAME,CAAAA,CAAAA,IAAAA,MAAAA,CAAcF,CAAM,CAAA,CAAA,CAAA,CAAGG,WAC7B,CAAA,CAAA,KAAA,CAAA,MAAA,CAAA,CAAIC,CAAmBC,CAAAA,QAAAA,CAASH,OAC5BT,CAA+B,EAAA,OAAA,GAA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,SAAW,CAAA,MAAA,CAAQ,QAmB5DM,CAA0C,CAAA,CAC9C2D,GAAK,CAAA,GAAIT,CAAAA,GAAI,CAAA,CAAC,QAAS,QACvBK,CAAAA,CAAAA,CAAAA,MAAAA,CAAQ,GAAIL,CAAAA,GAAAA,CAAI,CAAC,OAAA,CAAS,cAC1Ba,CAAAA,CAAAA,CAAAA,GAAAA,CAAK,GAAIb,CAAAA,GAAAA,CAAI,CAAC,OAAA,CAAS,WAGzB,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"sanitize.cjs.js","sources":["../../../../src/nile-wysiwyg-editor/engine/sanitize.ts"],"sourcesContent":["/**\n * HTML sanitization pre-pass. The ProseMirror schema is the real whitelist —\n * anything it can't parse is dropped — but this pass removes actively\n * dangerous content (scripts, event handlers, javascript: URLs) before the\n * string ever touches a live DOM, and strips style declarations down to the\n * set the schema understands.\n */\n\nimport { isAllowedEmbedSrc, EMBED_SANDBOX, EMBED_REFERRER_POLICY } from './plugins/embeds';\n\n/** Elements removed together with their content. */\nconst DROP_WITH_CONTENT = new Set([\n 'script', 'frame', 'frameset', 'object', 'embed',\n 'applet', 'form', 'input', 'textarea', 'select', 'button', 'meta', 'link',\n 'base', 'title', 'noscript', 'template', 'svg', 'math', 'canvas', 'audio',\n 'video', 'dialog', 'slot',\n]);\n\n/** Elements kept as-is (with filtered attributes). Extended in later phases. */\nconst ALLOWED_TAGS = new Set([\n 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'ul', 'ol', 'li',\n 'br', 'hr', 'a', 'b', 'strong', 'i', 'em', 'u', 's', 'strike', 'del',\n 'span', 'code', 'sub', 'sup', 'div', 'font',\n 'pre', 'figure', 'figcaption', 'img', 'iframe',\n 'table', 'thead', 'tbody', 'tfoot', 'tr', 'td', 'th', 'colgroup', 'col',\n]);\n\n/** Attributes allowed per tag (on top of GLOBAL_ATTRS). */\nconst TAG_ATTRS: Record<string, Set<string>> = {\n a: new Set(['href', 'title', 'target', 'rel', 'id', 'name', 'data-bookmark']),\n table: new Set(['role', 'data-layout']),\n ol: new Set(['start', 'type', 'data-list-style']),\n ul: new Set(['data-task-list']),\n figure: new Set(['data-align']),\n li: new Set(['data-task-item', 'data-checked']),\n span: new Set([\n 'data-mention-trigger', 'data-mention-key', 'data-mention-label',\n 'data-merge-field', 'data-merge-label', 'data-math', 'data-math-display',\n ]),\n pre: new Set(['data-language']),\n img: new Set(['src', 'alt', 'title', 'width', 'height']),\n td: new Set(['colspan', 'rowspan', 'data-colwidth']),\n th: new Set(['colspan', 'rowspan', 'data-colwidth']),\n col: new Set(['span', 'width']),\n div: new Set(['data-embed-provider', 'data-width', 'data-align']),\n iframe: new Set([\n 'src', 'title', 'frameborder', 'allowfullscreen', 'allow', 'sandbox', 'referrerpolicy',\n ]),\n};\n\nconst GLOBAL_ATTRS = new Set(['style', 'align', 'class', 'id']);\n\n/** Author class/id names starting with these are the editor's own; drop them so\n * content can't impersonate or restyle the chrome. */\nconst RESERVED_NAME = /^(?:nile-wysiwyg|ProseMirror)/;\n\n/** Filtered `class`: reserved-prefixed tokens removed. Empty → drop attribute. */\nfunction cleanClassAttr(value: string): string {\n return value\n .split(/\\s+/)\n .filter(token => token && !RESERVED_NAME.test(token))\n .join(' ');\n}\n\n/** Style declarations the schema can represent. Everything else is noise. */\nconst ALLOWED_STYLES = new Set([\n 'color', 'background-color', 'font-family', 'font-size', 'font-style',\n 'font-weight', 'text-align', 'text-decoration', 'text-decoration-line',\n 'vertical-align', 'margin-left', 'margin-inline-start', 'list-style-type',\n 'line-height',\n]);\n\nconst SAFE_URL_PROTOCOLS = ['http:', 'https:', 'mailto:', 'tel:', 'ftp:'];\n\nexport function isSafeUrl(url: string, allowDataImage = false): boolean {\n const trimmed = url.trim();\n if (trimmed === '') return false;\n // Relative URLs and fragments have no protocol — safe.\n if (/^(#|\\/|\\.\\/|\\.\\.\\/)/.test(trimmed)) return true;\n const match = /^([a-z][a-z0-9+.-]*):/i.exec(trimmed);\n if (!match) return true;\n const protocol = `${match[1].toLowerCase()}:`;\n if (SAFE_URL_PROTOCOLS.includes(protocol)) return true;\n if (allowDataImage && protocol === 'data:') {\n // Raster images only — data:image/svg+xml can carry scripts.\n return /^data:image\\/(png|gif|jpe?g|webp|avif|bmp);/i.test(trimmed);\n }\n return false;\n}\n\n/** Size styles allowed only where they are part of the document model. */\nconst SIZED_TAGS: Record<string, Set<string>> = {\n img: new Set(['width', 'height']),\n figure: new Set(['width', 'margin-right']),\n div: new Set(['width', 'max-width']),\n};\n\nfunction filterStyle(value: string, tag: string): string {\n const extra = SIZED_TAGS[tag];\n return value\n .split(';')\n .map(decl => decl.trim())\n .filter(decl => {\n const name = decl.slice(0, decl.indexOf(':')).trim().toLowerCase();\n if (!ALLOWED_STYLES.has(name) && !(extra && extra.has(name))) return false;\n // Defense in depth: CSS url()/expression() smuggling.\n return !/url\\s*\\(|expression\\s*\\(/i.test(decl);\n })\n .join('; ');\n}\n\n/**\n * Sanitizes the CSS inside a <style> block. Neutralizes the vectors that make\n * a raw stylesheet dangerous while leaving ordinary rules intact:\n * - `@import` (external fetch / data exfiltration) — removed,\n * - `expression()`, `behavior:`, `-moz-binding:` (script execution) — broken,\n * - `url(...)` pointing anywhere other than a safe data: image or a local\n * `#fragment` — replaced with `url(#)`,\n * - any `</style` sequence — stripped so the text can't break out of the\n * element when the document is re-serialized.\n * CSS comments are dropped first so none of the above can hide inside one.\n */\nexport function sanitizeCss(css: string): string {\n return css\n .replace(/<\\/style/gi, '')\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/@import[^;]*;?/gi, '')\n .replace(/expression\\s*\\(/gi, 'blocked(')\n .replace(/(behavior|-moz-binding)(\\s*):/gi, 'blocked-prop$2:')\n .replace(/url\\(\\s*(['\"]?)([^)]*?)\\1\\s*\\)/gi, (full, _quote, raw) => {\n const url = String(raw).trim();\n if (/^#/.test(url)) return full;\n if (/^data:image\\/(png|gif|jpe?g|webp|avif|bmp);/i.test(url)) return full;\n return 'url(#)';\n })\n .trim();\n}\n\nfunction sanitizeElement(el: Element): void {\n const tag = el.tagName.toLowerCase();\n const allowed = TAG_ATTRS[tag];\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name.toLowerCase();\n const keep =\n (GLOBAL_ATTRS.has(name) || (allowed !== undefined && allowed.has(name))) &&\n !name.startsWith('on');\n if (!keep) {\n el.removeAttribute(attr.name);\n continue;\n }\n if (name === 'style') {\n const filtered = filterStyle(attr.value, tag);\n if (filtered) el.setAttribute('style', filtered);\n else el.removeAttribute('style');\n } else if (name === 'class') {\n const cleaned = cleanClassAttr(attr.value);\n if (cleaned) el.setAttribute('class', cleaned);\n else el.removeAttribute('class');\n } else if (name === 'id') {\n if (RESERVED_NAME.test(attr.value)) el.removeAttribute('id');\n } else if (name === 'href' || name === 'src') {\n // Raster data: URLs are allowed on images only.\n if (!isSafeUrl(attr.value, tag === 'img')) el.removeAttribute(attr.name);\n } else if (name === 'target') {\n if (attr.value === '_blank') el.setAttribute('rel', 'noopener noreferrer');\n else el.removeAttribute('target');\n }\n }\n}\n\nfunction walk(node: Element): void {\n for (const child of Array.from(node.children)) {\n const tag = child.tagName.toLowerCase();\n if (DROP_WITH_CONTENT.has(tag)) {\n child.remove();\n continue;\n }\n // iframes are allowed for any https src, but always force-sandboxed so an\n // untrusted embed can never navigate the top window or run unrestricted.\n if (tag === 'iframe') {\n if (!isAllowedEmbedSrc(child.getAttribute('src') ?? '')) {\n child.remove();\n continue;\n }\n child.setAttribute('sandbox', EMBED_SANDBOX);\n child.setAttribute('referrerpolicy', EMBED_REFERRER_POLICY);\n }\n // <style> blocks are kept, but their CSS is sanitized and any attributes\n // (media, nonce, …) dropped. Handled before the unwrap branch below so the\n // raw CSS is never spilled into the document as visible text.\n if (tag === 'style') {\n child.textContent = sanitizeCss(child.textContent ?? '');\n for (const attr of Array.from(child.attributes)) child.removeAttribute(attr.name);\n continue;\n }\n if (!ALLOWED_TAGS.has(tag)) {\n // Unknown wrapper (article, section, table for now, …): keep its\n // content, drop the element itself.\n walk(child);\n child.replaceWith(...Array.from(child.childNodes));\n continue;\n }\n sanitizeElement(child);\n walk(child);\n }\n}\n\n/**\n * Sanitizes an HTML string. Parsing happens in an inert document created by\n * DOMParser, so embedded scripts never execute and images never load.\n */\nexport function sanitizeHtml(html: string): string {\n // Wrap in an explicit <body> so metadata-like tags (notably <style>) stay in\n // the body instead of being hoisted into <head> by the HTML parser — which\n // would drop them before walk() ever sees them. Mirrors htmlToDoc's parse.\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');\n walk(doc.body);\n return doc.body.innerHTML;\n}\n"],"names":["isSafeUrl","url","allowDataImage","trimmed","trim","test","match","exec","protocol","toLowerCase","SAFE_URL_PROTOCOLS","includes","filterStyle","value","tag","extra","SIZED_TAGS","split","map","decl","filter","name","slice","indexOf","ALLOWED_STYLES","has","join","sanitizeElement","el","tagName","allowed","TAG_ATTRS","_i","_Array$from","Array","from","attributes","length","attr","GLOBAL_ATTRS","undefined","startsWith","filtered","setAttribute","removeAttribute","cleaned","token","RESERVED_NAME","walk","node","_i3","_Array$from2","children","child","DROP_WITH_CONTENT","remove","_o$getAttribute","isAllowedEmbedSrc","getAttribute","EMBED_SANDBOX","EMBED_REFERRER_POLICY","ALLOWED_TAGS","replaceWith","childNodes","_o$textContent","textContent","replace","full","_quote","raw","String","_i4","_Array$from3","sanitizeHtml","html","doc","DOMParser","parseFromString","body","innerHTML","Set","a","table","ol","ul","figure","li","span","pre","img","td","th","col","div","iframe"],"mappings":"2mCA0EgBA,CAAAA,CAAAA,CAAUC,CAAaC,CACrC,IADqCA,CAAAA,CAAAA,CAAAA,SAAAA,CAAAA,MAAAA,IAAAA,SAAAA,MAAAA,SAAAA,CAAAA,SAAAA,IAAAA,CAAiB,CACtD,CAAA,GAAMC,CAAAA,CAAUF,CAAAA,CAAAA,CAAIG,OACpB,GAAgB,EAAA,GAAZD,CAAgB,CAAA,MAAA,CAAO,CAE3B,CA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AAIb,CAAAA,GAAAA,CAAI,CAAC,qBAAA,CAAuB,aAAc,YACnDc,CAAAA,CAAAA,CAAAA,MAAAA,CAAQ,GAAId,CAAAA,GAAAA,CAAI,CACd,KAAO,CAAA,OAAA,CAAS,aAAe,CAAA,iBAAA,CAAmB,QAAS,SAAW,CAAA,gBAAA,CAAA,CAAA,CAAA,CAIpEzC,CAAe,CAAA,GAAIyC,CAAAA,GAAI,CAAA,CAAC,OAAS,CAAA,OAAA,CAAS,QAAS,IAInDjC,CAAAA,CAAAA,CAAAA,CAAAA,CAAgB,+BAWtB,CAAMvB,EAAiB,GAAIwD,CAAAA,GAAAA,CAAI,CAC7B,OAAA,CAAS,mBAAoB,aAAe,CAAA,WAAA,CAAa,YACzD,CAAA,aAAA,CAAe,YAAc,CAAA,iBAAA,CAAmB,sBAChD,CAAA,gBAAA,CAAkB,cAAe,qBAAuB,CAAA,iBAAA,CACxD,aAGItE,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAAC,OAAS,CAAA,QAAA,CAAU,SAAW,CAAA,MAAA,CAAQ,QAmB5DM,CAAAA,CAA0C,CAC9CyE,GAAAA,CAAK,GAAIT,CAAAA,GAAI,CAAA,CAAC,OAAS,CAAA,QAAA,CAAA,CAAA,CACvBK,OAAQ,GAAIL,CAAAA,GAAAA,CAAI,CAAC,OAAA,CAAS,cAC1Ba,CAAAA,CAAAA,CAAAA,GAAAA,CAAK,GAAIb,CAAAA,GAAAA,CAAI,CAAC,OAAS,CAAA,WAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as t}from"./plugins/embeds.esm.js";import"../../index-6f3fa4ab.esm.js";const
|
|
1
|
+
import{i as t,E as e,a}from"./plugins/embeds.esm.js";import"../../index-6f3fa4ab.esm.js";const i=new Set(["script","frame","frameset","object","embed","applet","form","input","textarea","select","button","meta","link","base","title","noscript","template","svg","math","canvas","audio","video","dialog","slot"]),n=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","ul","ol","li","br","hr","a","b","strong","i","em","u","s","strike","del","span","code","sub","sup","div","font","pre","figure","figcaption","img","iframe","table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),r={a:new Set(["href","title","target","rel","id","name","data-bookmark"]),table:new Set(["role","data-layout"]),ol:new Set(["start","type","data-list-style"]),ul:new Set(["data-task-list"]),figure:new Set(["data-align"]),li:new Set(["data-task-item","data-checked"]),span:new Set(["data-mention-trigger","data-mention-key","data-mention-label","data-merge-field","data-merge-label","data-math","data-math-display"]),pre:new Set(["data-language"]),img:new Set(["src","alt","title","width","height"]),td:new Set(["colspan","rowspan","data-colwidth"]),th:new Set(["colspan","rowspan","data-colwidth"]),col:new Set(["span","width"]),div:new Set(["data-embed-provider","data-width","data-align"]),iframe:new Set(["src","title","frameborder","allowfullscreen","allow","sandbox","referrerpolicy"])},o=new Set(["style","align","class","id"]),s=/^(?:nile-wysiwyg|ProseMirror)/;const l=new Set(["color","background-color","font-family","font-size","font-style","font-weight","text-align","text-decoration","text-decoration-line","vertical-align","margin-left","margin-inline-start","list-style-type","line-height"]),d=["http:","https:","mailto:","tel:","ftp:"];function c(t,e=!1){const a=t.trim();if(""===a)return!1;if(/^(#|\/|\.\/|\.\.\/)/.test(a))return!0;const i=/^([a-z][a-z0-9+.-]*):/i.exec(a);if(!i)return!0;const n=`${i[1].toLowerCase()}:`;return!!d.includes(n)||!(!e||"data:"!==n)&&/^data:image\/(png|gif|jpe?g|webp|avif|bmp);/i.test(a)}const f={img:new Set(["width","height"]),figure:new Set(["width","margin-right"]),div:new Set(["width","max-width"])};function g(t,e){const a=f[e];return t.split(";").map((t=>t.trim())).filter((t=>{const e=t.slice(0,t.indexOf(":")).trim().toLowerCase();return!!(l.has(e)||a&&a.has(e))&&!/url\s*\(|expression\s*\(/i.test(t)})).join("; ")}function m(t){const e=t.tagName.toLowerCase(),a=r[e];for(const i of Array.from(t.attributes)){const n=i.name.toLowerCase();if((o.has(n)||void 0!==a&&a.has(n))&&!n.startsWith("on"))if("style"===n){const a=g(i.value,e);a?t.setAttribute("style",a):t.removeAttribute("style")}else if("class"===n){const e=i.value.split(/\s+/).filter((t=>t&&!s.test(t))).join(" ");e?t.setAttribute("class",e):t.removeAttribute("class")}else"id"===n?s.test(i.value)&&t.removeAttribute("id"):"href"===n||"src"===n?c(i.value,"img"===e)||t.removeAttribute(i.name):"target"===n&&("_blank"===i.value?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("target"));else t.removeAttribute(i.name)}}function p(r){for(const o of Array.from(r.children)){const r=o.tagName.toLowerCase();if(i.has(r))o.remove();else{if("iframe"===r){if(!t(o.getAttribute("src")??"")){o.remove();continue}o.setAttribute("sandbox",e),o.setAttribute("referrerpolicy",a)}if("style"!==r)n.has(r)?(m(o),p(o)):(p(o),o.replaceWith(...Array.from(o.childNodes)));else{o.textContent=(o.textContent??"").replace(/<\/style/gi,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/@import[^;]*;?/gi,"").replace(/expression\s*\(/gi,"blocked(").replace(/(behavior|-moz-binding)(\s*):/gi,"blocked-prop$2:").replace(/url\(\s*(['"]?)([^)]*?)\1\s*\)/gi,((t,e,a)=>{const i=String(a).trim();return/^#/.test(i)||/^data:image\/(png|gif|jpe?g|webp|avif|bmp);/i.test(i)?t:"url(#)"})).trim();for(const t of Array.from(o.attributes))o.removeAttribute(t.name)}}}}function w(t){const e=(new DOMParser).parseFromString(`<body>${t}</body>`,"text/html");return p(e.body),e.body.innerHTML}export{c as i,w as s};
|