Comparing version 0.1.5 to 0.1.6
@@ -1,5 +0,5 @@ | ||
'use strict';var e=require("lexical"),f=require("lexical/ParagraphNode"),g=require("lexical/CodeHighlightNode");function h(a,...c){c.forEach(b=>{null!=b&&"string"===typeof b&&a.classList.add(...b.split(" "))})} | ||
class k extends e.ElementNode{static getType(){return"code"}static clone(a){return new k(a.__language,a.__key)}constructor(a,c){super(c);this.__language=a}createDOM(a){const c=document.createElement("code");h(c,a.theme.code);c.setAttribute("spellcheck","false");return c}updateDOM(){return!1}insertNewAfter(a){var c=this.getChildren(),b=c.length;if(2<=b&&"\n"===c[b-1].getTextContent()&&"\n"===c[b-2].getTextContent()&&a.isCollapsed()&&a.anchor.key===this.__key&&a.anchor.offset===b)return c[b-1].remove(), | ||
c[b-2].remove(),a=f.$createParagraphNode(),this.insertAfter(a),a;c=a.anchor.getNode();var d=l(c);if(null!=d){b=0;for(d=d.getTextContent();b<d.length&&/[\t ]/.test(d[b]);)b+=1;if(0<b)return b=d.substring(0,b),b=g.$createCodeHighlightNode(b),c.insertAfter(b),a.insertNodes([e.$createLineBreakNode()]),b.select(),b}return null}canInsertTab(){return!0}collapseAtStart(){const a=f.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}setLanguage(a){this.getWritable().__language= | ||
a}getLanguage(){return this.getLatest().__language}}function l(a){let c=null;const b=a.getPreviousSiblings();for(b.push(a);0<b.length&&(a=b.pop(),g.$isCodeHighlightNode(a)&&(c=a),!e.$isLineBreakNode(a)););return c}exports.$createCodeNode=function(a){return new k(a)};exports.$isCodeNode=function(a){return a instanceof k};exports.CodeNode=k;exports.getFirstCodeHighlightNodeOfLine=l; | ||
exports.getLastCodeHighlightNodeOfLine=function(a){let c=null;const b=a.getNextSiblings();for(b.unshift(a);0<b.length&&(a=b.shift(),g.$isCodeHighlightNode(a)&&(c=a),!e.$isLineBreakNode(a)););return c}; | ||
'use strict';var d=require("lexical"),f=require("lexical/CodeHighlightNode");function g(a,...c){c.forEach(b=>{null!=b&&"string"===typeof b&&a.classList.add(...b.split(" "))})} | ||
class h extends d.ElementNode{static getType(){return"code"}static clone(a){return new h(a.__language,a.__key)}constructor(a,c){super(c);this.__language=a}createDOM(a){const c=document.createElement("code");g(c,a.theme.code);c.setAttribute("spellcheck","false");return c}updateDOM(){return!1}insertNewAfter(a){var c=this.getChildren(),b=c.length;if(2<=b&&"\n"===c[b-1].getTextContent()&&"\n"===c[b-2].getTextContent()&&a.isCollapsed()&&a.anchor.key===this.__key&&a.anchor.offset===b)return c[b-1].remove(), | ||
c[b-2].remove(),a=d.$createParagraphNode(),this.insertAfter(a),a;c=a.anchor.getNode();var e=k(c);if(null!=e){b=0;for(e=e.getTextContent();b<e.length&&/[\t ]/.test(e[b]);)b+=1;if(0<b)return b=e.substring(0,b),b=f.$createCodeHighlightNode(b),c.insertAfter(b),a.insertNodes([d.$createLineBreakNode()]),b.select(),b}return null}canInsertTab(){return!0}collapseAtStart(){const a=d.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}setLanguage(a){this.getWritable().__language= | ||
a}getLanguage(){return this.getLatest().__language}}function k(a){let c=null;const b=a.getPreviousSiblings();for(b.push(a);0<b.length&&(a=b.pop(),f.$isCodeHighlightNode(a)&&(c=a),!d.$isLineBreakNode(a)););return c}exports.$createCodeNode=function(a){return new h(a)};exports.$isCodeNode=function(a){return a instanceof h};exports.CodeNode=h;exports.getFirstCodeHighlightNodeOfLine=k; | ||
exports.getLastCodeHighlightNodeOfLine=function(a){let c=null;const b=a.getNextSiblings();for(b.unshift(a);0<b.length&&(a=b.shift(),f.$isCodeHighlightNode(a)&&(c=a),!d.$isLineBreakNode(a)););return c}; |
@@ -1,3 +0,3 @@ | ||
'use strict';var d=require("lexical"),e=require("lexical/ParagraphNode");function f(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})} | ||
class g extends d.ElementNode{static getType(){return"heading"}static clone(a){return new g(a.__tag,a.__key)}constructor(a,b){super(b);this.__tag=a}getTag(){return this.__tag}createDOM(a){const b=this.__tag,c=document.createElement(b);a=a.theme.heading;void 0!==a&&f(c,a[b]);return c}updateDOM(){return!1}insertNewAfter(){const a=e.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=> | ||
a.append(b));this.replace(a);return!0}}exports.$createHeadingNode=function(a){return new g(a)};exports.$isHeadingNode=function(a){return a instanceof g};exports.HeadingNode=g; | ||
'use strict';var d=require("lexical");function e(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})} | ||
class f extends d.ElementNode{static getType(){return"heading"}static clone(a){return new f(a.__tag,a.__key)}constructor(a,b){super(b);this.__tag=a}getTag(){return this.__tag}createDOM(a){const b=this.__tag,c=document.createElement(b);a=a.theme.heading;void 0!==a&&e(c,a[b]);return c}updateDOM(){return!1}insertNewAfter(){const a=d.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=d.$createParagraphNode();this.getChildren().forEach(b=> | ||
a.append(b));this.replace(a);return!0}}exports.$createHeadingNode=function(a){return new f(a)};exports.$isHeadingNode=function(a){return a instanceof f};exports.HeadingNode=f; |
@@ -1,8 +0,8 @@ | ||
'use strict';var f=require("lexical"),g=require("lexical/ParagraphNode"),l=require("lexical/ListNode"),m=require("lexical/ListItemNode");function n(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function p(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}function q(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})} | ||
class r extends f.ElementNode{static getType(){return"listitem"}static clone(a){return new r(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("li");b.value=t(this);u(b,a.theme,this);return b}updateDOM(a,b,c){b.value=t(this);u(b,c.theme,this);return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];if(f.$isElementNode(c)&&this.canMergeWith(c)){const d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a){if(v(a))return super.replace(a); | ||
const b=this.getParentOrThrow();if(l.$isListNode(b)){var c=b.__children;const e=c.length;var d=c.indexOf(this.__key);if(0===d)b.insertBefore(a);else if(d===e-1)b.insertAfter(a);else{c=l.$createListNode(b.__tag);const h=b.getChildren();for(d+=1;d<e;d++)c.append(h[d]);b.insertAfter(a);a.insertAfter(c)}this.remove();1===e&&b.remove()}return a}insertAfter(a){var b=this.getNextSiblings();if(v(a))return b.forEach(d=>d.markDirty()),super.insertAfter(a);var c=this.getParentOrThrow();l.$isListNode(c)||n(1); | ||
if(l.$isListNode(a)&&a.getTag()===c.getTag()){b=a;a=a.getChildren();for(c=a.length-1;0<=c;c--)b=a[c],this.insertAfter(b);return b}c.insertAfter(a);if(0!==b.length){const d=l.$createListNode(c.getTag());b.forEach(e=>d.append(e));a.insertAfter(d)}return a}insertNewAfter(){var a=this.getNextSibling(),b=this.getPreviousSibling();var c=this.getParent();l.$isListNode(c)||n(2);for(var d=c;null!==d;)d=d.getParent(),l.$isListNode(d)&&(c=d);d=!0;var e=this.getFirstChild();if(l.$isListNode(e))d=!1;else for(e= | ||
this;null!==e;)m.$isListItemNode(e)&&0<e.getNextSiblings().length&&(d=!1),e=e.getParent();if(f.$isElementNode(c)&&""===this.getTextContent()&&(null===b||null===a)&&d){null===a?(a=g.$createParagraphNode(),c.insertAfter(a)):(a=g.$createParagraphNode(),c.insertBefore(a));for(b=this;null==b.getNextSibling()&&null==b.getPreviousSibling();){c=b.getParent();if(null==c||!v(b)&&!l.$isListNode(b))break;b=c}b.remove()}else a=w(),this.insertAfter(a);return a}collapseAtStart(a){const b=g.$createParagraphNode(); | ||
this.getChildren().forEach(h=>b.append(h));var c=this.getParentOrThrow(),d=c.getParentOrThrow();const e=v(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.replace(b),c=a.anchor,a=a.focus,d=b.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}insertBefore(a){const b=this.getNextSiblings();v(a)&&b.forEach(c=>c.markDirty());return super.insertBefore(a)}canInsertAfter(a){return v(a)}canReplaceWith(a){return v(a)}canMergeWith(a){return g.$isParagraphNode(a)|| | ||
v(a)}}function t(a){var b=a.getParent();let c=1;null!=b&&(l.$isListNode(b)?c=b.__start:n(47));a=a.getPreviousSiblings();for(b=0;b<a.length;b++){const d=a[b];v(d)&&!l.$isListNode(d.getFirstChild())&&c++}return c}function u(a,b,c){const d=[],e=[],h=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var k=b.nested.listitem;void 0!==h&&(b=h.split(" "),d.push(...b));void 0!==k&&(k=k.split(" "),c.getChildren().some(x=>l.$isListNode(x))?d.push(...k):e.push(...k));0<d.length&&p(a,...d);0<e.length&&q(a,...e)} | ||
function w(){return new r}function v(a){return a instanceof r}exports.$createListItemNode=w;exports.$isListItemNode=v;exports.ListItemNode=r; | ||
'use strict';var f=require("lexical"),g=require("lexical/ListNode"),h=require("lexical/ListItemNode");function m(a){throw Error(`Minified Lexical error #${a}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}function n(a,...b){b.forEach(c=>{null!=c&&"string"===typeof c&&a.classList.add(...c.split(" "))})}function p(a,...b){b.forEach(c=>{a.classList.remove(...c.split(" "))})} | ||
class q extends f.ElementNode{static getType(){return"listitem"}static clone(a){return new q(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("li");b.value=r(this);t(b,a.theme,this);return b}updateDOM(a,b,c){b.value=r(this);t(b,c.theme,this);return!1}append(...a){for(let b=0;b<a.length;b++){const c=a[b];if(f.$isElementNode(c)&&this.canMergeWith(c)){const d=c.getChildren();this.append(...d);c.remove()}else super.append(c)}return this}replace(a){if(u(a))return super.replace(a); | ||
const b=this.getParentOrThrow();if(g.$isListNode(b)){var c=b.__children;const e=c.length;var d=c.indexOf(this.__key);if(0===d)b.insertBefore(a);else if(d===e-1)b.insertAfter(a);else{c=g.$createListNode(b.__tag);const k=b.getChildren();for(d+=1;d<e;d++)c.append(k[d]);b.insertAfter(a);a.insertAfter(c)}this.remove();1===e&&b.remove()}return a}insertAfter(a){var b=this.getNextSiblings();if(u(a))return b.forEach(d=>d.markDirty()),super.insertAfter(a);var c=this.getParentOrThrow();g.$isListNode(c)||m(1); | ||
if(g.$isListNode(a)&&a.getTag()===c.getTag()){b=a;a=a.getChildren();for(c=a.length-1;0<=c;c--)b=a[c],this.insertAfter(b);return b}c.insertAfter(a);if(0!==b.length){const d=g.$createListNode(c.getTag());b.forEach(e=>d.append(e));a.insertAfter(d)}return a}insertNewAfter(){var a=this.getNextSibling(),b=this.getPreviousSibling();var c=this.getParent();g.$isListNode(c)||m(2);for(var d=c;null!==d;)d=d.getParent(),g.$isListNode(d)&&(c=d);d=!0;var e=this.getFirstChild();if(g.$isListNode(e))d=!1;else for(e= | ||
this;null!==e;)h.$isListItemNode(e)&&0<e.getNextSiblings().length&&(d=!1),e=e.getParent();if(f.$isElementNode(c)&&""===this.getTextContent()&&(null===b||null===a)&&d){null===a?(a=f.$createParagraphNode(),c.insertAfter(a)):(a=f.$createParagraphNode(),c.insertBefore(a));for(b=this;null==b.getNextSibling()&&null==b.getPreviousSibling();){c=b.getParent();if(null==c||!u(b)&&!g.$isListNode(b))break;b=c}b.remove()}else a=v(),this.insertAfter(a);return a}collapseAtStart(a){const b=f.$createParagraphNode(); | ||
this.getChildren().forEach(k=>b.append(k));var c=this.getParentOrThrow(),d=c.getParentOrThrow();const e=u(d);1===c.getChildrenSize()?e?(c.remove(),d.select()):(c.replace(b),c=a.anchor,a=a.focus,d=b.getKey(),"element"===c.type&&c.getNode().is(this)&&c.set(d,c.offset,"element"),"element"===a.type&&a.getNode().is(this)&&a.set(d,a.offset,"element")):(c.insertBefore(b),this.remove());return!0}getIndent(){let a=this.getParentOrThrow().getParentOrThrow(),b=0;for(;u(a);)a=a.getParentOrThrow().getParentOrThrow(), | ||
b++;return b}setIndent(){return this}insertBefore(a){const b=this.getNextSiblings();u(a)&&b.forEach(c=>c.markDirty());return super.insertBefore(a)}canInsertAfter(a){return u(a)}canReplaceWith(a){return u(a)}canMergeWith(a){return f.$isParagraphNode(a)||u(a)}}function r(a){var b=a.getParent();let c=1;null!=b&&(g.$isListNode(b)?c=b.__start:m(47));a=a.getPreviousSiblings();for(b=0;b<a.length;b++){const d=a[b];u(d)&&!g.$isListNode(d.getFirstChild())&&c++}return c} | ||
function t(a,b,c){const d=[],e=[],k=(b=b.list)?b.listitem:void 0;if(b&&b.nested)var l=b.nested.listitem;void 0!==k&&(b=k.split(" "),d.push(...b));void 0!==l&&(l=l.split(" "),c.getChildren().some(w=>g.$isListNode(w))?d.push(...l):e.push(...l));0<d.length&&n(a,...d);0<e.length&&p(a,...e)}function v(){return new q}function u(a){return a instanceof q}exports.$createListItemNode=v;exports.$isListItemNode=u;exports.ListItemNode=q; |
@@ -16,3 +16,3 @@ { | ||
"license": "MIT", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"main": "Lexical.js", | ||
@@ -19,0 +19,0 @@ "repository": { |
@@ -1,3 +0,3 @@ | ||
'use strict';var c=require("lexical"),e=require("lexical/ParagraphNode");function f(a,...b){b.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})} | ||
class g extends c.ElementNode{static getType(){return"quote"}static clone(a){return new g(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("blockquote");f(b,a.theme.quote);return b}updateDOM(){return!1}insertNewAfter(){const a=e.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=e.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}}exports.$createQuoteNode=function(){return new g}; | ||
exports.$isQuoteNode=function(a){return a instanceof g};exports.QuoteNode=g; | ||
'use strict';var c=require("lexical");function d(a,...b){b.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})} | ||
class f extends c.ElementNode{static getType(){return"quote"}static clone(a){return new f(a.__key)}constructor(a){super(a)}createDOM(a){const b=document.createElement("blockquote");d(b,a.theme.quote);return b}updateDOM(){return!1}insertNewAfter(){const a=c.$createParagraphNode(),b=this.getDirection();a.setDirection(b);this.insertAfter(a);return a}collapseAtStart(){const a=c.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}}exports.$createQuoteNode=function(){return new f}; | ||
exports.$isQuoteNode=function(a){return a instanceof f};exports.QuoteNode=f; |
@@ -1,10 +0,15 @@ | ||
'use strict';var r=require("lexical");function y(a,...f){f.forEach(e=>{null!=e&&"string"===typeof e&&a.classList.add(...e.split(" "))})}const z=document.createElement("style");z.appendChild(document.createTextNode("::selection{background-color: transparent}"));function A(a){for(;null!=a;){const f=a.nodeName;if("TD"===f||"TH"===f){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null} | ||
function B(a,f,e){const q=[],l={rows:0,columns:0,cells:q};(new MutationObserver(p=>{e.update(()=>{var d=f.firstChild;let m=0,g=0;var b=!1;for(let h=0;h<p.length;h++){const t=p[h].target.nodeName;if("TABLE"===t||"TR"===t){b=!0;break}}if(b){for(q.length=0;null!=d;){b=d.nodeName;if("TD"===b||"TH"===b)b={elem:d,highlighted:!1,x:m,y:g},d._cell=b,void 0===q[g]&&(q[g]=[]),q[g][m]=b;else if(b=d.firstChild,null!=b){d=b;continue}b=d.nextSibling;if(null!=b)m++,d=b;else if(b=d.parentNode,null!=b){d=b.nextSibling; | ||
if(null==d)break;g++;m=0}}l.columns=m+1;l.rows=g+1;a.setGrid(l)}})})).observe(f,{childList:!0,subtree:!0});a.setGrid(l);return l} | ||
function C(a,f,e,q,l){const p=[];for(let d=0;d<l.length;d++){const m=l[d];for(let g=0;g<m.length;g++){const b=m[g],h=b.elem.style;g>=a&&g<=f&&d>=e&&d<=q?(b.highlighted||(b.highlighted=!0,h.setProperty("background-color","rgb(163, 187, 255)"),h.setProperty("caret-color","transparent")),p.push(b)):b.highlighted&&(b.highlighted=!1,h.removeProperty("background-color"),h.removeProperty("caret-color"))}}return p} | ||
function D(a,f,e){const q=a.getGrid();if(null!==e.getRootElement()){var l=!1,p=!1,d=-1,m=-1,g=-1,b=-1,h=[];if(null==q)throw Error("Table grid not found.");f.addEventListener("mousemove",k=>{if(l){var c=A(k.target);if(null!==c){const u=c.x;c=c.y;if(!p&&(d!==u||m!==c))k.preventDefault(),k=window.getSelection(),k.setBaseAndExtent(k.anchorNode,0,k.anchorNode,0),p=!0,document.body&&document.body.appendChild(z),null===w&&(w=e.addListener("command",(v,x)=>{if("deleteCharacter"===v){if(h.length===q.columns* | ||
q.rows)return a.selectPrevious(),a.remove(),t(),!0;h.forEach(({elem:n})=>{n=r.$getNearestNodeFromDOMNode(n);r.$isElementNode(n)&&n.clear()});return!0}if("formatText"===v)return F(x),!0;"insertText"===v&&t();return!1},1));else if(u===g&&c===b)return;g=u;b=c;if(p){const v=Math.min(d,g),x=Math.max(d,g),n=Math.min(m,b),G=Math.max(m,b);e.update(()=>{h=a.setSelectionState({fromX:v,toX:x,fromY:n,toY:G})})}}}});var t=()=>{e.update(()=>{l=p=!1;b=g=m=d=-1;e.update(()=>{a.setSelectionState(null)});h=[];null!== | ||
w&&(w(),w=null);const k=z.parentNode;null!=k&&k.removeChild(z)})};f.addEventListener("mouseleave",()=>{});var F=k=>{let c=r.$getSelection();null===c&&(c=r.$createSelection());const u=c,v=u.anchor,x=u.focus;h.forEach(n=>{n=r.$getNearestNodeFromDOMNode(n.elem);r.$isElementNode(n)&&(v.set(n.getKey(),0,"element"),x.set(n.getKey(),n.getChildrenSize(),"element"),u.formatText(k))});c.anchor.set(c.anchor.key,c.anchor.offset,c.anchor.type);c.focus.set(c.anchor.key,c.anchor.offset,c.anchor.type);r.$setSelection(c)}, | ||
w=null;f.addEventListener("mousedown",k=>{l?p&&t():setTimeout(()=>{p&&t();const c=A(k.target);null!==c&&(l=!0,d=c.x,m=c.y,document.addEventListener("mouseup",()=>{l=!1},{capture:!0,once:!0}))},0)});window.addEventListener("click",k=>{0<h.length&&!f.contains(k.target)&&e.update(()=>{a.setSelectionState(null)})})}} | ||
class E extends r.ElementNode{static getType(){return"table"}static clone(a){return new E(a.__key,a.__selectionShape,a.__grid)}constructor(a,f,e){super(a);this.__selectionShape=f;this.__grid=e}createDOM(a,f){const e=document.createElement("table");y(e,a.theme.table);B(this,e,f);D(this,e,f);return e}updateDOM(){return!1}canExtractContents(){return!1}canBeEmpty(){return!1}setSelectionState(a){this.getWritable().__selectionShape=a;return null==this.__grid?[]:a?C(a.fromX,a.toX,a.fromY,a.toY,this.__grid.cells): | ||
C(-1,-1,-1,-1,this.__grid.cells)}getSelectionState(){return this.__selectionShape}setGrid(a){this.getWritable().__grid=a}getGrid(){return this.__grid}}exports.$createTableNode=function(){return new E};exports.$isTableNode=function(a){return a instanceof E};exports.TableNode=E;exports.trackTableGrid=B; | ||
'use strict';var n=require("lexical"),y=require("lexical/TableCellNode");function A(a,...g){g.forEach(d=>{null!=d&&"string"===typeof d&&a.classList.add(...d.split(" "))})}function B(a,g){for(;a!==n.$getRoot()&&null!=a;){if(g(a))return a;a=a.getParent()}return null}const C=document.createElement("style");C.appendChild(document.createTextNode("::selection{background-color: transparent}")); | ||
function D(a){for(;null!=a;){const g=a.nodeName;if("TD"===g||"TH"===g){a=a._cell;if(void 0===a)break;return a}a=a.parentNode}return null} | ||
function E(a,g,d){const k=[],l={rows:0,columns:0,cells:k};(new MutationObserver(t=>{d.update(()=>{var h=g.firstChild;let u=0,p=0;var e=!1;for(let q=0;q<t.length;q++){const w=t[q].target.nodeName;if("TABLE"===w||"TR"===w){e=!0;break}}if(e){for(k.length=0;null!=h;){e=h.nodeName;if("TD"===e||"TH"===e)e={elem:h,highlighted:!1,x:u,y:p},h._cell=e,void 0===k[p]&&(k[p]=[]),k[p][u]=e;else if(e=h.firstChild,null!=e){h=e;continue}e=h.nextSibling;if(null!=e)u++,h=e;else if(e=h.parentNode,null!=e){h=e.nextSibling; | ||
if(null==h)break;p++;u=0}}l.columns=u+1;l.rows=p+1;a.setGrid(l)}})})).observe(g,{childList:!0,subtree:!0});a.setGrid(l);return l} | ||
function F(a,g,d,k,l){const t=[];for(let h=0;h<l.length;h++){const u=l[h];for(let p=0;p<u.length;p++){const e=u[p],q=e.elem.style;p>=a&&p<=g&&h>=d&&h<=k?(e.highlighted||(e.highlighted=!0,q.setProperty("background-color","rgb(163, 187, 255)"),q.setProperty("caret-color","transparent")),t.push(e)):e.highlighted&&(e.highlighted=!1,q.removeProperty("background-color"),q.removeProperty("caret-color"))}}return t} | ||
function H(a,g,d){if(null!==d.getRootElement()){E(a,g,d);var k=a.getGrid(),l=!1,t=!1,h=-1,u=-1,p=-1,e=-1,q=[];if(null==k)throw Error("Table grid not found.");g.addEventListener("mousemove",c=>{if(l){var b=D(c.target);if(null!==b){const f=b.x;b=b.y;if(!t&&(h!==f||u!==b))c.preventDefault(),c=window.getSelection(),c.setBaseAndExtent(c.anchorNode,0,c.anchorNode,0),t=!0,document.body&&document.body.appendChild(C),null===x&&(x=d.addListener("command",(m,v)=>{if("deleteCharacter"===m){if(q.length===k.columns* | ||
k.rows)return a.selectPrevious(),a.remove(),w(),!0;q.forEach(({elem:r})=>{r=n.$getNearestNodeFromDOMNode(r);if(n.$isElementNode(r)){r.clear();const z=n.$createParagraphNode(),J=n.$createTextNode();z.append(J);r.append(z)}});a.setSelectionState(null);n.$setSelection(null);return!0}if("formatText"===m)return K(v),!0;"insertText"===m&&w();return!1},1));else if(f===p&&b===e)return;p=f;e=b;if(t){const m=Math.min(h,p),v=Math.max(h,p),r=Math.min(u,e),z=Math.max(u,e);d.update(()=>{q=a.setSelectionState({fromX:m, | ||
toX:v,fromY:r,toY:z})})}}}});var w=()=>{d.update(()=>{l=t=!1;e=p=u=h=-1;d.update(()=>{a.setSelectionState(null)});q=[];null!==x&&(x(),x=null);const c=C.parentNode;null!=c&&c.removeChild(C)})};g.addEventListener("mouseleave",()=>{});var K=c=>{let b=n.$getSelection();null===b&&(b=n.$createSelection());const f=b,m=f.anchor,v=f.focus;q.forEach(r=>{r=n.$getNearestNodeFromDOMNode(r.elem);n.$isElementNode(r)&&(m.set(r.getKey(),0,"element"),v.set(r.getKey(),r.getChildrenSize(),"element"),f.formatText(c))}); | ||
b.anchor.set(b.anchor.key,b.anchor.offset,b.anchor.type);b.focus.set(b.anchor.key,b.anchor.offset,b.anchor.type);n.$setSelection(b)},x=null;g.addEventListener("mousedown",c=>{l?t&&w():setTimeout(()=>{t&&w();const b=D(c.target);null!==b&&(l=!0,h=b.x,u=b.y,document.addEventListener("mouseup",()=>{l=!1},{capture:!0,once:!0}))},0)});window.addEventListener("click",c=>{0<q.length&&!g.contains(c.target)&&d.update(()=>{a.setSelectionState(null)})});var G=(c,b,f)=>{let m;switch(f){case "backward":case "forward":f= | ||
"forward"===f;m=b!==(f?k.columns-1:0)?a.getCellNodeFromCords(c,b+(f?1:-1)):c!==(f?k.rows-1:0)?a.getCellNodeFromCords(c+(f?1:-1),f?0:k.columns-1):f?a.getNextSibling():a.getPreviousSibling();break;case "up":m=0!==c?a.getCellNodeFromCords(c-1,b):a.getPreviousSibling();break;case "down":m=c!==k.rows-1?a.getCellNodeFromCords(c+1,b):a.getNextSibling()}return n.$isElementNode(m)||n.$isTextNode(m)?(m.select(),!0):!1};d.addListener("command",(c,b)=>{var f=n.$getSelection();if(null==f)return!1;const m=B(f.anchor.getNode(), | ||
v=>y.$isTableCellNode(v));if(!y.$isTableCellNode(m))return!1;if("deleteCharacter"===c&&0===q.length&&f.isCollapsed()&&0===f.anchor.offset)return!0;if(("indentContent"===c||"outdentContent"===c)&&f.isCollapsed()&&0===q.length)return b=a.getCordsFromCellNode(m),G(b.x,b.y,"indentContent"===c?"forward":"backward"),!0;if(("keyArrowDown"===c||"keyArrowUp"===c)&&f.isCollapsed()&&0===q.length){const v=a.getCordsFromCellNode(m);f=B(f.anchor.getNode(),r=>n.$isElementNode(r));if("keyArrowUp"===c&&f===m.getFirstChild()|| | ||
"keyArrowDown"===c&&f===m.getLastChild())return b.preventDefault(),b.stopImmediatePropagation(),G(v.x,v.y,"keyArrowUp"===c?"up":"down"),!0}return!1},4)}} | ||
class I extends n.ElementNode{static getType(){return"table"}static clone(a){return new I(a.__key,a.__selectionShape,a.__grid)}constructor(a,g,d){super(a);this.__selectionShape=g;this.__grid=d}createDOM(a,g){const d=document.createElement("table");A(d,a.theme.table);H(this,d,g);return d}updateDOM(){return!1}canExtractContents(){return!1}canBeEmpty(){return!1}setSelectionState(a){this.getWritable().__selectionShape=a;return null==this.__grid?[]:a?F(a.fromX,a.toX,a.fromY,a.toY,this.__grid.cells):F(-1, | ||
-1,-1,-1,this.__grid.cells)}getSelectionState(){return this.__selectionShape}getCordsFromCellNode(a){if(!this.__grid)throw Error("Grid not found.");const {rows:g,cells:d}=this.__grid;for(let l=0;l<g;l++){var k=d[l];if(null==k)throw Error(`Row not found at x:${l}`);k=k.findIndex(({elem:t})=>n.$getNearestNodeFromDOMNode(t)===a);if(-1!==k)return{x:l,y:k}}throw Error("Cell not found in table.");}getCellNodeFromCords(a,g){if(!this.__grid)throw Error("Grid not found.");var {cells:d}=this.__grid;d=d[a]; | ||
if(null==d)throw Error(`Table row x:"${a}" not found.`);d=d[g];if(null==d)throw Error(`Table cell y:"${g}" in row x:"${a}" not found.`);a=n.$getNearestNodeFromDOMNode(d.elem);if(y.$isTableCellNode(a))return a;throw Error("Node at cords not TableCellNode.");}setGrid(a){this.getWritable().__grid=a}getGrid(){return this.__grid}}exports.$createTableNode=function(){return new I};exports.$isTableNode=function(a){return a instanceof I};exports.TableNode=I;exports.trackTableGrid=E; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
92525
381
14
0
16