@wangeditor-next/plugin-formula 2.0.6 → 2.0.8

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 CHANGED
@@ -22,11 +22,14 @@ pnpm add @wangeditor-next/plugin-formula
22
22
  ```js
23
23
  import { Boot, IEditorConfig, IToolbarConfig } from '@wangeditor-next/editor'
24
24
  import formulaModule from '@wangeditor-next/plugin-formula'
25
+ import 'katex/dist/katex.min.css'
25
26
 
26
27
  // 注册。要在创建编辑器之前注册,且只能注册一次,不可重复注册。
27
28
  Boot.registerModule(formulaModule)
28
29
  ```
29
30
 
31
+ 需要确保页面引入 KaTeX 样式,否则公式会退化为未排版状态。
32
+
30
33
  ### 配置
31
34
 
32
35
  ```js
@@ -18,6 +18,7 @@ interface IHoverbarConf {
18
18
  export type AlertType = 'success' | 'info' | 'warning' | 'error';
19
19
  export type TextStyleMode = 'inline' | 'class';
20
20
  export type ClassStylePolicy = 'preserve-data' | 'fallback-inline' | 'strict';
21
+ export type TableWidthExportMode = 'adaptive' | 'explicit';
21
22
  export type StyleClassTokenType = 'color' | 'bgColor' | 'fontSize' | 'fontFamily' | 'textAlign' | 'lineHeight' | 'indent';
22
23
  export interface IClassStyleUnsupportedPayload {
23
24
  type: string;
@@ -88,12 +89,14 @@ interface IEmotionConfig {
88
89
  }
89
90
  interface IInsertTableConfig {
90
91
  minWidth: number;
92
+ minRowHeight: number;
91
93
  tableHeader: {
92
94
  selected: boolean;
93
95
  };
94
96
  tableFullWidth: {
95
97
  selected: boolean;
96
98
  };
99
+ widthExportMode: TableWidthExportMode;
97
100
  }
98
101
  interface IInsertTableColConfig {
99
102
  insertPosition: 'before' | 'after';
@@ -2,7 +2,7 @@
2
2
  * @description 绑定 node 的关系
3
3
  * @author wangfupeng
4
4
  */
5
- import { Node, Ancestor } from 'slate';
5
+ import { Ancestor, Node } from 'slate';
6
6
  import { IDomEditor } from '../editor/interface';
7
7
  /**
8
8
  * createEditor 未传递 selector 时,绑定 node 的关系( NODE_TO_PARENT, NODE_TO_INDEX 等 )
@@ -2,9 +2,9 @@
2
2
  * @description create toolbar
3
3
  * @author wangfupeng
4
4
  */
5
+ import { IToolbarConfig } from '../config/interface';
5
6
  import { IDomEditor } from '../editor/interface';
6
7
  import Toolbar from '../menus/bar/Toolbar';
7
- import { IToolbarConfig } from '../config/interface';
8
8
  import { DOMElement } from '../utils/dom';
9
9
  interface ICreateOption {
10
10
  selector: string | DOMElement;
@@ -3,8 +3,8 @@
3
3
  * @author wangfupeng
4
4
  */
5
5
  import { Dom7Array } from '../../utils/dom';
6
- import { IBarItem } from './index';
7
6
  import { ISelectMenu } from '../interface';
7
+ import { IBarItem } from './index';
8
8
  declare class BarItemSelect implements IBarItem {
9
9
  readonly $elem: Dom7Array;
10
10
  private readonly $button;
@@ -2,9 +2,9 @@
2
2
  * @description bar item
3
3
  * @author wangfupeng
4
4
  */
5
- import { Dom7Array } from '../../utils/dom';
6
- import { IButtonMenu, ISelectMenu, IDropPanelMenu, IModalMenu, IMenuGroup } from '../interface';
7
5
  import { IDomEditor } from '../../editor/interface';
6
+ import { Dom7Array } from '../../utils/dom';
7
+ import { IButtonMenu, IDropPanelMenu, IMenuGroup, IModalMenu, ISelectMenu } from '../interface';
8
8
  import GroupButton from './GroupButton';
9
9
  type MenuType = IButtonMenu | ISelectMenu | IDropPanelMenu | IModalMenu;
10
10
  export interface IBarItem {
@@ -2,13 +2,11 @@
2
2
  * @description dropPanel class
3
3
  * @author wangfupeng
4
4
  */
5
- import { IDomEditor } from '../../editor/interface';
6
5
  import { Dom7Array } from '../../utils/dom';
7
6
  import PanelAndModal from './BaseClass';
8
7
  declare class DropPanel extends PanelAndModal {
9
8
  type: string;
10
9
  readonly $elem: Dom7Array;
11
- constructor(editor: IDomEditor);
12
10
  genSelfElem(): Dom7Array | null;
13
11
  }
14
12
  export default DropPanel;
@@ -2,10 +2,10 @@
2
2
  * @description modal class
3
3
  * @author wangfupeng
4
4
  */
5
+ import { IDomEditor } from '../../editor/interface';
5
6
  import { Dom7Array, DOMElement } from '../../utils/dom';
6
7
  import { IPositionStyle } from '../interface';
7
8
  import PanelAndModal from './BaseClass';
8
- import { IDomEditor } from '../../editor/interface';
9
9
  declare class Modal extends PanelAndModal {
10
10
  type: string;
11
11
  readonly $elem: Dom7Array;
@@ -2,7 +2,7 @@
2
2
  * @description slate node to vnode
3
3
  * @author wangfupeng
4
4
  */
5
- import { Node, Ancestor } from 'slate';
5
+ import { Ancestor, Node } from 'slate';
6
6
  import { VNode } from 'snabbdom';
7
7
  import { IDomEditor } from '../editor/interface';
8
8
  /**
@@ -2,8 +2,8 @@
2
2
  * @description 生成 text vnode
3
3
  * @author wangfupeng
4
4
  */
5
- import { Text as SlateText, Ancestor } from 'slate';
5
+ import { Ancestor, Text as SlateText } from 'slate';
6
6
  import { VNode } from 'snabbdom';
7
7
  import { IDomEditor } from '../../editor/interface';
8
- declare function genTextVnode(leafNode: SlateText, isLast: boolean | undefined, textNode: SlateText, parent: Ancestor, editor: IDomEditor): VNode;
8
+ declare function genTextVnode(leafNode: SlateText, textNode: SlateText, parent: Ancestor, editor: IDomEditor, isLast?: boolean): VNode;
9
9
  export default genTextVnode;
@@ -4,16 +4,16 @@
4
4
  */
5
5
  import handleBeforeInput from './beforeInput';
6
6
  import handleOnBlur from './blur';
7
- import handleOnFocus from './focus';
8
7
  import handleOnClick from './click';
9
- import { handleCompositionStart, handleCompositionEnd, handleCompositionUpdate } from './composition';
10
- import handleOnKeydown from './keydown';
11
- import handleKeypress from './keypress';
8
+ import { handleCompositionEnd, handleCompositionStart, handleCompositionUpdate } from './composition';
12
9
  import handleOnCopy from './copy';
13
10
  import handleOnCut from './cut';
14
- import handleOnPaste from './paste';
15
- import { handleOnDragover, handleOnDragstart, handleOnDragend } from './drag';
11
+ import { handleOnDragend, handleOnDragover, handleOnDragstart } from './drag';
16
12
  import handleOnDrop from './drop';
13
+ import handleOnFocus from './focus';
14
+ import handleOnKeydown from './keydown';
15
+ import handleKeypress from './keypress';
16
+ import handleOnPaste from './paste';
17
17
  declare const eventConf: {
18
18
  beforeinput: typeof handleBeforeInput;
19
19
  blur: typeof handleOnBlur;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("katex"),require("@wangeditor-next/editor"),require("snabbdom")):"function"==typeof define&&define.amd?define(["katex","@wangeditor-next/editor","snabbdom"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).WangEditorFormulaPlugin=e(t.katex,t.editor,t.snabbdom)}(this,function(t,e,n){"use strict";var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)};function r(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)l.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return l}"function"==typeof SuppressedError&&SuppressedError,function(){if(void 0!==window.Reflect&&void 0!==window.customElements&&!window.customElements.polyfillWrapFlushCallback){var t=HTMLElement,e=function(){return Reflect.construct(t,[],this.constructor)};window.HTMLElement=e,HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}}();var i=function(e){function n(){var t=e.call(this)||this,n=t.attachShadow({mode:"open"}),o=n.ownerDocument.createElement("span");return o.style.display="inline-block",n.appendChild(o),t.span=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),Object.defineProperty(n,"observedAttributes",{get:function(){return["data-value"]},enumerable:!1,configurable:!0}),n.prototype.attributeChangedCallback=function(t,e,n){if("data-value"===t){if(e===n)return;this.render(n||"")}},n.prototype.render=function(e){t.render(e,this.span,{throwOnError:!1,output:"mathml"})},n}(HTMLElement);window.customElements.get("w-e-formula-card")||window.customElements.define("w-e-formula-card",i),e.i18nAddResources("en",{formula:{formula:"Formula",placeholder:"Use LateX syntax",insert:"Insert formula",edit:"Edit formula",ok:"OK"}}),e.i18nAddResources("zh-CN",{formula:{formula:"公式",placeholder:"使用 LateX 语法",insert:"插入公式",edit:"编辑公式",ok:"确定"}});var l={type:"formula",elemToHtml:function(t,e){var n=t.value;return'<span data-w-e-type="formula" data-w-e-is-void data-w-e-is-inline data-value="'.concat(void 0===n?"":n,'"></span>')}};function s(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function a(t={},e={}){Object.keys(e).forEach(n=>{void 0===t[n]?t[n]=e[n]:s(e[n])&&s(t[n])&&Object.keys(e[n]).length>0&&a(t[n],e[n])})}const u={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function c(){const t="undefined"!=typeof document?document:{};return a(t,u),t}const f={document:u,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:t=>"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0),cancelAnimationFrame(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function d(){const t="undefined"!=typeof window?window:{};return a(t,f),t}class p extends Array{constructor(t){"number"==typeof t?super(t):(super(...t||[]),function(t){const e=t.__proto__;Object.defineProperty(t,"__proto__",{get:()=>e,set(t){e.__proto__=t}})}(this))}}function h(t,e){const n=d(),o=c();let r=[];if(!e&&t instanceof p)return t;if(!t)return new p(r);if("string"==typeof t){const n=t.trim();if(n.indexOf("<")>=0&&n.indexOf(">")>=0){let t="div";0===n.indexOf("<li")&&(t="ul"),0===n.indexOf("<tr")&&(t="tbody"),0!==n.indexOf("<td")&&0!==n.indexOf("<th")||(t="tr"),0===n.indexOf("<tbody")&&(t="table"),0===n.indexOf("<option")&&(t="select");const e=o.createElement(t);e.innerHTML=n;for(let t=0;t<e.childNodes.length;t+=1)r.push(e.childNodes[t])}else r=function(t,e){if("string"!=typeof t)return[t];const n=[],o=e.querySelectorAll(t);for(let t=0;t<o.length;t+=1)n.push(o[t]);return n}(t.trim(),e||o)}else if(t.nodeType||t===n||t===o)r.push(t);else if(Array.isArray(t)){if(t instanceof p)return t;r=t}return new p(function(t){const e=[];for(let n=0;n<t.length;n+=1)-1===e.indexOf(t[n])&&e.push(t[n]);return e}(r))}function m(t){if(void 0===t){const t=this[0];if(!t)return;if(t.multiple&&"select"===t.nodeName.toLowerCase()){const e=[];for(let n=0;n<t.selectedOptions.length;n+=1)e.push(t.selectedOptions[n].value);return e}return t.value}for(let e=0;e<this.length;e+=1){const n=this[e];if(Array.isArray(t)&&n.multiple&&"select"===n.nodeName.toLowerCase())for(let e=0;e<n.options.length;e+=1)n.options[e].selected=t.indexOf(n.options[e].value)>=0;else n.value=t}return this}function v(...t){let[e,n,o,r]=t;function i(t){const e=t.target;if(!e)return;const r=t.target.dom7EventData||[];if(r.indexOf(t)<0&&r.unshift(t),h(e).is(n))o.apply(e,r);else{const t=h(e).parents();for(let e=0;e<t.length;e+=1)h(t[e]).is(n)&&o.apply(t[e],r)}}function l(t){const e=t&&t.target&&t.target.dom7EventData||[];e.indexOf(t)<0&&e.unshift(t),o.apply(this,e)}"function"==typeof t[1]&&([e,o,r]=t,n=void 0),r||(r=!1);const s=e.split(" ");let a;for(let t=0;t<this.length;t+=1){const e=this[t];if(n)for(a=0;a<s.length;a+=1){const t=s[a];e.dom7LiveListeners||(e.dom7LiveListeners={}),e.dom7LiveListeners[t]||(e.dom7LiveListeners[t]=[]),e.dom7LiveListeners[t].push({listener:o,proxyListener:i}),e.addEventListener(t,i,r)}else for(a=0;a<s.length;a+=1){const t=s[a];e.dom7Listeners||(e.dom7Listeners={}),e.dom7Listeners[t]||(e.dom7Listeners[t]=[]),e.dom7Listeners[t].push({listener:o,proxyListener:l}),e.addEventListener(t,l,r)}}return this}function y(t){if(void 0===t)return this[0]?this[0].innerHTML:null;for(let e=0;e<this.length;e+=1)this[e].innerHTML=t;return this}function g(t){const e=d(),n=c(),o=this[0];let r,i;if(!o||void 0===t)return!1;if("string"==typeof t){if(o.matches)return o.matches(t);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(t);if(o.msMatchesSelector)return o.msMatchesSelector(t);for(r=h(t),i=0;i<r.length;i+=1)if(r[i]===o)return!0;return!1}if(t===n)return o===n;if(t===e)return o===e;if(t.nodeType||t instanceof p){for(r=t.nodeType?[t]:t,i=0;i<r.length;i+=1)if(r[i]===o)return!0;return!1}return!1}function E(...t){let e;const n=c();for(let o=0;o<t.length;o+=1){e=t[o];for(let t=0;t<this.length;t+=1)if("string"==typeof e){const o=n.createElement("div");for(o.innerHTML=e;o.firstChild;)this[t].appendChild(o.firstChild)}else if(e instanceof p)for(let n=0;n<e.length;n+=1)this[t].appendChild(e[n]);else this[t].appendChild(e)}return this}function b(t){const e=[];for(let n=0;n<this.length;n+=1){let o=this[n].parentNode;for(;o;)t?h(o).is(t)&&e.push(o):e.push(o),o=o.parentNode}return h(e)}function w(t){const e=[];for(let n=0;n<this.length;n+=1){const o=this[n].querySelectorAll(t);for(let t=0;t<o.length;t+=1)e.push(o[t])}return h(e)}h.fn=p.prototype;const x="resize scroll".split(" ");const L=(T="focus",function(...t){if(void 0===t[0]){for(let t=0;t<this.length;t+=1)x.indexOf(T)<0&&(T in this[t]?this[t][T]():h(this[t]).trigger(T));return this}return this.on(T,...t)});var T;E&&(h.fn.append=E),y&&(h.fn.html=y),m&&(h.fn.val=m),v&&(h.fn.on=v),L&&(h.fn.focus=L),g&&(h.fn.is=g),b&&(h.fn.parents=b),w&&(h.fn.find=w);function S(t){return"".concat(t,"-").concat(((t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[t]];return e})())}function M(){return S("w-e-insert-formula")}var O=function(){function t(){this.title=e.t("formula.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=M(),this.buttonId=M()}return t.prototype.getSelectedElem=function(t){var n=e.DomEditor.getSelectedNodeByType(t,"formula");return null==n?null:n},t.prototype.getValue=function(t){var e=this.getSelectedElem(t);return e&&e.value||""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var n=t.selection;return null==n||(!!e.SlateRange.isExpanded(n)||null==this.getSelectedElem(t))},t.prototype.getModalPositionNode=function(t){return this.getSelectedElem(t)},t.prototype.getModalContentElem=function(t){var n=this,o=this.textareaId,i=this.buttonId,l=r(e.genModalTextareaElems(e.t("formula.formula"),o,e.t("formula.placeholder")),2),s=l[0],a=h(l[1]),u=r(e.genModalButtonElems(i,e.t("formula.ok")),1)[0];if(null==this.$content){var c=h("<div></div>");c.on("click","#".concat(i),function(e){e.preventDefault();var r=c.find("#".concat(o)).val().trim();n.updateFormula(t,r),t.hidePanelOrModal()}),this.$content=c}var f=this.$content;f.html(""),f.append(s),f.append(u);var d=this.getValue(t);return a.val(d),setTimeout(function(){a.focus()}),f[0]},t.prototype.updateFormula=function(t,n){if(n&&(t.restoreSelection(),!this.isDisabled(t))){var o=this.getSelectedElem(t);if(null!=o){var r=e.DomEditor.findPath(t,o),i={value:n};e.SlateTransforms.setNodes(t,i,{at:r})}}},t}();function N(){return S("w-e-insert-formula")}var k=function(){function t(){this.title=e.t("formula.insert"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=N(),this.buttonId=N()}return t.prototype.getValue=function(t){return""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var n=t.selection;if(null==n)return!0;if(e.SlateRange.isExpanded(n))return!0;var o=e.DomEditor.getSelectedElems(t);return!!o.some(function(e){return t.isVoid(e)})||!!o.some(function(t){return"pre"===e.DomEditor.getNodeType(t)})},t.prototype.getModalPositionNode=function(t){return null},t.prototype.getModalContentElem=function(t){var n=this,o=this.textareaId,i=this.buttonId,l=r(e.genModalTextareaElems(e.t("formula.formula"),o,e.t("formula.placeholder")),2),s=l[0],a=h(l[1]),u=r(e.genModalButtonElems(i,e.t("formula.ok")),1)[0];if(null==this.$content){var c=h("<div></div>");c.on("click","#".concat(i),function(e){e.preventDefault();var r=c.find("#".concat(o)).val().trim();n.insertFormula(t,r),t.hidePanelOrModal()}),this.$content=c}var f=this.$content;return f.html(""),f.append(s),f.append(u),a.val(""),setTimeout(function(){a.focus()}),f[0]},t.prototype.insertFormula=function(t,e){if(e&&(t.restoreSelection(),!this.isDisabled(t))){var n={type:"formula",value:e,children:[{text:""}]};t.insertNode(n)}},t}();return{editorPlugin:function(t){var n=t.isInline,o=t.isVoid,r=t;return r.isInline=function(t){return"formula"===e.DomEditor.getNodeType(t)||n(t)},r.isVoid=function(t){return"formula"===e.DomEditor.getNodeType(t)||o(t)},r},renderElems:[{type:"formula",renderElem:function(t,o,r){var i=e.DomEditor.isNodeSelected(r,t),l=t.value,s=void 0===l?"":l,a=n.h("w-e-formula-card",{dataset:{value:s}},null);return n.h("div",{className:"w-e-textarea-formula-container",props:{contentEditable:!1},style:{display:"inline-block",marginLeft:"3px",marginRight:"3px",border:i?"2px solid var(--w-e-textarea-selected-border-color)":"2px solid transparent",borderRadius:"3px",padding:"3px 3px"}},[a])}}],elemsToHtml:[l],parseElemsHtml:[{selector:'span[data-w-e-type="formula"]',parseElemHtml:function(t,e,n){return{type:"formula",value:t.getAttribute("data-value")||"",children:[{text:""}]}}}],menus:[{key:"insertFormula",factory:function(){return new k}},{key:"editFormula",factory:function(){return new O}}]}});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("katex"),require("@wangeditor-next/editor"),require("snabbdom")):"function"==typeof define&&define.amd?define(["katex","@wangeditor-next/editor","snabbdom"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).WangEditorFormulaPlugin=e(t.katex,t.editor,t.snabbdom)}(this,function(t,e,n){"use strict";var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)};function r(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)l.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return l}"function"==typeof SuppressedError&&SuppressedError,function(){if(void 0!==window.Reflect&&void 0!==window.customElements&&!window.customElements.polyfillWrapFlushCallback){var t=HTMLElement,e=function(){return Reflect.construct(t,[],this.constructor)};window.HTMLElement=e,HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}}();var i=function(e){function n(){var t=e.call(this)||this;return t.span=null,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),Object.defineProperty(n,"observedAttributes",{get:function(){return["data-value"]},enumerable:!1,configurable:!0}),n.prototype.attributeChangedCallback=function(t,e,n){if("data-value"===t){if(e===n)return;this.render(n||"")}},n.prototype.ensureSpan=function(){if(this.span)return this.span;var t=(this.ownerDocument||window.document).createElement("span");return t.style.display="inline-block",this.appendChild(t),this.span=t,t},n.prototype.render=function(e){var n=this.ensureSpan();t.render(e,n,{throwOnError:!1,output:"htmlAndMathml"})},n}(HTMLElement);window.customElements.get("w-e-formula-card")||window.customElements.define("w-e-formula-card",i),e.i18nAddResources("en",{formula:{formula:"Formula",placeholder:"Use LateX syntax",insert:"Insert formula",edit:"Edit formula",ok:"OK"}}),e.i18nAddResources("zh-CN",{formula:{formula:"公式",placeholder:"使用 LateX 语法",insert:"插入公式",edit:"编辑公式",ok:"确定"}});var l={type:"formula",elemToHtml:function(t,e){var n=t.value;return'<span data-w-e-type="formula" data-w-e-is-void data-w-e-is-inline data-value="'.concat(void 0===n?"":n,'"></span>')}};function s(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function a(t={},e={}){Object.keys(e).forEach(n=>{void 0===t[n]?t[n]=e[n]:s(e[n])&&s(t[n])&&Object.keys(e[n]).length>0&&a(t[n],e[n])})}const u={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function c(){const t="undefined"!=typeof document?document:{};return a(t,u),t}const f={document:u,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:t=>"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0),cancelAnimationFrame(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function d(){const t="undefined"!=typeof window?window:{};return a(t,f),t}class p extends Array{constructor(t){"number"==typeof t?super(t):(super(...t||[]),function(t){const e=t.__proto__;Object.defineProperty(t,"__proto__",{get:()=>e,set(t){e.__proto__=t}})}(this))}}function h(t,e){const n=d(),o=c();let r=[];if(!e&&t instanceof p)return t;if(!t)return new p(r);if("string"==typeof t){const n=t.trim();if(n.indexOf("<")>=0&&n.indexOf(">")>=0){let t="div";0===n.indexOf("<li")&&(t="ul"),0===n.indexOf("<tr")&&(t="tbody"),0!==n.indexOf("<td")&&0!==n.indexOf("<th")||(t="tr"),0===n.indexOf("<tbody")&&(t="table"),0===n.indexOf("<option")&&(t="select");const e=o.createElement(t);e.innerHTML=n;for(let t=0;t<e.childNodes.length;t+=1)r.push(e.childNodes[t])}else r=function(t,e){if("string"!=typeof t)return[t];const n=[],o=e.querySelectorAll(t);for(let t=0;t<o.length;t+=1)n.push(o[t]);return n}(t.trim(),e||o)}else if(t.nodeType||t===n||t===o)r.push(t);else if(Array.isArray(t)){if(t instanceof p)return t;r=t}return new p(function(t){const e=[];for(let n=0;n<t.length;n+=1)-1===e.indexOf(t[n])&&e.push(t[n]);return e}(r))}function m(t){if(void 0===t){const t=this[0];if(!t)return;if(t.multiple&&"select"===t.nodeName.toLowerCase()){const e=[];for(let n=0;n<t.selectedOptions.length;n+=1)e.push(t.selectedOptions[n].value);return e}return t.value}for(let e=0;e<this.length;e+=1){const n=this[e];if(Array.isArray(t)&&n.multiple&&"select"===n.nodeName.toLowerCase())for(let e=0;e<n.options.length;e+=1)n.options[e].selected=t.indexOf(n.options[e].value)>=0;else n.value=t}return this}function v(...t){let[e,n,o,r]=t;function i(t){const e=t.target;if(!e)return;const r=t.target.dom7EventData||[];if(r.indexOf(t)<0&&r.unshift(t),h(e).is(n))o.apply(e,r);else{const t=h(e).parents();for(let e=0;e<t.length;e+=1)h(t[e]).is(n)&&o.apply(t[e],r)}}function l(t){const e=t&&t.target&&t.target.dom7EventData||[];e.indexOf(t)<0&&e.unshift(t),o.apply(this,e)}"function"==typeof t[1]&&([e,o,r]=t,n=void 0),r||(r=!1);const s=e.split(" ");let a;for(let t=0;t<this.length;t+=1){const e=this[t];if(n)for(a=0;a<s.length;a+=1){const t=s[a];e.dom7LiveListeners||(e.dom7LiveListeners={}),e.dom7LiveListeners[t]||(e.dom7LiveListeners[t]=[]),e.dom7LiveListeners[t].push({listener:o,proxyListener:i}),e.addEventListener(t,i,r)}else for(a=0;a<s.length;a+=1){const t=s[a];e.dom7Listeners||(e.dom7Listeners={}),e.dom7Listeners[t]||(e.dom7Listeners[t]=[]),e.dom7Listeners[t].push({listener:o,proxyListener:l}),e.addEventListener(t,l,r)}}return this}function y(t){if(void 0===t)return this[0]?this[0].innerHTML:null;for(let e=0;e<this.length;e+=1)this[e].innerHTML=t;return this}function g(t){const e=d(),n=c(),o=this[0];let r,i;if(!o||void 0===t)return!1;if("string"==typeof t){if(o.matches)return o.matches(t);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(t);if(o.msMatchesSelector)return o.msMatchesSelector(t);for(r=h(t),i=0;i<r.length;i+=1)if(r[i]===o)return!0;return!1}if(t===n)return o===n;if(t===e)return o===e;if(t.nodeType||t instanceof p){for(r=t.nodeType?[t]:t,i=0;i<r.length;i+=1)if(r[i]===o)return!0;return!1}return!1}function E(...t){let e;const n=c();for(let o=0;o<t.length;o+=1){e=t[o];for(let t=0;t<this.length;t+=1)if("string"==typeof e){const o=n.createElement("div");for(o.innerHTML=e;o.firstChild;)this[t].appendChild(o.firstChild)}else if(e instanceof p)for(let n=0;n<e.length;n+=1)this[t].appendChild(e[n]);else this[t].appendChild(e)}return this}function b(t){const e=[];for(let n=0;n<this.length;n+=1){let o=this[n].parentNode;for(;o;)t?h(o).is(t)&&e.push(o):e.push(o),o=o.parentNode}return h(e)}function w(t){const e=[];for(let n=0;n<this.length;n+=1){const o=this[n].querySelectorAll(t);for(let t=0;t<o.length;t+=1)e.push(o[t])}return h(e)}h.fn=p.prototype;const x="resize scroll".split(" ");const L=(T="focus",function(...t){if(void 0===t[0]){for(let t=0;t<this.length;t+=1)x.indexOf(T)<0&&(T in this[t]?this[t][T]():h(this[t]).trigger(T));return this}return this.on(T,...t)});var T;E&&(h.fn.append=E),y&&(h.fn.html=y),m&&(h.fn.val=m),v&&(h.fn.on=v),L&&(h.fn.focus=L),g&&(h.fn.is=g),b&&(h.fn.parents=b),w&&(h.fn.find=w);function S(t){return"".concat(t,"-").concat(((t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[t]];return e})())}function M(){return S("w-e-insert-formula")}var O=function(){function t(){this.title=e.t("formula.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=M(),this.buttonId=M()}return t.prototype.getSelectedElem=function(t){var n=e.DomEditor.getSelectedNodeByType(t,"formula");return null==n?null:n},t.prototype.getValue=function(t){var e=this.getSelectedElem(t);return e&&e.value||""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var n=t.selection;return null==n||(!!e.SlateRange.isExpanded(n)||null==this.getSelectedElem(t))},t.prototype.getModalPositionNode=function(t){return this.getSelectedElem(t)},t.prototype.getModalContentElem=function(t){var n=this,o=this.textareaId,i=this.buttonId,l=r(e.genModalTextareaElems(e.t("formula.formula"),o,e.t("formula.placeholder")),2),s=l[0],a=h(l[1]),u=r(e.genModalButtonElems(i,e.t("formula.ok")),1)[0];if(null==this.$content){var c=h("<div></div>");c.on("click","#".concat(i),function(e){e.preventDefault();var r=c.find("#".concat(o)).val().trim();n.updateFormula(t,r),t.hidePanelOrModal()}),this.$content=c}var f=this.$content;f.html(""),f.append(s),f.append(u);var d=this.getValue(t);return a.val(d),setTimeout(function(){a.focus()}),f[0]},t.prototype.updateFormula=function(t,n){if(n&&(t.restoreSelection(),!this.isDisabled(t))){var o=this.getSelectedElem(t);if(null!=o){var r=e.DomEditor.findPath(t,o),i={value:n};e.SlateTransforms.setNodes(t,i,{at:r})}}},t}();function N(){return S("w-e-insert-formula")}var A=function(){function t(){this.title=e.t("formula.insert"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=N(),this.buttonId=N()}return t.prototype.getValue=function(t){return""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var n=t.selection;if(null==n)return!0;if(e.SlateRange.isExpanded(n))return!0;var o=e.DomEditor.getSelectedElems(t);return!!o.some(function(e){return t.isVoid(e)})||!!o.some(function(t){return"pre"===e.DomEditor.getNodeType(t)})},t.prototype.getModalPositionNode=function(t){return null},t.prototype.getModalContentElem=function(t){var n=this,o=this.textareaId,i=this.buttonId,l=r(e.genModalTextareaElems(e.t("formula.formula"),o,e.t("formula.placeholder")),2),s=l[0],a=h(l[1]),u=r(e.genModalButtonElems(i,e.t("formula.ok")),1)[0];if(null==this.$content){var c=h("<div></div>");c.on("click","#".concat(i),function(e){e.preventDefault();var r=c.find("#".concat(o)).val().trim();n.insertFormula(t,r),t.hidePanelOrModal()}),this.$content=c}var f=this.$content;return f.html(""),f.append(s),f.append(u),a.val(""),setTimeout(function(){a.focus()}),f[0]},t.prototype.insertFormula=function(t,e){if(e&&(t.restoreSelection(),!this.isDisabled(t))){var n={type:"formula",value:e,children:[{text:""}]};t.insertNode(n)}},t}();return{editorPlugin:function(t){var n=t.isInline,o=t.isVoid,r=t;return r.isInline=function(t){return"formula"===e.DomEditor.getNodeType(t)||n(t)},r.isVoid=function(t){return"formula"===e.DomEditor.getNodeType(t)||o(t)},r},renderElems:[{type:"formula",renderElem:function(t,o,r){var i=e.DomEditor.isNodeSelected(r,t),l=t.value,s=void 0===l?"":l,a=n.h("w-e-formula-card",{dataset:{value:s}},null);return n.h("div",{className:"w-e-textarea-formula-container",props:{contentEditable:!1},style:{display:"inline-block",marginLeft:"3px",marginRight:"3px",border:i?"2px solid var(--w-e-textarea-selected-border-color)":"2px solid transparent",borderRadius:"3px",padding:"3px 3px"}},[a])}}],elemsToHtml:[l],parseElemsHtml:[{selector:'span[data-w-e-type="formula"]',parseElemHtml:function(t,e,n){return{type:"formula",value:t.getAttribute("data-value")||"",children:[{text:""}]}}}],menus:[{key:"insertFormula",factory:function(){return new A}},{key:"editFormula",factory:function(){return new O}}]}});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/register-custom-elem/native-shim.ts","../src/register-custom-elem/index.ts","../src/module/local.ts","../src/module/elem-to-html.ts","../../../node_modules/.pnpm/ssr-window@4.0.2/node_modules/ssr-window/ssr-window.esm.js","../../../node_modules/.pnpm/dom7@4.0.6/node_modules/dom7/dom7.esm.js","../src/utils/dom.ts","../src/utils/util.ts","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.browser.js","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/url-alphabet/index.js","../src/module/menu/EditFormula.ts","../src/constants/icon-svg.ts","../src/module/menu/InsertFormula.ts","../src/module/index.ts","../src/module/plugin.ts","../src/module/render-elem.ts","../src/module/parse-elem-html.ts","../src/module/menu/index.ts"],"sourcesContent":["// @ts-nocheck\n\n// 参考 https://github.com/webcomponents/custom-elements/blob/master/src/native-shim.js\n\n/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * This shim allows elements written in, or compiled to, ES5 to work on native\n * implementations of Custom Elements v1. It sets new.target to the value of\n * this.constructor so that the native HTMLElement constructor can access the\n * current under-construction element's definition.\n */\n(function () {\n if (\n // No Reflect, no classes, no need for shim because native custom elements\n // require ES2015 classes or Reflect.\n window.Reflect === undefined\n || window.customElements === undefined\n // The webcomponentsjs custom elements polyfill doesn't require\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\n || window.customElements.polyfillWrapFlushCallback\n ) {\n return\n }\n const BuiltInHTMLElement = HTMLElement\n /**\n * With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.\n * However, if we declare the function as a property on an object literal, and\n * use quotes for the property name, then closure will leave that much intact,\n * which is enough for the JS VM to correctly set Function.prototype.name.\n */\n const wrapperForTheName = {\n // eslint-disable-next-line func-names\n HTMLElement: /** @this {!Object} */ function HTMLElement() {\n return Reflect.construct(BuiltInHTMLElement, [], /** @type {!Function} */ this.constructor)\n },\n }\n\n window.HTMLElement = wrapperForTheName.HTMLElement\n HTMLElement.prototype = BuiltInHTMLElement.prototype\n HTMLElement.prototype.constructor = HTMLElement\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement)\n}())\n","/**\n * @description 注册自定义 elem\n * @author wangfupeng\n */\n\nimport './native-shim'\n\nimport katex from 'katex'\n\nclass WangEditorFormulaCard extends HTMLElement {\n private span: HTMLElement\n\n // 监听的 attr\n static get observedAttributes() {\n return ['data-value']\n }\n\n constructor() {\n super()\n const shadow = this.attachShadow({ mode: 'open' })\n const document = shadow.ownerDocument\n const span = document.createElement('span')\n\n span.style.display = 'inline-block'\n shadow.appendChild(span)\n this.span = span\n }\n\n // connectedCallback() {\n // // 当 custom element首次被插入文档DOM时,被调用\n // console.log('connected')\n // }\n // disconnectedCallback() {\n // // 当 custom element从文档DOM中删除时,被调用\n // console.log('disconnected')\n // }\n // adoptedCallback() {\n // // 当 custom element被移动到新的文档时,被调用\n // console.log('adopted')\n // }\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'data-value') {\n if (oldValue === newValue) { return }\n this.render(newValue || '')\n }\n }\n\n private render(value: string) {\n katex.render(value, this.span, {\n throwOnError: false,\n output: 'mathml',\n })\n }\n}\n\nif (!window.customElements.get('w-e-formula-card')) {\n window.customElements.define('w-e-formula-card', WangEditorFormulaCard)\n}\n","/**\n * @description 多语言\n * @author wangfupeng\n */\n\nimport { i18nAddResources } from '@wangeditor-next/editor'\n\ni18nAddResources('en', {\n formula: {\n formula: 'Formula',\n placeholder: 'Use LateX syntax',\n insert: 'Insert formula',\n edit: 'Edit formula',\n ok: 'OK',\n },\n})\n\ni18nAddResources('zh-CN', {\n formula: {\n formula: '公式',\n placeholder: '使用 LateX 语法',\n insert: '插入公式',\n edit: '编辑公式',\n ok: '确定',\n },\n})\n","/**\n * @description elem to html\n * @author wangfupeng\n */\n\nimport { SlateElement } from '@wangeditor-next/editor'\n\nimport { FormulaElement } from './custom-types'\n\n// 生成 html 的函数\nfunction formulaToHtml(elem: SlateElement, _childrenHtml: string): string {\n const { value = '' } = elem as FormulaElement\n\n return `<span data-w-e-type=\"formula\" data-w-e-is-void data-w-e-is-inline data-value=\"${value}\"></span>`\n}\n\n// 配置\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n elemToHtml: formulaToHtml,\n}\n\nexport default conf\n","/**\n * SSR Window 4.0.2\n * Better handling for window object in SSR environment\n * https://github.com/nolimits4web/ssr-window\n *\n * Copyright 2021, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: December 13, 2021\n */\n/* eslint-disable no-param-reassign */\nfunction isObject(obj) {\n return (obj !== null &&\n typeof obj === 'object' &&\n 'constructor' in obj &&\n obj.constructor === Object);\n}\nfunction extend(target = {}, src = {}) {\n Object.keys(src).forEach((key) => {\n if (typeof target[key] === 'undefined')\n target[key] = src[key];\n else if (isObject(src[key]) &&\n isObject(target[key]) &&\n Object.keys(src[key]).length > 0) {\n extend(target[key], src[key]);\n }\n });\n}\n\nconst ssrDocument = {\n body: {},\n addEventListener() { },\n removeEventListener() { },\n activeElement: {\n blur() { },\n nodeName: '',\n },\n querySelector() {\n return null;\n },\n querySelectorAll() {\n return [];\n },\n getElementById() {\n return null;\n },\n createEvent() {\n return {\n initEvent() { },\n };\n },\n createElement() {\n return {\n children: [],\n childNodes: [],\n style: {},\n setAttribute() { },\n getElementsByTagName() {\n return [];\n },\n };\n },\n createElementNS() {\n return {};\n },\n importNode() {\n return null;\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n};\nfunction getDocument() {\n const doc = typeof document !== 'undefined' ? document : {};\n extend(doc, ssrDocument);\n return doc;\n}\n\nconst ssrWindow = {\n document: ssrDocument,\n navigator: {\n userAgent: '',\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n history: {\n replaceState() { },\n pushState() { },\n go() { },\n back() { },\n },\n CustomEvent: function CustomEvent() {\n return this;\n },\n addEventListener() { },\n removeEventListener() { },\n getComputedStyle() {\n return {\n getPropertyValue() {\n return '';\n },\n };\n },\n Image() { },\n Date() { },\n screen: {},\n setTimeout() { },\n clearTimeout() { },\n matchMedia() {\n return {};\n },\n requestAnimationFrame(callback) {\n if (typeof setTimeout === 'undefined') {\n callback();\n return null;\n }\n return setTimeout(callback, 0);\n },\n cancelAnimationFrame(id) {\n if (typeof setTimeout === 'undefined') {\n return;\n }\n clearTimeout(id);\n },\n};\nfunction getWindow() {\n const win = typeof window !== 'undefined' ? window : {};\n extend(win, ssrWindow);\n return win;\n}\n\nexport { extend, getDocument, getWindow, ssrDocument, ssrWindow };\n","/**\n * Dom7 4.0.6\n * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API\n * https://framework7.io/docs/dom7.html\n *\n * Copyright 2023, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: February 2, 2023\n */\nimport { getWindow, getDocument } from 'ssr-window';\n\n/* eslint-disable no-proto */\nfunction makeReactive(obj) {\n const proto = obj.__proto__;\n Object.defineProperty(obj, '__proto__', {\n get() {\n return proto;\n },\n\n set(value) {\n proto.__proto__ = value;\n }\n\n });\n}\n\nclass Dom7 extends Array {\n constructor(items) {\n if (typeof items === 'number') {\n super(items);\n } else {\n super(...(items || []));\n makeReactive(this);\n }\n }\n\n}\n\nfunction arrayFlat(arr = []) {\n const res = [];\n arr.forEach(el => {\n if (Array.isArray(el)) {\n res.push(...arrayFlat(el));\n } else {\n res.push(el);\n }\n });\n return res;\n}\nfunction arrayFilter(arr, callback) {\n return Array.prototype.filter.call(arr, callback);\n}\nfunction arrayUnique(arr) {\n const uniqueArray = [];\n\n for (let i = 0; i < arr.length; i += 1) {\n if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);\n }\n\n return uniqueArray;\n}\nfunction toCamelCase(string) {\n return string.toLowerCase().replace(/-(.)/g, (match, group) => group.toUpperCase());\n}\n\n// eslint-disable-next-line\n\nfunction qsa(selector, context) {\n if (typeof selector !== 'string') {\n return [selector];\n }\n\n const a = [];\n const res = context.querySelectorAll(selector);\n\n for (let i = 0; i < res.length; i += 1) {\n a.push(res[i]);\n }\n\n return a;\n}\n\nfunction $(selector, context) {\n const window = getWindow();\n const document = getDocument();\n let arr = [];\n\n if (!context && selector instanceof Dom7) {\n return selector;\n }\n\n if (!selector) {\n return new Dom7(arr);\n }\n\n if (typeof selector === 'string') {\n const html = selector.trim();\n\n if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {\n let toCreate = 'div';\n if (html.indexOf('<li') === 0) toCreate = 'ul';\n if (html.indexOf('<tr') === 0) toCreate = 'tbody';\n if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';\n if (html.indexOf('<tbody') === 0) toCreate = 'table';\n if (html.indexOf('<option') === 0) toCreate = 'select';\n const tempParent = document.createElement(toCreate);\n tempParent.innerHTML = html;\n\n for (let i = 0; i < tempParent.childNodes.length; i += 1) {\n arr.push(tempParent.childNodes[i]);\n }\n } else {\n arr = qsa(selector.trim(), context || document);\n } // arr = qsa(selector, document);\n\n } else if (selector.nodeType || selector === window || selector === document) {\n arr.push(selector);\n } else if (Array.isArray(selector)) {\n if (selector instanceof Dom7) return selector;\n arr = selector;\n }\n\n return new Dom7(arrayUnique(arr));\n}\n\n$.fn = Dom7.prototype;\n\n// eslint-disable-next-line\n\nfunction addClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.add(...classNames);\n });\n return this;\n}\n\nfunction removeClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.remove(...classNames);\n });\n return this;\n}\n\nfunction toggleClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n classNames.forEach(className => {\n el.classList.toggle(className);\n });\n });\n}\n\nfunction hasClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n return arrayFilter(this, el => {\n return classNames.filter(className => el.classList.contains(className)).length > 0;\n }).length > 0;\n}\n\nfunction attr(attrs, value) {\n if (arguments.length === 1 && typeof attrs === 'string') {\n // Get attr\n if (this[0]) return this[0].getAttribute(attrs);\n return undefined;\n } // Set attrs\n\n\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i].setAttribute(attrs, value);\n } else {\n // Object\n for (const attrName in attrs) {\n this[i][attrName] = attrs[attrName];\n this[i].setAttribute(attrName, attrs[attrName]);\n }\n }\n }\n\n return this;\n}\n\nfunction removeAttr(attr) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].removeAttribute(attr);\n }\n\n return this;\n}\n\nfunction prop(props, value) {\n if (arguments.length === 1 && typeof props === 'string') {\n // Get prop\n if (this[0]) return this[0][props];\n } else {\n // Set props\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i][props] = value;\n } else {\n // Object\n for (const propName in props) {\n this[i][propName] = props[propName];\n }\n }\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction data(key, value) {\n let el;\n\n if (typeof value === 'undefined') {\n el = this[0];\n if (!el) return undefined; // Get value\n\n if (el.dom7ElementDataStorage && key in el.dom7ElementDataStorage) {\n return el.dom7ElementDataStorage[key];\n }\n\n const dataKey = el.getAttribute(`data-${key}`);\n\n if (dataKey) {\n return dataKey;\n }\n\n return undefined;\n } // Set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n el = this[i];\n if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};\n el.dom7ElementDataStorage[key] = value;\n }\n\n return this;\n}\n\nfunction removeData(key) {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.dom7ElementDataStorage && el.dom7ElementDataStorage[key]) {\n el.dom7ElementDataStorage[key] = null;\n delete el.dom7ElementDataStorage[key];\n }\n }\n}\n\nfunction dataset() {\n const el = this[0];\n if (!el) return undefined;\n const dataset = {}; // eslint-disable-line\n\n if (el.dataset) {\n for (const dataKey in el.dataset) {\n dataset[dataKey] = el.dataset[dataKey];\n }\n } else {\n for (let i = 0; i < el.attributes.length; i += 1) {\n const attr = el.attributes[i];\n\n if (attr.name.indexOf('data-') >= 0) {\n dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value;\n }\n }\n }\n\n for (const key in dataset) {\n if (dataset[key] === 'false') dataset[key] = false;else if (dataset[key] === 'true') dataset[key] = true;else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] *= 1;\n }\n\n return dataset;\n}\n\nfunction val(value) {\n if (typeof value === 'undefined') {\n // get value\n const el = this[0];\n if (!el) return undefined;\n\n if (el.multiple && el.nodeName.toLowerCase() === 'select') {\n const values = [];\n\n for (let i = 0; i < el.selectedOptions.length; i += 1) {\n values.push(el.selectedOptions[i].value);\n }\n\n return values;\n }\n\n return el.value;\n } // set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (Array.isArray(value) && el.multiple && el.nodeName.toLowerCase() === 'select') {\n for (let j = 0; j < el.options.length; j += 1) {\n el.options[j].selected = value.indexOf(el.options[j].value) >= 0;\n }\n } else {\n el.value = value;\n }\n }\n\n return this;\n}\n\nfunction value(value) {\n return this.val(value);\n}\n\nfunction transform(transform) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transform = transform;\n }\n\n return this;\n}\n\nfunction transition(duration) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration;\n }\n\n return this;\n}\n\nfunction on(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n\n function handleLiveEvent(e) {\n const target = e.target;\n if (!target) return;\n const eventData = e.target.dom7EventData || [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n if ($(target).is(targetSelector)) listener.apply(target, eventData);else {\n const parents = $(target).parents(); // eslint-disable-line\n\n for (let k = 0; k < parents.length; k += 1) {\n if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData);\n }\n }\n }\n\n function handleEvent(e) {\n const eventData = e && e.target ? e.target.dom7EventData || [] : [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n listener.apply(this, eventData);\n }\n\n const events = eventType.split(' ');\n let j;\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (!targetSelector) {\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7Listeners) el.dom7Listeners = {};\n if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];\n el.dom7Listeners[event].push({\n listener,\n proxyListener: handleEvent\n });\n el.addEventListener(event, handleEvent, capture);\n }\n } else {\n // Live events\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7LiveListeners) el.dom7LiveListeners = {};\n if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = [];\n el.dom7LiveListeners[event].push({\n listener,\n proxyListener: handleLiveEvent\n });\n el.addEventListener(event, handleLiveEvent, capture);\n }\n }\n }\n\n return this;\n}\n\nfunction off(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n const events = eventType.split(' ');\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n let handlers;\n\n if (!targetSelector && el.dom7Listeners) {\n handlers = el.dom7Listeners[event];\n } else if (targetSelector && el.dom7LiveListeners) {\n handlers = el.dom7LiveListeners[event];\n }\n\n if (handlers && handlers.length) {\n for (let k = handlers.length - 1; k >= 0; k -= 1) {\n const handler = handlers[k];\n\n if (listener && handler.listener === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (!listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction once(...args) {\n const dom = this;\n let [eventName, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventName, listener, capture] = args;\n targetSelector = undefined;\n }\n\n function onceHandler(...eventArgs) {\n listener.apply(this, eventArgs);\n dom.off(eventName, targetSelector, onceHandler, capture);\n\n if (onceHandler.dom7proxy) {\n delete onceHandler.dom7proxy;\n }\n }\n\n onceHandler.dom7proxy = listener;\n return dom.on(eventName, targetSelector, onceHandler, capture);\n}\n\nfunction trigger(...args) {\n const window = getWindow();\n const events = args[0].split(' ');\n const eventData = args[1];\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n\n if (window.CustomEvent) {\n const evt = new window.CustomEvent(event, {\n detail: eventData,\n bubbles: true,\n cancelable: true\n });\n el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0);\n el.dispatchEvent(evt);\n el.dom7EventData = [];\n delete el.dom7EventData;\n }\n }\n }\n\n return this;\n}\n\nfunction transitionStart(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionstart', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionstart', fireCallBack);\n }\n\n return this;\n}\n\nfunction transitionEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionend', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionend', fireCallBack);\n }\n\n return this;\n}\n\nfunction animationEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('animationend', fireCallBack);\n }\n\n if (callback) {\n dom.on('animationend', fireCallBack);\n }\n\n return this;\n}\n\nfunction width() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerWidth;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('width'));\n }\n\n return null;\n}\n\nfunction outerWidth(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));\n }\n\n return this[0].offsetWidth;\n }\n\n return null;\n}\n\nfunction height() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerHeight;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('height'));\n }\n\n return null;\n}\n\nfunction outerHeight(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));\n }\n\n return this[0].offsetHeight;\n }\n\n return null;\n}\n\nfunction offset() {\n if (this.length > 0) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n const box = el.getBoundingClientRect();\n const body = document.body;\n const clientTop = el.clientTop || body.clientTop || 0;\n const clientLeft = el.clientLeft || body.clientLeft || 0;\n const scrollTop = el === window ? window.scrollY : el.scrollTop;\n const scrollLeft = el === window ? window.scrollX : el.scrollLeft;\n return {\n top: box.top + scrollTop - clientTop,\n left: box.left + scrollLeft - clientLeft\n };\n }\n\n return null;\n}\n\nfunction hide() {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.display = 'none';\n }\n\n return this;\n}\n\nfunction show() {\n const window = getWindow();\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.style.display === 'none') {\n el.style.display = '';\n }\n\n if (window.getComputedStyle(el, null).getPropertyValue('display') === 'none') {\n // Still not visible\n el.style.display = 'block';\n }\n }\n\n return this;\n}\n\nfunction styles() {\n const window = getWindow();\n if (this[0]) return window.getComputedStyle(this[0], null);\n return {};\n}\n\nfunction css(props, value) {\n const window = getWindow();\n let i;\n\n if (arguments.length === 1) {\n if (typeof props === 'string') {\n // .css('width')\n if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);\n } else {\n // .css({ width: '100px' })\n for (i = 0; i < this.length; i += 1) {\n for (const prop in props) {\n this[i].style[prop] = props[prop];\n }\n }\n\n return this;\n }\n }\n\n if (arguments.length === 2 && typeof props === 'string') {\n // .css('width', '100px')\n for (i = 0; i < this.length; i += 1) {\n this[i].style[props] = value;\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction each(callback) {\n if (!callback) return this;\n this.forEach((el, index) => {\n callback.apply(el, [el, index]);\n });\n return this;\n}\n\nfunction filter(callback) {\n const result = arrayFilter(this, callback);\n return $(result);\n}\n\nfunction html(html) {\n if (typeof html === 'undefined') {\n return this[0] ? this[0].innerHTML : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].innerHTML = html;\n }\n\n return this;\n}\n\nfunction text(text) {\n if (typeof text === 'undefined') {\n return this[0] ? this[0].textContent.trim() : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].textContent = text;\n }\n\n return this;\n}\n\nfunction is(selector) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n let compareWith;\n let i;\n if (!el || typeof selector === 'undefined') return false;\n\n if (typeof selector === 'string') {\n if (el.matches) return el.matches(selector);\n if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);\n if (el.msMatchesSelector) return el.msMatchesSelector(selector);\n compareWith = $(selector);\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n if (selector === document) {\n return el === document;\n }\n\n if (selector === window) {\n return el === window;\n }\n\n if (selector.nodeType || selector instanceof Dom7) {\n compareWith = selector.nodeType ? [selector] : selector;\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n return false;\n}\n\nfunction index() {\n let child = this[0];\n let i;\n\n if (child) {\n i = 0; // eslint-disable-next-line\n\n while ((child = child.previousSibling) !== null) {\n if (child.nodeType === 1) i += 1;\n }\n\n return i;\n }\n\n return undefined;\n}\n\nfunction eq(index) {\n if (typeof index === 'undefined') return this;\n const length = this.length;\n\n if (index > length - 1) {\n return $([]);\n }\n\n if (index < 0) {\n const returnIndex = length + index;\n if (returnIndex < 0) return $([]);\n return $([this[returnIndex]]);\n }\n\n return $([this[index]]);\n}\n\nfunction append(...els) {\n let newChild;\n const document = getDocument();\n\n for (let k = 0; k < els.length; k += 1) {\n newChild = els[k];\n\n for (let i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n while (tempDiv.firstChild) {\n this[i].appendChild(tempDiv.firstChild);\n }\n } else if (newChild instanceof Dom7) {\n for (let j = 0; j < newChild.length; j += 1) {\n this[i].appendChild(newChild[j]);\n }\n } else {\n this[i].appendChild(newChild);\n }\n }\n }\n\n return this;\n}\n\nfunction appendTo(parent) {\n $(parent).append(this);\n return this;\n}\n\nfunction prepend(newChild) {\n const document = getDocument();\n let i;\n let j;\n\n for (i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {\n this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);\n }\n } else if (newChild instanceof Dom7) {\n for (j = 0; j < newChild.length; j += 1) {\n this[i].insertBefore(newChild[j], this[i].childNodes[0]);\n }\n } else {\n this[i].insertBefore(newChild, this[i].childNodes[0]);\n }\n }\n\n return this;\n}\n\nfunction prependTo(parent) {\n $(parent).prepend(this);\n return this;\n}\n\nfunction insertBefore(selector) {\n const before = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (before.length === 1) {\n before[0].parentNode.insertBefore(this[i], before[0]);\n } else if (before.length > 1) {\n for (let j = 0; j < before.length; j += 1) {\n before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);\n }\n }\n }\n}\n\nfunction insertAfter(selector) {\n const after = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (after.length === 1) {\n after[0].parentNode.insertBefore(this[i], after[0].nextSibling);\n } else if (after.length > 1) {\n for (let j = 0; j < after.length; j += 1) {\n after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);\n }\n }\n }\n}\n\nfunction next(selector) {\n if (this.length > 0) {\n if (selector) {\n if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {\n return $([this[0].nextElementSibling]);\n }\n\n return $([]);\n }\n\n if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction nextAll(selector) {\n const nextEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.nextElementSibling) {\n const next = el.nextElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(next).is(selector)) nextEls.push(next);\n } else nextEls.push(next);\n\n el = next;\n }\n\n return $(nextEls);\n}\n\nfunction prev(selector) {\n if (this.length > 0) {\n const el = this[0];\n\n if (selector) {\n if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {\n return $([el.previousElementSibling]);\n }\n\n return $([]);\n }\n\n if (el.previousElementSibling) return $([el.previousElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction prevAll(selector) {\n const prevEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.previousElementSibling) {\n const prev = el.previousElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(prev).is(selector)) prevEls.push(prev);\n } else prevEls.push(prev);\n\n el = prev;\n }\n\n return $(prevEls);\n}\n\nfunction siblings(selector) {\n return this.nextAll(selector).add(this.prevAll(selector));\n}\n\nfunction parent(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode !== null) {\n if (selector) {\n if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);\n } else {\n parents.push(this[i].parentNode);\n }\n }\n }\n\n return $(parents);\n}\n\nfunction parents(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n let parent = this[i].parentNode; // eslint-disable-line\n\n while (parent) {\n if (selector) {\n if ($(parent).is(selector)) parents.push(parent);\n } else {\n parents.push(parent);\n }\n\n parent = parent.parentNode;\n }\n }\n\n return $(parents);\n}\n\nfunction closest(selector) {\n let closest = this; // eslint-disable-line\n\n if (typeof selector === 'undefined') {\n return $([]);\n }\n\n if (!closest.is(selector)) {\n closest = closest.parents(selector).eq(0);\n }\n\n return closest;\n}\n\nfunction find(selector) {\n const foundElements = [];\n\n for (let i = 0; i < this.length; i += 1) {\n const found = this[i].querySelectorAll(selector);\n\n for (let j = 0; j < found.length; j += 1) {\n foundElements.push(found[j]);\n }\n }\n\n return $(foundElements);\n}\n\nfunction children(selector) {\n const children = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n const childNodes = this[i].children;\n\n for (let j = 0; j < childNodes.length; j += 1) {\n if (!selector || $(childNodes[j]).is(selector)) {\n children.push(childNodes[j]);\n }\n }\n }\n\n return $(children);\n}\n\nfunction remove() {\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);\n }\n\n return this;\n}\n\nfunction detach() {\n return this.remove();\n}\n\nfunction add(...els) {\n const dom = this;\n let i;\n let j;\n\n for (i = 0; i < els.length; i += 1) {\n const toAdd = $(els[i]);\n\n for (j = 0; j < toAdd.length; j += 1) {\n dom.push(toAdd[j]);\n }\n }\n\n return dom;\n}\n\nfunction empty() {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.nodeType === 1) {\n for (let j = 0; j < el.childNodes.length; j += 1) {\n if (el.childNodes[j].parentNode) {\n el.childNodes[j].parentNode.removeChild(el.childNodes[j]);\n }\n }\n\n el.textContent = '';\n }\n }\n\n return this;\n}\n\n// eslint-disable-next-line\n\nfunction scrollTo(...args) {\n const window = getWindow();\n let [left, top, duration, easing, callback] = args;\n\n if (args.length === 4 && typeof easing === 'function') {\n callback = easing;\n [left, top, duration, callback, easing] = args;\n }\n\n if (typeof easing === 'undefined') easing = 'swing';\n return this.each(function animate() {\n const el = this;\n let currentTop;\n let currentLeft;\n let maxTop;\n let maxLeft;\n let newTop;\n let newLeft;\n let scrollTop; // eslint-disable-line\n\n let scrollLeft; // eslint-disable-line\n\n let animateTop = top > 0 || top === 0;\n let animateLeft = left > 0 || left === 0;\n\n if (typeof easing === 'undefined') {\n easing = 'swing';\n }\n\n if (animateTop) {\n currentTop = el.scrollTop;\n\n if (!duration) {\n el.scrollTop = top;\n }\n }\n\n if (animateLeft) {\n currentLeft = el.scrollLeft;\n\n if (!duration) {\n el.scrollLeft = left;\n }\n }\n\n if (!duration) return;\n\n if (animateTop) {\n maxTop = el.scrollHeight - el.offsetHeight;\n newTop = Math.max(Math.min(top, maxTop), 0);\n }\n\n if (animateLeft) {\n maxLeft = el.scrollWidth - el.offsetWidth;\n newLeft = Math.max(Math.min(left, maxLeft), 0);\n }\n\n let startTime = null;\n if (animateTop && newTop === currentTop) animateTop = false;\n if (animateLeft && newLeft === currentLeft) animateLeft = false;\n\n function render(time = new Date().getTime()) {\n if (startTime === null) {\n startTime = time;\n }\n\n const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);\n const easeProgress = easing === 'linear' ? progress : 0.5 - Math.cos(progress * Math.PI) / 2;\n let done;\n if (animateTop) scrollTop = currentTop + easeProgress * (newTop - currentTop);\n if (animateLeft) scrollLeft = currentLeft + easeProgress * (newLeft - currentLeft);\n\n if (animateTop && newTop > currentTop && scrollTop >= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateTop && newTop < currentTop && scrollTop <= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (done) {\n if (callback) callback();\n return;\n }\n\n if (animateTop) el.scrollTop = scrollTop;\n if (animateLeft) el.scrollLeft = scrollLeft;\n window.requestAnimationFrame(render);\n }\n\n window.requestAnimationFrame(render);\n });\n} // scrollTop(top, duration, easing, callback) {\n\n\nfunction scrollTop(...args) {\n let [top, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [top, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof top === 'undefined') {\n if (dom.length > 0) return dom[0].scrollTop;\n return null;\n }\n\n return dom.scrollTo(undefined, top, duration, easing, callback);\n}\n\nfunction scrollLeft(...args) {\n let [left, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [left, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof left === 'undefined') {\n if (dom.length > 0) return dom[0].scrollLeft;\n return null;\n }\n\n return dom.scrollTo(left, undefined, duration, easing, callback);\n}\n\n// eslint-disable-next-line\n\nfunction animate(initialProps, initialParams) {\n const window = getWindow();\n const els = this;\n const a = {\n props: Object.assign({}, initialProps),\n params: Object.assign({\n duration: 300,\n easing: 'swing' // or 'linear'\n\n /* Callbacks\n begin(elements)\n complete(elements)\n progress(elements, complete, remaining, start, tweenValue)\n */\n\n }, initialParams),\n elements: els,\n animating: false,\n que: [],\n\n easingProgress(easing, progress) {\n if (easing === 'swing') {\n return 0.5 - Math.cos(progress * Math.PI) / 2;\n }\n\n if (typeof easing === 'function') {\n return easing(progress);\n }\n\n return progress;\n },\n\n stop() {\n if (a.frameId) {\n window.cancelAnimationFrame(a.frameId);\n }\n\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n a.que = [];\n },\n\n done(complete) {\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n if (complete) complete(els);\n\n if (a.que.length > 0) {\n const que = a.que.shift();\n a.animate(que[0], que[1]);\n }\n },\n\n animate(props, params) {\n if (a.animating) {\n a.que.push([props, params]);\n return a;\n }\n\n const elements = []; // Define & Cache Initials & Units\n\n a.elements.each((el, index) => {\n let initialFullValue;\n let initialValue;\n let unit;\n let finalValue;\n let finalFullValue;\n if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a;\n elements[index] = {\n container: el\n };\n Object.keys(props).forEach(prop => {\n initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.');\n initialValue = parseFloat(initialFullValue);\n unit = initialFullValue.replace(initialValue, '');\n finalValue = parseFloat(props[prop]);\n finalFullValue = props[prop] + unit;\n elements[index][prop] = {\n initialFullValue,\n initialValue,\n unit,\n finalValue,\n finalFullValue,\n currentValue: initialValue\n };\n });\n });\n let startTime = null;\n let time;\n let elementsDone = 0;\n let propsDone = 0;\n let done;\n let began = false;\n a.animating = true;\n\n function render() {\n time = new Date().getTime();\n let progress;\n let easeProgress; // let el;\n\n if (!began) {\n began = true;\n if (params.begin) params.begin(els);\n }\n\n if (startTime === null) {\n startTime = time;\n }\n\n if (params.progress) {\n // eslint-disable-next-line\n params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), startTime + params.duration - time < 0 ? 0 : startTime + params.duration - time, startTime);\n }\n\n elements.forEach(element => {\n const el = element;\n if (done || el.done) return;\n Object.keys(props).forEach(prop => {\n if (done || el.done) return;\n progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0);\n easeProgress = a.easingProgress(params.easing, progress);\n const {\n initialValue,\n finalValue,\n unit\n } = el[prop];\n el[prop].currentValue = initialValue + easeProgress * (finalValue - initialValue);\n const currentValue = el[prop].currentValue;\n\n if (finalValue > initialValue && currentValue >= finalValue || finalValue < initialValue && currentValue <= finalValue) {\n el.container.style[prop] = finalValue + unit;\n propsDone += 1;\n\n if (propsDone === Object.keys(props).length) {\n el.done = true;\n elementsDone += 1;\n }\n\n if (elementsDone === elements.length) {\n done = true;\n }\n }\n\n if (done) {\n a.done(params.complete);\n return;\n }\n\n el.container.style[prop] = currentValue + unit;\n });\n });\n if (done) return; // Then call\n\n a.frameId = window.requestAnimationFrame(render);\n }\n\n a.frameId = window.requestAnimationFrame(render);\n return a;\n }\n\n };\n\n if (a.elements.length === 0) {\n return els;\n }\n\n let animateInstance;\n\n for (let i = 0; i < a.elements.length; i += 1) {\n if (a.elements[i].dom7AnimateInstance) {\n animateInstance = a.elements[i].dom7AnimateInstance;\n } else a.elements[i].dom7AnimateInstance = a;\n }\n\n if (!animateInstance) {\n animateInstance = a;\n }\n\n if (initialProps === 'stop') {\n animateInstance.stop();\n } else {\n animateInstance.animate(a.props, a.params);\n }\n\n return els;\n}\n\nfunction stop() {\n const els = this;\n\n for (let i = 0; i < els.length; i += 1) {\n if (els[i].dom7AnimateInstance) {\n els[i].dom7AnimateInstance.stop();\n }\n }\n}\n\nconst noTrigger = 'resize scroll'.split(' ');\n\nfunction shortcut(name) {\n function eventHandler(...args) {\n if (typeof args[0] === 'undefined') {\n for (let i = 0; i < this.length; i += 1) {\n if (noTrigger.indexOf(name) < 0) {\n if (name in this[i]) this[i][name]();else {\n $(this[i]).trigger(name);\n }\n }\n }\n\n return this;\n }\n\n return this.on(name, ...args);\n }\n\n return eventHandler;\n}\n\nconst click = shortcut('click');\nconst blur = shortcut('blur');\nconst focus = shortcut('focus');\nconst focusin = shortcut('focusin');\nconst focusout = shortcut('focusout');\nconst keyup = shortcut('keyup');\nconst keydown = shortcut('keydown');\nconst keypress = shortcut('keypress');\nconst submit = shortcut('submit');\nconst change = shortcut('change');\nconst mousedown = shortcut('mousedown');\nconst mousemove = shortcut('mousemove');\nconst mouseup = shortcut('mouseup');\nconst mouseenter = shortcut('mouseenter');\nconst mouseleave = shortcut('mouseleave');\nconst mouseout = shortcut('mouseout');\nconst mouseover = shortcut('mouseover');\nconst touchstart = shortcut('touchstart');\nconst touchend = shortcut('touchend');\nconst touchmove = shortcut('touchmove');\nconst resize = shortcut('resize');\nconst scroll = shortcut('scroll');\n\nexport default $;\nexport { $, add, addClass, animate, animationEnd, append, appendTo, attr, blur, change, children, click, closest, css, data, dataset, detach, each, empty, eq, filter, find, focus, focusin, focusout, hasClass, height, hide, html, index, insertAfter, insertBefore, is, keydown, keypress, keyup, mousedown, mouseenter, mouseleave, mousemove, mouseout, mouseover, mouseup, next, nextAll, off, offset, on, once, outerHeight, outerWidth, parent, parents, prepend, prependTo, prev, prevAll, prop, remove, removeAttr, removeClass, removeData, resize, scroll, scrollLeft, scrollTo, scrollTop, show, siblings, stop, styles, submit, text, toggleClass, touchend, touchmove, touchstart, transform, transition, transitionEnd, transitionStart, trigger, val, value, width };\n","/**\n * @description DOM 操作\n * @author wangfupeng\n */\n\nimport $, {\n append, find, focus, html, is, on, parents, val,\n} from 'dom7'\n\n// COMPAT: This is required to prevent TypeScript aliases from doing some very\n// weird things for Slate's types with the same name as globals. (2019/11/27)\n// https://github.com/microsoft/TypeScript/issues/35002\nimport DOMNode = globalThis.Node\nimport DOMComment = globalThis.Comment\nimport DOMElement = globalThis.Element\nimport DOMText = globalThis.Text\nimport DOMRange = globalThis.Range\nimport DOMSelection = globalThis.Selection\nimport DOMStaticRange = globalThis.StaticRange\n\nif (append) { $.fn.append = append }\nif (html) { $.fn.html = html }\nif (val) { $.fn.val = val }\nif (on) { $.fn.on = on }\nif (focus) { $.fn.focus = focus }\nif (is) { $.fn.is = is }\nif (parents) { $.fn.parents = parents }\nif (find) { $.fn.find = find }\n\nexport { Dom7Array } from 'dom7'\nexport default $\nexport {\n DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText,\n}\n","/**\n * @description 工具函数\n * @author wangfupeng\n */\n\nimport { nanoid } from 'nanoid'\n\n/**\n * 获取随机数字符串\n * @param prefix 前缀\n * @returns 随机数字符串\n */\nexport function genRandomStr(prefix: string = 'r'): string {\n return `${prefix}-${nanoid()}`\n}\n\n// export function replaceSymbols(str: string) {\n// return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')\n// }\n","/* @ts-self-types=\"./index.d.ts\" */\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << Math.log2(alphabet.length - 1)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step | 0\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length >= size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","/**\n * @description edit formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n SlateTransforms,\n t,\n} from '@wangeditor-next/editor'\n\nimport { PENCIL_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass EditFormulaMenu implements IModalMenu {\n readonly title = t('formula.edit')\n\n readonly iconSvg = PENCIL_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n private getSelectedElem(editor: IDomEditor): FormulaElement | null {\n const node = DomEditor.getSelectedNodeByType(editor, 'formula')\n\n if (node == null) { return null }\n return node as FormulaElement\n }\n\n /**\n * 获取公式 value\n * @param editor editor\n */\n getValue(editor: IDomEditor): string | boolean {\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem) {\n return formulaElem.value || ''\n }\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 无需 active\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n // 未匹配到 formula node 则禁用\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem == null) { return true }\n\n return false\n }\n\n // modal 定位\n getModalPositionNode(editor: IDomEditor): SlateNode | null {\n return this.getSelectedElem(editor)\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.updateFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n const value = this.getValue(editor)\n\n $textarea.val(value)\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private updateFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const selectedElem = this.getSelectedElem(editor)\n\n if (selectedElem == null) { return }\n\n const path = DomEditor.findPath(editor, selectedElem)\n const props: Partial<FormulaElement> = { value }\n\n SlateTransforms.setNodes(editor, props, { at: path })\n }\n}\n\nexport default EditFormulaMenu\n","/**\n * @description icon svg\n * @author wangfupeng\n */\n\n/**\n * 【注意】svg 字符串的长度 ,否则会导致代码体积过大\n * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293\n * 找不到再从 iconfont.com 搜索\n */\n\n// 公式\nexport const SIGMA_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z\"></path></svg>'\n\n// 编辑\nexport const PENCIL_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z\"></path></svg>'\n","/**\n * @description insert formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n t,\n} from '@wangeditor-next/editor'\n\nimport { SIGMA_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass InsertFormulaMenu implements IModalMenu {\n readonly title = t('formula.insert')\n\n readonly iconSvg = SIGMA_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n getValue(_editor: IDomEditor): string | boolean {\n // 插入菜单,不需要 value\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 任何时候,都不用激活 menu\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n const selectedElems = DomEditor.getSelectedElems(editor)\n\n const hasVoidElem = selectedElems.some(elem => editor.isVoid(elem))\n\n if (hasVoidElem) { return true } // 选中了 void 元素,禁用\n\n const hasPreElem = selectedElems.some(elem => DomEditor.getNodeType(elem) === 'pre')\n\n if (hasPreElem) { return true } // 选中了 pre 原则,禁用\n\n return false\n }\n\n getModalPositionNode(_editor: IDomEditor): SlateNode | null {\n return null // modal 依据选区定位\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.insertFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n $textarea.val('')\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private insertFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const formulaElem: FormulaElement = {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 需要有一个空 text\n }\n\n editor.insertNode(formulaElem)\n }\n}\n\nexport default InsertFormulaMenu\n","/**\n * @description formula module entry\n * @author wangfupeng\n */\n\nimport './local' // 多语言\n\nimport { IModuleConf } from '@wangeditor-next/editor'\n\nimport elemToHtmlConf from './elem-to-html'\nimport { editFormulaMenuConf, insertFormulaMenuConf } from './menu/index'\nimport parseHtmlConf from './parse-elem-html'\nimport withFormula from './plugin'\nimport renderElemConf from './render-elem'\n\nconst module: Partial<IModuleConf> = {\n editorPlugin: withFormula,\n renderElems: [renderElemConf],\n elemsToHtml: [elemToHtmlConf],\n parseElemsHtml: [parseHtmlConf],\n menus: [insertFormulaMenuConf, editFormulaMenuConf],\n}\n\nexport default module\n","/**\n * @description formula plugin\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor } from '@wangeditor-next/editor'\n\nfunction withFormula<T extends IDomEditor>(editor: T) {\n const { isInline, isVoid } = editor\n const newEditor = editor\n\n // 重写 isInline\n newEditor.isInline = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isInline(elem)\n }\n\n // 重写 isVoid\n newEditor.isVoid = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isVoid(elem)\n }\n\n return newEditor\n}\n\nexport default withFormula\n","/**\n * @description render elem\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor, SlateElement } from '@wangeditor-next/editor'\nimport { h, VNode } from 'snabbdom'\n\nimport { FormulaElement } from './custom-types'\n\nfunction renderFormula(elem: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode {\n // 当前节点是否选中\n const selected = DomEditor.isNodeSelected(editor, elem)\n\n // 构建 formula vnode\n const { value = '' } = elem as FormulaElement\n const formulaVnode = h(\n 'w-e-formula-card',\n {\n dataset: { value },\n },\n null,\n )\n\n // 构建容器 vnode\n const containerVnode = h(\n 'div',\n {\n className: 'w-e-textarea-formula-container',\n props: {\n contentEditable: false, // 不可编辑\n },\n style: {\n display: 'inline-block', // inline\n marginLeft: '3px',\n marginRight: '3px',\n border: selected // 选中/不选中,样式不一样\n ? '2px solid var(--w-e-textarea-selected-border-color)'\n : '2px solid transparent',\n borderRadius: '3px',\n padding: '3px 3px',\n },\n },\n [formulaVnode],\n )\n\n return containerVnode\n}\n\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n renderElem: renderFormula,\n}\n\nexport default conf\n","/**\n * @description parse elem html\n * @author wangfupeng\n */\n\nimport { IDomEditor, SlateDescendant, SlateElement } from '@wangeditor-next/editor'\n\nimport { DOMElement } from '../utils/dom'\nimport { FormulaElement } from './custom-types'\n\nfunction parseHtml(\n elem: DOMElement,\n _children: SlateDescendant[],\n _editor: IDomEditor,\n): SlateElement {\n const value = elem.getAttribute('data-value') || ''\n\n return {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 必须有一个空白 text\n } as FormulaElement\n}\n\nconst parseHtmlConf = {\n selector: 'span[data-w-e-type=\"formula\"]',\n parseElemHtml: parseHtml,\n}\n\nexport default parseHtmlConf\n","/**\n * @description formula menu entry\n * @author wangfupeng\n */\n\nimport EditFormulaMenu from './EditFormula'\nimport InsertFormulaMenu from './InsertFormula'\n\nexport const insertFormulaMenuConf = {\n key: 'insertFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new InsertFormulaMenu()\n },\n}\n\nexport const editFormulaMenuConf = {\n key: 'editFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new EditFormulaMenu()\n },\n}\n"],"names":["undefined","window","Reflect","customElements","polyfillWrapFlushCallback","BuiltInHTMLElement","HTMLElement","wrapperForTheName","construct","this","constructor","prototype","Object","setPrototypeOf","WangEditorFormulaCard","_super","_this","shadow","attachShadow","mode","span","ownerDocument","createElement","style","display","appendChild","__extends","defineProperty","get","attributeChangedCallback","name","oldValue","newValue","render","value","katex","throwOnError","output","define","i18nAddResources","formula","placeholder","insert","edit","ok","conf","type","elemToHtml","elem","_childrenHtml","_a","concat","isObject","obj","extend","target","src","keys","forEach","key","length","ssrDocument","body","addEventListener","removeEventListener","activeElement","blur","nodeName","querySelector","querySelectorAll","getElementById","createEvent","initEvent","children","childNodes","setAttribute","getElementsByTagName","createElementNS","importNode","location","hash","host","hostname","href","origin","pathname","protocol","search","getDocument","doc","document","ssrWindow","navigator","userAgent","history","replaceState","pushState","go","back","CustomEvent","getComputedStyle","getPropertyValue","Image","Date","screen","setTimeout","clearTimeout","matchMedia","requestAnimationFrame","callback","cancelAnimationFrame","id","getWindow","win","Dom7","Array","items","super","proto","__proto__","set","makeReactive","$","selector","context","arr","html","trim","indexOf","toCreate","tempParent","innerHTML","i","push","a","res","qsa","nodeType","isArray","uniqueArray","arrayUnique","val","el","multiple","toLowerCase","values","selectedOptions","j","options","selected","on","args","eventType","targetSelector","listener","capture","handleLiveEvent","e","eventData","dom7EventData","unshift","is","apply","parents","k","handleEvent","events","split","event","dom7LiveListeners","proxyListener","dom7Listeners","compareWith","matches","webkitMatchesSelector","msMatchesSelector","append","els","newChild","tempDiv","firstChild","parent","parentNode","find","foundElements","found","fn","noTrigger","focus","trigger","genRandomStr","prefix","size","bytes","crypto","getRandomValues","Uint8Array","nanoid","genDomID","EditFormulaMenu","title","t","iconSvg","tag","showModal","modalWidth","$content","textareaId","buttonId","getSelectedElem","editor","node","DomEditor","getSelectedNodeByType","getValue","formulaElem","isActive","_editor","exec","_value","isDisabled","selection","SlateRange","isExpanded","getModalPositionNode","getModalContentElem","_b","__read","genModalTextareaElems","textareaContainerElem","$textarea","buttonContainerElem","genModalButtonElems","$content_1","preventDefault","updateFormula","hidePanelOrModal","restoreSelection","selectedElem","path","findPath","props","SlateTransforms","setNodes","at","InsertFormulaMenu","selectedElems","getSelectedElems","some","isVoid","getNodeType","insertFormula","text","insertNode","editorPlugin","isInline","newEditor","renderElems","renderElem","isNodeSelected","formulaVnode","h","dataset","className","contentEditable","marginLeft","marginRight","border","borderRadius","padding","elemsToHtml","elemToHtmlConf","parseElemsHtml","parseElemHtml","_children","getAttribute","menus","factory"],"mappings":"y6BAoBC,WACC,QAGqBA,IAAnBC,OAAOC,cACsBF,IAA1BC,OAAOE,iBAGPF,OAAOE,eAAeC,0BAP3B,CAWA,IAAMC,EAAqBC,YAOrBC,EAEgC,WAClC,OAAOL,QAAQM,UAAUH,EAAoB,GAA6BI,KAAKC,YACjF,EAGFT,OAAOK,YAAcC,EACrBD,YAAYK,UAAYN,EAAmBM,UAC3CL,YAAYK,UAAUD,YAAcJ,YACpCM,OAAOC,eAAeP,YAAaD,EAlBnC,CAmBD,CA9BA,GCXD,IAAAS,EAAA,SAAAC,GAQE,SAAAD,IACE,IAAAE,EAAAD,cAAON,KACDQ,EAASD,EAAKE,aAAa,CAAEC,KAAM,SAEnCC,EADWH,EAAOI,cACFC,cAAc,eAEpCF,EAAKG,MAAMC,QAAU,eACrBP,EAAOQ,YAAYL,GACnBJ,EAAKI,KAAOA,GACd,CA2BF,0PA5CoCM,CAAAZ,EAAAC,GAIlCH,OAAAe,eAAWb,EAAA,qBAAkB,CAA7Bc,IAAA,WACE,MAAO,CAAC,aACV,kCAyBAd,EAAAH,UAAAkB,yBAAA,SAAyBC,EAAcC,EAAyBC,GAC9D,GAAa,eAATF,EAAuB,CACzB,GAAIC,IAAaC,EAAY,OAC7BvB,KAAKwB,OAAOD,GAA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IAM5B+M,EAAS/M,EAClB,EAGAgN,EAAUP,OAAS,SAAAzM,GAGjB,MAAa,YAFAoK,EAAAA,UAAUsC,YAAY1M,IAM5ByM,EAAOzM,EAChB,EAEOgN,CACT,EDjBEC,YAAa,CEgCF,CACXnN,KAAM,UACNoN,WAzCF,SAAuBlN,EAAoByB,EAA0ByI,GAEnE,IAAM7D,EAAW+D,EAAAA,UAAU+C,eAAejD,EAAQlK,GAG1CE,EAAeF,EAAsBd,MAArCA,OAAK,IAAAgB,EAAG,KACVkN,EAAeC,EAAAA,EACnB,mBACA,CACEC,QAAS,CAAEpO,MAAKA,IAElB,MAyBF,OArBuBmO,EAAAA,EACrB,MACA,CACEE,UAAW,iCACXtB,MAAO,CACLuB,iBAAiB,GAEnBjP,MAAO,CACLC,QAAS,eACTiP,WAAY,MACZC,YAAa,MACbC,OAAQtH,EACJ,sDACA,wBACJuH,aAAc,MACdC,QAAS,YAGb,CAACT,GAIL,IF7BEU,YAAa,CAACC,GACdC,eAAgB,CGKI,CACpBrJ,SAAU,gCACVsJ,cAhBF,SACEjO,EACAkO,EACAzD,GAIA,MAAO,CACL3K,KAAM,UACNZ,MAJYc,EAAKmO,aAAa,eAAiB,GAK/C1M,SAAU,CAAC,CAAEmL,KAAM,KAEvB,IHFEwB,MAAO,CIZ4B,CACnCzN,IAAK,gBACL0N,QAAO,WACL,OAAO,IAAIhC,CACb,GAGiC,CACjC1L,IAAK,cACL0N,QAAO,WACL,OAAO,IAAI9E,CACb","x_google_ignoreList":[4,5,8,9]}
1
+ {"version":3,"file":"index.js","sources":["../src/register-custom-elem/native-shim.ts","../src/register-custom-elem/index.ts","../src/module/local.ts","../src/module/elem-to-html.ts","../../../node_modules/.pnpm/ssr-window@4.0.2/node_modules/ssr-window/ssr-window.esm.js","../../../node_modules/.pnpm/dom7@4.0.6/node_modules/dom7/dom7.esm.js","../src/utils/dom.ts","../src/utils/util.ts","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.browser.js","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/url-alphabet/index.js","../src/module/menu/EditFormula.ts","../src/constants/icon-svg.ts","../src/module/menu/InsertFormula.ts","../src/module/index.ts","../src/module/plugin.ts","../src/module/render-elem.ts","../src/module/parse-elem-html.ts","../src/module/menu/index.ts"],"sourcesContent":["// @ts-nocheck\n\n// 参考 https://github.com/webcomponents/custom-elements/blob/master/src/native-shim.js\n\n/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * This shim allows elements written in, or compiled to, ES5 to work on native\n * implementations of Custom Elements v1. It sets new.target to the value of\n * this.constructor so that the native HTMLElement constructor can access the\n * current under-construction element's definition.\n */\n(function () {\n if (\n // No Reflect, no classes, no need for shim because native custom elements\n // require ES2015 classes or Reflect.\n window.Reflect === undefined\n || window.customElements === undefined\n // The webcomponentsjs custom elements polyfill doesn't require\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\n || window.customElements.polyfillWrapFlushCallback\n ) {\n return\n }\n const BuiltInHTMLElement = HTMLElement\n /**\n * With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.\n * However, if we declare the function as a property on an object literal, and\n * use quotes for the property name, then closure will leave that much intact,\n * which is enough for the JS VM to correctly set Function.prototype.name.\n */\n const wrapperForTheName = {\n // eslint-disable-next-line func-names\n HTMLElement: /** @this {!Object} */ function HTMLElement() {\n return Reflect.construct(BuiltInHTMLElement, [], /** @type {!Function} */ this.constructor)\n },\n }\n\n window.HTMLElement = wrapperForTheName.HTMLElement\n HTMLElement.prototype = BuiltInHTMLElement.prototype\n HTMLElement.prototype.constructor = HTMLElement\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement)\n}())\n","/**\n * @description 注册自定义 elem\n * @author wangfupeng\n */\n\nimport './native-shim'\n\nimport katex from 'katex'\n\nclass WangEditorFormulaCard extends HTMLElement {\n private span: HTMLElement | null = null\n\n // 监听的 attr\n static get observedAttributes() {\n return ['data-value']\n }\n\n constructor() {\n super()\n }\n\n // connectedCallback() {\n // // 当 custom element首次被插入文档DOM时,被调用\n // console.log('connected')\n // }\n // disconnectedCallback() {\n // // 当 custom element从文档DOM中删除时,被调用\n // console.log('disconnected')\n // }\n // adoptedCallback() {\n // // 当 custom element被移动到新的文档时,被调用\n // console.log('adopted')\n // }\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'data-value') {\n if (oldValue === newValue) { return }\n this.render(newValue || '')\n }\n }\n\n private ensureSpan() {\n if (this.span) { return this.span }\n\n const document = this.ownerDocument || window.document\n const span = document.createElement('span')\n\n span.style.display = 'inline-block'\n this.appendChild(span)\n this.span = span\n\n return span\n }\n\n private render(value: string) {\n const span = this.ensureSpan()\n\n katex.render(value, span, {\n throwOnError: false,\n output: 'htmlAndMathml',\n })\n }\n}\n\nif (!window.customElements.get('w-e-formula-card')) {\n window.customElements.define('w-e-formula-card', WangEditorFormulaCard)\n}\n","/**\n * @description 多语言\n * @author wangfupeng\n */\n\nimport { i18nAddResources } from '@wangeditor-next/editor'\n\ni18nAddResources('en', {\n formula: {\n formula: 'Formula',\n placeholder: 'Use LateX syntax',\n insert: 'Insert formula',\n edit: 'Edit formula',\n ok: 'OK',\n },\n})\n\ni18nAddResources('zh-CN', {\n formula: {\n formula: '公式',\n placeholder: '使用 LateX 语法',\n insert: '插入公式',\n edit: '编辑公式',\n ok: '确定',\n },\n})\n","/**\n * @description elem to html\n * @author wangfupeng\n */\n\nimport { SlateElement } from '@wangeditor-next/editor'\n\nimport { FormulaElement } from './custom-types'\n\n// 生成 html 的函数\nfunction formulaToHtml(elem: SlateElement, _childrenHtml: string): string {\n const { value = '' } = elem as FormulaElement\n\n return `<span data-w-e-type=\"formula\" data-w-e-is-void data-w-e-is-inline data-value=\"${value}\"></span>`\n}\n\n// 配置\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n elemToHtml: formulaToHtml,\n}\n\nexport default conf\n","/**\n * SSR Window 4.0.2\n * Better handling for window object in SSR environment\n * https://github.com/nolimits4web/ssr-window\n *\n * Copyright 2021, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: December 13, 2021\n */\n/* eslint-disable no-param-reassign */\nfunction isObject(obj) {\n return (obj !== null &&\n typeof obj === 'object' &&\n 'constructor' in obj &&\n obj.constructor === Object);\n}\nfunction extend(target = {}, src = {}) {\n Object.keys(src).forEach((key) => {\n if (typeof target[key] === 'undefined')\n target[key] = src[key];\n else if (isObject(src[key]) &&\n isObject(target[key]) &&\n Object.keys(src[key]).length > 0) {\n extend(target[key], src[key]);\n }\n });\n}\n\nconst ssrDocument = {\n body: {},\n addEventListener() { },\n removeEventListener() { },\n activeElement: {\n blur() { },\n nodeName: '',\n },\n querySelector() {\n return null;\n },\n querySelectorAll() {\n return [];\n },\n getElementById() {\n return null;\n },\n createEvent() {\n return {\n initEvent() { },\n };\n },\n createElement() {\n return {\n children: [],\n childNodes: [],\n style: {},\n setAttribute() { },\n getElementsByTagName() {\n return [];\n },\n };\n },\n createElementNS() {\n return {};\n },\n importNode() {\n return null;\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n};\nfunction getDocument() {\n const doc = typeof document !== 'undefined' ? document : {};\n extend(doc, ssrDocument);\n return doc;\n}\n\nconst ssrWindow = {\n document: ssrDocument,\n navigator: {\n userAgent: '',\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n history: {\n replaceState() { },\n pushState() { },\n go() { },\n back() { },\n },\n CustomEvent: function CustomEvent() {\n return this;\n },\n addEventListener() { },\n removeEventListener() { },\n getComputedStyle() {\n return {\n getPropertyValue() {\n return '';\n },\n };\n },\n Image() { },\n Date() { },\n screen: {},\n setTimeout() { },\n clearTimeout() { },\n matchMedia() {\n return {};\n },\n requestAnimationFrame(callback) {\n if (typeof setTimeout === 'undefined') {\n callback();\n return null;\n }\n return setTimeout(callback, 0);\n },\n cancelAnimationFrame(id) {\n if (typeof setTimeout === 'undefined') {\n return;\n }\n clearTimeout(id);\n },\n};\nfunction getWindow() {\n const win = typeof window !== 'undefined' ? window : {};\n extend(win, ssrWindow);\n return win;\n}\n\nexport { extend, getDocument, getWindow, ssrDocument, ssrWindow };\n","/**\n * Dom7 4.0.6\n * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API\n * https://framework7.io/docs/dom7.html\n *\n * Copyright 2023, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: February 2, 2023\n */\nimport { getWindow, getDocument } from 'ssr-window';\n\n/* eslint-disable no-proto */\nfunction makeReactive(obj) {\n const proto = obj.__proto__;\n Object.defineProperty(obj, '__proto__', {\n get() {\n return proto;\n },\n\n set(value) {\n proto.__proto__ = value;\n }\n\n });\n}\n\nclass Dom7 extends Array {\n constructor(items) {\n if (typeof items === 'number') {\n super(items);\n } else {\n super(...(items || []));\n makeReactive(this);\n }\n }\n\n}\n\nfunction arrayFlat(arr = []) {\n const res = [];\n arr.forEach(el => {\n if (Array.isArray(el)) {\n res.push(...arrayFlat(el));\n } else {\n res.push(el);\n }\n });\n return res;\n}\nfunction arrayFilter(arr, callback) {\n return Array.prototype.filter.call(arr, callback);\n}\nfunction arrayUnique(arr) {\n const uniqueArray = [];\n\n for (let i = 0; i < arr.length; i += 1) {\n if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);\n }\n\n return uniqueArray;\n}\nfunction toCamelCase(string) {\n return string.toLowerCase().replace(/-(.)/g, (match, group) => group.toUpperCase());\n}\n\n// eslint-disable-next-line\n\nfunction qsa(selector, context) {\n if (typeof selector !== 'string') {\n return [selector];\n }\n\n const a = [];\n const res = context.querySelectorAll(selector);\n\n for (let i = 0; i < res.length; i += 1) {\n a.push(res[i]);\n }\n\n return a;\n}\n\nfunction $(selector, context) {\n const window = getWindow();\n const document = getDocument();\n let arr = [];\n\n if (!context && selector instanceof Dom7) {\n return selector;\n }\n\n if (!selector) {\n return new Dom7(arr);\n }\n\n if (typeof selector === 'string') {\n const html = selector.trim();\n\n if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {\n let toCreate = 'div';\n if (html.indexOf('<li') === 0) toCreate = 'ul';\n if (html.indexOf('<tr') === 0) toCreate = 'tbody';\n if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';\n if (html.indexOf('<tbody') === 0) toCreate = 'table';\n if (html.indexOf('<option') === 0) toCreate = 'select';\n const tempParent = document.createElement(toCreate);\n tempParent.innerHTML = html;\n\n for (let i = 0; i < tempParent.childNodes.length; i += 1) {\n arr.push(tempParent.childNodes[i]);\n }\n } else {\n arr = qsa(selector.trim(), context || document);\n } // arr = qsa(selector, document);\n\n } else if (selector.nodeType || selector === window || selector === document) {\n arr.push(selector);\n } else if (Array.isArray(selector)) {\n if (selector instanceof Dom7) return selector;\n arr = selector;\n }\n\n return new Dom7(arrayUnique(arr));\n}\n\n$.fn = Dom7.prototype;\n\n// eslint-disable-next-line\n\nfunction addClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.add(...classNames);\n });\n return this;\n}\n\nfunction removeClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.remove(...classNames);\n });\n return this;\n}\n\nfunction toggleClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n classNames.forEach(className => {\n el.classList.toggle(className);\n });\n });\n}\n\nfunction hasClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n return arrayFilter(this, el => {\n return classNames.filter(className => el.classList.contains(className)).length > 0;\n }).length > 0;\n}\n\nfunction attr(attrs, value) {\n if (arguments.length === 1 && typeof attrs === 'string') {\n // Get attr\n if (this[0]) return this[0].getAttribute(attrs);\n return undefined;\n } // Set attrs\n\n\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i].setAttribute(attrs, value);\n } else {\n // Object\n for (const attrName in attrs) {\n this[i][attrName] = attrs[attrName];\n this[i].setAttribute(attrName, attrs[attrName]);\n }\n }\n }\n\n return this;\n}\n\nfunction removeAttr(attr) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].removeAttribute(attr);\n }\n\n return this;\n}\n\nfunction prop(props, value) {\n if (arguments.length === 1 && typeof props === 'string') {\n // Get prop\n if (this[0]) return this[0][props];\n } else {\n // Set props\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i][props] = value;\n } else {\n // Object\n for (const propName in props) {\n this[i][propName] = props[propName];\n }\n }\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction data(key, value) {\n let el;\n\n if (typeof value === 'undefined') {\n el = this[0];\n if (!el) return undefined; // Get value\n\n if (el.dom7ElementDataStorage && key in el.dom7ElementDataStorage) {\n return el.dom7ElementDataStorage[key];\n }\n\n const dataKey = el.getAttribute(`data-${key}`);\n\n if (dataKey) {\n return dataKey;\n }\n\n return undefined;\n } // Set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n el = this[i];\n if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};\n el.dom7ElementDataStorage[key] = value;\n }\n\n return this;\n}\n\nfunction removeData(key) {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.dom7ElementDataStorage && el.dom7ElementDataStorage[key]) {\n el.dom7ElementDataStorage[key] = null;\n delete el.dom7ElementDataStorage[key];\n }\n }\n}\n\nfunction dataset() {\n const el = this[0];\n if (!el) return undefined;\n const dataset = {}; // eslint-disable-line\n\n if (el.dataset) {\n for (const dataKey in el.dataset) {\n dataset[dataKey] = el.dataset[dataKey];\n }\n } else {\n for (let i = 0; i < el.attributes.length; i += 1) {\n const attr = el.attributes[i];\n\n if (attr.name.indexOf('data-') >= 0) {\n dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value;\n }\n }\n }\n\n for (const key in dataset) {\n if (dataset[key] === 'false') dataset[key] = false;else if (dataset[key] === 'true') dataset[key] = true;else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] *= 1;\n }\n\n return dataset;\n}\n\nfunction val(value) {\n if (typeof value === 'undefined') {\n // get value\n const el = this[0];\n if (!el) return undefined;\n\n if (el.multiple && el.nodeName.toLowerCase() === 'select') {\n const values = [];\n\n for (let i = 0; i < el.selectedOptions.length; i += 1) {\n values.push(el.selectedOptions[i].value);\n }\n\n return values;\n }\n\n return el.value;\n } // set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (Array.isArray(value) && el.multiple && el.nodeName.toLowerCase() === 'select') {\n for (let j = 0; j < el.options.length; j += 1) {\n el.options[j].selected = value.indexOf(el.options[j].value) >= 0;\n }\n } else {\n el.value = value;\n }\n }\n\n return this;\n}\n\nfunction value(value) {\n return this.val(value);\n}\n\nfunction transform(transform) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transform = transform;\n }\n\n return this;\n}\n\nfunction transition(duration) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration;\n }\n\n return this;\n}\n\nfunction on(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n\n function handleLiveEvent(e) {\n const target = e.target;\n if (!target) return;\n const eventData = e.target.dom7EventData || [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n if ($(target).is(targetSelector)) listener.apply(target, eventData);else {\n const parents = $(target).parents(); // eslint-disable-line\n\n for (let k = 0; k < parents.length; k += 1) {\n if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData);\n }\n }\n }\n\n function handleEvent(e) {\n const eventData = e && e.target ? e.target.dom7EventData || [] : [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n listener.apply(this, eventData);\n }\n\n const events = eventType.split(' ');\n let j;\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (!targetSelector) {\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7Listeners) el.dom7Listeners = {};\n if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];\n el.dom7Listeners[event].push({\n listener,\n proxyListener: handleEvent\n });\n el.addEventListener(event, handleEvent, capture);\n }\n } else {\n // Live events\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7LiveListeners) el.dom7LiveListeners = {};\n if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = [];\n el.dom7LiveListeners[event].push({\n listener,\n proxyListener: handleLiveEvent\n });\n el.addEventListener(event, handleLiveEvent, capture);\n }\n }\n }\n\n return this;\n}\n\nfunction off(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n const events = eventType.split(' ');\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n let handlers;\n\n if (!targetSelector && el.dom7Listeners) {\n handlers = el.dom7Listeners[event];\n } else if (targetSelector && el.dom7LiveListeners) {\n handlers = el.dom7LiveListeners[event];\n }\n\n if (handlers && handlers.length) {\n for (let k = handlers.length - 1; k >= 0; k -= 1) {\n const handler = handlers[k];\n\n if (listener && handler.listener === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (!listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction once(...args) {\n const dom = this;\n let [eventName, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventName, listener, capture] = args;\n targetSelector = undefined;\n }\n\n function onceHandler(...eventArgs) {\n listener.apply(this, eventArgs);\n dom.off(eventName, targetSelector, onceHandler, capture);\n\n if (onceHandler.dom7proxy) {\n delete onceHandler.dom7proxy;\n }\n }\n\n onceHandler.dom7proxy = listener;\n return dom.on(eventName, targetSelector, onceHandler, capture);\n}\n\nfunction trigger(...args) {\n const window = getWindow();\n const events = args[0].split(' ');\n const eventData = args[1];\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n\n if (window.CustomEvent) {\n const evt = new window.CustomEvent(event, {\n detail: eventData,\n bubbles: true,\n cancelable: true\n });\n el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0);\n el.dispatchEvent(evt);\n el.dom7EventData = [];\n delete el.dom7EventData;\n }\n }\n }\n\n return this;\n}\n\nfunction transitionStart(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionstart', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionstart', fireCallBack);\n }\n\n return this;\n}\n\nfunction transitionEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionend', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionend', fireCallBack);\n }\n\n return this;\n}\n\nfunction animationEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('animationend', fireCallBack);\n }\n\n if (callback) {\n dom.on('animationend', fireCallBack);\n }\n\n return this;\n}\n\nfunction width() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerWidth;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('width'));\n }\n\n return null;\n}\n\nfunction outerWidth(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));\n }\n\n return this[0].offsetWidth;\n }\n\n return null;\n}\n\nfunction height() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerHeight;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('height'));\n }\n\n return null;\n}\n\nfunction outerHeight(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));\n }\n\n return this[0].offsetHeight;\n }\n\n return null;\n}\n\nfunction offset() {\n if (this.length > 0) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n const box = el.getBoundingClientRect();\n const body = document.body;\n const clientTop = el.clientTop || body.clientTop || 0;\n const clientLeft = el.clientLeft || body.clientLeft || 0;\n const scrollTop = el === window ? window.scrollY : el.scrollTop;\n const scrollLeft = el === window ? window.scrollX : el.scrollLeft;\n return {\n top: box.top + scrollTop - clientTop,\n left: box.left + scrollLeft - clientLeft\n };\n }\n\n return null;\n}\n\nfunction hide() {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.display = 'none';\n }\n\n return this;\n}\n\nfunction show() {\n const window = getWindow();\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.style.display === 'none') {\n el.style.display = '';\n }\n\n if (window.getComputedStyle(el, null).getPropertyValue('display') === 'none') {\n // Still not visible\n el.style.display = 'block';\n }\n }\n\n return this;\n}\n\nfunction styles() {\n const window = getWindow();\n if (this[0]) return window.getComputedStyle(this[0], null);\n return {};\n}\n\nfunction css(props, value) {\n const window = getWindow();\n let i;\n\n if (arguments.length === 1) {\n if (typeof props === 'string') {\n // .css('width')\n if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);\n } else {\n // .css({ width: '100px' })\n for (i = 0; i < this.length; i += 1) {\n for (const prop in props) {\n this[i].style[prop] = props[prop];\n }\n }\n\n return this;\n }\n }\n\n if (arguments.length === 2 && typeof props === 'string') {\n // .css('width', '100px')\n for (i = 0; i < this.length; i += 1) {\n this[i].style[props] = value;\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction each(callback) {\n if (!callback) return this;\n this.forEach((el, index) => {\n callback.apply(el, [el, index]);\n });\n return this;\n}\n\nfunction filter(callback) {\n const result = arrayFilter(this, callback);\n return $(result);\n}\n\nfunction html(html) {\n if (typeof html === 'undefined') {\n return this[0] ? this[0].innerHTML : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].innerHTML = html;\n }\n\n return this;\n}\n\nfunction text(text) {\n if (typeof text === 'undefined') {\n return this[0] ? this[0].textContent.trim() : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].textContent = text;\n }\n\n return this;\n}\n\nfunction is(selector) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n let compareWith;\n let i;\n if (!el || typeof selector === 'undefined') return false;\n\n if (typeof selector === 'string') {\n if (el.matches) return el.matches(selector);\n if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);\n if (el.msMatchesSelector) return el.msMatchesSelector(selector);\n compareWith = $(selector);\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n if (selector === document) {\n return el === document;\n }\n\n if (selector === window) {\n return el === window;\n }\n\n if (selector.nodeType || selector instanceof Dom7) {\n compareWith = selector.nodeType ? [selector] : selector;\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n return false;\n}\n\nfunction index() {\n let child = this[0];\n let i;\n\n if (child) {\n i = 0; // eslint-disable-next-line\n\n while ((child = child.previousSibling) !== null) {\n if (child.nodeType === 1) i += 1;\n }\n\n return i;\n }\n\n return undefined;\n}\n\nfunction eq(index) {\n if (typeof index === 'undefined') return this;\n const length = this.length;\n\n if (index > length - 1) {\n return $([]);\n }\n\n if (index < 0) {\n const returnIndex = length + index;\n if (returnIndex < 0) return $([]);\n return $([this[returnIndex]]);\n }\n\n return $([this[index]]);\n}\n\nfunction append(...els) {\n let newChild;\n const document = getDocument();\n\n for (let k = 0; k < els.length; k += 1) {\n newChild = els[k];\n\n for (let i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n while (tempDiv.firstChild) {\n this[i].appendChild(tempDiv.firstChild);\n }\n } else if (newChild instanceof Dom7) {\n for (let j = 0; j < newChild.length; j += 1) {\n this[i].appendChild(newChild[j]);\n }\n } else {\n this[i].appendChild(newChild);\n }\n }\n }\n\n return this;\n}\n\nfunction appendTo(parent) {\n $(parent).append(this);\n return this;\n}\n\nfunction prepend(newChild) {\n const document = getDocument();\n let i;\n let j;\n\n for (i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {\n this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);\n }\n } else if (newChild instanceof Dom7) {\n for (j = 0; j < newChild.length; j += 1) {\n this[i].insertBefore(newChild[j], this[i].childNodes[0]);\n }\n } else {\n this[i].insertBefore(newChild, this[i].childNodes[0]);\n }\n }\n\n return this;\n}\n\nfunction prependTo(parent) {\n $(parent).prepend(this);\n return this;\n}\n\nfunction insertBefore(selector) {\n const before = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (before.length === 1) {\n before[0].parentNode.insertBefore(this[i], before[0]);\n } else if (before.length > 1) {\n for (let j = 0; j < before.length; j += 1) {\n before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);\n }\n }\n }\n}\n\nfunction insertAfter(selector) {\n const after = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (after.length === 1) {\n after[0].parentNode.insertBefore(this[i], after[0].nextSibling);\n } else if (after.length > 1) {\n for (let j = 0; j < after.length; j += 1) {\n after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);\n }\n }\n }\n}\n\nfunction next(selector) {\n if (this.length > 0) {\n if (selector) {\n if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {\n return $([this[0].nextElementSibling]);\n }\n\n return $([]);\n }\n\n if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction nextAll(selector) {\n const nextEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.nextElementSibling) {\n const next = el.nextElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(next).is(selector)) nextEls.push(next);\n } else nextEls.push(next);\n\n el = next;\n }\n\n return $(nextEls);\n}\n\nfunction prev(selector) {\n if (this.length > 0) {\n const el = this[0];\n\n if (selector) {\n if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {\n return $([el.previousElementSibling]);\n }\n\n return $([]);\n }\n\n if (el.previousElementSibling) return $([el.previousElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction prevAll(selector) {\n const prevEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.previousElementSibling) {\n const prev = el.previousElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(prev).is(selector)) prevEls.push(prev);\n } else prevEls.push(prev);\n\n el = prev;\n }\n\n return $(prevEls);\n}\n\nfunction siblings(selector) {\n return this.nextAll(selector).add(this.prevAll(selector));\n}\n\nfunction parent(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode !== null) {\n if (selector) {\n if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);\n } else {\n parents.push(this[i].parentNode);\n }\n }\n }\n\n return $(parents);\n}\n\nfunction parents(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n let parent = this[i].parentNode; // eslint-disable-line\n\n while (parent) {\n if (selector) {\n if ($(parent).is(selector)) parents.push(parent);\n } else {\n parents.push(parent);\n }\n\n parent = parent.parentNode;\n }\n }\n\n return $(parents);\n}\n\nfunction closest(selector) {\n let closest = this; // eslint-disable-line\n\n if (typeof selector === 'undefined') {\n return $([]);\n }\n\n if (!closest.is(selector)) {\n closest = closest.parents(selector).eq(0);\n }\n\n return closest;\n}\n\nfunction find(selector) {\n const foundElements = [];\n\n for (let i = 0; i < this.length; i += 1) {\n const found = this[i].querySelectorAll(selector);\n\n for (let j = 0; j < found.length; j += 1) {\n foundElements.push(found[j]);\n }\n }\n\n return $(foundElements);\n}\n\nfunction children(selector) {\n const children = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n const childNodes = this[i].children;\n\n for (let j = 0; j < childNodes.length; j += 1) {\n if (!selector || $(childNodes[j]).is(selector)) {\n children.push(childNodes[j]);\n }\n }\n }\n\n return $(children);\n}\n\nfunction remove() {\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);\n }\n\n return this;\n}\n\nfunction detach() {\n return this.remove();\n}\n\nfunction add(...els) {\n const dom = this;\n let i;\n let j;\n\n for (i = 0; i < els.length; i += 1) {\n const toAdd = $(els[i]);\n\n for (j = 0; j < toAdd.length; j += 1) {\n dom.push(toAdd[j]);\n }\n }\n\n return dom;\n}\n\nfunction empty() {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.nodeType === 1) {\n for (let j = 0; j < el.childNodes.length; j += 1) {\n if (el.childNodes[j].parentNode) {\n el.childNodes[j].parentNode.removeChild(el.childNodes[j]);\n }\n }\n\n el.textContent = '';\n }\n }\n\n return this;\n}\n\n// eslint-disable-next-line\n\nfunction scrollTo(...args) {\n const window = getWindow();\n let [left, top, duration, easing, callback] = args;\n\n if (args.length === 4 && typeof easing === 'function') {\n callback = easing;\n [left, top, duration, callback, easing] = args;\n }\n\n if (typeof easing === 'undefined') easing = 'swing';\n return this.each(function animate() {\n const el = this;\n let currentTop;\n let currentLeft;\n let maxTop;\n let maxLeft;\n let newTop;\n let newLeft;\n let scrollTop; // eslint-disable-line\n\n let scrollLeft; // eslint-disable-line\n\n let animateTop = top > 0 || top === 0;\n let animateLeft = left > 0 || left === 0;\n\n if (typeof easing === 'undefined') {\n easing = 'swing';\n }\n\n if (animateTop) {\n currentTop = el.scrollTop;\n\n if (!duration) {\n el.scrollTop = top;\n }\n }\n\n if (animateLeft) {\n currentLeft = el.scrollLeft;\n\n if (!duration) {\n el.scrollLeft = left;\n }\n }\n\n if (!duration) return;\n\n if (animateTop) {\n maxTop = el.scrollHeight - el.offsetHeight;\n newTop = Math.max(Math.min(top, maxTop), 0);\n }\n\n if (animateLeft) {\n maxLeft = el.scrollWidth - el.offsetWidth;\n newLeft = Math.max(Math.min(left, maxLeft), 0);\n }\n\n let startTime = null;\n if (animateTop && newTop === currentTop) animateTop = false;\n if (animateLeft && newLeft === currentLeft) animateLeft = false;\n\n function render(time = new Date().getTime()) {\n if (startTime === null) {\n startTime = time;\n }\n\n const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);\n const easeProgress = easing === 'linear' ? progress : 0.5 - Math.cos(progress * Math.PI) / 2;\n let done;\n if (animateTop) scrollTop = currentTop + easeProgress * (newTop - currentTop);\n if (animateLeft) scrollLeft = currentLeft + easeProgress * (newLeft - currentLeft);\n\n if (animateTop && newTop > currentTop && scrollTop >= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateTop && newTop < currentTop && scrollTop <= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (done) {\n if (callback) callback();\n return;\n }\n\n if (animateTop) el.scrollTop = scrollTop;\n if (animateLeft) el.scrollLeft = scrollLeft;\n window.requestAnimationFrame(render);\n }\n\n window.requestAnimationFrame(render);\n });\n} // scrollTop(top, duration, easing, callback) {\n\n\nfunction scrollTop(...args) {\n let [top, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [top, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof top === 'undefined') {\n if (dom.length > 0) return dom[0].scrollTop;\n return null;\n }\n\n return dom.scrollTo(undefined, top, duration, easing, callback);\n}\n\nfunction scrollLeft(...args) {\n let [left, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [left, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof left === 'undefined') {\n if (dom.length > 0) return dom[0].scrollLeft;\n return null;\n }\n\n return dom.scrollTo(left, undefined, duration, easing, callback);\n}\n\n// eslint-disable-next-line\n\nfunction animate(initialProps, initialParams) {\n const window = getWindow();\n const els = this;\n const a = {\n props: Object.assign({}, initialProps),\n params: Object.assign({\n duration: 300,\n easing: 'swing' // or 'linear'\n\n /* Callbacks\n begin(elements)\n complete(elements)\n progress(elements, complete, remaining, start, tweenValue)\n */\n\n }, initialParams),\n elements: els,\n animating: false,\n que: [],\n\n easingProgress(easing, progress) {\n if (easing === 'swing') {\n return 0.5 - Math.cos(progress * Math.PI) / 2;\n }\n\n if (typeof easing === 'function') {\n return easing(progress);\n }\n\n return progress;\n },\n\n stop() {\n if (a.frameId) {\n window.cancelAnimationFrame(a.frameId);\n }\n\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n a.que = [];\n },\n\n done(complete) {\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n if (complete) complete(els);\n\n if (a.que.length > 0) {\n const que = a.que.shift();\n a.animate(que[0], que[1]);\n }\n },\n\n animate(props, params) {\n if (a.animating) {\n a.que.push([props, params]);\n return a;\n }\n\n const elements = []; // Define & Cache Initials & Units\n\n a.elements.each((el, index) => {\n let initialFullValue;\n let initialValue;\n let unit;\n let finalValue;\n let finalFullValue;\n if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a;\n elements[index] = {\n container: el\n };\n Object.keys(props).forEach(prop => {\n initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.');\n initialValue = parseFloat(initialFullValue);\n unit = initialFullValue.replace(initialValue, '');\n finalValue = parseFloat(props[prop]);\n finalFullValue = props[prop] + unit;\n elements[index][prop] = {\n initialFullValue,\n initialValue,\n unit,\n finalValue,\n finalFullValue,\n currentValue: initialValue\n };\n });\n });\n let startTime = null;\n let time;\n let elementsDone = 0;\n let propsDone = 0;\n let done;\n let began = false;\n a.animating = true;\n\n function render() {\n time = new Date().getTime();\n let progress;\n let easeProgress; // let el;\n\n if (!began) {\n began = true;\n if (params.begin) params.begin(els);\n }\n\n if (startTime === null) {\n startTime = time;\n }\n\n if (params.progress) {\n // eslint-disable-next-line\n params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), startTime + params.duration - time < 0 ? 0 : startTime + params.duration - time, startTime);\n }\n\n elements.forEach(element => {\n const el = element;\n if (done || el.done) return;\n Object.keys(props).forEach(prop => {\n if (done || el.done) return;\n progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0);\n easeProgress = a.easingProgress(params.easing, progress);\n const {\n initialValue,\n finalValue,\n unit\n } = el[prop];\n el[prop].currentValue = initialValue + easeProgress * (finalValue - initialValue);\n const currentValue = el[prop].currentValue;\n\n if (finalValue > initialValue && currentValue >= finalValue || finalValue < initialValue && currentValue <= finalValue) {\n el.container.style[prop] = finalValue + unit;\n propsDone += 1;\n\n if (propsDone === Object.keys(props).length) {\n el.done = true;\n elementsDone += 1;\n }\n\n if (elementsDone === elements.length) {\n done = true;\n }\n }\n\n if (done) {\n a.done(params.complete);\n return;\n }\n\n el.container.style[prop] = currentValue + unit;\n });\n });\n if (done) return; // Then call\n\n a.frameId = window.requestAnimationFrame(render);\n }\n\n a.frameId = window.requestAnimationFrame(render);\n return a;\n }\n\n };\n\n if (a.elements.length === 0) {\n return els;\n }\n\n let animateInstance;\n\n for (let i = 0; i < a.elements.length; i += 1) {\n if (a.elements[i].dom7AnimateInstance) {\n animateInstance = a.elements[i].dom7AnimateInstance;\n } else a.elements[i].dom7AnimateInstance = a;\n }\n\n if (!animateInstance) {\n animateInstance = a;\n }\n\n if (initialProps === 'stop') {\n animateInstance.stop();\n } else {\n animateInstance.animate(a.props, a.params);\n }\n\n return els;\n}\n\nfunction stop() {\n const els = this;\n\n for (let i = 0; i < els.length; i += 1) {\n if (els[i].dom7AnimateInstance) {\n els[i].dom7AnimateInstance.stop();\n }\n }\n}\n\nconst noTrigger = 'resize scroll'.split(' ');\n\nfunction shortcut(name) {\n function eventHandler(...args) {\n if (typeof args[0] === 'undefined') {\n for (let i = 0; i < this.length; i += 1) {\n if (noTrigger.indexOf(name) < 0) {\n if (name in this[i]) this[i][name]();else {\n $(this[i]).trigger(name);\n }\n }\n }\n\n return this;\n }\n\n return this.on(name, ...args);\n }\n\n return eventHandler;\n}\n\nconst click = shortcut('click');\nconst blur = shortcut('blur');\nconst focus = shortcut('focus');\nconst focusin = shortcut('focusin');\nconst focusout = shortcut('focusout');\nconst keyup = shortcut('keyup');\nconst keydown = shortcut('keydown');\nconst keypress = shortcut('keypress');\nconst submit = shortcut('submit');\nconst change = shortcut('change');\nconst mousedown = shortcut('mousedown');\nconst mousemove = shortcut('mousemove');\nconst mouseup = shortcut('mouseup');\nconst mouseenter = shortcut('mouseenter');\nconst mouseleave = shortcut('mouseleave');\nconst mouseout = shortcut('mouseout');\nconst mouseover = shortcut('mouseover');\nconst touchstart = shortcut('touchstart');\nconst touchend = shortcut('touchend');\nconst touchmove = shortcut('touchmove');\nconst resize = shortcut('resize');\nconst scroll = shortcut('scroll');\n\nexport default $;\nexport { $, add, addClass, animate, animationEnd, append, appendTo, attr, blur, change, children, click, closest, css, data, dataset, detach, each, empty, eq, filter, find, focus, focusin, focusout, hasClass, height, hide, html, index, insertAfter, insertBefore, is, keydown, keypress, keyup, mousedown, mouseenter, mouseleave, mousemove, mouseout, mouseover, mouseup, next, nextAll, off, offset, on, once, outerHeight, outerWidth, parent, parents, prepend, prependTo, prev, prevAll, prop, remove, removeAttr, removeClass, removeData, resize, scroll, scrollLeft, scrollTo, scrollTop, show, siblings, stop, styles, submit, text, toggleClass, touchend, touchmove, touchstart, transform, transition, transitionEnd, transitionStart, trigger, val, value, width };\n","/**\n * @description DOM 操作\n * @author wangfupeng\n */\n\nimport $, {\n append, find, focus, html, is, on, parents, val,\n} from 'dom7'\n\n// COMPAT: This is required to prevent TypeScript aliases from doing some very\n// weird things for Slate's types with the same name as globals. (2019/11/27)\n// https://github.com/microsoft/TypeScript/issues/35002\nimport DOMNode = globalThis.Node\nimport DOMComment = globalThis.Comment\nimport DOMElement = globalThis.Element\nimport DOMText = globalThis.Text\nimport DOMRange = globalThis.Range\nimport DOMSelection = globalThis.Selection\nimport DOMStaticRange = globalThis.StaticRange\n\nif (append) { $.fn.append = append }\nif (html) { $.fn.html = html }\nif (val) { $.fn.val = val }\nif (on) { $.fn.on = on }\nif (focus) { $.fn.focus = focus }\nif (is) { $.fn.is = is }\nif (parents) { $.fn.parents = parents }\nif (find) { $.fn.find = find }\n\nexport { Dom7Array } from 'dom7'\nexport default $\nexport {\n DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText,\n}\n","/**\n * @description 工具函数\n * @author wangfupeng\n */\n\nimport { nanoid } from 'nanoid'\n\n/**\n * 获取随机数字符串\n * @param prefix 前缀\n * @returns 随机数字符串\n */\nexport function genRandomStr(prefix: string = 'r'): string {\n return `${prefix}-${nanoid()}`\n}\n\n// export function replaceSymbols(str: string) {\n// return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')\n// }\n","/* @ts-self-types=\"./index.d.ts\" */\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << Math.log2(alphabet.length - 1)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step | 0\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length >= size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","/**\n * @description edit formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n SlateTransforms,\n t,\n} from '@wangeditor-next/editor'\n\nimport { PENCIL_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass EditFormulaMenu implements IModalMenu {\n readonly title = t('formula.edit')\n\n readonly iconSvg = PENCIL_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n private getSelectedElem(editor: IDomEditor): FormulaElement | null {\n const node = DomEditor.getSelectedNodeByType(editor, 'formula')\n\n if (node == null) { return null }\n return node as FormulaElement\n }\n\n /**\n * 获取公式 value\n * @param editor editor\n */\n getValue(editor: IDomEditor): string | boolean {\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem) {\n return formulaElem.value || ''\n }\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 无需 active\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n // 未匹配到 formula node 则禁用\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem == null) { return true }\n\n return false\n }\n\n // modal 定位\n getModalPositionNode(editor: IDomEditor): SlateNode | null {\n return this.getSelectedElem(editor)\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.updateFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n const value = this.getValue(editor)\n\n $textarea.val(value)\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private updateFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const selectedElem = this.getSelectedElem(editor)\n\n if (selectedElem == null) { return }\n\n const path = DomEditor.findPath(editor, selectedElem)\n const props: Partial<FormulaElement> = { value }\n\n SlateTransforms.setNodes(editor, props, { at: path })\n }\n}\n\nexport default EditFormulaMenu\n","/**\n * @description icon svg\n * @author wangfupeng\n */\n\n/**\n * 【注意】svg 字符串的长度 ,否则会导致代码体积过大\n * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293\n * 找不到再从 iconfont.com 搜索\n */\n\n// 公式\nexport const SIGMA_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z\"></path></svg>'\n\n// 编辑\nexport const PENCIL_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z\"></path></svg>'\n","/**\n * @description insert formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n t,\n} from '@wangeditor-next/editor'\n\nimport { SIGMA_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass InsertFormulaMenu implements IModalMenu {\n readonly title = t('formula.insert')\n\n readonly iconSvg = SIGMA_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n getValue(_editor: IDomEditor): string | boolean {\n // 插入菜单,不需要 value\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 任何时候,都不用激活 menu\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n const selectedElems = DomEditor.getSelectedElems(editor)\n\n const hasVoidElem = selectedElems.some(elem => editor.isVoid(elem))\n\n if (hasVoidElem) { return true } // 选中了 void 元素,禁用\n\n const hasPreElem = selectedElems.some(elem => DomEditor.getNodeType(elem) === 'pre')\n\n if (hasPreElem) { return true } // 选中了 pre 原则,禁用\n\n return false\n }\n\n getModalPositionNode(_editor: IDomEditor): SlateNode | null {\n return null // modal 依据选区定位\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.insertFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n $textarea.val('')\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private insertFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const formulaElem: FormulaElement = {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 需要有一个空 text\n }\n\n editor.insertNode(formulaElem)\n }\n}\n\nexport default InsertFormulaMenu\n","/**\n * @description formula module entry\n * @author wangfupeng\n */\n\nimport './local' // 多语言\n\nimport { IModuleConf } from '@wangeditor-next/editor'\n\nimport elemToHtmlConf from './elem-to-html'\nimport { editFormulaMenuConf, insertFormulaMenuConf } from './menu/index'\nimport parseHtmlConf from './parse-elem-html'\nimport withFormula from './plugin'\nimport renderElemConf from './render-elem'\n\nconst module: Partial<IModuleConf> = {\n editorPlugin: withFormula,\n renderElems: [renderElemConf],\n elemsToHtml: [elemToHtmlConf],\n parseElemsHtml: [parseHtmlConf],\n menus: [insertFormulaMenuConf, editFormulaMenuConf],\n}\n\nexport default module\n","/**\n * @description formula plugin\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor } from '@wangeditor-next/editor'\n\nfunction withFormula<T extends IDomEditor>(editor: T) {\n const { isInline, isVoid } = editor\n const newEditor = editor\n\n // 重写 isInline\n newEditor.isInline = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isInline(elem)\n }\n\n // 重写 isVoid\n newEditor.isVoid = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isVoid(elem)\n }\n\n return newEditor\n}\n\nexport default withFormula\n","/**\n * @description render elem\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor, SlateElement } from '@wangeditor-next/editor'\nimport { h, VNode } from 'snabbdom'\n\nimport { FormulaElement } from './custom-types'\n\nfunction renderFormula(elem: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode {\n // 当前节点是否选中\n const selected = DomEditor.isNodeSelected(editor, elem)\n\n // 构建 formula vnode\n const { value = '' } = elem as FormulaElement\n const formulaVnode = h(\n 'w-e-formula-card',\n {\n dataset: { value },\n },\n null,\n )\n\n // 构建容器 vnode\n const containerVnode = h(\n 'div',\n {\n className: 'w-e-textarea-formula-container',\n props: {\n contentEditable: false, // 不可编辑\n },\n style: {\n display: 'inline-block', // inline\n marginLeft: '3px',\n marginRight: '3px',\n border: selected // 选中/不选中,样式不一样\n ? '2px solid var(--w-e-textarea-selected-border-color)'\n : '2px solid transparent',\n borderRadius: '3px',\n padding: '3px 3px',\n },\n },\n [formulaVnode],\n )\n\n return containerVnode\n}\n\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n renderElem: renderFormula,\n}\n\nexport default conf\n","/**\n * @description parse elem html\n * @author wangfupeng\n */\n\nimport { IDomEditor, SlateDescendant, SlateElement } from '@wangeditor-next/editor'\n\nimport { DOMElement } from '../utils/dom'\nimport { FormulaElement } from './custom-types'\n\nfunction parseHtml(\n elem: DOMElement,\n _children: SlateDescendant[],\n _editor: IDomEditor,\n): SlateElement {\n const value = elem.getAttribute('data-value') || ''\n\n return {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 必须有一个空白 text\n } as FormulaElement\n}\n\nconst parseHtmlConf = {\n selector: 'span[data-w-e-type=\"formula\"]',\n parseElemHtml: parseHtml,\n}\n\nexport default parseHtmlConf\n","/**\n * @description formula menu entry\n * @author wangfupeng\n */\n\nimport EditFormulaMenu from './EditFormula'\nimport InsertFormulaMenu from './InsertFormula'\n\nexport const insertFormulaMenuConf = {\n key: 'insertFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new InsertFormulaMenu()\n },\n}\n\nexport const editFormulaMenuConf = {\n key: 'editFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new EditFormulaMenu()\n },\n}\n"],"names":["undefined","window","Reflect","customElements","polyfillWrapFlushCallback","BuiltInHTMLElement","HTMLElement","wrapperForTheName","construct","this","constructor","prototype","Object","setPrototypeOf","WangEditorFormulaCard","_super","_this","span","__extends","defineProperty","get","attributeChangedCallback","name","oldValue","newValue","render","ensureSpan","ownerDocument","document","createElement","style","display","appendChild","value","katex","throwOnError","output","define","i18nAddResources","formula","placeholder","insert","edit","ok","conf","type","elemToHtml","elem","_childrenHtml","_a","concat","isObject","obj","extend","target","src","keys","forEach","key","length","ssrDocument","body","addEventListener","removeEventListener","activeElement","blur","nodeName","querySelector","querySelectorAll","getElementById","createEvent","initEvent","children","childNodes","setAttribute","getElementsByTagName","createElementNS","importNode","location","hash","host","hostname","href","origin","pathname","protocol","search","getDocument","doc","ssrWindow","navigator","userAgent","history","replaceState","pushState","go","back","CustomEvent","getComputedStyle","getPropertyValue","Image","Date","screen","setTimeout","clearTimeout","matchMedia","requestAnimationFrame","callback","cancelAnimationFrame","id","getWindow","win","Dom7","Array","items","super","proto","__proto__","set","makeReactive","$","selector","context","arr","html","trim","indexOf","toCreate","tempParent","innerHTML","i","push","a","res","qsa","nodeType","isArray","uniqueArray","arrayUnique","val","el","multiple","toLowerCase","values","selectedOptions","j","options","selected","on","args","eventType","targetSelector","listener","capture","handleLiveEvent","e","eventData","dom7EventData","unshift","is","apply","parents","k","handleEvent","events","split","event","dom7LiveListeners","proxyListener","dom7Listeners","compareWith","matches","webkitMatchesSelector","msMatchesSelector","append","els","newChild","tempDiv","firstChild","parent","parentNode","find","foundElements","found","fn","noTrigger","focus","trigger","genRandomStr","prefix","size","bytes","crypto","getRandomValues","Uint8Array","nanoid","genDomID","EditFormulaMenu","title","t","iconSvg","tag","showModal","modalWidth","$content","textareaId","buttonId","getSelectedElem","editor","node","DomEditor","getSelectedNodeByType","getValue","formulaElem","isActive","_editor","exec","_value","isDisabled","selection","SlateRange","isExpanded","getModalPositionNode","getModalContentElem","_b","__read","genModalTextareaElems","textareaContainerElem","$textarea","buttonContainerElem","genModalButtonElems","$content_1","preventDefault","updateFormula","hidePanelOrModal","restoreSelection","selectedElem","path","findPath","props","SlateTransforms","setNodes","at","InsertFormulaMenu","selectedElems","getSelectedElems","some","isVoid","getNodeType","insertFormula","text","insertNode","editorPlugin","isInline","newEditor","renderElems","renderElem","isNodeSelected","formulaVnode","h","dataset","className","contentEditable","marginLeft","marginRight","border","borderRadius","padding","elemsToHtml","elemToHtmlConf","parseElemsHtml","parseElemHtml","_children","getAttribute","menus","factory"],"mappings":"y6BAoBC,WACC,QAGqBA,IAAnBC,OAAOC,cACsBF,IAA1BC,OAAOE,iBAGPF,OAAOE,eAAeC,0BAP3B,CAWA,IAAMC,EAAqBC,YAOrBC,EAEgC,WAClC,OAAOL,QAAQM,UAAUH,EAAoB,GAA6BI,KAAKC,YACjF,EAGFT,OAAOK,YAAcC,EACrBD,YAAYK,UAAYN,EAAmBM,UAC3CL,YAAYK,UAAUD,YAAcJ,YACpCM,OAAOC,eAAeP,YAAaD,EAlBnC,CAmBD,CA9BA,GCXD,IAAAS,EAAA,SAAAC,GAQE,SAAAD,IACE,IAAAE,EAAAD,cAAON,YARDO,EAAAC,KAA2B,MASnC,CA0CF,0PApDoCC,CAAAJ,EAAAC,GAIlCH,OAAAO,eAAWL,EAAA,qBAAkB,CAA7BM,IAAA,WACE,MAAO,CAAC,aACV,kCAkBAN,EAAAH,UAAAU,yBAAA,SAAyBC,EAAcC,EAAyBC,GAC9D,GAAa,eAATF,EAAuB,CACzB,GAAIC,IAAaC,EAAY,OAC7Bf,KAAKgB,OAAOD,GAAY,GAC1B,CACF,EAEQV,EAAAH,UAAAe,WAAR,WACE,GAAIjB,KAAKQ,KAAQ,OAAOR,KAAKQ,KAE7B,IACMA,GADWR,KAAKkB,eAAiB1B,OAAO2B,UACxBC,cAAc,QAMpC,OAJAZ,EAAKa,MAAMC,QAAU,eACrBtB,KAAKuB,YAAYf,GACjBR,KAAKQ,KAAOA,EAELA,CACT,EAEQH,EAAAH,UAAAc,OAA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M5B8M,EAAS9M,EAClB,EAGA+M,EAAUP,OAAS,SAAAxM,GAGjB,MAAa,YAFAmK,EAAAA,UAAUsC,YAAYzM,IAM5BwM,EAAOxM,EAChB,EAEO+M,CACT,EDjBEC,YAAa,CEgCF,CACXlN,KAAM,UACNmN,WAzCF,SAAuBjN,EAAoByB,EAA0BwI,GAEnE,IAAM7D,EAAW+D,EAAAA,UAAU+C,eAAejD,EAAQjK,GAG1CE,EAAeF,EAAsBd,MAArCA,OAAK,IAAAgB,EAAG,KACViN,EAAeC,EAAAA,EACnB,mBACA,CACEC,QAAS,CAAEnO,MAAKA,IAElB,MAyBF,OArBuBkO,EAAAA,EACrB,MACA,CACEE,UAAW,iCACXtB,MAAO,CACLuB,iBAAiB,GAEnBxO,MAAO,CACLC,QAAS,eACTwO,WAAY,MACZC,YAAa,MACbC,OAAQtH,EACJ,sDACA,wBACJuH,aAAc,MACdC,QAAS,YAGb,CAACT,GAIL,IF7BEU,YAAa,CAACC,GACdC,eAAgB,CGKI,CACpBrJ,SAAU,gCACVsJ,cAhBF,SACEhO,EACAiO,EACAzD,GAIA,MAAO,CACL1K,KAAM,UACNZ,MAJYc,EAAKkO,aAAa,eAAiB,GAK/CzM,SAAU,CAAC,CAAEkL,KAAM,KAEvB,IHFEwB,MAAO,CIZ4B,CACnCxN,IAAK,gBACLyN,QAAO,WACL,OAAO,IAAIhC,CACb,GAGiC,CACjCzL,IAAK,cACLyN,QAAO,WACL,OAAO,IAAI9E,CACb","x_google_ignoreList":[4,5,8,9]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import t from"katex";import{i18nAddResources as e,t as n,DomEditor as r,SlateRange as o,genModalTextareaElems as i,genModalButtonElems as l,SlateTransforms as s}from"@wangeditor-next/editor";import{h as a}from"snabbdom";var u=function(t,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},u(t,e)};function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)l.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return l}"function"==typeof SuppressedError&&SuppressedError,function(){if(void 0!==window.Reflect&&void 0!==window.customElements&&!window.customElements.polyfillWrapFlushCallback){var t=HTMLElement,e=function(){return Reflect.construct(t,[],this.constructor)};window.HTMLElement=e,HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}}();var f=function(e){function n(){var t=e.call(this)||this,n=t.attachShadow({mode:"open"}),r=n.ownerDocument.createElement("span");return r.style.display="inline-block",n.appendChild(r),t.span=r,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),Object.defineProperty(n,"observedAttributes",{get:function(){return["data-value"]},enumerable:!1,configurable:!0}),n.prototype.attributeChangedCallback=function(t,e,n){if("data-value"===t){if(e===n)return;this.render(n||"")}},n.prototype.render=function(e){t.render(e,this.span,{throwOnError:!1,output:"mathml"})},n}(HTMLElement);window.customElements.get("w-e-formula-card")||window.customElements.define("w-e-formula-card",f),e("en",{formula:{formula:"Formula",placeholder:"Use LateX syntax",insert:"Insert formula",edit:"Edit formula",ok:"OK"}}),e("zh-CN",{formula:{formula:"公式",placeholder:"使用 LateX 语法",insert:"插入公式",edit:"编辑公式",ok:"确定"}});var d={type:"formula",elemToHtml:function(t,e){var n=t.value;return'<span data-w-e-type="formula" data-w-e-is-void data-w-e-is-inline data-value="'.concat(void 0===n?"":n,'"></span>')}};function p(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function h(t={},e={}){Object.keys(e).forEach(n=>{void 0===t[n]?t[n]=e[n]:p(e[n])&&p(t[n])&&Object.keys(e[n]).length>0&&h(t[n],e[n])})}const m={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function v(){const t="undefined"!=typeof document?document:{};return h(t,m),t}const y={document:m,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:t=>"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0),cancelAnimationFrame(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function g(){const t="undefined"!=typeof window?window:{};return h(t,y),t}class E extends Array{constructor(t){"number"==typeof t?super(t):(super(...t||[]),function(t){const e=t.__proto__;Object.defineProperty(t,"__proto__",{get:()=>e,set(t){e.__proto__=t}})}(this))}}function w(t,e){const n=g(),r=v();let o=[];if(!e&&t instanceof E)return t;if(!t)return new E(o);if("string"==typeof t){const n=t.trim();if(n.indexOf("<")>=0&&n.indexOf(">")>=0){let t="div";0===n.indexOf("<li")&&(t="ul"),0===n.indexOf("<tr")&&(t="tbody"),0!==n.indexOf("<td")&&0!==n.indexOf("<th")||(t="tr"),0===n.indexOf("<tbody")&&(t="table"),0===n.indexOf("<option")&&(t="select");const e=r.createElement(t);e.innerHTML=n;for(let t=0;t<e.childNodes.length;t+=1)o.push(e.childNodes[t])}else o=function(t,e){if("string"!=typeof t)return[t];const n=[],r=e.querySelectorAll(t);for(let t=0;t<r.length;t+=1)n.push(r[t]);return n}(t.trim(),e||r)}else if(t.nodeType||t===n||t===r)o.push(t);else if(Array.isArray(t)){if(t instanceof E)return t;o=t}return new E(function(t){const e=[];for(let n=0;n<t.length;n+=1)-1===e.indexOf(t[n])&&e.push(t[n]);return e}(o))}function b(t){if(void 0===t){const t=this[0];if(!t)return;if(t.multiple&&"select"===t.nodeName.toLowerCase()){const e=[];for(let n=0;n<t.selectedOptions.length;n+=1)e.push(t.selectedOptions[n].value);return e}return t.value}for(let e=0;e<this.length;e+=1){const n=this[e];if(Array.isArray(t)&&n.multiple&&"select"===n.nodeName.toLowerCase())for(let e=0;e<n.options.length;e+=1)n.options[e].selected=t.indexOf(n.options[e].value)>=0;else n.value=t}return this}function L(...t){let[e,n,r,o]=t;function i(t){const e=t.target;if(!e)return;const o=t.target.dom7EventData||[];if(o.indexOf(t)<0&&o.unshift(t),w(e).is(n))r.apply(e,o);else{const t=w(e).parents();for(let e=0;e<t.length;e+=1)w(t[e]).is(n)&&r.apply(t[e],o)}}function l(t){const e=t&&t.target&&t.target.dom7EventData||[];e.indexOf(t)<0&&e.unshift(t),r.apply(this,e)}"function"==typeof t[1]&&([e,r,o]=t,n=void 0),o||(o=!1);const s=e.split(" ");let a;for(let t=0;t<this.length;t+=1){const e=this[t];if(n)for(a=0;a<s.length;a+=1){const t=s[a];e.dom7LiveListeners||(e.dom7LiveListeners={}),e.dom7LiveListeners[t]||(e.dom7LiveListeners[t]=[]),e.dom7LiveListeners[t].push({listener:r,proxyListener:i}),e.addEventListener(t,i,o)}else for(a=0;a<s.length;a+=1){const t=s[a];e.dom7Listeners||(e.dom7Listeners={}),e.dom7Listeners[t]||(e.dom7Listeners[t]=[]),e.dom7Listeners[t].push({listener:r,proxyListener:l}),e.addEventListener(t,l,o)}}return this}function x(t){if(void 0===t)return this[0]?this[0].innerHTML:null;for(let e=0;e<this.length;e+=1)this[e].innerHTML=t;return this}function O(t){const e=g(),n=v(),r=this[0];let o,i;if(!r||void 0===t)return!1;if("string"==typeof t){if(r.matches)return r.matches(t);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(t);if(r.msMatchesSelector)return r.msMatchesSelector(t);for(o=w(t),i=0;i<o.length;i+=1)if(o[i]===r)return!0;return!1}if(t===n)return r===n;if(t===e)return r===e;if(t.nodeType||t instanceof E){for(o=t.nodeType?[t]:t,i=0;i<o.length;i+=1)if(o[i]===r)return!0;return!1}return!1}function S(...t){let e;const n=v();for(let r=0;r<t.length;r+=1){e=t[r];for(let t=0;t<this.length;t+=1)if("string"==typeof e){const r=n.createElement("div");for(r.innerHTML=e;r.firstChild;)this[t].appendChild(r.firstChild)}else if(e instanceof E)for(let n=0;n<e.length;n+=1)this[t].appendChild(e[n]);else this[t].appendChild(e)}return this}function T(t){const e=[];for(let n=0;n<this.length;n+=1){let r=this[n].parentNode;for(;r;)t?w(r).is(t)&&e.push(r):e.push(r),r=r.parentNode}return w(e)}function M(t){const e=[];for(let n=0;n<this.length;n+=1){const r=this[n].querySelectorAll(t);for(let t=0;t<r.length;t+=1)e.push(r[t])}return w(e)}w.fn=E.prototype;const N="resize scroll".split(" ");const _=(H="focus",function(...t){if(void 0===t[0]){for(let t=0;t<this.length;t+=1)N.indexOf(H)<0&&(H in this[t]?this[t][H]():w(this[t]).trigger(H));return this}return this.on(H,...t)});var H;S&&(w.fn.append=S),x&&(w.fn.html=x),b&&(w.fn.val=b),L&&(w.fn.on=L),_&&(w.fn.focus=_),O&&(w.fn.is=O),T&&(w.fn.parents=T),M&&(w.fn.find=M);function k(t){return"".concat(t,"-").concat(((t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[t]];return e})())}function A(){return k("w-e-insert-formula")}var C=function(){function t(){this.title=n("formula.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=A(),this.buttonId=A()}return t.prototype.getSelectedElem=function(t){var e=r.getSelectedNodeByType(t,"formula");return null==e?null:e},t.prototype.getValue=function(t){var e=this.getSelectedElem(t);return e&&e.value||""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var e=t.selection;return null==e||(!!o.isExpanded(e)||null==this.getSelectedElem(t))},t.prototype.getModalPositionNode=function(t){return this.getSelectedElem(t)},t.prototype.getModalContentElem=function(t){var e=this,r=this.textareaId,o=this.buttonId,s=c(i(n("formula.formula"),r,n("formula.placeholder")),2),a=s[0],u=w(s[1]),f=c(l(o,n("formula.ok")),1)[0];if(null==this.$content){var d=w("<div></div>");d.on("click","#".concat(o),function(n){n.preventDefault();var o=d.find("#".concat(r)).val().trim();e.updateFormula(t,o),t.hidePanelOrModal()}),this.$content=d}var p=this.$content;p.html(""),p.append(a),p.append(f);var h=this.getValue(t);return u.val(h),setTimeout(function(){u.focus()}),p[0]},t.prototype.updateFormula=function(t,e){if(e&&(t.restoreSelection(),!this.isDisabled(t))){var n=this.getSelectedElem(t);if(null!=n){var o=r.findPath(t,n),i={value:e};s.setNodes(t,i,{at:o})}}},t}();function I(){return k("w-e-insert-formula")}var P=function(){function t(){this.title=n("formula.insert"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=I(),this.buttonId=I()}return t.prototype.getValue=function(t){return""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var e=t.selection;if(null==e)return!0;if(o.isExpanded(e))return!0;var n=r.getSelectedElems(t);return!!n.some(function(e){return t.isVoid(e)})||!!n.some(function(t){return"pre"===r.getNodeType(t)})},t.prototype.getModalPositionNode=function(t){return null},t.prototype.getModalContentElem=function(t){var e=this,r=this.textareaId,o=this.buttonId,s=c(i(n("formula.formula"),r,n("formula.placeholder")),2),a=s[0],u=w(s[1]),f=c(l(o,n("formula.ok")),1)[0];if(null==this.$content){var d=w("<div></div>");d.on("click","#".concat(o),function(n){n.preventDefault();var o=d.find("#".concat(r)).val().trim();e.insertFormula(t,o),t.hidePanelOrModal()}),this.$content=d}var p=this.$content;return p.html(""),p.append(a),p.append(f),u.val(""),setTimeout(function(){u.focus()}),p[0]},t.prototype.insertFormula=function(t,e){if(e&&(t.restoreSelection(),!this.isDisabled(t))){var n={type:"formula",value:e,children:[{text:""}]};t.insertNode(n)}},t}();var j={editorPlugin:function(t){var e=t.isInline,n=t.isVoid,o=t;return o.isInline=function(t){return"formula"===r.getNodeType(t)||e(t)},o.isVoid=function(t){return"formula"===r.getNodeType(t)||n(t)},o},renderElems:[{type:"formula",renderElem:function(t,e,n){var o=r.isNodeSelected(n,t),i=t.value,l=a("w-e-formula-card",{dataset:{value:void 0===i?"":i}},null);return a("div",{className:"w-e-textarea-formula-container",props:{contentEditable:!1},style:{display:"inline-block",marginLeft:"3px",marginRight:"3px",border:o?"2px solid var(--w-e-textarea-selected-border-color)":"2px solid transparent",borderRadius:"3px",padding:"3px 3px"}},[l])}}],elemsToHtml:[d],parseElemsHtml:[{selector:'span[data-w-e-type="formula"]',parseElemHtml:function(t,e,n){return{type:"formula",value:t.getAttribute("data-value")||"",children:[{text:""}]}}}],menus:[{key:"insertFormula",factory:function(){return new P}},{key:"editFormula",factory:function(){return new C}}]};export{j as default};
1
+ import t from"katex";import{i18nAddResources as e,t as n,DomEditor as r,SlateRange as o,genModalTextareaElems as i,genModalButtonElems as l,SlateTransforms as s}from"@wangeditor-next/editor";import{h as a}from"snabbdom";var u=function(t,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},u(t,e)};function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)l.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return l}"function"==typeof SuppressedError&&SuppressedError,function(){if(void 0!==window.Reflect&&void 0!==window.customElements&&!window.customElements.polyfillWrapFlushCallback){var t=HTMLElement,e=function(){return Reflect.construct(t,[],this.constructor)};window.HTMLElement=e,HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}}();var f=function(e){function n(){var t=e.call(this)||this;return t.span=null,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),Object.defineProperty(n,"observedAttributes",{get:function(){return["data-value"]},enumerable:!1,configurable:!0}),n.prototype.attributeChangedCallback=function(t,e,n){if("data-value"===t){if(e===n)return;this.render(n||"")}},n.prototype.ensureSpan=function(){if(this.span)return this.span;var t=(this.ownerDocument||window.document).createElement("span");return t.style.display="inline-block",this.appendChild(t),this.span=t,t},n.prototype.render=function(e){var n=this.ensureSpan();t.render(e,n,{throwOnError:!1,output:"htmlAndMathml"})},n}(HTMLElement);window.customElements.get("w-e-formula-card")||window.customElements.define("w-e-formula-card",f),e("en",{formula:{formula:"Formula",placeholder:"Use LateX syntax",insert:"Insert formula",edit:"Edit formula",ok:"OK"}}),e("zh-CN",{formula:{formula:"公式",placeholder:"使用 LateX 语法",insert:"插入公式",edit:"编辑公式",ok:"确定"}});var d={type:"formula",elemToHtml:function(t,e){var n=t.value;return'<span data-w-e-type="formula" data-w-e-is-void data-w-e-is-inline data-value="'.concat(void 0===n?"":n,'"></span>')}};function p(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function h(t={},e={}){Object.keys(e).forEach(n=>{void 0===t[n]?t[n]=e[n]:p(e[n])&&p(t[n])&&Object.keys(e[n]).length>0&&h(t[n],e[n])})}const m={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function v(){const t="undefined"!=typeof document?document:{};return h(t,m),t}const y={document:m,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:t=>"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0),cancelAnimationFrame(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function g(){const t="undefined"!=typeof window?window:{};return h(t,y),t}class E extends Array{constructor(t){"number"==typeof t?super(t):(super(...t||[]),function(t){const e=t.__proto__;Object.defineProperty(t,"__proto__",{get:()=>e,set(t){e.__proto__=t}})}(this))}}function w(t,e){const n=g(),r=v();let o=[];if(!e&&t instanceof E)return t;if(!t)return new E(o);if("string"==typeof t){const n=t.trim();if(n.indexOf("<")>=0&&n.indexOf(">")>=0){let t="div";0===n.indexOf("<li")&&(t="ul"),0===n.indexOf("<tr")&&(t="tbody"),0!==n.indexOf("<td")&&0!==n.indexOf("<th")||(t="tr"),0===n.indexOf("<tbody")&&(t="table"),0===n.indexOf("<option")&&(t="select");const e=r.createElement(t);e.innerHTML=n;for(let t=0;t<e.childNodes.length;t+=1)o.push(e.childNodes[t])}else o=function(t,e){if("string"!=typeof t)return[t];const n=[],r=e.querySelectorAll(t);for(let t=0;t<r.length;t+=1)n.push(r[t]);return n}(t.trim(),e||r)}else if(t.nodeType||t===n||t===r)o.push(t);else if(Array.isArray(t)){if(t instanceof E)return t;o=t}return new E(function(t){const e=[];for(let n=0;n<t.length;n+=1)-1===e.indexOf(t[n])&&e.push(t[n]);return e}(o))}function b(t){if(void 0===t){const t=this[0];if(!t)return;if(t.multiple&&"select"===t.nodeName.toLowerCase()){const e=[];for(let n=0;n<t.selectedOptions.length;n+=1)e.push(t.selectedOptions[n].value);return e}return t.value}for(let e=0;e<this.length;e+=1){const n=this[e];if(Array.isArray(t)&&n.multiple&&"select"===n.nodeName.toLowerCase())for(let e=0;e<n.options.length;e+=1)n.options[e].selected=t.indexOf(n.options[e].value)>=0;else n.value=t}return this}function L(...t){let[e,n,r,o]=t;function i(t){const e=t.target;if(!e)return;const o=t.target.dom7EventData||[];if(o.indexOf(t)<0&&o.unshift(t),w(e).is(n))r.apply(e,o);else{const t=w(e).parents();for(let e=0;e<t.length;e+=1)w(t[e]).is(n)&&r.apply(t[e],o)}}function l(t){const e=t&&t.target&&t.target.dom7EventData||[];e.indexOf(t)<0&&e.unshift(t),r.apply(this,e)}"function"==typeof t[1]&&([e,r,o]=t,n=void 0),o||(o=!1);const s=e.split(" ");let a;for(let t=0;t<this.length;t+=1){const e=this[t];if(n)for(a=0;a<s.length;a+=1){const t=s[a];e.dom7LiveListeners||(e.dom7LiveListeners={}),e.dom7LiveListeners[t]||(e.dom7LiveListeners[t]=[]),e.dom7LiveListeners[t].push({listener:r,proxyListener:i}),e.addEventListener(t,i,o)}else for(a=0;a<s.length;a+=1){const t=s[a];e.dom7Listeners||(e.dom7Listeners={}),e.dom7Listeners[t]||(e.dom7Listeners[t]=[]),e.dom7Listeners[t].push({listener:r,proxyListener:l}),e.addEventListener(t,l,o)}}return this}function x(t){if(void 0===t)return this[0]?this[0].innerHTML:null;for(let e=0;e<this.length;e+=1)this[e].innerHTML=t;return this}function O(t){const e=g(),n=v(),r=this[0];let o,i;if(!r||void 0===t)return!1;if("string"==typeof t){if(r.matches)return r.matches(t);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(t);if(r.msMatchesSelector)return r.msMatchesSelector(t);for(o=w(t),i=0;i<o.length;i+=1)if(o[i]===r)return!0;return!1}if(t===n)return r===n;if(t===e)return r===e;if(t.nodeType||t instanceof E){for(o=t.nodeType?[t]:t,i=0;i<o.length;i+=1)if(o[i]===r)return!0;return!1}return!1}function S(...t){let e;const n=v();for(let r=0;r<t.length;r+=1){e=t[r];for(let t=0;t<this.length;t+=1)if("string"==typeof e){const r=n.createElement("div");for(r.innerHTML=e;r.firstChild;)this[t].appendChild(r.firstChild)}else if(e instanceof E)for(let n=0;n<e.length;n+=1)this[t].appendChild(e[n]);else this[t].appendChild(e)}return this}function T(t){const e=[];for(let n=0;n<this.length;n+=1){let r=this[n].parentNode;for(;r;)t?w(r).is(t)&&e.push(r):e.push(r),r=r.parentNode}return w(e)}function M(t){const e=[];for(let n=0;n<this.length;n+=1){const r=this[n].querySelectorAll(t);for(let t=0;t<r.length;t+=1)e.push(r[t])}return w(e)}w.fn=E.prototype;const N="resize scroll".split(" ");const _=(A="focus",function(...t){if(void 0===t[0]){for(let t=0;t<this.length;t+=1)N.indexOf(A)<0&&(A in this[t]?this[t][A]():w(this[t]).trigger(A));return this}return this.on(A,...t)});var A;S&&(w.fn.append=S),x&&(w.fn.html=x),b&&(w.fn.val=b),L&&(w.fn.on=L),_&&(w.fn.focus=_),O&&(w.fn.is=O),T&&(w.fn.parents=T),M&&(w.fn.find=M);function H(t){return"".concat(t,"-").concat(((t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[t]];return e})())}function k(){return H("w-e-insert-formula")}var C=function(){function t(){this.title=n("formula.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=k(),this.buttonId=k()}return t.prototype.getSelectedElem=function(t){var e=r.getSelectedNodeByType(t,"formula");return null==e?null:e},t.prototype.getValue=function(t){var e=this.getSelectedElem(t);return e&&e.value||""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var e=t.selection;return null==e||(!!o.isExpanded(e)||null==this.getSelectedElem(t))},t.prototype.getModalPositionNode=function(t){return this.getSelectedElem(t)},t.prototype.getModalContentElem=function(t){var e=this,r=this.textareaId,o=this.buttonId,s=c(i(n("formula.formula"),r,n("formula.placeholder")),2),a=s[0],u=w(s[1]),f=c(l(o,n("formula.ok")),1)[0];if(null==this.$content){var d=w("<div></div>");d.on("click","#".concat(o),function(n){n.preventDefault();var o=d.find("#".concat(r)).val().trim();e.updateFormula(t,o),t.hidePanelOrModal()}),this.$content=d}var p=this.$content;p.html(""),p.append(a),p.append(f);var h=this.getValue(t);return u.val(h),setTimeout(function(){u.focus()}),p[0]},t.prototype.updateFormula=function(t,e){if(e&&(t.restoreSelection(),!this.isDisabled(t))){var n=this.getSelectedElem(t);if(null!=n){var o=r.findPath(t,n),i={value:e};s.setNodes(t,i,{at:o})}}},t}();function I(){return H("w-e-insert-formula")}var P=function(){function t(){this.title=n("formula.insert"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.textareaId=I(),this.buttonId=I()}return t.prototype.getValue=function(t){return""},t.prototype.isActive=function(t){return!1},t.prototype.exec=function(t,e){},t.prototype.isDisabled=function(t){var e=t.selection;if(null==e)return!0;if(o.isExpanded(e))return!0;var n=r.getSelectedElems(t);return!!n.some(function(e){return t.isVoid(e)})||!!n.some(function(t){return"pre"===r.getNodeType(t)})},t.prototype.getModalPositionNode=function(t){return null},t.prototype.getModalContentElem=function(t){var e=this,r=this.textareaId,o=this.buttonId,s=c(i(n("formula.formula"),r,n("formula.placeholder")),2),a=s[0],u=w(s[1]),f=c(l(o,n("formula.ok")),1)[0];if(null==this.$content){var d=w("<div></div>");d.on("click","#".concat(o),function(n){n.preventDefault();var o=d.find("#".concat(r)).val().trim();e.insertFormula(t,o),t.hidePanelOrModal()}),this.$content=d}var p=this.$content;return p.html(""),p.append(a),p.append(f),u.val(""),setTimeout(function(){u.focus()}),p[0]},t.prototype.insertFormula=function(t,e){if(e&&(t.restoreSelection(),!this.isDisabled(t))){var n={type:"formula",value:e,children:[{text:""}]};t.insertNode(n)}},t}();var j={editorPlugin:function(t){var e=t.isInline,n=t.isVoid,o=t;return o.isInline=function(t){return"formula"===r.getNodeType(t)||e(t)},o.isVoid=function(t){return"formula"===r.getNodeType(t)||n(t)},o},renderElems:[{type:"formula",renderElem:function(t,e,n){var o=r.isNodeSelected(n,t),i=t.value,l=a("w-e-formula-card",{dataset:{value:void 0===i?"":i}},null);return a("div",{className:"w-e-textarea-formula-container",props:{contentEditable:!1},style:{display:"inline-block",marginLeft:"3px",marginRight:"3px",border:o?"2px solid var(--w-e-textarea-selected-border-color)":"2px solid transparent",borderRadius:"3px",padding:"3px 3px"}},[l])}}],elemsToHtml:[d],parseElemsHtml:[{selector:'span[data-w-e-type="formula"]',parseElemHtml:function(t,e,n){return{type:"formula",value:t.getAttribute("data-value")||"",children:[{text:""}]}}}],menus:[{key:"insertFormula",factory:function(){return new P}},{key:"editFormula",factory:function(){return new C}}]};export{j as default};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/register-custom-elem/native-shim.ts","../src/register-custom-elem/index.ts","../src/module/local.ts","../src/module/elem-to-html.ts","../../../node_modules/.pnpm/ssr-window@4.0.2/node_modules/ssr-window/ssr-window.esm.js","../../../node_modules/.pnpm/dom7@4.0.6/node_modules/dom7/dom7.esm.js","../src/utils/dom.ts","../src/utils/util.ts","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.browser.js","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/url-alphabet/index.js","../src/module/menu/EditFormula.ts","../src/constants/icon-svg.ts","../src/module/menu/InsertFormula.ts","../src/module/render-elem.ts","../src/module/index.ts","../src/module/plugin.ts","../src/module/parse-elem-html.ts","../src/module/menu/index.ts"],"sourcesContent":["// @ts-nocheck\n\n// 参考 https://github.com/webcomponents/custom-elements/blob/master/src/native-shim.js\n\n/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * This shim allows elements written in, or compiled to, ES5 to work on native\n * implementations of Custom Elements v1. It sets new.target to the value of\n * this.constructor so that the native HTMLElement constructor can access the\n * current under-construction element's definition.\n */\n(function () {\n if (\n // No Reflect, no classes, no need for shim because native custom elements\n // require ES2015 classes or Reflect.\n window.Reflect === undefined\n || window.customElements === undefined\n // The webcomponentsjs custom elements polyfill doesn't require\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\n || window.customElements.polyfillWrapFlushCallback\n ) {\n return\n }\n const BuiltInHTMLElement = HTMLElement\n /**\n * With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.\n * However, if we declare the function as a property on an object literal, and\n * use quotes for the property name, then closure will leave that much intact,\n * which is enough for the JS VM to correctly set Function.prototype.name.\n */\n const wrapperForTheName = {\n // eslint-disable-next-line func-names\n HTMLElement: /** @this {!Object} */ function HTMLElement() {\n return Reflect.construct(BuiltInHTMLElement, [], /** @type {!Function} */ this.constructor)\n },\n }\n\n window.HTMLElement = wrapperForTheName.HTMLElement\n HTMLElement.prototype = BuiltInHTMLElement.prototype\n HTMLElement.prototype.constructor = HTMLElement\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement)\n}())\n","/**\n * @description 注册自定义 elem\n * @author wangfupeng\n */\n\nimport './native-shim'\n\nimport katex from 'katex'\n\nclass WangEditorFormulaCard extends HTMLElement {\n private span: HTMLElement\n\n // 监听的 attr\n static get observedAttributes() {\n return ['data-value']\n }\n\n constructor() {\n super()\n const shadow = this.attachShadow({ mode: 'open' })\n const document = shadow.ownerDocument\n const span = document.createElement('span')\n\n span.style.display = 'inline-block'\n shadow.appendChild(span)\n this.span = span\n }\n\n // connectedCallback() {\n // // 当 custom element首次被插入文档DOM时,被调用\n // console.log('connected')\n // }\n // disconnectedCallback() {\n // // 当 custom element从文档DOM中删除时,被调用\n // console.log('disconnected')\n // }\n // adoptedCallback() {\n // // 当 custom element被移动到新的文档时,被调用\n // console.log('adopted')\n // }\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'data-value') {\n if (oldValue === newValue) { return }\n this.render(newValue || '')\n }\n }\n\n private render(value: string) {\n katex.render(value, this.span, {\n throwOnError: false,\n output: 'mathml',\n })\n }\n}\n\nif (!window.customElements.get('w-e-formula-card')) {\n window.customElements.define('w-e-formula-card', WangEditorFormulaCard)\n}\n","/**\n * @description 多语言\n * @author wangfupeng\n */\n\nimport { i18nAddResources } from '@wangeditor-next/editor'\n\ni18nAddResources('en', {\n formula: {\n formula: 'Formula',\n placeholder: 'Use LateX syntax',\n insert: 'Insert formula',\n edit: 'Edit formula',\n ok: 'OK',\n },\n})\n\ni18nAddResources('zh-CN', {\n formula: {\n formula: '公式',\n placeholder: '使用 LateX 语法',\n insert: '插入公式',\n edit: '编辑公式',\n ok: '确定',\n },\n})\n","/**\n * @description elem to html\n * @author wangfupeng\n */\n\nimport { SlateElement } from '@wangeditor-next/editor'\n\nimport { FormulaElement } from './custom-types'\n\n// 生成 html 的函数\nfunction formulaToHtml(elem: SlateElement, _childrenHtml: string): string {\n const { value = '' } = elem as FormulaElement\n\n return `<span data-w-e-type=\"formula\" data-w-e-is-void data-w-e-is-inline data-value=\"${value}\"></span>`\n}\n\n// 配置\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n elemToHtml: formulaToHtml,\n}\n\nexport default conf\n","/**\n * SSR Window 4.0.2\n * Better handling for window object in SSR environment\n * https://github.com/nolimits4web/ssr-window\n *\n * Copyright 2021, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: December 13, 2021\n */\n/* eslint-disable no-param-reassign */\nfunction isObject(obj) {\n return (obj !== null &&\n typeof obj === 'object' &&\n 'constructor' in obj &&\n obj.constructor === Object);\n}\nfunction extend(target = {}, src = {}) {\n Object.keys(src).forEach((key) => {\n if (typeof target[key] === 'undefined')\n target[key] = src[key];\n else if (isObject(src[key]) &&\n isObject(target[key]) &&\n Object.keys(src[key]).length > 0) {\n extend(target[key], src[key]);\n }\n });\n}\n\nconst ssrDocument = {\n body: {},\n addEventListener() { },\n removeEventListener() { },\n activeElement: {\n blur() { },\n nodeName: '',\n },\n querySelector() {\n return null;\n },\n querySelectorAll() {\n return [];\n },\n getElementById() {\n return null;\n },\n createEvent() {\n return {\n initEvent() { },\n };\n },\n createElement() {\n return {\n children: [],\n childNodes: [],\n style: {},\n setAttribute() { },\n getElementsByTagName() {\n return [];\n },\n };\n },\n createElementNS() {\n return {};\n },\n importNode() {\n return null;\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n};\nfunction getDocument() {\n const doc = typeof document !== 'undefined' ? document : {};\n extend(doc, ssrDocument);\n return doc;\n}\n\nconst ssrWindow = {\n document: ssrDocument,\n navigator: {\n userAgent: '',\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n history: {\n replaceState() { },\n pushState() { },\n go() { },\n back() { },\n },\n CustomEvent: function CustomEvent() {\n return this;\n },\n addEventListener() { },\n removeEventListener() { },\n getComputedStyle() {\n return {\n getPropertyValue() {\n return '';\n },\n };\n },\n Image() { },\n Date() { },\n screen: {},\n setTimeout() { },\n clearTimeout() { },\n matchMedia() {\n return {};\n },\n requestAnimationFrame(callback) {\n if (typeof setTimeout === 'undefined') {\n callback();\n return null;\n }\n return setTimeout(callback, 0);\n },\n cancelAnimationFrame(id) {\n if (typeof setTimeout === 'undefined') {\n return;\n }\n clearTimeout(id);\n },\n};\nfunction getWindow() {\n const win = typeof window !== 'undefined' ? window : {};\n extend(win, ssrWindow);\n return win;\n}\n\nexport { extend, getDocument, getWindow, ssrDocument, ssrWindow };\n","/**\n * Dom7 4.0.6\n * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API\n * https://framework7.io/docs/dom7.html\n *\n * Copyright 2023, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: February 2, 2023\n */\nimport { getWindow, getDocument } from 'ssr-window';\n\n/* eslint-disable no-proto */\nfunction makeReactive(obj) {\n const proto = obj.__proto__;\n Object.defineProperty(obj, '__proto__', {\n get() {\n return proto;\n },\n\n set(value) {\n proto.__proto__ = value;\n }\n\n });\n}\n\nclass Dom7 extends Array {\n constructor(items) {\n if (typeof items === 'number') {\n super(items);\n } else {\n super(...(items || []));\n makeReactive(this);\n }\n }\n\n}\n\nfunction arrayFlat(arr = []) {\n const res = [];\n arr.forEach(el => {\n if (Array.isArray(el)) {\n res.push(...arrayFlat(el));\n } else {\n res.push(el);\n }\n });\n return res;\n}\nfunction arrayFilter(arr, callback) {\n return Array.prototype.filter.call(arr, callback);\n}\nfunction arrayUnique(arr) {\n const uniqueArray = [];\n\n for (let i = 0; i < arr.length; i += 1) {\n if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);\n }\n\n return uniqueArray;\n}\nfunction toCamelCase(string) {\n return string.toLowerCase().replace(/-(.)/g, (match, group) => group.toUpperCase());\n}\n\n// eslint-disable-next-line\n\nfunction qsa(selector, context) {\n if (typeof selector !== 'string') {\n return [selector];\n }\n\n const a = [];\n const res = context.querySelectorAll(selector);\n\n for (let i = 0; i < res.length; i += 1) {\n a.push(res[i]);\n }\n\n return a;\n}\n\nfunction $(selector, context) {\n const window = getWindow();\n const document = getDocument();\n let arr = [];\n\n if (!context && selector instanceof Dom7) {\n return selector;\n }\n\n if (!selector) {\n return new Dom7(arr);\n }\n\n if (typeof selector === 'string') {\n const html = selector.trim();\n\n if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {\n let toCreate = 'div';\n if (html.indexOf('<li') === 0) toCreate = 'ul';\n if (html.indexOf('<tr') === 0) toCreate = 'tbody';\n if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';\n if (html.indexOf('<tbody') === 0) toCreate = 'table';\n if (html.indexOf('<option') === 0) toCreate = 'select';\n const tempParent = document.createElement(toCreate);\n tempParent.innerHTML = html;\n\n for (let i = 0; i < tempParent.childNodes.length; i += 1) {\n arr.push(tempParent.childNodes[i]);\n }\n } else {\n arr = qsa(selector.trim(), context || document);\n } // arr = qsa(selector, document);\n\n } else if (selector.nodeType || selector === window || selector === document) {\n arr.push(selector);\n } else if (Array.isArray(selector)) {\n if (selector instanceof Dom7) return selector;\n arr = selector;\n }\n\n return new Dom7(arrayUnique(arr));\n}\n\n$.fn = Dom7.prototype;\n\n// eslint-disable-next-line\n\nfunction addClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.add(...classNames);\n });\n return this;\n}\n\nfunction removeClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.remove(...classNames);\n });\n return this;\n}\n\nfunction toggleClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n classNames.forEach(className => {\n el.classList.toggle(className);\n });\n });\n}\n\nfunction hasClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n return arrayFilter(this, el => {\n return classNames.filter(className => el.classList.contains(className)).length > 0;\n }).length > 0;\n}\n\nfunction attr(attrs, value) {\n if (arguments.length === 1 && typeof attrs === 'string') {\n // Get attr\n if (this[0]) return this[0].getAttribute(attrs);\n return undefined;\n } // Set attrs\n\n\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i].setAttribute(attrs, value);\n } else {\n // Object\n for (const attrName in attrs) {\n this[i][attrName] = attrs[attrName];\n this[i].setAttribute(attrName, attrs[attrName]);\n }\n }\n }\n\n return this;\n}\n\nfunction removeAttr(attr) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].removeAttribute(attr);\n }\n\n return this;\n}\n\nfunction prop(props, value) {\n if (arguments.length === 1 && typeof props === 'string') {\n // Get prop\n if (this[0]) return this[0][props];\n } else {\n // Set props\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i][props] = value;\n } else {\n // Object\n for (const propName in props) {\n this[i][propName] = props[propName];\n }\n }\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction data(key, value) {\n let el;\n\n if (typeof value === 'undefined') {\n el = this[0];\n if (!el) return undefined; // Get value\n\n if (el.dom7ElementDataStorage && key in el.dom7ElementDataStorage) {\n return el.dom7ElementDataStorage[key];\n }\n\n const dataKey = el.getAttribute(`data-${key}`);\n\n if (dataKey) {\n return dataKey;\n }\n\n return undefined;\n } // Set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n el = this[i];\n if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};\n el.dom7ElementDataStorage[key] = value;\n }\n\n return this;\n}\n\nfunction removeData(key) {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.dom7ElementDataStorage && el.dom7ElementDataStorage[key]) {\n el.dom7ElementDataStorage[key] = null;\n delete el.dom7ElementDataStorage[key];\n }\n }\n}\n\nfunction dataset() {\n const el = this[0];\n if (!el) return undefined;\n const dataset = {}; // eslint-disable-line\n\n if (el.dataset) {\n for (const dataKey in el.dataset) {\n dataset[dataKey] = el.dataset[dataKey];\n }\n } else {\n for (let i = 0; i < el.attributes.length; i += 1) {\n const attr = el.attributes[i];\n\n if (attr.name.indexOf('data-') >= 0) {\n dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value;\n }\n }\n }\n\n for (const key in dataset) {\n if (dataset[key] === 'false') dataset[key] = false;else if (dataset[key] === 'true') dataset[key] = true;else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] *= 1;\n }\n\n return dataset;\n}\n\nfunction val(value) {\n if (typeof value === 'undefined') {\n // get value\n const el = this[0];\n if (!el) return undefined;\n\n if (el.multiple && el.nodeName.toLowerCase() === 'select') {\n const values = [];\n\n for (let i = 0; i < el.selectedOptions.length; i += 1) {\n values.push(el.selectedOptions[i].value);\n }\n\n return values;\n }\n\n return el.value;\n } // set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (Array.isArray(value) && el.multiple && el.nodeName.toLowerCase() === 'select') {\n for (let j = 0; j < el.options.length; j += 1) {\n el.options[j].selected = value.indexOf(el.options[j].value) >= 0;\n }\n } else {\n el.value = value;\n }\n }\n\n return this;\n}\n\nfunction value(value) {\n return this.val(value);\n}\n\nfunction transform(transform) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transform = transform;\n }\n\n return this;\n}\n\nfunction transition(duration) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration;\n }\n\n return this;\n}\n\nfunction on(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n\n function handleLiveEvent(e) {\n const target = e.target;\n if (!target) return;\n const eventData = e.target.dom7EventData || [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n if ($(target).is(targetSelector)) listener.apply(target, eventData);else {\n const parents = $(target).parents(); // eslint-disable-line\n\n for (let k = 0; k < parents.length; k += 1) {\n if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData);\n }\n }\n }\n\n function handleEvent(e) {\n const eventData = e && e.target ? e.target.dom7EventData || [] : [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n listener.apply(this, eventData);\n }\n\n const events = eventType.split(' ');\n let j;\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (!targetSelector) {\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7Listeners) el.dom7Listeners = {};\n if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];\n el.dom7Listeners[event].push({\n listener,\n proxyListener: handleEvent\n });\n el.addEventListener(event, handleEvent, capture);\n }\n } else {\n // Live events\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7LiveListeners) el.dom7LiveListeners = {};\n if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = [];\n el.dom7LiveListeners[event].push({\n listener,\n proxyListener: handleLiveEvent\n });\n el.addEventListener(event, handleLiveEvent, capture);\n }\n }\n }\n\n return this;\n}\n\nfunction off(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n const events = eventType.split(' ');\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n let handlers;\n\n if (!targetSelector && el.dom7Listeners) {\n handlers = el.dom7Listeners[event];\n } else if (targetSelector && el.dom7LiveListeners) {\n handlers = el.dom7LiveListeners[event];\n }\n\n if (handlers && handlers.length) {\n for (let k = handlers.length - 1; k >= 0; k -= 1) {\n const handler = handlers[k];\n\n if (listener && handler.listener === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (!listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction once(...args) {\n const dom = this;\n let [eventName, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventName, listener, capture] = args;\n targetSelector = undefined;\n }\n\n function onceHandler(...eventArgs) {\n listener.apply(this, eventArgs);\n dom.off(eventName, targetSelector, onceHandler, capture);\n\n if (onceHandler.dom7proxy) {\n delete onceHandler.dom7proxy;\n }\n }\n\n onceHandler.dom7proxy = listener;\n return dom.on(eventName, targetSelector, onceHandler, capture);\n}\n\nfunction trigger(...args) {\n const window = getWindow();\n const events = args[0].split(' ');\n const eventData = args[1];\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n\n if (window.CustomEvent) {\n const evt = new window.CustomEvent(event, {\n detail: eventData,\n bubbles: true,\n cancelable: true\n });\n el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0);\n el.dispatchEvent(evt);\n el.dom7EventData = [];\n delete el.dom7EventData;\n }\n }\n }\n\n return this;\n}\n\nfunction transitionStart(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionstart', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionstart', fireCallBack);\n }\n\n return this;\n}\n\nfunction transitionEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionend', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionend', fireCallBack);\n }\n\n return this;\n}\n\nfunction animationEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('animationend', fireCallBack);\n }\n\n if (callback) {\n dom.on('animationend', fireCallBack);\n }\n\n return this;\n}\n\nfunction width() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerWidth;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('width'));\n }\n\n return null;\n}\n\nfunction outerWidth(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));\n }\n\n return this[0].offsetWidth;\n }\n\n return null;\n}\n\nfunction height() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerHeight;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('height'));\n }\n\n return null;\n}\n\nfunction outerHeight(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));\n }\n\n return this[0].offsetHeight;\n }\n\n return null;\n}\n\nfunction offset() {\n if (this.length > 0) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n const box = el.getBoundingClientRect();\n const body = document.body;\n const clientTop = el.clientTop || body.clientTop || 0;\n const clientLeft = el.clientLeft || body.clientLeft || 0;\n const scrollTop = el === window ? window.scrollY : el.scrollTop;\n const scrollLeft = el === window ? window.scrollX : el.scrollLeft;\n return {\n top: box.top + scrollTop - clientTop,\n left: box.left + scrollLeft - clientLeft\n };\n }\n\n return null;\n}\n\nfunction hide() {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.display = 'none';\n }\n\n return this;\n}\n\nfunction show() {\n const window = getWindow();\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.style.display === 'none') {\n el.style.display = '';\n }\n\n if (window.getComputedStyle(el, null).getPropertyValue('display') === 'none') {\n // Still not visible\n el.style.display = 'block';\n }\n }\n\n return this;\n}\n\nfunction styles() {\n const window = getWindow();\n if (this[0]) return window.getComputedStyle(this[0], null);\n return {};\n}\n\nfunction css(props, value) {\n const window = getWindow();\n let i;\n\n if (arguments.length === 1) {\n if (typeof props === 'string') {\n // .css('width')\n if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);\n } else {\n // .css({ width: '100px' })\n for (i = 0; i < this.length; i += 1) {\n for (const prop in props) {\n this[i].style[prop] = props[prop];\n }\n }\n\n return this;\n }\n }\n\n if (arguments.length === 2 && typeof props === 'string') {\n // .css('width', '100px')\n for (i = 0; i < this.length; i += 1) {\n this[i].style[props] = value;\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction each(callback) {\n if (!callback) return this;\n this.forEach((el, index) => {\n callback.apply(el, [el, index]);\n });\n return this;\n}\n\nfunction filter(callback) {\n const result = arrayFilter(this, callback);\n return $(result);\n}\n\nfunction html(html) {\n if (typeof html === 'undefined') {\n return this[0] ? this[0].innerHTML : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].innerHTML = html;\n }\n\n return this;\n}\n\nfunction text(text) {\n if (typeof text === 'undefined') {\n return this[0] ? this[0].textContent.trim() : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].textContent = text;\n }\n\n return this;\n}\n\nfunction is(selector) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n let compareWith;\n let i;\n if (!el || typeof selector === 'undefined') return false;\n\n if (typeof selector === 'string') {\n if (el.matches) return el.matches(selector);\n if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);\n if (el.msMatchesSelector) return el.msMatchesSelector(selector);\n compareWith = $(selector);\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n if (selector === document) {\n return el === document;\n }\n\n if (selector === window) {\n return el === window;\n }\n\n if (selector.nodeType || selector instanceof Dom7) {\n compareWith = selector.nodeType ? [selector] : selector;\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n return false;\n}\n\nfunction index() {\n let child = this[0];\n let i;\n\n if (child) {\n i = 0; // eslint-disable-next-line\n\n while ((child = child.previousSibling) !== null) {\n if (child.nodeType === 1) i += 1;\n }\n\n return i;\n }\n\n return undefined;\n}\n\nfunction eq(index) {\n if (typeof index === 'undefined') return this;\n const length = this.length;\n\n if (index > length - 1) {\n return $([]);\n }\n\n if (index < 0) {\n const returnIndex = length + index;\n if (returnIndex < 0) return $([]);\n return $([this[returnIndex]]);\n }\n\n return $([this[index]]);\n}\n\nfunction append(...els) {\n let newChild;\n const document = getDocument();\n\n for (let k = 0; k < els.length; k += 1) {\n newChild = els[k];\n\n for (let i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n while (tempDiv.firstChild) {\n this[i].appendChild(tempDiv.firstChild);\n }\n } else if (newChild instanceof Dom7) {\n for (let j = 0; j < newChild.length; j += 1) {\n this[i].appendChild(newChild[j]);\n }\n } else {\n this[i].appendChild(newChild);\n }\n }\n }\n\n return this;\n}\n\nfunction appendTo(parent) {\n $(parent).append(this);\n return this;\n}\n\nfunction prepend(newChild) {\n const document = getDocument();\n let i;\n let j;\n\n for (i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {\n this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);\n }\n } else if (newChild instanceof Dom7) {\n for (j = 0; j < newChild.length; j += 1) {\n this[i].insertBefore(newChild[j], this[i].childNodes[0]);\n }\n } else {\n this[i].insertBefore(newChild, this[i].childNodes[0]);\n }\n }\n\n return this;\n}\n\nfunction prependTo(parent) {\n $(parent).prepend(this);\n return this;\n}\n\nfunction insertBefore(selector) {\n const before = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (before.length === 1) {\n before[0].parentNode.insertBefore(this[i], before[0]);\n } else if (before.length > 1) {\n for (let j = 0; j < before.length; j += 1) {\n before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);\n }\n }\n }\n}\n\nfunction insertAfter(selector) {\n const after = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (after.length === 1) {\n after[0].parentNode.insertBefore(this[i], after[0].nextSibling);\n } else if (after.length > 1) {\n for (let j = 0; j < after.length; j += 1) {\n after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);\n }\n }\n }\n}\n\nfunction next(selector) {\n if (this.length > 0) {\n if (selector) {\n if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {\n return $([this[0].nextElementSibling]);\n }\n\n return $([]);\n }\n\n if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction nextAll(selector) {\n const nextEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.nextElementSibling) {\n const next = el.nextElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(next).is(selector)) nextEls.push(next);\n } else nextEls.push(next);\n\n el = next;\n }\n\n return $(nextEls);\n}\n\nfunction prev(selector) {\n if (this.length > 0) {\n const el = this[0];\n\n if (selector) {\n if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {\n return $([el.previousElementSibling]);\n }\n\n return $([]);\n }\n\n if (el.previousElementSibling) return $([el.previousElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction prevAll(selector) {\n const prevEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.previousElementSibling) {\n const prev = el.previousElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(prev).is(selector)) prevEls.push(prev);\n } else prevEls.push(prev);\n\n el = prev;\n }\n\n return $(prevEls);\n}\n\nfunction siblings(selector) {\n return this.nextAll(selector).add(this.prevAll(selector));\n}\n\nfunction parent(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode !== null) {\n if (selector) {\n if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);\n } else {\n parents.push(this[i].parentNode);\n }\n }\n }\n\n return $(parents);\n}\n\nfunction parents(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n let parent = this[i].parentNode; // eslint-disable-line\n\n while (parent) {\n if (selector) {\n if ($(parent).is(selector)) parents.push(parent);\n } else {\n parents.push(parent);\n }\n\n parent = parent.parentNode;\n }\n }\n\n return $(parents);\n}\n\nfunction closest(selector) {\n let closest = this; // eslint-disable-line\n\n if (typeof selector === 'undefined') {\n return $([]);\n }\n\n if (!closest.is(selector)) {\n closest = closest.parents(selector).eq(0);\n }\n\n return closest;\n}\n\nfunction find(selector) {\n const foundElements = [];\n\n for (let i = 0; i < this.length; i += 1) {\n const found = this[i].querySelectorAll(selector);\n\n for (let j = 0; j < found.length; j += 1) {\n foundElements.push(found[j]);\n }\n }\n\n return $(foundElements);\n}\n\nfunction children(selector) {\n const children = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n const childNodes = this[i].children;\n\n for (let j = 0; j < childNodes.length; j += 1) {\n if (!selector || $(childNodes[j]).is(selector)) {\n children.push(childNodes[j]);\n }\n }\n }\n\n return $(children);\n}\n\nfunction remove() {\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);\n }\n\n return this;\n}\n\nfunction detach() {\n return this.remove();\n}\n\nfunction add(...els) {\n const dom = this;\n let i;\n let j;\n\n for (i = 0; i < els.length; i += 1) {\n const toAdd = $(els[i]);\n\n for (j = 0; j < toAdd.length; j += 1) {\n dom.push(toAdd[j]);\n }\n }\n\n return dom;\n}\n\nfunction empty() {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.nodeType === 1) {\n for (let j = 0; j < el.childNodes.length; j += 1) {\n if (el.childNodes[j].parentNode) {\n el.childNodes[j].parentNode.removeChild(el.childNodes[j]);\n }\n }\n\n el.textContent = '';\n }\n }\n\n return this;\n}\n\n// eslint-disable-next-line\n\nfunction scrollTo(...args) {\n const window = getWindow();\n let [left, top, duration, easing, callback] = args;\n\n if (args.length === 4 && typeof easing === 'function') {\n callback = easing;\n [left, top, duration, callback, easing] = args;\n }\n\n if (typeof easing === 'undefined') easing = 'swing';\n return this.each(function animate() {\n const el = this;\n let currentTop;\n let currentLeft;\n let maxTop;\n let maxLeft;\n let newTop;\n let newLeft;\n let scrollTop; // eslint-disable-line\n\n let scrollLeft; // eslint-disable-line\n\n let animateTop = top > 0 || top === 0;\n let animateLeft = left > 0 || left === 0;\n\n if (typeof easing === 'undefined') {\n easing = 'swing';\n }\n\n if (animateTop) {\n currentTop = el.scrollTop;\n\n if (!duration) {\n el.scrollTop = top;\n }\n }\n\n if (animateLeft) {\n currentLeft = el.scrollLeft;\n\n if (!duration) {\n el.scrollLeft = left;\n }\n }\n\n if (!duration) return;\n\n if (animateTop) {\n maxTop = el.scrollHeight - el.offsetHeight;\n newTop = Math.max(Math.min(top, maxTop), 0);\n }\n\n if (animateLeft) {\n maxLeft = el.scrollWidth - el.offsetWidth;\n newLeft = Math.max(Math.min(left, maxLeft), 0);\n }\n\n let startTime = null;\n if (animateTop && newTop === currentTop) animateTop = false;\n if (animateLeft && newLeft === currentLeft) animateLeft = false;\n\n function render(time = new Date().getTime()) {\n if (startTime === null) {\n startTime = time;\n }\n\n const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);\n const easeProgress = easing === 'linear' ? progress : 0.5 - Math.cos(progress * Math.PI) / 2;\n let done;\n if (animateTop) scrollTop = currentTop + easeProgress * (newTop - currentTop);\n if (animateLeft) scrollLeft = currentLeft + easeProgress * (newLeft - currentLeft);\n\n if (animateTop && newTop > currentTop && scrollTop >= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateTop && newTop < currentTop && scrollTop <= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (done) {\n if (callback) callback();\n return;\n }\n\n if (animateTop) el.scrollTop = scrollTop;\n if (animateLeft) el.scrollLeft = scrollLeft;\n window.requestAnimationFrame(render);\n }\n\n window.requestAnimationFrame(render);\n });\n} // scrollTop(top, duration, easing, callback) {\n\n\nfunction scrollTop(...args) {\n let [top, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [top, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof top === 'undefined') {\n if (dom.length > 0) return dom[0].scrollTop;\n return null;\n }\n\n return dom.scrollTo(undefined, top, duration, easing, callback);\n}\n\nfunction scrollLeft(...args) {\n let [left, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [left, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof left === 'undefined') {\n if (dom.length > 0) return dom[0].scrollLeft;\n return null;\n }\n\n return dom.scrollTo(left, undefined, duration, easing, callback);\n}\n\n// eslint-disable-next-line\n\nfunction animate(initialProps, initialParams) {\n const window = getWindow();\n const els = this;\n const a = {\n props: Object.assign({}, initialProps),\n params: Object.assign({\n duration: 300,\n easing: 'swing' // or 'linear'\n\n /* Callbacks\n begin(elements)\n complete(elements)\n progress(elements, complete, remaining, start, tweenValue)\n */\n\n }, initialParams),\n elements: els,\n animating: false,\n que: [],\n\n easingProgress(easing, progress) {\n if (easing === 'swing') {\n return 0.5 - Math.cos(progress * Math.PI) / 2;\n }\n\n if (typeof easing === 'function') {\n return easing(progress);\n }\n\n return progress;\n },\n\n stop() {\n if (a.frameId) {\n window.cancelAnimationFrame(a.frameId);\n }\n\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n a.que = [];\n },\n\n done(complete) {\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n if (complete) complete(els);\n\n if (a.que.length > 0) {\n const que = a.que.shift();\n a.animate(que[0], que[1]);\n }\n },\n\n animate(props, params) {\n if (a.animating) {\n a.que.push([props, params]);\n return a;\n }\n\n const elements = []; // Define & Cache Initials & Units\n\n a.elements.each((el, index) => {\n let initialFullValue;\n let initialValue;\n let unit;\n let finalValue;\n let finalFullValue;\n if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a;\n elements[index] = {\n container: el\n };\n Object.keys(props).forEach(prop => {\n initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.');\n initialValue = parseFloat(initialFullValue);\n unit = initialFullValue.replace(initialValue, '');\n finalValue = parseFloat(props[prop]);\n finalFullValue = props[prop] + unit;\n elements[index][prop] = {\n initialFullValue,\n initialValue,\n unit,\n finalValue,\n finalFullValue,\n currentValue: initialValue\n };\n });\n });\n let startTime = null;\n let time;\n let elementsDone = 0;\n let propsDone = 0;\n let done;\n let began = false;\n a.animating = true;\n\n function render() {\n time = new Date().getTime();\n let progress;\n let easeProgress; // let el;\n\n if (!began) {\n began = true;\n if (params.begin) params.begin(els);\n }\n\n if (startTime === null) {\n startTime = time;\n }\n\n if (params.progress) {\n // eslint-disable-next-line\n params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), startTime + params.duration - time < 0 ? 0 : startTime + params.duration - time, startTime);\n }\n\n elements.forEach(element => {\n const el = element;\n if (done || el.done) return;\n Object.keys(props).forEach(prop => {\n if (done || el.done) return;\n progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0);\n easeProgress = a.easingProgress(params.easing, progress);\n const {\n initialValue,\n finalValue,\n unit\n } = el[prop];\n el[prop].currentValue = initialValue + easeProgress * (finalValue - initialValue);\n const currentValue = el[prop].currentValue;\n\n if (finalValue > initialValue && currentValue >= finalValue || finalValue < initialValue && currentValue <= finalValue) {\n el.container.style[prop] = finalValue + unit;\n propsDone += 1;\n\n if (propsDone === Object.keys(props).length) {\n el.done = true;\n elementsDone += 1;\n }\n\n if (elementsDone === elements.length) {\n done = true;\n }\n }\n\n if (done) {\n a.done(params.complete);\n return;\n }\n\n el.container.style[prop] = currentValue + unit;\n });\n });\n if (done) return; // Then call\n\n a.frameId = window.requestAnimationFrame(render);\n }\n\n a.frameId = window.requestAnimationFrame(render);\n return a;\n }\n\n };\n\n if (a.elements.length === 0) {\n return els;\n }\n\n let animateInstance;\n\n for (let i = 0; i < a.elements.length; i += 1) {\n if (a.elements[i].dom7AnimateInstance) {\n animateInstance = a.elements[i].dom7AnimateInstance;\n } else a.elements[i].dom7AnimateInstance = a;\n }\n\n if (!animateInstance) {\n animateInstance = a;\n }\n\n if (initialProps === 'stop') {\n animateInstance.stop();\n } else {\n animateInstance.animate(a.props, a.params);\n }\n\n return els;\n}\n\nfunction stop() {\n const els = this;\n\n for (let i = 0; i < els.length; i += 1) {\n if (els[i].dom7AnimateInstance) {\n els[i].dom7AnimateInstance.stop();\n }\n }\n}\n\nconst noTrigger = 'resize scroll'.split(' ');\n\nfunction shortcut(name) {\n function eventHandler(...args) {\n if (typeof args[0] === 'undefined') {\n for (let i = 0; i < this.length; i += 1) {\n if (noTrigger.indexOf(name) < 0) {\n if (name in this[i]) this[i][name]();else {\n $(this[i]).trigger(name);\n }\n }\n }\n\n return this;\n }\n\n return this.on(name, ...args);\n }\n\n return eventHandler;\n}\n\nconst click = shortcut('click');\nconst blur = shortcut('blur');\nconst focus = shortcut('focus');\nconst focusin = shortcut('focusin');\nconst focusout = shortcut('focusout');\nconst keyup = shortcut('keyup');\nconst keydown = shortcut('keydown');\nconst keypress = shortcut('keypress');\nconst submit = shortcut('submit');\nconst change = shortcut('change');\nconst mousedown = shortcut('mousedown');\nconst mousemove = shortcut('mousemove');\nconst mouseup = shortcut('mouseup');\nconst mouseenter = shortcut('mouseenter');\nconst mouseleave = shortcut('mouseleave');\nconst mouseout = shortcut('mouseout');\nconst mouseover = shortcut('mouseover');\nconst touchstart = shortcut('touchstart');\nconst touchend = shortcut('touchend');\nconst touchmove = shortcut('touchmove');\nconst resize = shortcut('resize');\nconst scroll = shortcut('scroll');\n\nexport default $;\nexport { $, add, addClass, animate, animationEnd, append, appendTo, attr, blur, change, children, click, closest, css, data, dataset, detach, each, empty, eq, filter, find, focus, focusin, focusout, hasClass, height, hide, html, index, insertAfter, insertBefore, is, keydown, keypress, keyup, mousedown, mouseenter, mouseleave, mousemove, mouseout, mouseover, mouseup, next, nextAll, off, offset, on, once, outerHeight, outerWidth, parent, parents, prepend, prependTo, prev, prevAll, prop, remove, removeAttr, removeClass, removeData, resize, scroll, scrollLeft, scrollTo, scrollTop, show, siblings, stop, styles, submit, text, toggleClass, touchend, touchmove, touchstart, transform, transition, transitionEnd, transitionStart, trigger, val, value, width };\n","/**\n * @description DOM 操作\n * @author wangfupeng\n */\n\nimport $, {\n append, find, focus, html, is, on, parents, val,\n} from 'dom7'\n\n// COMPAT: This is required to prevent TypeScript aliases from doing some very\n// weird things for Slate's types with the same name as globals. (2019/11/27)\n// https://github.com/microsoft/TypeScript/issues/35002\nimport DOMNode = globalThis.Node\nimport DOMComment = globalThis.Comment\nimport DOMElement = globalThis.Element\nimport DOMText = globalThis.Text\nimport DOMRange = globalThis.Range\nimport DOMSelection = globalThis.Selection\nimport DOMStaticRange = globalThis.StaticRange\n\nif (append) { $.fn.append = append }\nif (html) { $.fn.html = html }\nif (val) { $.fn.val = val }\nif (on) { $.fn.on = on }\nif (focus) { $.fn.focus = focus }\nif (is) { $.fn.is = is }\nif (parents) { $.fn.parents = parents }\nif (find) { $.fn.find = find }\n\nexport { Dom7Array } from 'dom7'\nexport default $\nexport {\n DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText,\n}\n","/**\n * @description 工具函数\n * @author wangfupeng\n */\n\nimport { nanoid } from 'nanoid'\n\n/**\n * 获取随机数字符串\n * @param prefix 前缀\n * @returns 随机数字符串\n */\nexport function genRandomStr(prefix: string = 'r'): string {\n return `${prefix}-${nanoid()}`\n}\n\n// export function replaceSymbols(str: string) {\n// return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')\n// }\n","/* @ts-self-types=\"./index.d.ts\" */\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << Math.log2(alphabet.length - 1)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step | 0\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length >= size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","/**\n * @description edit formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n SlateTransforms,\n t,\n} from '@wangeditor-next/editor'\n\nimport { PENCIL_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass EditFormulaMenu implements IModalMenu {\n readonly title = t('formula.edit')\n\n readonly iconSvg = PENCIL_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n private getSelectedElem(editor: IDomEditor): FormulaElement | null {\n const node = DomEditor.getSelectedNodeByType(editor, 'formula')\n\n if (node == null) { return null }\n return node as FormulaElement\n }\n\n /**\n * 获取公式 value\n * @param editor editor\n */\n getValue(editor: IDomEditor): string | boolean {\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem) {\n return formulaElem.value || ''\n }\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 无需 active\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n // 未匹配到 formula node 则禁用\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem == null) { return true }\n\n return false\n }\n\n // modal 定位\n getModalPositionNode(editor: IDomEditor): SlateNode | null {\n return this.getSelectedElem(editor)\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.updateFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n const value = this.getValue(editor)\n\n $textarea.val(value)\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private updateFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const selectedElem = this.getSelectedElem(editor)\n\n if (selectedElem == null) { return }\n\n const path = DomEditor.findPath(editor, selectedElem)\n const props: Partial<FormulaElement> = { value }\n\n SlateTransforms.setNodes(editor, props, { at: path })\n }\n}\n\nexport default EditFormulaMenu\n","/**\n * @description icon svg\n * @author wangfupeng\n */\n\n/**\n * 【注意】svg 字符串的长度 ,否则会导致代码体积过大\n * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293\n * 找不到再从 iconfont.com 搜索\n */\n\n// 公式\nexport const SIGMA_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z\"></path></svg>'\n\n// 编辑\nexport const PENCIL_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z\"></path></svg>'\n","/**\n * @description insert formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n t,\n} from '@wangeditor-next/editor'\n\nimport { SIGMA_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass InsertFormulaMenu implements IModalMenu {\n readonly title = t('formula.insert')\n\n readonly iconSvg = SIGMA_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n getValue(_editor: IDomEditor): string | boolean {\n // 插入菜单,不需要 value\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 任何时候,都不用激活 menu\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n const selectedElems = DomEditor.getSelectedElems(editor)\n\n const hasVoidElem = selectedElems.some(elem => editor.isVoid(elem))\n\n if (hasVoidElem) { return true } // 选中了 void 元素,禁用\n\n const hasPreElem = selectedElems.some(elem => DomEditor.getNodeType(elem) === 'pre')\n\n if (hasPreElem) { return true } // 选中了 pre 原则,禁用\n\n return false\n }\n\n getModalPositionNode(_editor: IDomEditor): SlateNode | null {\n return null // modal 依据选区定位\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.insertFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n $textarea.val('')\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private insertFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const formulaElem: FormulaElement = {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 需要有一个空 text\n }\n\n editor.insertNode(formulaElem)\n }\n}\n\nexport default InsertFormulaMenu\n","/**\n * @description render elem\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor, SlateElement } from '@wangeditor-next/editor'\nimport { h, VNode } from 'snabbdom'\n\nimport { FormulaElement } from './custom-types'\n\nfunction renderFormula(elem: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode {\n // 当前节点是否选中\n const selected = DomEditor.isNodeSelected(editor, elem)\n\n // 构建 formula vnode\n const { value = '' } = elem as FormulaElement\n const formulaVnode = h(\n 'w-e-formula-card',\n {\n dataset: { value },\n },\n null,\n )\n\n // 构建容器 vnode\n const containerVnode = h(\n 'div',\n {\n className: 'w-e-textarea-formula-container',\n props: {\n contentEditable: false, // 不可编辑\n },\n style: {\n display: 'inline-block', // inline\n marginLeft: '3px',\n marginRight: '3px',\n border: selected // 选中/不选中,样式不一样\n ? '2px solid var(--w-e-textarea-selected-border-color)'\n : '2px solid transparent',\n borderRadius: '3px',\n padding: '3px 3px',\n },\n },\n [formulaVnode],\n )\n\n return containerVnode\n}\n\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n renderElem: renderFormula,\n}\n\nexport default conf\n","/**\n * @description formula module entry\n * @author wangfupeng\n */\n\nimport './local' // 多语言\n\nimport { IModuleConf } from '@wangeditor-next/editor'\n\nimport elemToHtmlConf from './elem-to-html'\nimport { editFormulaMenuConf, insertFormulaMenuConf } from './menu/index'\nimport parseHtmlConf from './parse-elem-html'\nimport withFormula from './plugin'\nimport renderElemConf from './render-elem'\n\nconst module: Partial<IModuleConf> = {\n editorPlugin: withFormula,\n renderElems: [renderElemConf],\n elemsToHtml: [elemToHtmlConf],\n parseElemsHtml: [parseHtmlConf],\n menus: [insertFormulaMenuConf, editFormulaMenuConf],\n}\n\nexport default module\n","/**\n * @description formula plugin\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor } from '@wangeditor-next/editor'\n\nfunction withFormula<T extends IDomEditor>(editor: T) {\n const { isInline, isVoid } = editor\n const newEditor = editor\n\n // 重写 isInline\n newEditor.isInline = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isInline(elem)\n }\n\n // 重写 isVoid\n newEditor.isVoid = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isVoid(elem)\n }\n\n return newEditor\n}\n\nexport default withFormula\n","/**\n * @description parse elem html\n * @author wangfupeng\n */\n\nimport { IDomEditor, SlateDescendant, SlateElement } from '@wangeditor-next/editor'\n\nimport { DOMElement } from '../utils/dom'\nimport { FormulaElement } from './custom-types'\n\nfunction parseHtml(\n elem: DOMElement,\n _children: SlateDescendant[],\n _editor: IDomEditor,\n): SlateElement {\n const value = elem.getAttribute('data-value') || ''\n\n return {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 必须有一个空白 text\n } as FormulaElement\n}\n\nconst parseHtmlConf = {\n selector: 'span[data-w-e-type=\"formula\"]',\n parseElemHtml: parseHtml,\n}\n\nexport default parseHtmlConf\n","/**\n * @description formula menu entry\n * @author wangfupeng\n */\n\nimport EditFormulaMenu from './EditFormula'\nimport InsertFormulaMenu from './InsertFormula'\n\nexport const insertFormulaMenuConf = {\n key: 'insertFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new InsertFormulaMenu()\n },\n}\n\nexport const editFormulaMenuConf = {\n key: 'editFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new EditFormulaMenu()\n },\n}\n"],"names":["undefined","window","Reflect","customElements","polyfillWrapFlushCallback","BuiltInHTMLElement","HTMLElement","wrapperForTheName","construct","this","constructor","prototype","Object","setPrototypeOf","WangEditorFormulaCard","_super","_this","shadow","attachShadow","mode","span","ownerDocument","createElement","style","display","appendChild","__extends","defineProperty","get","attributeChangedCallback","name","oldValue","newValue","render","value","katex","throwOnError","output","define","i18nAddResources","formula","placeholder","insert","edit","ok","conf","type","elemToHtml","elem","_childrenHtml","_a","concat","isObject","obj","extend","target","src","keys","forEach","key","length","ssrDocument","body","addEventListener","removeEventListener","activeElement","blur","nodeName","querySelector","querySelectorAll","getElementById","createEvent","initEvent","children","childNodes","setAttribute","getElementsByTagName","createElementNS","importNode","location","hash","host","hostname","href","origin","pathname","protocol","search","getDocument","doc","document","ssrWindow","navigator","userAgent","history","replaceState","pushState","go","back","CustomEvent","getComputedStyle","getPropertyValue","Image","Date","screen","setTimeout","clearTimeout","matchMedia","requestAnimationFrame","callback","cancelAnimationFrame","id","getWindow","win","Dom7","Array","items","super","proto","__proto__","set","makeReactive","$","selector","context","arr","html","trim","indexOf","toCreate","tempParent","innerHTML","i","push","a","res","qsa","nodeType","isArray","uniqueArray","arrayUnique","val","el","multiple","toLowerCase","values","selectedOptions","j","options","selected","on","args","eventType","targetSelector","listener","capture","handleLiveEvent","e","eventData","dom7EventData","unshift","is","apply","parents","k","handleEvent","events","split","event","dom7LiveListeners","proxyListener","dom7Listeners","compareWith","matches","webkitMatchesSelector","msMatchesSelector","append","els","newChild","tempDiv","firstChild","parent","parentNode","find","foundElements","found","fn","noTrigger","focus","trigger","genRandomStr","prefix","size","bytes","crypto","getRandomValues","Uint8Array","nanoid","genDomID","EditFormulaMenu","title","t","iconSvg","tag","showModal","modalWidth","$content","textareaId","buttonId","getSelectedElem","editor","node","DomEditor","getSelectedNodeByType","getValue","formulaElem","isActive","_editor","exec","_value","isDisabled","selection","SlateRange","isExpanded","getModalPositionNode","getModalContentElem","_b","__read","genModalTextareaElems","textareaContainerElem","$textarea","buttonContainerElem","genModalButtonElems","$content_1","preventDefault","updateFormula","hidePanelOrModal","restoreSelection","selectedElem","path","findPath","props","SlateTransforms","setNodes","at","InsertFormulaMenu","selectedElems","getSelectedElems","some","isVoid","getNodeType","insertFormula","text","insertNode","module","editorPlugin","isInline","newEditor","renderElems","renderElem","isNodeSelected","formulaVnode","h","dataset","className","contentEditable","marginLeft","marginRight","border","borderRadius","padding","elemsToHtml","elemToHtmlConf","parseElemsHtml","parseElemHtml","_children","getAttribute","menus","factory"],"mappings":"wvBAoBC,WACC,QAGqBA,IAAnBC,OAAOC,cACsBF,IAA1BC,OAAOE,iBAGPF,OAAOE,eAAeC,0BAP3B,CAWA,IAAMC,EAAqBC,YAOrBC,EAEgC,WAClC,OAAOL,QAAQM,UAAUH,EAAoB,GAA6BI,KAAKC,YACjF,EAGFT,OAAOK,YAAcC,EACrBD,YAAYK,UAAYN,EAAmBM,UAC3CL,YAAYK,UAAUD,YAAcJ,YACpCM,OAAOC,eAAeP,YAAaD,EAlBnC,CAmBD,CA9BA,GCXD,IAAAS,EAAA,SAAAC,GAQE,SAAAD,IACE,IAAAE,EAAAD,cAAON,KACDQ,EAASD,EAAKE,aAAa,CAAEC,KAAM,SAEnCC,EADWH,EAAOI,cACFC,cAAc,eAEpCF,EAAKG,MAAMC,QAAU,eACrBP,EAAO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,CACnCC,aCTF,SAA2C7C,GACjC,IAAA8C,EAAqB9C,EAAM8C,SAAjBP,EAAWvC,EAAMuC,OAC7BQ,EAAY/C,EAwBlB,OArBA+C,EAAUD,SAAW,SAAAhN,GAGnB,MAAa,YAFAoK,EAAUsC,YAAY1M,IAM5BgN,EAAShN,EAClB,EAGAiN,EAAUR,OAAS,SAAAzM,GAGjB,MAAa,YAFAoK,EAAUsC,YAAY1M,IAM5ByM,EAAOzM,EAChB,EAEOiN,CACT,EDjBEC,YAAa,CDgCF,CACXpN,KAAM,UACNqN,WAzCF,SAAuBnN,EAAoByB,EAA0ByI,GAEnE,IAAM7D,EAAW+D,EAAUgD,eAAelD,EAAQlK,GAG1CE,EAAeF,EAAsBd,MACvCmO,EAAeC,EACnB,mBACA,CACEC,QAAS,CAAErO,WAJF,IAAAgB,EAAG,OAMd,MAyBF,OArBuBoN,EACrB,MACA,CACEE,UAAW,iCACXvB,MAAO,CACLwB,iBAAiB,GAEnBlP,MAAO,CACLC,QAAS,eACTkP,WAAY,MACZC,YAAa,MACbC,OAAQvH,EACJ,sDACA,wBACJwH,aAAc,MACdC,QAAS,YAGb,CAACT,GAIL,IC7BEU,YAAa,CAACC,GACdC,eAAgB,CEKI,CACpBtJ,SAAU,gCACVuJ,cAhBF,SACElO,EACAmO,EACA1D,GAIA,MAAO,CACL3K,KAAM,UACNZ,MAJYc,EAAKoO,aAAa,eAAiB,GAK/C3M,SAAU,CAAC,CAAEmL,KAAM,KAEvB,IFFEyB,MAAO,CGZ4B,CACnC1N,IAAK,gBACL2N,QAAO,WACL,OAAO,IAAIjC,CACb,GAGiC,CACjC1L,IAAK,cACL2N,QAAO,WACL,OAAO,IAAI/E,CACb","x_google_ignoreList":[4,5,8,9]}
1
+ {"version":3,"file":"index.mjs","sources":["../src/register-custom-elem/native-shim.ts","../src/register-custom-elem/index.ts","../src/module/local.ts","../src/module/elem-to-html.ts","../../../node_modules/.pnpm/ssr-window@4.0.2/node_modules/ssr-window/ssr-window.esm.js","../../../node_modules/.pnpm/dom7@4.0.6/node_modules/dom7/dom7.esm.js","../src/utils/dom.ts","../src/utils/util.ts","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.browser.js","../../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/url-alphabet/index.js","../src/module/menu/EditFormula.ts","../src/constants/icon-svg.ts","../src/module/menu/InsertFormula.ts","../src/module/render-elem.ts","../src/module/index.ts","../src/module/plugin.ts","../src/module/parse-elem-html.ts","../src/module/menu/index.ts"],"sourcesContent":["// @ts-nocheck\n\n// 参考 https://github.com/webcomponents/custom-elements/blob/master/src/native-shim.js\n\n/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * This shim allows elements written in, or compiled to, ES5 to work on native\n * implementations of Custom Elements v1. It sets new.target to the value of\n * this.constructor so that the native HTMLElement constructor can access the\n * current under-construction element's definition.\n */\n(function () {\n if (\n // No Reflect, no classes, no need for shim because native custom elements\n // require ES2015 classes or Reflect.\n window.Reflect === undefined\n || window.customElements === undefined\n // The webcomponentsjs custom elements polyfill doesn't require\n // ES2015-compatible construction (`super()` or `Reflect.construct`).\n || window.customElements.polyfillWrapFlushCallback\n ) {\n return\n }\n const BuiltInHTMLElement = HTMLElement\n /**\n * With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.\n * However, if we declare the function as a property on an object literal, and\n * use quotes for the property name, then closure will leave that much intact,\n * which is enough for the JS VM to correctly set Function.prototype.name.\n */\n const wrapperForTheName = {\n // eslint-disable-next-line func-names\n HTMLElement: /** @this {!Object} */ function HTMLElement() {\n return Reflect.construct(BuiltInHTMLElement, [], /** @type {!Function} */ this.constructor)\n },\n }\n\n window.HTMLElement = wrapperForTheName.HTMLElement\n HTMLElement.prototype = BuiltInHTMLElement.prototype\n HTMLElement.prototype.constructor = HTMLElement\n Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement)\n}())\n","/**\n * @description 注册自定义 elem\n * @author wangfupeng\n */\n\nimport './native-shim'\n\nimport katex from 'katex'\n\nclass WangEditorFormulaCard extends HTMLElement {\n private span: HTMLElement | null = null\n\n // 监听的 attr\n static get observedAttributes() {\n return ['data-value']\n }\n\n constructor() {\n super()\n }\n\n // connectedCallback() {\n // // 当 custom element首次被插入文档DOM时,被调用\n // console.log('connected')\n // }\n // disconnectedCallback() {\n // // 当 custom element从文档DOM中删除时,被调用\n // console.log('disconnected')\n // }\n // adoptedCallback() {\n // // 当 custom element被移动到新的文档时,被调用\n // console.log('adopted')\n // }\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'data-value') {\n if (oldValue === newValue) { return }\n this.render(newValue || '')\n }\n }\n\n private ensureSpan() {\n if (this.span) { return this.span }\n\n const document = this.ownerDocument || window.document\n const span = document.createElement('span')\n\n span.style.display = 'inline-block'\n this.appendChild(span)\n this.span = span\n\n return span\n }\n\n private render(value: string) {\n const span = this.ensureSpan()\n\n katex.render(value, span, {\n throwOnError: false,\n output: 'htmlAndMathml',\n })\n }\n}\n\nif (!window.customElements.get('w-e-formula-card')) {\n window.customElements.define('w-e-formula-card', WangEditorFormulaCard)\n}\n","/**\n * @description 多语言\n * @author wangfupeng\n */\n\nimport { i18nAddResources } from '@wangeditor-next/editor'\n\ni18nAddResources('en', {\n formula: {\n formula: 'Formula',\n placeholder: 'Use LateX syntax',\n insert: 'Insert formula',\n edit: 'Edit formula',\n ok: 'OK',\n },\n})\n\ni18nAddResources('zh-CN', {\n formula: {\n formula: '公式',\n placeholder: '使用 LateX 语法',\n insert: '插入公式',\n edit: '编辑公式',\n ok: '确定',\n },\n})\n","/**\n * @description elem to html\n * @author wangfupeng\n */\n\nimport { SlateElement } from '@wangeditor-next/editor'\n\nimport { FormulaElement } from './custom-types'\n\n// 生成 html 的函数\nfunction formulaToHtml(elem: SlateElement, _childrenHtml: string): string {\n const { value = '' } = elem as FormulaElement\n\n return `<span data-w-e-type=\"formula\" data-w-e-is-void data-w-e-is-inline data-value=\"${value}\"></span>`\n}\n\n// 配置\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n elemToHtml: formulaToHtml,\n}\n\nexport default conf\n","/**\n * SSR Window 4.0.2\n * Better handling for window object in SSR environment\n * https://github.com/nolimits4web/ssr-window\n *\n * Copyright 2021, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: December 13, 2021\n */\n/* eslint-disable no-param-reassign */\nfunction isObject(obj) {\n return (obj !== null &&\n typeof obj === 'object' &&\n 'constructor' in obj &&\n obj.constructor === Object);\n}\nfunction extend(target = {}, src = {}) {\n Object.keys(src).forEach((key) => {\n if (typeof target[key] === 'undefined')\n target[key] = src[key];\n else if (isObject(src[key]) &&\n isObject(target[key]) &&\n Object.keys(src[key]).length > 0) {\n extend(target[key], src[key]);\n }\n });\n}\n\nconst ssrDocument = {\n body: {},\n addEventListener() { },\n removeEventListener() { },\n activeElement: {\n blur() { },\n nodeName: '',\n },\n querySelector() {\n return null;\n },\n querySelectorAll() {\n return [];\n },\n getElementById() {\n return null;\n },\n createEvent() {\n return {\n initEvent() { },\n };\n },\n createElement() {\n return {\n children: [],\n childNodes: [],\n style: {},\n setAttribute() { },\n getElementsByTagName() {\n return [];\n },\n };\n },\n createElementNS() {\n return {};\n },\n importNode() {\n return null;\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n};\nfunction getDocument() {\n const doc = typeof document !== 'undefined' ? document : {};\n extend(doc, ssrDocument);\n return doc;\n}\n\nconst ssrWindow = {\n document: ssrDocument,\n navigator: {\n userAgent: '',\n },\n location: {\n hash: '',\n host: '',\n hostname: '',\n href: '',\n origin: '',\n pathname: '',\n protocol: '',\n search: '',\n },\n history: {\n replaceState() { },\n pushState() { },\n go() { },\n back() { },\n },\n CustomEvent: function CustomEvent() {\n return this;\n },\n addEventListener() { },\n removeEventListener() { },\n getComputedStyle() {\n return {\n getPropertyValue() {\n return '';\n },\n };\n },\n Image() { },\n Date() { },\n screen: {},\n setTimeout() { },\n clearTimeout() { },\n matchMedia() {\n return {};\n },\n requestAnimationFrame(callback) {\n if (typeof setTimeout === 'undefined') {\n callback();\n return null;\n }\n return setTimeout(callback, 0);\n },\n cancelAnimationFrame(id) {\n if (typeof setTimeout === 'undefined') {\n return;\n }\n clearTimeout(id);\n },\n};\nfunction getWindow() {\n const win = typeof window !== 'undefined' ? window : {};\n extend(win, ssrWindow);\n return win;\n}\n\nexport { extend, getDocument, getWindow, ssrDocument, ssrWindow };\n","/**\n * Dom7 4.0.6\n * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API\n * https://framework7.io/docs/dom7.html\n *\n * Copyright 2023, Vladimir Kharlampidi\n *\n * Licensed under MIT\n *\n * Released on: February 2, 2023\n */\nimport { getWindow, getDocument } from 'ssr-window';\n\n/* eslint-disable no-proto */\nfunction makeReactive(obj) {\n const proto = obj.__proto__;\n Object.defineProperty(obj, '__proto__', {\n get() {\n return proto;\n },\n\n set(value) {\n proto.__proto__ = value;\n }\n\n });\n}\n\nclass Dom7 extends Array {\n constructor(items) {\n if (typeof items === 'number') {\n super(items);\n } else {\n super(...(items || []));\n makeReactive(this);\n }\n }\n\n}\n\nfunction arrayFlat(arr = []) {\n const res = [];\n arr.forEach(el => {\n if (Array.isArray(el)) {\n res.push(...arrayFlat(el));\n } else {\n res.push(el);\n }\n });\n return res;\n}\nfunction arrayFilter(arr, callback) {\n return Array.prototype.filter.call(arr, callback);\n}\nfunction arrayUnique(arr) {\n const uniqueArray = [];\n\n for (let i = 0; i < arr.length; i += 1) {\n if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);\n }\n\n return uniqueArray;\n}\nfunction toCamelCase(string) {\n return string.toLowerCase().replace(/-(.)/g, (match, group) => group.toUpperCase());\n}\n\n// eslint-disable-next-line\n\nfunction qsa(selector, context) {\n if (typeof selector !== 'string') {\n return [selector];\n }\n\n const a = [];\n const res = context.querySelectorAll(selector);\n\n for (let i = 0; i < res.length; i += 1) {\n a.push(res[i]);\n }\n\n return a;\n}\n\nfunction $(selector, context) {\n const window = getWindow();\n const document = getDocument();\n let arr = [];\n\n if (!context && selector instanceof Dom7) {\n return selector;\n }\n\n if (!selector) {\n return new Dom7(arr);\n }\n\n if (typeof selector === 'string') {\n const html = selector.trim();\n\n if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {\n let toCreate = 'div';\n if (html.indexOf('<li') === 0) toCreate = 'ul';\n if (html.indexOf('<tr') === 0) toCreate = 'tbody';\n if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';\n if (html.indexOf('<tbody') === 0) toCreate = 'table';\n if (html.indexOf('<option') === 0) toCreate = 'select';\n const tempParent = document.createElement(toCreate);\n tempParent.innerHTML = html;\n\n for (let i = 0; i < tempParent.childNodes.length; i += 1) {\n arr.push(tempParent.childNodes[i]);\n }\n } else {\n arr = qsa(selector.trim(), context || document);\n } // arr = qsa(selector, document);\n\n } else if (selector.nodeType || selector === window || selector === document) {\n arr.push(selector);\n } else if (Array.isArray(selector)) {\n if (selector instanceof Dom7) return selector;\n arr = selector;\n }\n\n return new Dom7(arrayUnique(arr));\n}\n\n$.fn = Dom7.prototype;\n\n// eslint-disable-next-line\n\nfunction addClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.add(...classNames);\n });\n return this;\n}\n\nfunction removeClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n el.classList.remove(...classNames);\n });\n return this;\n}\n\nfunction toggleClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n this.forEach(el => {\n classNames.forEach(className => {\n el.classList.toggle(className);\n });\n });\n}\n\nfunction hasClass(...classes) {\n const classNames = arrayFlat(classes.map(c => c.split(' ')));\n return arrayFilter(this, el => {\n return classNames.filter(className => el.classList.contains(className)).length > 0;\n }).length > 0;\n}\n\nfunction attr(attrs, value) {\n if (arguments.length === 1 && typeof attrs === 'string') {\n // Get attr\n if (this[0]) return this[0].getAttribute(attrs);\n return undefined;\n } // Set attrs\n\n\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i].setAttribute(attrs, value);\n } else {\n // Object\n for (const attrName in attrs) {\n this[i][attrName] = attrs[attrName];\n this[i].setAttribute(attrName, attrs[attrName]);\n }\n }\n }\n\n return this;\n}\n\nfunction removeAttr(attr) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].removeAttribute(attr);\n }\n\n return this;\n}\n\nfunction prop(props, value) {\n if (arguments.length === 1 && typeof props === 'string') {\n // Get prop\n if (this[0]) return this[0][props];\n } else {\n // Set props\n for (let i = 0; i < this.length; i += 1) {\n if (arguments.length === 2) {\n // String\n this[i][props] = value;\n } else {\n // Object\n for (const propName in props) {\n this[i][propName] = props[propName];\n }\n }\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction data(key, value) {\n let el;\n\n if (typeof value === 'undefined') {\n el = this[0];\n if (!el) return undefined; // Get value\n\n if (el.dom7ElementDataStorage && key in el.dom7ElementDataStorage) {\n return el.dom7ElementDataStorage[key];\n }\n\n const dataKey = el.getAttribute(`data-${key}`);\n\n if (dataKey) {\n return dataKey;\n }\n\n return undefined;\n } // Set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n el = this[i];\n if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};\n el.dom7ElementDataStorage[key] = value;\n }\n\n return this;\n}\n\nfunction removeData(key) {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.dom7ElementDataStorage && el.dom7ElementDataStorage[key]) {\n el.dom7ElementDataStorage[key] = null;\n delete el.dom7ElementDataStorage[key];\n }\n }\n}\n\nfunction dataset() {\n const el = this[0];\n if (!el) return undefined;\n const dataset = {}; // eslint-disable-line\n\n if (el.dataset) {\n for (const dataKey in el.dataset) {\n dataset[dataKey] = el.dataset[dataKey];\n }\n } else {\n for (let i = 0; i < el.attributes.length; i += 1) {\n const attr = el.attributes[i];\n\n if (attr.name.indexOf('data-') >= 0) {\n dataset[toCamelCase(attr.name.split('data-')[1])] = attr.value;\n }\n }\n }\n\n for (const key in dataset) {\n if (dataset[key] === 'false') dataset[key] = false;else if (dataset[key] === 'true') dataset[key] = true;else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] *= 1;\n }\n\n return dataset;\n}\n\nfunction val(value) {\n if (typeof value === 'undefined') {\n // get value\n const el = this[0];\n if (!el) return undefined;\n\n if (el.multiple && el.nodeName.toLowerCase() === 'select') {\n const values = [];\n\n for (let i = 0; i < el.selectedOptions.length; i += 1) {\n values.push(el.selectedOptions[i].value);\n }\n\n return values;\n }\n\n return el.value;\n } // set value\n\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (Array.isArray(value) && el.multiple && el.nodeName.toLowerCase() === 'select') {\n for (let j = 0; j < el.options.length; j += 1) {\n el.options[j].selected = value.indexOf(el.options[j].value) >= 0;\n }\n } else {\n el.value = value;\n }\n }\n\n return this;\n}\n\nfunction value(value) {\n return this.val(value);\n}\n\nfunction transform(transform) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transform = transform;\n }\n\n return this;\n}\n\nfunction transition(duration) {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration;\n }\n\n return this;\n}\n\nfunction on(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n\n function handleLiveEvent(e) {\n const target = e.target;\n if (!target) return;\n const eventData = e.target.dom7EventData || [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n if ($(target).is(targetSelector)) listener.apply(target, eventData);else {\n const parents = $(target).parents(); // eslint-disable-line\n\n for (let k = 0; k < parents.length; k += 1) {\n if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData);\n }\n }\n }\n\n function handleEvent(e) {\n const eventData = e && e.target ? e.target.dom7EventData || [] : [];\n\n if (eventData.indexOf(e) < 0) {\n eventData.unshift(e);\n }\n\n listener.apply(this, eventData);\n }\n\n const events = eventType.split(' ');\n let j;\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (!targetSelector) {\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7Listeners) el.dom7Listeners = {};\n if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];\n el.dom7Listeners[event].push({\n listener,\n proxyListener: handleEvent\n });\n el.addEventListener(event, handleEvent, capture);\n }\n } else {\n // Live events\n for (j = 0; j < events.length; j += 1) {\n const event = events[j];\n if (!el.dom7LiveListeners) el.dom7LiveListeners = {};\n if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = [];\n el.dom7LiveListeners[event].push({\n listener,\n proxyListener: handleLiveEvent\n });\n el.addEventListener(event, handleLiveEvent, capture);\n }\n }\n }\n\n return this;\n}\n\nfunction off(...args) {\n let [eventType, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventType, listener, capture] = args;\n targetSelector = undefined;\n }\n\n if (!capture) capture = false;\n const events = eventType.split(' ');\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n let handlers;\n\n if (!targetSelector && el.dom7Listeners) {\n handlers = el.dom7Listeners[event];\n } else if (targetSelector && el.dom7LiveListeners) {\n handlers = el.dom7LiveListeners[event];\n }\n\n if (handlers && handlers.length) {\n for (let k = handlers.length - 1; k >= 0; k -= 1) {\n const handler = handlers[k];\n\n if (listener && handler.listener === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n } else if (!listener) {\n el.removeEventListener(event, handler.proxyListener, capture);\n handlers.splice(k, 1);\n }\n }\n }\n }\n }\n\n return this;\n}\n\nfunction once(...args) {\n const dom = this;\n let [eventName, targetSelector, listener, capture] = args;\n\n if (typeof args[1] === 'function') {\n [eventName, listener, capture] = args;\n targetSelector = undefined;\n }\n\n function onceHandler(...eventArgs) {\n listener.apply(this, eventArgs);\n dom.off(eventName, targetSelector, onceHandler, capture);\n\n if (onceHandler.dom7proxy) {\n delete onceHandler.dom7proxy;\n }\n }\n\n onceHandler.dom7proxy = listener;\n return dom.on(eventName, targetSelector, onceHandler, capture);\n}\n\nfunction trigger(...args) {\n const window = getWindow();\n const events = args[0].split(' ');\n const eventData = args[1];\n\n for (let i = 0; i < events.length; i += 1) {\n const event = events[i];\n\n for (let j = 0; j < this.length; j += 1) {\n const el = this[j];\n\n if (window.CustomEvent) {\n const evt = new window.CustomEvent(event, {\n detail: eventData,\n bubbles: true,\n cancelable: true\n });\n el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0);\n el.dispatchEvent(evt);\n el.dom7EventData = [];\n delete el.dom7EventData;\n }\n }\n }\n\n return this;\n}\n\nfunction transitionStart(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionstart', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionstart', fireCallBack);\n }\n\n return this;\n}\n\nfunction transitionEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('transitionend', fireCallBack);\n }\n\n if (callback) {\n dom.on('transitionend', fireCallBack);\n }\n\n return this;\n}\n\nfunction animationEnd(callback) {\n const dom = this;\n\n function fireCallBack(e) {\n if (e.target !== this) return;\n callback.call(this, e);\n dom.off('animationend', fireCallBack);\n }\n\n if (callback) {\n dom.on('animationend', fireCallBack);\n }\n\n return this;\n}\n\nfunction width() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerWidth;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('width'));\n }\n\n return null;\n}\n\nfunction outerWidth(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));\n }\n\n return this[0].offsetWidth;\n }\n\n return null;\n}\n\nfunction height() {\n const window = getWindow();\n\n if (this[0] === window) {\n return window.innerHeight;\n }\n\n if (this.length > 0) {\n return parseFloat(this.css('height'));\n }\n\n return null;\n}\n\nfunction outerHeight(includeMargins) {\n if (this.length > 0) {\n if (includeMargins) {\n const styles = this.styles();\n return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));\n }\n\n return this[0].offsetHeight;\n }\n\n return null;\n}\n\nfunction offset() {\n if (this.length > 0) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n const box = el.getBoundingClientRect();\n const body = document.body;\n const clientTop = el.clientTop || body.clientTop || 0;\n const clientLeft = el.clientLeft || body.clientLeft || 0;\n const scrollTop = el === window ? window.scrollY : el.scrollTop;\n const scrollLeft = el === window ? window.scrollX : el.scrollLeft;\n return {\n top: box.top + scrollTop - clientTop,\n left: box.left + scrollLeft - clientLeft\n };\n }\n\n return null;\n}\n\nfunction hide() {\n for (let i = 0; i < this.length; i += 1) {\n this[i].style.display = 'none';\n }\n\n return this;\n}\n\nfunction show() {\n const window = getWindow();\n\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.style.display === 'none') {\n el.style.display = '';\n }\n\n if (window.getComputedStyle(el, null).getPropertyValue('display') === 'none') {\n // Still not visible\n el.style.display = 'block';\n }\n }\n\n return this;\n}\n\nfunction styles() {\n const window = getWindow();\n if (this[0]) return window.getComputedStyle(this[0], null);\n return {};\n}\n\nfunction css(props, value) {\n const window = getWindow();\n let i;\n\n if (arguments.length === 1) {\n if (typeof props === 'string') {\n // .css('width')\n if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);\n } else {\n // .css({ width: '100px' })\n for (i = 0; i < this.length; i += 1) {\n for (const prop in props) {\n this[i].style[prop] = props[prop];\n }\n }\n\n return this;\n }\n }\n\n if (arguments.length === 2 && typeof props === 'string') {\n // .css('width', '100px')\n for (i = 0; i < this.length; i += 1) {\n this[i].style[props] = value;\n }\n\n return this;\n }\n\n return this;\n}\n\nfunction each(callback) {\n if (!callback) return this;\n this.forEach((el, index) => {\n callback.apply(el, [el, index]);\n });\n return this;\n}\n\nfunction filter(callback) {\n const result = arrayFilter(this, callback);\n return $(result);\n}\n\nfunction html(html) {\n if (typeof html === 'undefined') {\n return this[0] ? this[0].innerHTML : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].innerHTML = html;\n }\n\n return this;\n}\n\nfunction text(text) {\n if (typeof text === 'undefined') {\n return this[0] ? this[0].textContent.trim() : null;\n }\n\n for (let i = 0; i < this.length; i += 1) {\n this[i].textContent = text;\n }\n\n return this;\n}\n\nfunction is(selector) {\n const window = getWindow();\n const document = getDocument();\n const el = this[0];\n let compareWith;\n let i;\n if (!el || typeof selector === 'undefined') return false;\n\n if (typeof selector === 'string') {\n if (el.matches) return el.matches(selector);\n if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);\n if (el.msMatchesSelector) return el.msMatchesSelector(selector);\n compareWith = $(selector);\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n if (selector === document) {\n return el === document;\n }\n\n if (selector === window) {\n return el === window;\n }\n\n if (selector.nodeType || selector instanceof Dom7) {\n compareWith = selector.nodeType ? [selector] : selector;\n\n for (i = 0; i < compareWith.length; i += 1) {\n if (compareWith[i] === el) return true;\n }\n\n return false;\n }\n\n return false;\n}\n\nfunction index() {\n let child = this[0];\n let i;\n\n if (child) {\n i = 0; // eslint-disable-next-line\n\n while ((child = child.previousSibling) !== null) {\n if (child.nodeType === 1) i += 1;\n }\n\n return i;\n }\n\n return undefined;\n}\n\nfunction eq(index) {\n if (typeof index === 'undefined') return this;\n const length = this.length;\n\n if (index > length - 1) {\n return $([]);\n }\n\n if (index < 0) {\n const returnIndex = length + index;\n if (returnIndex < 0) return $([]);\n return $([this[returnIndex]]);\n }\n\n return $([this[index]]);\n}\n\nfunction append(...els) {\n let newChild;\n const document = getDocument();\n\n for (let k = 0; k < els.length; k += 1) {\n newChild = els[k];\n\n for (let i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n while (tempDiv.firstChild) {\n this[i].appendChild(tempDiv.firstChild);\n }\n } else if (newChild instanceof Dom7) {\n for (let j = 0; j < newChild.length; j += 1) {\n this[i].appendChild(newChild[j]);\n }\n } else {\n this[i].appendChild(newChild);\n }\n }\n }\n\n return this;\n}\n\nfunction appendTo(parent) {\n $(parent).append(this);\n return this;\n}\n\nfunction prepend(newChild) {\n const document = getDocument();\n let i;\n let j;\n\n for (i = 0; i < this.length; i += 1) {\n if (typeof newChild === 'string') {\n const tempDiv = document.createElement('div');\n tempDiv.innerHTML = newChild;\n\n for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {\n this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);\n }\n } else if (newChild instanceof Dom7) {\n for (j = 0; j < newChild.length; j += 1) {\n this[i].insertBefore(newChild[j], this[i].childNodes[0]);\n }\n } else {\n this[i].insertBefore(newChild, this[i].childNodes[0]);\n }\n }\n\n return this;\n}\n\nfunction prependTo(parent) {\n $(parent).prepend(this);\n return this;\n}\n\nfunction insertBefore(selector) {\n const before = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (before.length === 1) {\n before[0].parentNode.insertBefore(this[i], before[0]);\n } else if (before.length > 1) {\n for (let j = 0; j < before.length; j += 1) {\n before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);\n }\n }\n }\n}\n\nfunction insertAfter(selector) {\n const after = $(selector);\n\n for (let i = 0; i < this.length; i += 1) {\n if (after.length === 1) {\n after[0].parentNode.insertBefore(this[i], after[0].nextSibling);\n } else if (after.length > 1) {\n for (let j = 0; j < after.length; j += 1) {\n after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);\n }\n }\n }\n}\n\nfunction next(selector) {\n if (this.length > 0) {\n if (selector) {\n if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {\n return $([this[0].nextElementSibling]);\n }\n\n return $([]);\n }\n\n if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction nextAll(selector) {\n const nextEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.nextElementSibling) {\n const next = el.nextElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(next).is(selector)) nextEls.push(next);\n } else nextEls.push(next);\n\n el = next;\n }\n\n return $(nextEls);\n}\n\nfunction prev(selector) {\n if (this.length > 0) {\n const el = this[0];\n\n if (selector) {\n if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {\n return $([el.previousElementSibling]);\n }\n\n return $([]);\n }\n\n if (el.previousElementSibling) return $([el.previousElementSibling]);\n return $([]);\n }\n\n return $([]);\n}\n\nfunction prevAll(selector) {\n const prevEls = [];\n let el = this[0];\n if (!el) return $([]);\n\n while (el.previousElementSibling) {\n const prev = el.previousElementSibling; // eslint-disable-line\n\n if (selector) {\n if ($(prev).is(selector)) prevEls.push(prev);\n } else prevEls.push(prev);\n\n el = prev;\n }\n\n return $(prevEls);\n}\n\nfunction siblings(selector) {\n return this.nextAll(selector).add(this.prevAll(selector));\n}\n\nfunction parent(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode !== null) {\n if (selector) {\n if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);\n } else {\n parents.push(this[i].parentNode);\n }\n }\n }\n\n return $(parents);\n}\n\nfunction parents(selector) {\n const parents = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n let parent = this[i].parentNode; // eslint-disable-line\n\n while (parent) {\n if (selector) {\n if ($(parent).is(selector)) parents.push(parent);\n } else {\n parents.push(parent);\n }\n\n parent = parent.parentNode;\n }\n }\n\n return $(parents);\n}\n\nfunction closest(selector) {\n let closest = this; // eslint-disable-line\n\n if (typeof selector === 'undefined') {\n return $([]);\n }\n\n if (!closest.is(selector)) {\n closest = closest.parents(selector).eq(0);\n }\n\n return closest;\n}\n\nfunction find(selector) {\n const foundElements = [];\n\n for (let i = 0; i < this.length; i += 1) {\n const found = this[i].querySelectorAll(selector);\n\n for (let j = 0; j < found.length; j += 1) {\n foundElements.push(found[j]);\n }\n }\n\n return $(foundElements);\n}\n\nfunction children(selector) {\n const children = []; // eslint-disable-line\n\n for (let i = 0; i < this.length; i += 1) {\n const childNodes = this[i].children;\n\n for (let j = 0; j < childNodes.length; j += 1) {\n if (!selector || $(childNodes[j]).is(selector)) {\n children.push(childNodes[j]);\n }\n }\n }\n\n return $(children);\n}\n\nfunction remove() {\n for (let i = 0; i < this.length; i += 1) {\n if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);\n }\n\n return this;\n}\n\nfunction detach() {\n return this.remove();\n}\n\nfunction add(...els) {\n const dom = this;\n let i;\n let j;\n\n for (i = 0; i < els.length; i += 1) {\n const toAdd = $(els[i]);\n\n for (j = 0; j < toAdd.length; j += 1) {\n dom.push(toAdd[j]);\n }\n }\n\n return dom;\n}\n\nfunction empty() {\n for (let i = 0; i < this.length; i += 1) {\n const el = this[i];\n\n if (el.nodeType === 1) {\n for (let j = 0; j < el.childNodes.length; j += 1) {\n if (el.childNodes[j].parentNode) {\n el.childNodes[j].parentNode.removeChild(el.childNodes[j]);\n }\n }\n\n el.textContent = '';\n }\n }\n\n return this;\n}\n\n// eslint-disable-next-line\n\nfunction scrollTo(...args) {\n const window = getWindow();\n let [left, top, duration, easing, callback] = args;\n\n if (args.length === 4 && typeof easing === 'function') {\n callback = easing;\n [left, top, duration, callback, easing] = args;\n }\n\n if (typeof easing === 'undefined') easing = 'swing';\n return this.each(function animate() {\n const el = this;\n let currentTop;\n let currentLeft;\n let maxTop;\n let maxLeft;\n let newTop;\n let newLeft;\n let scrollTop; // eslint-disable-line\n\n let scrollLeft; // eslint-disable-line\n\n let animateTop = top > 0 || top === 0;\n let animateLeft = left > 0 || left === 0;\n\n if (typeof easing === 'undefined') {\n easing = 'swing';\n }\n\n if (animateTop) {\n currentTop = el.scrollTop;\n\n if (!duration) {\n el.scrollTop = top;\n }\n }\n\n if (animateLeft) {\n currentLeft = el.scrollLeft;\n\n if (!duration) {\n el.scrollLeft = left;\n }\n }\n\n if (!duration) return;\n\n if (animateTop) {\n maxTop = el.scrollHeight - el.offsetHeight;\n newTop = Math.max(Math.min(top, maxTop), 0);\n }\n\n if (animateLeft) {\n maxLeft = el.scrollWidth - el.offsetWidth;\n newLeft = Math.max(Math.min(left, maxLeft), 0);\n }\n\n let startTime = null;\n if (animateTop && newTop === currentTop) animateTop = false;\n if (animateLeft && newLeft === currentLeft) animateLeft = false;\n\n function render(time = new Date().getTime()) {\n if (startTime === null) {\n startTime = time;\n }\n\n const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);\n const easeProgress = easing === 'linear' ? progress : 0.5 - Math.cos(progress * Math.PI) / 2;\n let done;\n if (animateTop) scrollTop = currentTop + easeProgress * (newTop - currentTop);\n if (animateLeft) scrollLeft = currentLeft + easeProgress * (newLeft - currentLeft);\n\n if (animateTop && newTop > currentTop && scrollTop >= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateTop && newTop < currentTop && scrollTop <= newTop) {\n el.scrollTop = newTop;\n done = true;\n }\n\n if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) {\n el.scrollLeft = newLeft;\n done = true;\n }\n\n if (done) {\n if (callback) callback();\n return;\n }\n\n if (animateTop) el.scrollTop = scrollTop;\n if (animateLeft) el.scrollLeft = scrollLeft;\n window.requestAnimationFrame(render);\n }\n\n window.requestAnimationFrame(render);\n });\n} // scrollTop(top, duration, easing, callback) {\n\n\nfunction scrollTop(...args) {\n let [top, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [top, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof top === 'undefined') {\n if (dom.length > 0) return dom[0].scrollTop;\n return null;\n }\n\n return dom.scrollTo(undefined, top, duration, easing, callback);\n}\n\nfunction scrollLeft(...args) {\n let [left, duration, easing, callback] = args;\n\n if (args.length === 3 && typeof easing === 'function') {\n [left, duration, callback, easing] = args;\n }\n\n const dom = this;\n\n if (typeof left === 'undefined') {\n if (dom.length > 0) return dom[0].scrollLeft;\n return null;\n }\n\n return dom.scrollTo(left, undefined, duration, easing, callback);\n}\n\n// eslint-disable-next-line\n\nfunction animate(initialProps, initialParams) {\n const window = getWindow();\n const els = this;\n const a = {\n props: Object.assign({}, initialProps),\n params: Object.assign({\n duration: 300,\n easing: 'swing' // or 'linear'\n\n /* Callbacks\n begin(elements)\n complete(elements)\n progress(elements, complete, remaining, start, tweenValue)\n */\n\n }, initialParams),\n elements: els,\n animating: false,\n que: [],\n\n easingProgress(easing, progress) {\n if (easing === 'swing') {\n return 0.5 - Math.cos(progress * Math.PI) / 2;\n }\n\n if (typeof easing === 'function') {\n return easing(progress);\n }\n\n return progress;\n },\n\n stop() {\n if (a.frameId) {\n window.cancelAnimationFrame(a.frameId);\n }\n\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n a.que = [];\n },\n\n done(complete) {\n a.animating = false;\n a.elements.each(el => {\n const element = el;\n delete element.dom7AnimateInstance;\n });\n if (complete) complete(els);\n\n if (a.que.length > 0) {\n const que = a.que.shift();\n a.animate(que[0], que[1]);\n }\n },\n\n animate(props, params) {\n if (a.animating) {\n a.que.push([props, params]);\n return a;\n }\n\n const elements = []; // Define & Cache Initials & Units\n\n a.elements.each((el, index) => {\n let initialFullValue;\n let initialValue;\n let unit;\n let finalValue;\n let finalFullValue;\n if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a;\n elements[index] = {\n container: el\n };\n Object.keys(props).forEach(prop => {\n initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.');\n initialValue = parseFloat(initialFullValue);\n unit = initialFullValue.replace(initialValue, '');\n finalValue = parseFloat(props[prop]);\n finalFullValue = props[prop] + unit;\n elements[index][prop] = {\n initialFullValue,\n initialValue,\n unit,\n finalValue,\n finalFullValue,\n currentValue: initialValue\n };\n });\n });\n let startTime = null;\n let time;\n let elementsDone = 0;\n let propsDone = 0;\n let done;\n let began = false;\n a.animating = true;\n\n function render() {\n time = new Date().getTime();\n let progress;\n let easeProgress; // let el;\n\n if (!began) {\n began = true;\n if (params.begin) params.begin(els);\n }\n\n if (startTime === null) {\n startTime = time;\n }\n\n if (params.progress) {\n // eslint-disable-next-line\n params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), startTime + params.duration - time < 0 ? 0 : startTime + params.duration - time, startTime);\n }\n\n elements.forEach(element => {\n const el = element;\n if (done || el.done) return;\n Object.keys(props).forEach(prop => {\n if (done || el.done) return;\n progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0);\n easeProgress = a.easingProgress(params.easing, progress);\n const {\n initialValue,\n finalValue,\n unit\n } = el[prop];\n el[prop].currentValue = initialValue + easeProgress * (finalValue - initialValue);\n const currentValue = el[prop].currentValue;\n\n if (finalValue > initialValue && currentValue >= finalValue || finalValue < initialValue && currentValue <= finalValue) {\n el.container.style[prop] = finalValue + unit;\n propsDone += 1;\n\n if (propsDone === Object.keys(props).length) {\n el.done = true;\n elementsDone += 1;\n }\n\n if (elementsDone === elements.length) {\n done = true;\n }\n }\n\n if (done) {\n a.done(params.complete);\n return;\n }\n\n el.container.style[prop] = currentValue + unit;\n });\n });\n if (done) return; // Then call\n\n a.frameId = window.requestAnimationFrame(render);\n }\n\n a.frameId = window.requestAnimationFrame(render);\n return a;\n }\n\n };\n\n if (a.elements.length === 0) {\n return els;\n }\n\n let animateInstance;\n\n for (let i = 0; i < a.elements.length; i += 1) {\n if (a.elements[i].dom7AnimateInstance) {\n animateInstance = a.elements[i].dom7AnimateInstance;\n } else a.elements[i].dom7AnimateInstance = a;\n }\n\n if (!animateInstance) {\n animateInstance = a;\n }\n\n if (initialProps === 'stop') {\n animateInstance.stop();\n } else {\n animateInstance.animate(a.props, a.params);\n }\n\n return els;\n}\n\nfunction stop() {\n const els = this;\n\n for (let i = 0; i < els.length; i += 1) {\n if (els[i].dom7AnimateInstance) {\n els[i].dom7AnimateInstance.stop();\n }\n }\n}\n\nconst noTrigger = 'resize scroll'.split(' ');\n\nfunction shortcut(name) {\n function eventHandler(...args) {\n if (typeof args[0] === 'undefined') {\n for (let i = 0; i < this.length; i += 1) {\n if (noTrigger.indexOf(name) < 0) {\n if (name in this[i]) this[i][name]();else {\n $(this[i]).trigger(name);\n }\n }\n }\n\n return this;\n }\n\n return this.on(name, ...args);\n }\n\n return eventHandler;\n}\n\nconst click = shortcut('click');\nconst blur = shortcut('blur');\nconst focus = shortcut('focus');\nconst focusin = shortcut('focusin');\nconst focusout = shortcut('focusout');\nconst keyup = shortcut('keyup');\nconst keydown = shortcut('keydown');\nconst keypress = shortcut('keypress');\nconst submit = shortcut('submit');\nconst change = shortcut('change');\nconst mousedown = shortcut('mousedown');\nconst mousemove = shortcut('mousemove');\nconst mouseup = shortcut('mouseup');\nconst mouseenter = shortcut('mouseenter');\nconst mouseleave = shortcut('mouseleave');\nconst mouseout = shortcut('mouseout');\nconst mouseover = shortcut('mouseover');\nconst touchstart = shortcut('touchstart');\nconst touchend = shortcut('touchend');\nconst touchmove = shortcut('touchmove');\nconst resize = shortcut('resize');\nconst scroll = shortcut('scroll');\n\nexport default $;\nexport { $, add, addClass, animate, animationEnd, append, appendTo, attr, blur, change, children, click, closest, css, data, dataset, detach, each, empty, eq, filter, find, focus, focusin, focusout, hasClass, height, hide, html, index, insertAfter, insertBefore, is, keydown, keypress, keyup, mousedown, mouseenter, mouseleave, mousemove, mouseout, mouseover, mouseup, next, nextAll, off, offset, on, once, outerHeight, outerWidth, parent, parents, prepend, prependTo, prev, prevAll, prop, remove, removeAttr, removeClass, removeData, resize, scroll, scrollLeft, scrollTo, scrollTop, show, siblings, stop, styles, submit, text, toggleClass, touchend, touchmove, touchstart, transform, transition, transitionEnd, transitionStart, trigger, val, value, width };\n","/**\n * @description DOM 操作\n * @author wangfupeng\n */\n\nimport $, {\n append, find, focus, html, is, on, parents, val,\n} from 'dom7'\n\n// COMPAT: This is required to prevent TypeScript aliases from doing some very\n// weird things for Slate's types with the same name as globals. (2019/11/27)\n// https://github.com/microsoft/TypeScript/issues/35002\nimport DOMNode = globalThis.Node\nimport DOMComment = globalThis.Comment\nimport DOMElement = globalThis.Element\nimport DOMText = globalThis.Text\nimport DOMRange = globalThis.Range\nimport DOMSelection = globalThis.Selection\nimport DOMStaticRange = globalThis.StaticRange\n\nif (append) { $.fn.append = append }\nif (html) { $.fn.html = html }\nif (val) { $.fn.val = val }\nif (on) { $.fn.on = on }\nif (focus) { $.fn.focus = focus }\nif (is) { $.fn.is = is }\nif (parents) { $.fn.parents = parents }\nif (find) { $.fn.find = find }\n\nexport { Dom7Array } from 'dom7'\nexport default $\nexport {\n DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText,\n}\n","/**\n * @description 工具函数\n * @author wangfupeng\n */\n\nimport { nanoid } from 'nanoid'\n\n/**\n * 获取随机数字符串\n * @param prefix 前缀\n * @returns 随机数字符串\n */\nexport function genRandomStr(prefix: string = 'r'): string {\n return `${prefix}-${nanoid()}`\n}\n\n// export function replaceSymbols(str: string) {\n// return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')\n// }\n","/* @ts-self-types=\"./index.d.ts\" */\nimport { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'\nexport { urlAlphabet } from './url-alphabet/index.js'\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << Math.log2(alphabet.length - 1)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step | 0\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length >= size) return id\n }\n }\n }\n}\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += scopedUrlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","export const urlAlphabet =\n 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n","/**\n * @description edit formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n SlateTransforms,\n t,\n} from '@wangeditor-next/editor'\n\nimport { PENCIL_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass EditFormulaMenu implements IModalMenu {\n readonly title = t('formula.edit')\n\n readonly iconSvg = PENCIL_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n private getSelectedElem(editor: IDomEditor): FormulaElement | null {\n const node = DomEditor.getSelectedNodeByType(editor, 'formula')\n\n if (node == null) { return null }\n return node as FormulaElement\n }\n\n /**\n * 获取公式 value\n * @param editor editor\n */\n getValue(editor: IDomEditor): string | boolean {\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem) {\n return formulaElem.value || ''\n }\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 无需 active\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n // 未匹配到 formula node 则禁用\n const formulaElem = this.getSelectedElem(editor)\n\n if (formulaElem == null) { return true }\n\n return false\n }\n\n // modal 定位\n getModalPositionNode(editor: IDomEditor): SlateNode | null {\n return this.getSelectedElem(editor)\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.updateFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n const value = this.getValue(editor)\n\n $textarea.val(value)\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private updateFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const selectedElem = this.getSelectedElem(editor)\n\n if (selectedElem == null) { return }\n\n const path = DomEditor.findPath(editor, selectedElem)\n const props: Partial<FormulaElement> = { value }\n\n SlateTransforms.setNodes(editor, props, { at: path })\n }\n}\n\nexport default EditFormulaMenu\n","/**\n * @description icon svg\n * @author wangfupeng\n */\n\n/**\n * 【注意】svg 字符串的长度 ,否则会导致代码体积过大\n * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293\n * 找不到再从 iconfont.com 搜索\n */\n\n// 公式\nexport const SIGMA_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M941.6 734.72L985.984 640H1024l-64 384H0v-74.24l331.552-391.2L0 227.008V0h980L1024 256h-34.368l-18.72-38.88C935.584 143.744 909.024 128 832 128H169.984l353.056 353.056L225.632 832H768c116 0 146.656-41.568 173.6-97.28z\"></path></svg>'\n\n// 编辑\nexport const PENCIL_SVG = '<svg viewBox=\"0 0 1024 1024\"><path d=\"M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z\"></path></svg>'\n","/**\n * @description insert formula menu\n * @author wangfupeng\n */\n\nimport {\n DomEditor,\n genModalButtonElems,\n genModalTextareaElems,\n IDomEditor,\n IModalMenu,\n SlateNode,\n SlateRange,\n t,\n} from '@wangeditor-next/editor'\n\nimport { SIGMA_SVG } from '../../constants/icon-svg'\nimport $, { Dom7Array, DOMElement } from '../../utils/dom'\nimport { genRandomStr } from '../../utils/util'\nimport { FormulaElement } from '../custom-types'\n\n/**\n * 生成唯一的 DOM ID\n */\nfunction genDomID(): string {\n return genRandomStr('w-e-insert-formula')\n}\n\nclass InsertFormulaMenu implements IModalMenu {\n readonly title = t('formula.insert')\n\n readonly iconSvg = SIGMA_SVG\n\n readonly tag = 'button'\n\n readonly showModal = true // 点击 button 时显示 modal\n\n readonly modalWidth = 300\n\n private $content: Dom7Array | null = null\n\n private readonly textareaId = genDomID()\n\n private readonly buttonId = genDomID()\n\n getValue(_editor: IDomEditor): string | boolean {\n // 插入菜单,不需要 value\n return ''\n }\n\n isActive(_editor: IDomEditor): boolean {\n // 任何时候,都不用激活 menu\n return false\n }\n\n exec(_editor: IDomEditor, _value: string | boolean) {\n // 点击菜单时,弹出 modal 之前,不需要执行其他代码\n // 此处空着即可\n }\n\n isDisabled(editor: IDomEditor): boolean {\n const { selection } = editor\n\n if (selection == null) { return true }\n if (SlateRange.isExpanded(selection)) { return true } // 选区非折叠,禁用\n\n const selectedElems = DomEditor.getSelectedElems(editor)\n\n const hasVoidElem = selectedElems.some(elem => editor.isVoid(elem))\n\n if (hasVoidElem) { return true } // 选中了 void 元素,禁用\n\n const hasPreElem = selectedElems.some(elem => DomEditor.getNodeType(elem) === 'pre')\n\n if (hasPreElem) { return true } // 选中了 pre 原则,禁用\n\n return false\n }\n\n getModalPositionNode(_editor: IDomEditor): SlateNode | null {\n return null // modal 依据选区定位\n }\n\n getModalContentElem(editor: IDomEditor): DOMElement {\n const { textareaId, buttonId } = this\n\n const [textareaContainerElem, textareaElem] = genModalTextareaElems(\n t('formula.formula'),\n textareaId,\n t('formula.placeholder'),\n )\n const $textarea = $(textareaElem)\n const [buttonContainerElem] = genModalButtonElems(buttonId, t('formula.ok'))\n\n if (this.$content == null) {\n // 第一次渲染\n const $content = $('<div></div>')\n\n // 绑定事件(第一次渲染时绑定,不要重复绑定)\n $content.on('click', `#${buttonId}`, e => {\n e.preventDefault()\n const value = $content.find(`#${textareaId}`).val().trim()\n\n this.insertFormula(editor, value)\n editor.hidePanelOrModal() // 隐藏 modal\n })\n\n // 记录属性,重要\n this.$content = $content\n }\n\n const $content = this.$content\n\n $content.html('') // 先清空内容\n\n // append textarea and button\n $content.append(textareaContainerElem)\n $content.append(buttonContainerElem)\n\n // 设置 input val\n $textarea.val('')\n\n // focus 一个 input(异步,此时 DOM 尚未渲染)\n setTimeout(() => {\n $textarea.focus()\n })\n\n return $content[0]\n }\n\n private insertFormula(editor: IDomEditor, value: string) {\n if (!value) { return }\n\n // 还原选区\n editor.restoreSelection()\n\n if (this.isDisabled(editor)) { return }\n\n const formulaElem: FormulaElement = {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 需要有一个空 text\n }\n\n editor.insertNode(formulaElem)\n }\n}\n\nexport default InsertFormulaMenu\n","/**\n * @description render elem\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor, SlateElement } from '@wangeditor-next/editor'\nimport { h, VNode } from 'snabbdom'\n\nimport { FormulaElement } from './custom-types'\n\nfunction renderFormula(elem: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode {\n // 当前节点是否选中\n const selected = DomEditor.isNodeSelected(editor, elem)\n\n // 构建 formula vnode\n const { value = '' } = elem as FormulaElement\n const formulaVnode = h(\n 'w-e-formula-card',\n {\n dataset: { value },\n },\n null,\n )\n\n // 构建容器 vnode\n const containerVnode = h(\n 'div',\n {\n className: 'w-e-textarea-formula-container',\n props: {\n contentEditable: false, // 不可编辑\n },\n style: {\n display: 'inline-block', // inline\n marginLeft: '3px',\n marginRight: '3px',\n border: selected // 选中/不选中,样式不一样\n ? '2px solid var(--w-e-textarea-selected-border-color)'\n : '2px solid transparent',\n borderRadius: '3px',\n padding: '3px 3px',\n },\n },\n [formulaVnode],\n )\n\n return containerVnode\n}\n\nconst conf = {\n type: 'formula', // 节点 type ,重要!!!\n renderElem: renderFormula,\n}\n\nexport default conf\n","/**\n * @description formula module entry\n * @author wangfupeng\n */\n\nimport './local' // 多语言\n\nimport { IModuleConf } from '@wangeditor-next/editor'\n\nimport elemToHtmlConf from './elem-to-html'\nimport { editFormulaMenuConf, insertFormulaMenuConf } from './menu/index'\nimport parseHtmlConf from './parse-elem-html'\nimport withFormula from './plugin'\nimport renderElemConf from './render-elem'\n\nconst module: Partial<IModuleConf> = {\n editorPlugin: withFormula,\n renderElems: [renderElemConf],\n elemsToHtml: [elemToHtmlConf],\n parseElemsHtml: [parseHtmlConf],\n menus: [insertFormulaMenuConf, editFormulaMenuConf],\n}\n\nexport default module\n","/**\n * @description formula plugin\n * @author wangfupeng\n */\n\nimport { DomEditor, IDomEditor } from '@wangeditor-next/editor'\n\nfunction withFormula<T extends IDomEditor>(editor: T) {\n const { isInline, isVoid } = editor\n const newEditor = editor\n\n // 重写 isInline\n newEditor.isInline = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isInline(elem)\n }\n\n // 重写 isVoid\n newEditor.isVoid = elem => {\n const type = DomEditor.getNodeType(elem)\n\n if (type === 'formula') {\n return true\n }\n\n return isVoid(elem)\n }\n\n return newEditor\n}\n\nexport default withFormula\n","/**\n * @description parse elem html\n * @author wangfupeng\n */\n\nimport { IDomEditor, SlateDescendant, SlateElement } from '@wangeditor-next/editor'\n\nimport { DOMElement } from '../utils/dom'\nimport { FormulaElement } from './custom-types'\n\nfunction parseHtml(\n elem: DOMElement,\n _children: SlateDescendant[],\n _editor: IDomEditor,\n): SlateElement {\n const value = elem.getAttribute('data-value') || ''\n\n return {\n type: 'formula',\n value,\n children: [{ text: '' }], // void node 必须有一个空白 text\n } as FormulaElement\n}\n\nconst parseHtmlConf = {\n selector: 'span[data-w-e-type=\"formula\"]',\n parseElemHtml: parseHtml,\n}\n\nexport default parseHtmlConf\n","/**\n * @description formula menu entry\n * @author wangfupeng\n */\n\nimport EditFormulaMenu from './EditFormula'\nimport InsertFormulaMenu from './InsertFormula'\n\nexport const insertFormulaMenuConf = {\n key: 'insertFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new InsertFormulaMenu()\n },\n}\n\nexport const editFormulaMenuConf = {\n key: 'editFormula', // menu key ,唯一。注册之后,可配置到工具栏\n factory() {\n return new EditFormulaMenu()\n },\n}\n"],"names":["undefined","window","Reflect","customElements","polyfillWrapFlushCallback","BuiltInHTMLElement","HTMLElement","wrapperForTheName","construct","this","constructor","prototype","Object","setPrototypeOf","WangEditorFormulaCard","_super","_this","span","__extends","defineProperty","get","attributeChangedCallback","name","oldValue","newValue","render","ensureSpan","ownerDocument","document","createElement","style","display","appendChild","value","katex","throwOnError","output","define","i18nAddResources","formula","placeholder","insert","edit","ok","conf","type","elemToHtml","elem","_childrenHtml","_a","concat","isObject","obj","extend","target","src","keys","forEach","key","length","ssrDocument","body","addEventListener","removeEventListener","activeElement","blur","nodeName","querySelector","querySelectorAll","getElementById","createEvent","initEvent","children","childNodes","setAttribute","getElementsByTagName","createElementNS","importNode","location","hash","host","hostname","href","origin","pathname","protocol","search","getDocument","doc","ssrWindow","navigator","userAgent","history","replaceState","pushState","go","back","CustomEvent","getComputedStyle","getPropertyValue","Image","Date","screen","setTimeout","clearTimeout","matchMedia","requestAnimationFrame","callback","cancelAnimationFrame","id","getWindow","win","Dom7","Array","items","super","proto","__proto__","set","makeReactive","$","selector","context","arr","html","trim","indexOf","toCreate","tempParent","innerHTML","i","push","a","res","qsa","nodeType","isArray","uniqueArray","arrayUnique","val","el","multiple","toLowerCase","values","selectedOptions","j","options","selected","on","args","eventType","targetSelector","listener","capture","handleLiveEvent","e","eventData","dom7EventData","unshift","is","apply","parents","k","handleEvent","events","split","event","dom7LiveListeners","proxyListener","dom7Listeners","compareWith","matches","webkitMatchesSelector","msMatchesSelector","append","els","newChild","tempDiv","firstChild","parent","parentNode","find","foundElements","found","fn","noTrigger","focus","trigger","genRandomStr","prefix","size","bytes","crypto","getRandomValues","Uint8Array","nanoid","genDomID","EditFormulaMenu","title","t","iconSvg","tag","showModal","modalWidth","$content","textareaId","buttonId","getSelectedElem","editor","node","DomEditor","getSelectedNodeByType","getValue","formulaElem","isActive","_editor","exec","_value","isDisabled","selection","SlateRange","isExpanded","getModalPositionNode","getModalContentElem","_b","__read","genModalTextareaElems","textareaContainerElem","$textarea","buttonContainerElem","genModalButtonElems","$content_1","preventDefault","updateFormula","hidePanelOrModal","restoreSelection","selectedElem","path","findPath","props","SlateTransforms","setNodes","at","InsertFormulaMenu","selectedElems","getSelectedElems","some","isVoid","getNodeType","insertFormula","text","insertNode","module","editorPlugin","isInline","newEditor","renderElems","renderElem","isNodeSelected","formulaVnode","h","dataset","className","contentEditable","marginLeft","marginRight","border","borderRadius","padding","elemsToHtml","elemToHtmlConf","parseElemsHtml","parseElemHtml","_children","getAttribute","menus","factory"],"mappings":"wvBAoBC,WACC,QAGqBA,IAAnBC,OAAOC,cACsBF,IAA1BC,OAAOE,iBAGPF,OAAOE,eAAeC,0BAP3B,CAWA,IAAMC,EAAqBC,YAOrBC,EAEgC,WAClC,OAAOL,QAAQM,UAAUH,EAAoB,GAA6BI,KAAKC,YACjF,EAGFT,OAAOK,YAAcC,EACrBD,YAAYK,UAAYN,EAAmBM,UAC3CL,YAAYK,UAAUD,YAAcJ,YACpCM,OAAOC,eAAeP,YAAaD,EAlBnC,CAmBD,CA9BA,GCXD,IAAAS,EAAA,SAAAC,GAQE,SAAAD,IACE,IAAAE,EAAAD,cAAON,YARDO,EAAAC,KAA2B,MASnC,CA0CF,0PApDoCC,CAAAJ,EAAAC,GAIlCH,OAAAO,eAAWL,EAAA,qBAAkB,CAA7BM,IAAA,WACE,MAAO,CAAC,aACV,kCAkBAN,EAAAH,UAAAU,yBAAA,SAAyBC,EAAcC,EAAyBC,GAC9D,GAAa,eAATF,EAAuB,CACzB,GAAIC,IAAaC,EAAY,OAC7Bf,KAAKgB,OAAOD,GAAY,GAC1B,CACF,EAEQV,EAAAH,UAAAe,WAAR,WACE,GAAIjB,KAAKQ,KAAQ,OAAOR,KAAKQ,KAE7B,IACMA,GADWR,KAAKkB,eAAiB1B,OAAO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YAFAmK,EAAUsC,YAAYzM,IAM5B+M,EAAS/M,EAClB,EAGAgN,EAAUR,OAAS,SAAAxM,GAGjB,MAAa,YAFAmK,EAAUsC,YAAYzM,IAM5BwM,EAAOxM,EAChB,EAEOgN,CACT,EDjBEC,YAAa,CDgCF,CACXnN,KAAM,UACNoN,WAzCF,SAAuBlN,EAAoByB,EAA0BwI,GAEnE,IAAM7D,EAAW+D,EAAUgD,eAAelD,EAAQjK,GAG1CE,EAAeF,EAAsBd,MACvCkO,EAAeC,EACnB,mBACA,CACEC,QAAS,CAAEpO,WAJF,IAAAgB,EAAG,OAMd,MAyBF,OArBuBmN,EACrB,MACA,CACEE,UAAW,iCACXvB,MAAO,CACLwB,iBAAiB,GAEnBzO,MAAO,CACLC,QAAS,eACTyO,WAAY,MACZC,YAAa,MACbC,OAAQvH,EACJ,sDACA,wBACJwH,aAAc,MACdC,QAAS,YAGb,CAACT,GAIL,IC7BEU,YAAa,CAACC,GACdC,eAAgB,CEKI,CACpBtJ,SAAU,gCACVuJ,cAhBF,SACEjO,EACAkO,EACA1D,GAIA,MAAO,CACL1K,KAAM,UACNZ,MAJYc,EAAKmO,aAAa,eAAiB,GAK/C1M,SAAU,CAAC,CAAEkL,KAAM,KAEvB,IFFEyB,MAAO,CGZ4B,CACnCzN,IAAK,gBACL0N,QAAO,WACL,OAAO,IAAIjC,CACb,GAGiC,CACjCzL,IAAK,cACL0N,QAAO,WACL,OAAO,IAAI/E,CACb","x_google_ignoreList":[4,5,8,9]}
@@ -7,8 +7,8 @@ declare class TableFullWidth implements IButtonMenu {
7
7
  readonly title: string;
8
8
  readonly iconSvg = "<svg viewBox=\"0 0 1228 1024\"><path d=\"M862.514337 563.200461H404.581995v121.753478a13.311987 13.311987 0 0 1-6.655993 11.468789 10.23999 10.23999 0 0 1-12.083188-1.433599l-204.799795-179.199821a13.721586 13.721586 0 0 1 0-20.479979l204.799795-179.302221a10.23999 10.23999 0 0 1 12.185588-1.535998 13.209587 13.209587 0 0 1 6.553593 11.673588v115.097485h457.932342V319.693504a11.571188 11.571188 0 0 1 18.841582-10.239989l204.799795 179.19982a13.721586 13.721586 0 0 1 0 20.47998l-204.799795 179.199821a10.23999 10.23999 0 0 1-12.185588 1.535998 13.311987 13.311987 0 0 1-6.655994-11.571188V563.200461zM136.499064 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785H15.155185A15.155185 15.155185 0 0 1 0 1008.844815V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086294a15.155185 15.155185 0 0 1 15.257585 15.155185zM1228.798771 14.951409v993.893406a15.257585 15.257585 0 0 1-15.155185 15.052785h-106.188693a15.155185 15.155185 0 0 1-15.155185-15.052785V14.951409a15.257585 15.257585 0 0 1 15.155185-15.052785h106.086293A15.155185 15.155185 0 0 1 1228.798771 15.053809z\"></path></svg>";
9
9
  readonly tag = "button";
10
- getValue(_editor: IDomEditor): string | boolean;
11
- isActive(_editor: IDomEditor): boolean;
10
+ getValue(editor: IDomEditor): string | boolean;
11
+ isActive(editor: IDomEditor): boolean;
12
12
  isDisabled(editor: IDomEditor): boolean;
13
13
  exec(editor: IDomEditor, _value: string | boolean): void;
14
14
  }
@@ -16,6 +16,17 @@ import TableHander from './TableHeader';
16
16
  import TableProperty from './TableProperty';
17
17
  export declare const insertTableMenuConf: {
18
18
  key: string;
19
+ config: {
20
+ minWidth: number;
21
+ minRowHeight: number;
22
+ tableHeader: {
23
+ selected: boolean;
24
+ };
25
+ tableFullWidth: {
26
+ selected: boolean;
27
+ };
28
+ widthExportMode: string;
29
+ };
19
30
  factory(): InsertTable;
20
31
  };
21
32
  export declare const deleteTableMenuConf: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wangeditor-next/plugin-formula",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "wangEditor next formula 公式",
5
5
  "author": "cycleccc <2991205548@qq.com>",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "@wangeditor-next-shared/rollup-config": "^0.0.2"
39
39
  },
40
40
  "peerDependencies": {
41
- "@wangeditor-next/editor": "5.7.6",
41
+ "@wangeditor-next/editor": ">=5.7.8",
42
42
  "katex": "^0.16.0",
43
43
  "snabbdom": "^3.6.0"
44
44
  },