@lexical/react
Advanced tools
Comparing version 0.1.6 to 0.1.7
'use strict';var b=require("lexical"),g=require("react"),h=require("@lexical/react/DEPRECATED_useLexicalCanShowPlaceholder"),k="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;function l(a,c){const d=h(a),f=g.useCallback(e=>{a.setRootElement(e)},[a]);k(()=>a.addListener("error",c),[a,c]);return[f,d]}function m(a){throw a;} | ||
module.exports=function(a){const c=void 0!==a&&a.onError||m,d=g.useMemo(()=>b.createEditor(a),[a]),[f,e]=l(d,c);return[d,f,e]}; | ||
module.exports=function(a){const c=void 0!==a&&a.onError||m,d=g.useMemo(()=>{if(void 0!==a){const {onError:p,...n}=a;return b.createEditor(n)}return b.createEditor(a)},[a]),[f,e]=l(d,c);return[d,f,e]}; |
@@ -1,11 +0,11 @@ | ||
'use strict';var l=require("lexical/CodeNode"),m=require("lexical/ListItemNode"),t=require("lexical"),u=require("react"),w=require("lexical/HeadingNode"),x=require("lexical/ListNode"),y=require("lexical/QuoteNode");function z(e){throw Error(`Minified Lexical error #${e}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");} | ||
const A={requiresParagraphStart:!1,nodeTransformationKind:null,regEx:/(?:)/,regExExpectedCaptureGroupCount:0},B={...A,requiresParagraphStart:!0},E=[{...A,nodeTransformationKind:"textBold",regEx:/(\*)(?:\s*\b)(?:[^\*]*)(?:\b\s*)(\*\s)$/,regExExpectedCaptureGroupCount:2}],F=[{...B,regEx:/(?:# )/,nodeTransformationKind:"paragraphH1"},{...B,regEx:/(?:## )/,nodeTransformationKind:"paragraphH2"},{...B,regEx:/(?:### )/,nodeTransformationKind:"paragraphH2"},{...B,regEx:/(?:> )/,nodeTransformationKind:"paragraphBlockQuote"}, | ||
{...B,regEx:/(?:- )/,nodeTransformationKind:"paragraphUnorderedList"},{...B,regEx:/(?:\* )/,nodeTransformationKind:"paragraphUnorderedList"},{...B,nodeTransformationKind:"paragraphOrderedList",regEx:/^(\d+)\.\s/,regExExpectedCaptureGroupCount:1},{...B,regEx:/(?:``` )/,nodeTransformationKind:"paragraphCodeBlock"},...E]; | ||
function G(e,h,b){const a={regExCaptureGroups:[],text:"",textIndex:-1,triggerState:null};e=e.match(h);if(null!==e&&0===e.index&&e.length===b+1){a.textIndex=e.index;a.text=e[0];for(b=1;b<e.length;++b)a.regExCaptureGroups.push(e[b]);return a}return null} | ||
function H(e,h){e.update(()=>{var b=t.$getSelection();if(null==b)b=null;else{var a=b.anchor.getNode();b=t.$isTextNode(a)?{node:a,offset:b.anchor.offset}:null}if(null!==b){b={textNodeWithOffset:b,trimmedParagraphText:null};a:{a=!1===h.isParentAListItemNode?F:E;var c=a.length;for(var f=0;f<c;++f){var d=a[f];if(!1===h.isCodeBlock||"paragraphCodeBlock"===d.nodeTransformationKind){var g=d,k=b;if(null!==g.requiresParagraphStart&&!0===g.requiresParagraphStart)b:{var n=k;k=n.textNodeWithOffset;if(null=== | ||
k.node.getPreviousSibling()&&(n=n.textNodeWithOffset.node.getTextContent(),g=G(n,g.regEx,g.regExExpectedCaptureGroupCount),null!=g&&0===g.textIndex&&g.textIndex+g.text.length===k.offset))break b;g=null}else{if(null==k.trimmedParagraphText){var p=k.textNodeWithOffset.node.getParentOrThrow();if(t.$isElementNode(p)){if(null==k.trimmedParagraphText){n=k;var I=k.textNodeWithOffset.node,C=k.textNodeWithOffset.offset;let r="";p=p.getChildren();const J=p.length;for(let v=0;v<J;++v){const q=p[v];if(t.$isTextNode(q)){const D= | ||
q.getTextContent();if(q.is(I)){C>D.length&&z(50,q.__key);r+=q.getTextContent().substr(0,C);break}else r+=D}else r+="\u0004"}n.trimmedParagraphText=r}G(k.trimmedParagraphText,g.regEx,g.regExExpectedCaptureGroupCount)}else z(52,p.__key)}g=null}if(null!=g){g.triggerState=h;a={autoFormatCriteria:d,matchResultContext:g};break a}}}a={autoFormatCriteria:null,matchResultContext:null}}c=a;if(null!==c.autoFormatCriteria&&null!==c.matchResultContext&&(a=c.autoFormatCriteria,c=c.matchResultContext,a.requiresParagraphStart)){f= | ||
b.textNodeWithOffset;b=f.node.getParentOrThrow();f=f.node.spliceText(0,c.text.length,"",!0);""===f.getTextContent()&&(f.selectPrevious(),f.remove());f=b.getChildren();d=null;if(null!=a.nodeTransformationKind)switch(a.nodeTransformationKind){case "paragraphH1":d=w.$createHeadingNode("h1");d.append(...f);break;case "paragraphH2":d=w.$createHeadingNode("h2");d.append(...f);break;case "paragraphH3":d=w.$createHeadingNode("h3");d.append(...f);break;case "paragraphBlockQuote":d=y.$createQuoteNode();d.append(...f); | ||
break;case "paragraphUnorderedList":d=x.$createListNode("ul");a=m.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphOrderedList":a=parseInt(1===c.regExCaptureGroups.length?c.regExCaptureGroups[0]:"1",10);d=x.$createListNode("ol",a);a=m.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphCodeBlock":d=null!=c.triggerState&&c.triggerState.isCodeBlock?t.$createParagraphNode():l.$createCodeNode(),d.append(...f)}a=d;null!==a&&b.replace(a)}}})} | ||
function K(e){let h=null;e.read(()=>{const b=t.$getSelection();if(null!=b&&b.isCollapsed()){var a=b.anchor.getNode(),c=a.getParent(),f=null!==c&&m.$isListItemNode(c);c=null!==c&&t.$isElementNode(c);h={anchorOffset:b.anchor.offset,isCodeBlock:l.$isCodeNode(a),isSelectionCollapsed:b.isCollapsed(),isSimpleText:t.$isTextNode(a)&&a.isSimpleText(),isParentAnElementNode:c,isParentAListItemNode:f,nodeKey:a.getKey(),textContent:a.getTextContent()}}});return h} | ||
function L(e){u.useEffect(()=>{let h=null;e.addListener("update",({tags:b})=>{if(!1===b.has("historic")){b=K(e.getEditorState());var a=b;var c=h;if(null==a||null==c)a=!1;else{var f=a.textContent.length,d=a.anchorOffset-1;a=!0===a.isParentAnElementNode&&a.isSimpleText&&a.isSelectionCollapsed&&a.nodeKey===c.nodeKey&&a.anchorOffset!==c.anchorOffset&&0<=d&&d+1<=f&&" "===a.textContent.substr(d,1)&&a.textContent!==c.textContent}a&&null!=b&&H(e,b);h=b}else h=null})},[e])}module.exports=function(e){L(e)}; | ||
'use strict';var l=require("lexical/CodeNode"),m=require("@lexical/list"),q=require("lexical"),u=require("react"),w=require("lexical/HeadingNode"),x=require("lexical/QuoteNode");function y(e){throw Error(`Minified Lexical error #${e}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");} | ||
const z={requiresParagraphStart:!1,nodeTransformationKind:null,regEx:/(?:)/,regExExpectedCaptureGroupCount:0},A={...z,requiresParagraphStart:!0},D=[{...z,nodeTransformationKind:"textBold",regEx:/(\*)(?:\s*\b)(?:[^\*]*)(?:\b\s*)(\*\s)$/,regExExpectedCaptureGroupCount:2}],E=[{...A,regEx:/(?:# )/,nodeTransformationKind:"paragraphH1"},{...A,regEx:/(?:## )/,nodeTransformationKind:"paragraphH2"},{...A,regEx:/(?:### )/,nodeTransformationKind:"paragraphH2"},{...A,regEx:/(?:> )/,nodeTransformationKind:"paragraphBlockQuote"}, | ||
{...A,regEx:/(?:- )/,nodeTransformationKind:"paragraphUnorderedList"},{...A,regEx:/(?:\* )/,nodeTransformationKind:"paragraphUnorderedList"},{...A,nodeTransformationKind:"paragraphOrderedList",regEx:/^(\d+)\.\s/,regExExpectedCaptureGroupCount:1},{...A,regEx:/(?:``` )/,nodeTransformationKind:"paragraphCodeBlock"},...D]; | ||
function F(e,h,b){const a={regExCaptureGroups:[],text:"",textIndex:-1,triggerState:null};e=e.match(h);if(null!==e&&0===e.index&&e.length===b+1){a.textIndex=e.index;a.text=e[0];for(b=1;b<e.length;++b)a.regExCaptureGroups.push(e[b]);return a}return null} | ||
function G(e,h){e.update(()=>{var b=q.$getSelection();if(null==b)b=null;else{var a=b.anchor.getNode();b=q.$isTextNode(a)?{node:a,offset:b.anchor.offset}:null}if(null!==b){b={textNodeWithOffset:b,trimmedParagraphText:null};a:{a=!1===h.isParentAListItemNode?E:D;var c=a.length;for(var f=0;f<c;++f){var d=a[f];if(!1===h.isCodeBlock||"paragraphCodeBlock"===d.nodeTransformationKind){var g=d,k=b;if(null!==g.requiresParagraphStart&&!0===g.requiresParagraphStart)b:{var n=k;k=n.textNodeWithOffset;if(null=== | ||
k.node.getPreviousSibling()&&(n=n.textNodeWithOffset.node.getTextContent(),g=F(n,g.regEx,g.regExExpectedCaptureGroupCount),null!=g&&0===g.textIndex&&g.textIndex+g.text.length===k.offset))break b;g=null}else{if(null==k.trimmedParagraphText){var p=k.textNodeWithOffset.node.getParentOrThrow();if(q.$isElementNode(p)){if(null==k.trimmedParagraphText){n=k;var H=k.textNodeWithOffset.node,B=k.textNodeWithOffset.offset;let t="";p=p.getChildren();const I=p.length;for(let v=0;v<I;++v){const r=p[v];if(q.$isTextNode(r)){const C= | ||
r.getTextContent();if(r.is(H)){B>C.length&&y(50,r.__key);t+=r.getTextContent().substr(0,B);break}else t+=C}else t+="\u0004"}n.trimmedParagraphText=t}F(k.trimmedParagraphText,g.regEx,g.regExExpectedCaptureGroupCount)}else y(52,p.__key)}g=null}if(null!=g){g.triggerState=h;a={autoFormatCriteria:d,matchResultContext:g};break a}}}a={autoFormatCriteria:null,matchResultContext:null}}c=a;if(null!==c.autoFormatCriteria&&null!==c.matchResultContext&&(a=c.autoFormatCriteria,c=c.matchResultContext,a.requiresParagraphStart)){f= | ||
b.textNodeWithOffset;b=f.node.getParentOrThrow();f=f.node.spliceText(0,c.text.length,"",!0);""===f.getTextContent()&&(f.selectPrevious(),f.remove());f=b.getChildren();d=null;if(null!=a.nodeTransformationKind)switch(a.nodeTransformationKind){case "paragraphH1":d=w.$createHeadingNode("h1");d.append(...f);break;case "paragraphH2":d=w.$createHeadingNode("h2");d.append(...f);break;case "paragraphH3":d=w.$createHeadingNode("h3");d.append(...f);break;case "paragraphBlockQuote":d=x.$createQuoteNode();d.append(...f); | ||
break;case "paragraphUnorderedList":d=m.$createListNode("ul");a=m.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphOrderedList":a=parseInt(1===c.regExCaptureGroups.length?c.regExCaptureGroups[0]:"1",10);d=m.$createListNode("ol",a);a=m.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphCodeBlock":d=null!=c.triggerState&&c.triggerState.isCodeBlock?q.$createParagraphNode():l.$createCodeNode(),d.append(...f)}a=d;null!==a&&b.replace(a)}}})} | ||
function J(e){let h=null;e.read(()=>{const b=q.$getSelection();if(null!=b&&b.isCollapsed()){var a=b.anchor.getNode(),c=a.getParent(),f=null!==c&&m.$isListItemNode(c);c=null!==c&&q.$isElementNode(c);h={anchorOffset:b.anchor.offset,isCodeBlock:l.$isCodeNode(a),isSelectionCollapsed:b.isCollapsed(),isSimpleText:q.$isTextNode(a)&&a.isSimpleText(),isParentAnElementNode:c,isParentAListItemNode:f,nodeKey:a.getKey(),textContent:a.getTextContent()}}});return h} | ||
function K(e){u.useEffect(()=>{let h=null;e.addListener("update",({tags:b})=>{if(!1===b.has("historic")){b=J(e.getEditorState());var a=b;var c=h;if(null==a||null==c)a=!1;else{var f=a.textContent.length,d=a.anchorOffset-1;a=!0===a.isParentAnElementNode&&a.isSimpleText&&a.isSelectionCollapsed&&a.nodeKey===c.nodeKey&&a.anchorOffset!==c.anchorOffset&&0<=d&&d+1<=f&&" "===a.textContent.substr(d,1)&&a.textContent!==c.textContent}a&&null!=b&&G(e,b);h=b}else h=null})},[e])}module.exports=function(e){K(e)}; |
@@ -1,9 +0,8 @@ | ||
'use strict';var k=require("lexical"),l=require("react"),n=require("@lexical/react/withSubscriptions");function p(a,c){for(c(a);null!==a;){if(k.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let e=null;for(;null===e&&null!==a;)e=a.getNextSibling(),a=null===e?a.getParent():e}null!==a&&(a=c(a))}}function q(){return k.$getRoot().getTextContent()} | ||
function r(a,c,e){var g=Intl.Segmenter;let d=0;var b=0;if("function"===typeof g){a=(new g).segment(a);for(var {segment:f}of a){b+=e(f);if(b>c)break;d+=f.length}}else for(f=Array.from(a),a=f.length,g=0;g<a;g++){const h=f[g];b+=e(h);if(b>c)break;d+=h.length}return d} | ||
function t(a){const c=k.$getRoot();let e=0,g=c;p(c,d=>{if(u(d)){var b=e;if(e+d.getTextContentSize()<=a){var f=d.getParent();b=d.getPreviousSibling();var h=d.getNextSibling();v(d);d=k.$getSelection();null===d||d.anchor.getNode().isAttached()&&d.focus.getNode().isAttached()||(k.$isTextNode(b)?b.select():k.$isTextNode(h)?h.select():null!==f&&f.select());return g}if(b<a&&(f=d.getFirstDescendant(),h=null!==f?f.getTextContentSize():0,b+=h,f=k.$isTextNode(f)&&f.isSimpleText(),b=b<=a,f||b))return v(d),g}else k.$isLeafNode(d)&& | ||
(b=e,e+=d.getTextContentSize(),e>a&&!u(d.getParent())&&(f=k.$getSelection(),b<a&&k.$isTextNode(d)&&d.isSimpleText()?([,b]=d.splitText(a-b),b=w(b)):b=w(d),null!==f&&k.$setSelection(f),x(b)));return g=d})} | ||
class y extends k.ElementNode{static getType(){return"overflow"}static clone(a){return new y(a.__key)}constructor(a){super(a);this.__type="overflow"}createDOM(a){const c=document.createElement("div");a=a.theme.characterLimit;"string"===typeof a&&(c.className=a);return c}updateDOM(){return!1}insertNewAfter(a){return this.getParentOrThrow().insertNewAfter(a)}excludeFromCopy(){return!0}}function z(){return new y}function u(a){return a instanceof y} | ||
function w(a){const c=z();a.insertBefore(c);c.append(a);return c}function v(a){const c=a.getChildren(),e=c.length;for(let g=0;g<e;g++)a.insertBefore(c[g]);a.remove();return 0<e?c[e-1]:null} | ||
function x(a){const c=a.getPreviousSibling();if(u(c)){var e=a.getFirstChild(),g=c.getChildren(),d=g.length;if(null===e)a.append(...g);else for(var b=0;b<d;b++)e.insertBefore(g[b]);b=k.$getSelection();if(null!==b){e=b.anchor;g=e.getNode();b=b.focus;const f=e.getNode();g.is(c)?e.set(a.getKey(),e.offset,"element"):g.is(a)&&e.set(a.getKey(),d+e.offset,"element");f.is(c)?b.set(a.getKey(),b.offset,"element"):f.is(a)&&b.set(a.getKey(),d+b.offset,"element")}c.remove()}}exports.$createOverflowNode=z; | ||
exports.OverflowNode=y;exports.isOverflowNode=u;exports.mergePrevious=x; | ||
exports.useCharacterLimit=function(a,c,e={}){const {strlen:g=b=>b.length,remainingCharacters:d=()=>{}}=e;l.useEffect(()=>a.registerNodes([y]),[a]);l.useEffect(()=>{let b=a.getEditorState().read(q),f=0;return n(a.addListener("textcontent",h=>{b=h}),a.addListener("update",({dirtyLeaves:h})=>{var m=a.isComposing();h=0<h.size;if(!m&&h){m=g(b);h=m>c||null!==f&&f>c;d(c-m);if(null===f||h){const A=r(b,c,g);a.update(()=>{k.$log("CharacterLimit");t(A)},{tag:"without-history"})}f=m}}))},[a,c,d,g])}; | ||
'use strict';var k=require("lexical"),l=require("react"),n=require("@lexical/react/withSubscriptions"),p=require("lexical/OverflowNode");function q(a,e){for(e(a);null!==a;){if(k.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let d=null;for(;null===d&&null!==a;)d=a.getNextSibling(),a=null===d?a.getParent():d}null!==a&&(a=e(a))}}function r(){return k.$getRoot().getTextContent()} | ||
function t(a,e,d){var g=Intl.Segmenter;let c=0;var b=0;if("function"===typeof g){a=(new g).segment(a);for(var {segment:f}of a){b+=d(f);if(b>e)break;c+=f.length}}else for(f=Array.from(a),a=f.length,g=0;g<a;g++){const h=f[g];b+=d(h);if(b>e)break;c+=h.length}return c} | ||
function u(a){const e=k.$getRoot();let d=0,g=e;q(e,c=>{if(p.$isOverflowNode(c)){var b=d;if(d+c.getTextContentSize()<=a){var f=c.getParent();b=c.getPreviousSibling();var h=c.getNextSibling();v(c);c=k.$getSelection();null===c||c.anchor.getNode().isAttached()&&c.focus.getNode().isAttached()||(k.$isTextNode(b)?b.select():k.$isTextNode(h)?h.select():null!==f&&f.select());return g}if(b<a&&(f=c.getFirstDescendant(),h=null!==f?f.getTextContentSize():0,b+=h,f=k.$isTextNode(f)&&f.isSimpleText(),b=b<=a,f||b))return v(c), | ||
g}else k.$isLeafNode(c)&&(b=d,d+=c.getTextContentSize(),d>a&&!p.$isOverflowNode(c.getParent())&&(f=k.$getSelection(),b<a&&k.$isTextNode(c)&&c.isSimpleText()?([,b]=c.splitText(a-b),b=w(b)):b=w(c),null!==f&&k.$setSelection(f),x(b)));return g=c})}function w(a){const e=p.$createOverflowNode();a.insertBefore(e);e.append(a);return e}function v(a){const e=a.getChildren(),d=e.length;for(let g=0;g<d;g++)a.insertBefore(e[g]);a.remove();return 0<d?e[d-1]:null} | ||
function x(a){const e=a.getPreviousSibling();if(p.$isOverflowNode(e)){var d=a.getFirstChild(),g=e.getChildren(),c=g.length;if(null===d)a.append(...g);else for(var b=0;b<c;b++)d.insertBefore(g[b]);b=k.$getSelection();if(null!==b){d=b.anchor;g=d.getNode();b=b.focus;const f=d.getNode();g.is(e)?d.set(a.getKey(),d.offset,"element"):g.is(a)&&d.set(a.getKey(),c+d.offset,"element");f.is(e)?b.set(a.getKey(),b.offset,"element"):f.is(a)&&b.set(a.getKey(),c+b.offset,"element")}e.remove()}} | ||
exports.mergePrevious=x; | ||
exports.useCharacterLimit=function(a,e,d=Object.freeze({})){const {strlen:g=b=>b.length,remainingCharacters:c=()=>{}}=d;l.useEffect(()=>{if(!a.hasNodes([p.OverflowNode]))throw Error("useCharacterLimit: OverflowNode not registered on editor");},[a]);l.useEffect(()=>{let b=a.getEditorState().read(r),f=0;return n(a.addListener("textcontent",h=>{b=h}),a.addListener("update",({dirtyLeaves:h})=>{var m=a.isComposing();h=0<h.size;if(!m&&h){m=g(b);h=m>e||null!==f&&f>e;c(e-m);if(null===f||h){const y=t(b,e, | ||
g);a.update(()=>{k.$log("CharacterLimit");u(y)},{tag:"without-history"})}f=m}}))},[a,e,c,g])}; |
@@ -1,7 +0,7 @@ | ||
'use strict';var n=require("lexical"),r=require("react"),v=require("@lexical/react/withSubscriptions");function w(a,b,e){b=Array.from(b);e=Array.from(e);a=a._nodeMap;const c=[];for(var h=0;h<b.length;h++){const f=a.get(b[h]);void 0!==f&&c.push(f)}for(b=0;b<e.length;b++)e[b][1]&&(h=a.get(e[b][0]),void 0===h||n.$isRootNode(h)||c.push(h));return c} | ||
function x(a,b,e,c,h){if(null===a||0===e.size&&0===c.size)return 0;var f=b._selection,d=a._selection;if(h)return 1;if(null===f||null===d||!d.isCollapsed()||!f.isCollapsed())return 0;e=w(b,e,c);if(0===e.length)return 0;if(1<e.length){b=b._nodeMap;d=b.get(d.anchor.key);const g=b.get(f.anchor.key);return n.$isTextNode(g)&&n.$isElementNode(d)&&!a._nodeMap.has(g.__key)&&1===g.__text.length&&1===f.anchor.offset?e.every(k=>k===g||!n.$isTextNode(k))?2:0:0}b=e[0];a=a._nodeMap.get(b.__key);if(!n.$isTextNode(a)|| | ||
!n.$isTextNode(b)||a.__mode!==b.__mode)return 0;a=a.__text;b=b.__text;if(a===b)return 0;f=f.anchor;d=d.anchor;if(f.key!==d.key||"text"!==f.type)return 0;f=f.offset;d=d.offset;a=b.length-a.length;return 1===a&&d===f-1?2:-1===a&&d===f+1?3:-1===a&&d===f?4:0} | ||
function y(a,b){let e=Date.now(),c=0;return(h,f,d,g,k,m)=>{const p=Date.now();if(m.has("historic"))return c=0,e=p,2;const l=x(h,f,g,k,a.isComposing()),u=(()=>{if(m.has("without-history"))return 0;if(null===h)return 1;var q=f._selection;const t=h._selection;if(!(0<g.size||0<k.size))return null===t&&null!==q?0:2;q=null===d||d.editor===a;return 0!==l&&l===c&&p<e+b&&q?0:1})();e=p;c=l;return u}} | ||
function z(a,b,e=1E3){const c=r.useMemo(()=>b||A(),[b]),h=r.useCallback(()=>{c.undoStack=[];c.redoStack=[];c.current=null},[c]);r.useEffect(()=>{const f=y(a,e);return v(a.addListener("command",d=>{switch(d){case "undo":d=c.redoStack;var g=c.undoStack;if(0!==g.length){var k=c.current;const m=g.pop();null!==k&&(d.push(k),a.execCommand("canRedo",!0));0===g.length&&a.execCommand("canUndo",!1);c.current=m;m.editor.setEditorState(m.editorState.clone(m.undoSelection),{tag:"historic"})}return!0;case "redo":return d= | ||
c.redoStack,g=c.undoStack,0!==d.length&&(k=c.current,null!==k&&(g.push(k),a.execCommand("canUndo",!0)),g=d.pop(),0===d.length&&a.execCommand("canRedo",!1),c.current=g,g.editor.setEditorState(g.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),a.addListener("update",({editorState:d,prevEditorState:g,dirtyLeaves:k,dirtyElements:m,tags:p})=>{const l=c.current,u=c.redoStack,q=c.undoStack,t=null===l?null:l.editorState;if(null===l|| | ||
d!==t){k=f(g,d,l,k,m,p);if(1===k)0!==u.length&&(c.redoStack=[]),null!==l&&(q.push({...l,undoSelection:g.read(n.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;c.current={editor:a,editorState:d}}}))},[h,e,a,c])}function A(){return{current:null,redoStack:[],undoStack:[]}}exports.createEmptyHistoryState=A;exports.useLexicalHistory=function(a,b,e=1E3){return z(a,b,e)}; | ||
'use strict';var n=require("lexical"),r=require("react"),v=require("@lexical/react/withSubscriptions"); | ||
function w(b,d,k,a,h){if(null===b||0===k.size&&0===a.size)return 0;var g=d._selection,c=b._selection;if(h)return 1;if(null===g||null===c||!c.isCollapsed()||!g.isCollapsed())return 0;var e=Array.from(k);a=Array.from(a);k=d._nodeMap;h=[];for(var f=0;f<e.length;f++){const l=k.get(e[f]);void 0!==l&&h.push(l)}for(e=0;e<a.length;e++)a[e][1]&&(f=k.get(a[e][0]),void 0===f||n.$isRootNode(f)||h.push(f));if(0===h.length)return 0;if(1<h.length)return a=d._nodeMap,d=a.get(g.anchor.key),c=a.get(c.anchor.key),d&& | ||
c&&!b._nodeMap.has(d.__key)&&n.$isTextNode(d)&&1===d.__text.length&&1===g.anchor.offset?2:0;d=h[0];b=b._nodeMap.get(d.__key);if(!n.$isTextNode(b)||!n.$isTextNode(d)||b.__mode!==d.__mode)return 0;b=b.__text;d=d.__text;if(b===d)return 0;g=g.anchor;c=c.anchor;if(g.key!==c.key||"text"!==g.type)return 0;g=g.offset;c=c.offset;b=d.length-b.length;return 1===b&&c===g-1?2:-1===b&&c===g+1?3:-1===b&&c===g?4:0} | ||
function x(b,d){let k=Date.now(),a=0;return(h,g,c,e,f,l)=>{const p=Date.now();if(l.has("historic"))return a=0,k=p,2;const m=w(h,g,e,f,b.isComposing()),u=(()=>{if(l.has("without-history"))return 0;if(null===h)return 1;var q=g._selection;const t=h._selection;if(!(0<e.size||0<f.size))return null===t&&null!==q?0:2;q=null===c||c.editor===b;return 0!==m&&m===a&&p<k+d&&q?0:1})();k=p;a=m;return u}} | ||
function y(b,d,k=1E3){const a=r.useMemo(()=>d||z(),[d]),h=r.useCallback(()=>{a.undoStack=[];a.redoStack=[];a.current=null},[a]);r.useEffect(()=>{const g=x(b,k);return v(b.addListener("command",c=>{switch(c){case "undo":c=a.redoStack;var e=a.undoStack;if(0!==e.length){var f=a.current;const l=e.pop();null!==f&&(c.push(f),b.execCommand("canRedo",!0));0===e.length&&b.execCommand("canUndo",!1);a.current=l;l.editor.setEditorState(l.editorState.clone(l.undoSelection),{tag:"historic"})}return!0;case "redo":return c= | ||
a.redoStack,e=a.undoStack,0!==c.length&&(f=a.current,null!==f&&(e.push(f),b.execCommand("canUndo",!0)),e=c.pop(),0===c.length&&b.execCommand("canRedo",!1),a.current=e,e.editor.setEditorState(e.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),b.addListener("update",({editorState:c,prevEditorState:e,dirtyLeaves:f,dirtyElements:l,tags:p})=>{const m=a.current,u=a.redoStack,q=a.undoStack,t=null===m?null:m.editorState;if(null===m|| | ||
c!==t){f=g(e,c,m,f,l,p);if(1===f)0!==u.length&&(a.redoStack=[]),null!==m&&(q.push({...m,undoSelection:e.read(n.$getSelection)}),b.execCommand("canUndo",!0));else if(2===f)return;a.current={editor:b,editorState:c}}}))},[h,k,b,a])}function z(){return{current:null,redoStack:[],undoStack:[]}}exports.createEmptyHistoryState=z;exports.useLexicalHistory=function(b,d,k=1E3){return y(b,d,k)}; |
@@ -1,12 +0,1 @@ | ||
'use strict';var g=require("react"),l=require("lexical"),m=require("lexical/ListItemNode"),p=require("lexical/ListNode");function q(d){d=d.getParent();if(!p.$isListNode(d))throw Error("Minified Lexical error #2; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let a=d;for(;null!==a;)a=a.getParent(),p.$isListNode(a)&&(d=a);return d} | ||
function r(d){let a=[];d=d.getChildren().filter(m.$isListItemNode);for(let b=0;b<d.length;b++){const c=d[b],e=c.getFirstChild();p.$isListNode(e)?a=a.concat(r(e)):a.push(c)}return a}function t(d,a){for(;null!=d&&!(d instanceof a);)d=d.getParent();return d} | ||
function u(d){d.update(()=>{l.$log("removeList");var a=l.$getSelection();if(null!==a){const c=new Set,e=a.getNodes();a=a.anchor.getNode();if(0===e.length&&m.$isListItemNode(a))c.add(q(a));else for(a=0;a<e.length;a++){var b=e[a];l.$isLeafNode(b)&&(b=t(b,m.ListItemNode),null!=b&&c.add(q(b)))}c.forEach(f=>{let h=f;r(f).forEach(k=>{if(null!=k){const n=l.$createParagraphNode();n.append(...k.getChildren());h.insertAfter(n);h=n;k.remove()}});f.remove()})}})} | ||
function v(d,a){if(p.$isListNode(d))return d;const b=d.getPreviousSibling(),c=d.getNextSibling(),e=m.$createListItemNode();if(p.$isListNode(b)&&a===b.getTag())return e.append(d),b.append(e),p.$isListNode(c)&&a===c.getTag()&&(b.append(...c.getChildren()),c.remove()),b;if(p.$isListNode(c)&&a===c.getTag())return e.append(d),c.getFirstChildOrThrow().insertBefore(e),c;a=p.$createListNode(a);a.append(e);d.replace(a);e.append(d);return a} | ||
function w(d,a){d.update(()=>{l.$log("formatList");var b=l.$getSelection();if(null!==b){var c=b.getNodes();b=b.anchor.getNode();var e=b.getParent();if(0===c.length)c=p.$createListNode(a),l.$isRootNode(e)?(b.replace(c),b=m.$createListItemNode(),c.append(b)):m.$isListItemNode(b)&&(b=b.getParentOrThrow(),c.append(...b.getChildren()),b.replace(c));else for(b=new Set,e=0;e<c.length;e++){var f=c[e];if(l.$isElementNode(f)&&f.isEmpty()&&!b.has(f.getKey()))v(f,a);else if(l.$isLeafNode(f))for(f=f.getParent();null!= | ||
f;){const k=f.getKey();if(p.$isListNode(f)){if(!b.has(k)){var h=p.$createListNode(a);h.append(...f.getChildren());f.replace(h);b.add(k)}break}else{h=f.getParent();if(l.$isRootNode(h)&&!b.has(k)){b.add(k);v(f,a);break}f=h}}}}})} | ||
function x(d){var a=l.$getSelection();if(null===a)return!1;var b=a.getNodes(),c=[];0===b.length&&b.push(a.anchor.getNode());if(1===b.length){a:{for(b=b[0];null!==b;){if(m.$isListItemNode(b))break a;b=b.getParent()}b=null}null!==b&&(c=[b])}else{c=new Set;for(a=0;a<b.length;a++){const e=b[a];m.$isListItemNode(e)&&c.add(e)}c=Array.from(c)}return 0<c.length?("indent"===d?y(c):z(c),!0):!1}function A(d){return m.$isListItemNode(d)&&p.$isListNode(d.getFirstChild())} | ||
function y(d){d.forEach(a=>{if(!A(a)){var b=a.getParent(),c=a.getNextSibling(),e=a.getPreviousSibling();if(A(c)&&A(e))e=e.getFirstChild(),p.$isListNode(e)&&(e.append(a),a=c.getFirstChild(),p.$isListNode(a)&&(c=a.getChildren(),e.append(...c),a.remove()),e.getChildren().forEach(f=>f.markDirty()));else if(A(c))c=c.getFirstChild(),p.$isListNode(c)&&(e=c.getFirstChild(),null!==e&&e.insertBefore(a),c.getChildren().forEach(f=>f.markDirty()));else if(A(e))c=e.getFirstChild(),p.$isListNode(c)&&(c.append(a), | ||
c.getChildren().forEach(f=>f.markDirty()));else if(p.$isListNode(b)){const f=m.$createListItemNode(),h=p.$createListNode(b.getTag());f.append(h);h.append(a);e?e.insertAfter(f):c?c.insertBefore(f):b.append(f)}p.$isListNode(b)&&b.getChildren().forEach(f=>f.markDirty())}})} | ||
function z(d){d.forEach(a=>{if(!A(a)){var b=a.getParent(),c=b?b.getParent():void 0,e=c?c.getParent():void 0;if(p.$isListNode(e)&&m.$isListItemNode(c)&&p.$isListNode(b)){var f=b?b.getFirstChild():void 0,h=b?b.getLastChild():void 0;if(a.is(f))c.insertBefore(a),b.isEmpty()&&c.remove();else if(a.is(h))c.insertAfter(a),b.isEmpty()&&c.remove();else{var k=b.getTag();f=m.$createListItemNode();const n=p.$createListNode(k);f.append(n);a.getPreviousSiblings().forEach(B=>n.append(B));h=m.$createListItemNode(); | ||
k=p.$createListNode(k);h.append(k);k.append(...a.getNextSiblings());c.insertBefore(f);c.insertAfter(h);c.replace(a)}b.getChildren().forEach(n=>n.markDirty());e.getChildren().forEach(n=>n.markDirty())}}})} | ||
function C(d){g.useEffect(()=>d.addListener("command",a=>{if("indentContent"===a){if(x("indent"))return!0}else if("outdentContent"===a){if(x("outdent"))return!0}else{if("insertOrderedList"===a)return w(d,"ol"),!0;if("insertUnorderedList"===a)return w(d,"ul"),!0;if("removeList"===a)return u(d),!0}return!1},1),[d])}module.exports=function(d){C(d)}; | ||
'use strict';var b=require("react"),d=require("@lexical/list");function e(a){b.useEffect(()=>a.addListener("command",c=>{if("indentContent"===c){if(d.indentList())return!0}else if("outdentContent"===c){if(d.outdentList())return!0}else{if("insertOrderedList"===c)return d.insertList(a,"ol"),!0;if("insertUnorderedList"===c)return d.insertList(a,"ul"),!0;if("removeList"===c)return d.removeList(a),!0}return!1},1),[a])}module.exports=function(a){e(a)}; |
@@ -1,17 +0,16 @@ | ||
'use strict';var h=require("lexical"),u=require("react"),v=require("@lexical/react/withSubscriptions"); | ||
function w(a){u.useEffect(()=>{const b=e=>{var d=a.getRootElement();if(document.activeElement===d&&(d=e.data,"string"===typeof d)){try{var c=JSON.parse(d)}catch(f){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [f,g,k,l,r]=c;a.update(()=>{h.$log("useLexicalDragonSupport");const t=h.$getSelection();if(null!==t){var m=t.anchor;let p=m.getNode(),n=0,q=0;h.$isTextNode(p)&&0<=f&&0<=g&&(n=f,q=f+g,t.setTextNodeRange(p,n,p, | ||
q));if(n!==q||""!==k)t.insertRawText(k),p=m.getNode();h.$isTextNode(p)&&(n=l,q=l+r,m=p.getTextContentSize(),n=n>m?m:n,q=q>m?m:q,t.setTextNodeRange(p,n,p,q));e.stopImmediatePropagation()}})}}};window.addEventListener("message",b,!0);return()=>{window.removeEventListener("message",b,!0)}},[a])}function x(a,b){a=a.getData("text/plain");null!=a&&b.insertRawText(a)} | ||
function y(a,b){var e=a.focus;a=e.offset;"element"===e.type?b=e.getNode().getChildAtIndex(b?a-1:a):(e=e.getNode(),b=b&&0===a||!b&&a===e.getTextContentSize()?b?e.getPreviousSibling():e.getNextSibling():null);return h.$isDecoratorNode(b)}function z(a,b){a.preventDefault();b.update(()=>{h.$log("onPasteForPlainText");const e=h.$getSelection(),d=a.clipboardData;null!=d&&null!==e&&x(d,e)})} | ||
function A(a,b){B(a,b);b.update(()=>{h.$log("onCutForPlainText");const e=h.$getSelection();null!==e&&e.removeText()})}function B(a,b){a.preventDefault();b.update(()=>{h.$log("onCopyForPlainText");const e=a.clipboardData,d=h.$getSelection();if(null!==d&&null!=e){var c=window.getSelection();if(!c.isCollapsed){var f=c.getRangeAt(0);f&&(c=document.createElement("div"),f=f.cloneContents(),c.appendChild(f),e.setData("text/html",c.innerHTML));e.setData("text/plain",d.getTextContent())}}})} | ||
var C="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?u.useLayoutEffect:u.useEffect;function D(a,b){const e=h.$createParagraphNode();a.append(e);a=document.activeElement;(null!==h.$getSelection()||null!==a&&a===b.getRootElement())&&e.select()}function E(a){a.update(()=>{h.$log("initEditor");const b=h.$getRoot();null===b.getFirstChild()&&D(b,a)})} | ||
function F(a,b){a.update(()=>{h.$log("clearEditor");const e=h.$getRoot();e.clear();D(e,a)},{onUpdate:b})} | ||
function G(a,b){C(()=>{const e=v(a.addListener("command",(d,c)=>{const f=h.$getSelection();if(null===f)return!1;switch(d){case "deleteCharacter":return f.deleteCharacter(c),!0;case "deleteWord":return f.deleteWord(c),!0;case "deleteLine":return f.deleteLine(c),!0;case "insertText":return"string"===typeof c?f.insertText(c):(d=c.dataTransfer,null!=d?x(d,f):(c=c.data)&&f.insertText(c)),!0;case "removeText":return f.removeText(),!0;case "insertLineBreak":return f.insertLineBreak(c),!0;case "insertParagraph":return f.insertLineBreak(), | ||
!0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":d=c.shiftKey;if(y(f,!0))return c.preventDefault(),c=d,d="rtl"===f.anchor.getNode().getParentOrThrow().getDirection(),f.modify(c?"extend":"move",!d,"character"),!0;break;case "keyArrowRight":d=c.shiftKey;if(y(f,!1))return c.preventDefault(),c=d,d="rtl"===f.anchor.getNode().getParentOrThrow().getDirection(),f.modify(c?"extend": | ||
"move",d,"character"),!0;break;case "keyBackspace":return c.preventDefault(),a.execCommand("deleteCharacter",!0);case "keyDelete":return c.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return c.preventDefault(),a.execCommand("insertLineBreak");case "clearEditor":F(a);break;case "copy":return B(c,a),!0;case "cut":return A(c,a),!0;case "paste":return z(c,a),!0;case "drop":case "dragstart":return c.preventDefault(),!0}return!1},0));b&&E(a);return e},[a,b]);w(a)} | ||
function H(a,b,e){b=Array.from(b);e=Array.from(e);a=a._nodeMap;const d=[];for(var c=0;c<b.length;c++){const f=a.get(b[c]);void 0!==f&&d.push(f)}for(b=0;b<e.length;b++)e[b][1]&&(c=a.get(e[b][0]),void 0===c||h.$isRootNode(c)||d.push(c));return d} | ||
function I(a,b,e,d,c){if(null===a||0===e.size&&0===d.size)return 0;var f=b._selection,g=a._selection;if(c)return 1;if(null===f||null===g||!g.isCollapsed()||!f.isCollapsed())return 0;e=H(b,e,d);if(0===e.length)return 0;if(1<e.length){b=b._nodeMap;g=b.get(g.anchor.key);const k=b.get(f.anchor.key);return h.$isTextNode(k)&&h.$isElementNode(g)&&!a._nodeMap.has(k.__key)&&1===k.__text.length&&1===f.anchor.offset?e.every(l=>l===k||!h.$isTextNode(l))?2:0:0}b=e[0];a=a._nodeMap.get(b.__key);if(!h.$isTextNode(a)|| | ||
!h.$isTextNode(b)||a.__mode!==b.__mode)return 0;a=a.__text;b=b.__text;if(a===b)return 0;f=f.anchor;g=g.anchor;if(f.key!==g.key||"text"!==f.type)return 0;f=f.offset;g=g.offset;a=b.length-a.length;return 1===a&&g===f-1?2:-1===a&&g===f+1?3:-1===a&&g===f?4:0} | ||
function J(a,b){let e=Date.now(),d=0;return(c,f,g,k,l,r)=>{const t=Date.now();if(r.has("historic"))return d=0,e=t,2;const m=I(c,f,k,l,a.isComposing()),p=(()=>{if(r.has("without-history"))return 0;if(null===c)return 1;var n=f._selection;const q=c._selection;if(!(0<k.size||0<l.size))return null===q&&null!==n?0:2;n=null===g||g.editor===a;return 0!==m&&m===d&&t<e+b&&n?0:1})();e=t;d=m;return p}} | ||
function K(a,b,e=1E3){const d=u.useMemo(()=>b||{current:null,redoStack:[],undoStack:[]},[b]),c=u.useCallback(()=>{d.undoStack=[];d.redoStack=[];d.current=null},[d]);u.useEffect(()=>{const f=J(a,e);return v(a.addListener("command",g=>{switch(g){case "undo":g=d.redoStack;var k=d.undoStack;if(0!==k.length){var l=d.current;const r=k.pop();null!==l&&(g.push(l),a.execCommand("canRedo",!0));0===k.length&&a.execCommand("canUndo",!1);d.current=r;r.editor.setEditorState(r.editorState.clone(r.undoSelection), | ||
{tag:"historic"})}return!0;case "redo":return g=d.redoStack,k=d.undoStack,0!==g.length&&(l=d.current,null!==l&&(k.push(l),a.execCommand("canUndo",!0)),k=g.pop(),0===g.length&&a.execCommand("canRedo",!1),d.current=k,k.editor.setEditorState(k.editorState,{tag:"historic"})),!0;case "clearEditor":return c(),!1;case "clearHistory":return c(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:k,dirtyLeaves:l,dirtyElements:r,tags:t})=>{const m=d.current,p=d.redoStack,n=d.undoStack, | ||
q=null===m?null:m.editorState;if(null===m||g!==q){l=f(k,g,m,l,r,t);if(1===l)0!==p.length&&(d.redoStack=[]),null!==m&&(n.push({...m,undoSelection:k.read(h.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;d.current={editor:a,editorState:g}}}))},[c,e,a,d])}function L(a,b,e=1E3){return K(a,b,e)}module.exports=function(a,b){G(a,!0);L(a,b)}; | ||
'use strict';var l=require("lexical"),u=require("react"),v=require("@lexical/react/withSubscriptions"); | ||
function w(a){u.useEffect(()=>{const d=f=>{var c=a.getRootElement();if(document.activeElement===c&&(c=f.data,"string"===typeof c)){try{var b=JSON.parse(c)}catch(e){return}if(b&&"nuanria_messaging"===b.protocol&&"request"===b.type&&(b=b.payload)&&"makeChanges"===b.functionId&&(b=b.args)){const [e,g,h,k,n]=b;a.update(()=>{l.$log("useLexicalDragonSupport");const t=l.$getSelection();if(null!==t){var m=t.anchor;let q=m.getNode(),p=0,r=0;l.$isTextNode(q)&&0<=e&&0<=g&&(p=e,r=e+g,t.setTextNodeRange(q,p,q, | ||
r));if(p!==r||""!==h)t.insertRawText(h),q=m.getNode();l.$isTextNode(q)&&(p=k,r=k+n,m=q.getTextContentSize(),p=p>m?m:p,r=r>m?m:r,t.setTextNodeRange(q,p,q,r));f.stopImmediatePropagation()}})}}};window.addEventListener("message",d,!0);return()=>{window.removeEventListener("message",d,!0)}},[a])}function x(a,d){a=a.getData("text/plain");null!=a&&d.insertRawText(a)} | ||
function y(a,d){var f=a.focus;a=f.offset;"element"===f.type?d=f.getNode().getChildAtIndex(d?a-1:a):(f=f.getNode(),d=d&&0===a||!d&&a===f.getTextContentSize()?d?f.getPreviousSibling():f.getNextSibling():null);return l.$isDecoratorNode(d)}function z(a,d){a.preventDefault();d.update(()=>{l.$log("onPasteForPlainText");const f=l.$getSelection(),c=a.clipboardData;null!=c&&null!==f&&x(c,f)})} | ||
function A(a,d){B(a,d);d.update(()=>{l.$log("onCutForPlainText");const f=l.$getSelection();null!==f&&f.removeText()})}function B(a,d){a.preventDefault();d.update(()=>{l.$log("onCopyForPlainText");const f=a.clipboardData,c=l.$getSelection();if(null!==c&&null!=f){var b=window.getSelection();if(!b.isCollapsed){var e=b.getRangeAt(0);e&&(b=document.createElement("div"),e=e.cloneContents(),b.appendChild(e),f.setData("text/html",b.innerHTML));f.setData("text/plain",c.getTextContent())}}})} | ||
var C="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?u.useLayoutEffect:u.useEffect;function D(a,d){const f=l.$createParagraphNode();a.append(f);a=document.activeElement;(null!==l.$getSelection()||null!==a&&a===d.getRootElement())&&f.select()}function E(a){a.update(()=>{l.$log("initEditor");const d=l.$getRoot();null===d.getFirstChild()&&D(d,a)})} | ||
function F(a,d){a.update(()=>{l.$log("clearEditor");const f=l.$getRoot();f.clear();D(f,a)},{onUpdate:d})} | ||
function G(a,d){C(()=>{const f=v(a.addListener("command",(c,b)=>{const e=l.$getSelection();if(null===e)return!1;switch(c){case "deleteCharacter":return e.deleteCharacter(b),!0;case "deleteWord":return e.deleteWord(b),!0;case "deleteLine":return e.deleteLine(b),!0;case "insertText":return"string"===typeof b?e.insertText(b):(c=b.dataTransfer,null!=c?x(c,e):(b=b.data)&&e.insertText(b)),!0;case "removeText":return e.removeText(),!0;case "insertLineBreak":return e.insertLineBreak(b),!0;case "insertParagraph":return e.insertLineBreak(), | ||
!0;case "indentContent":case "outdentContent":case "insertHorizontalRule":case "insertImage":case "insertTable":case "formatElement":case "formatText":return!0;case "keyArrowLeft":c=b.shiftKey;if(y(e,!0))return b.preventDefault(),b=c,c="rtl"===e.anchor.getNode().getParentOrThrow().getDirection(),e.modify(b?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=b.shiftKey;if(y(e,!1))return b.preventDefault(),b=c,c="rtl"===e.anchor.getNode().getParentOrThrow().getDirection(),e.modify(b?"extend": | ||
"move",c,"character"),!0;break;case "keyBackspace":return b.preventDefault(),a.execCommand("deleteCharacter",!0);case "keyDelete":return b.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return b.preventDefault(),a.execCommand("insertLineBreak");case "clearEditor":F(a);break;case "copy":return B(b,a),!0;case "cut":return A(b,a),!0;case "paste":return z(b,a),!0;case "drop":case "dragstart":return b.preventDefault(),!0}return!1},0));d&&E(a);return f},[a,d]);w(a)} | ||
function H(a,d,f,c,b){if(null===a||0===f.size&&0===c.size)return 0;var e=d._selection,g=a._selection;if(b)return 1;if(null===e||null===g||!g.isCollapsed()||!e.isCollapsed())return 0;var h=Array.from(f);c=Array.from(c);f=d._nodeMap;b=[];for(var k=0;k<h.length;k++){const n=f.get(h[k]);void 0!==n&&b.push(n)}for(h=0;h<c.length;h++)c[h][1]&&(k=f.get(c[h][0]),void 0===k||l.$isRootNode(k)||b.push(k));if(0===b.length)return 0;if(1<b.length)return c=d._nodeMap,d=c.get(e.anchor.key),g=c.get(g.anchor.key),d&& | ||
g&&!a._nodeMap.has(d.__key)&&l.$isTextNode(d)&&1===d.__text.length&&1===e.anchor.offset?2:0;d=b[0];a=a._nodeMap.get(d.__key);if(!l.$isTextNode(a)||!l.$isTextNode(d)||a.__mode!==d.__mode)return 0;a=a.__text;d=d.__text;if(a===d)return 0;e=e.anchor;g=g.anchor;if(e.key!==g.key||"text"!==e.type)return 0;e=e.offset;g=g.offset;a=d.length-a.length;return 1===a&&g===e-1?2:-1===a&&g===e+1?3:-1===a&&g===e?4:0} | ||
function I(a,d){let f=Date.now(),c=0;return(b,e,g,h,k,n)=>{const t=Date.now();if(n.has("historic"))return c=0,f=t,2;const m=H(b,e,h,k,a.isComposing()),q=(()=>{if(n.has("without-history"))return 0;if(null===b)return 1;var p=e._selection;const r=b._selection;if(!(0<h.size||0<k.size))return null===r&&null!==p?0:2;p=null===g||g.editor===a;return 0!==m&&m===c&&t<f+d&&p?0:1})();f=t;c=m;return q}} | ||
function J(a,d,f=1E3){const c=u.useMemo(()=>d||{current:null,redoStack:[],undoStack:[]},[d]),b=u.useCallback(()=>{c.undoStack=[];c.redoStack=[];c.current=null},[c]);u.useEffect(()=>{const e=I(a,f);return v(a.addListener("command",g=>{switch(g){case "undo":g=c.redoStack;var h=c.undoStack;if(0!==h.length){var k=c.current;const n=h.pop();null!==k&&(g.push(k),a.execCommand("canRedo",!0));0===h.length&&a.execCommand("canUndo",!1);c.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection), | ||
{tag:"historic"})}return!0;case "redo":return g=c.redoStack,h=c.undoStack,0!==g.length&&(k=c.current,null!==k&&(h.push(k),a.execCommand("canUndo",!0)),h=g.pop(),0===g.length&&a.execCommand("canRedo",!1),c.current=h,h.editor.setEditorState(h.editorState,{tag:"historic"})),!0;case "clearEditor":return b(),!1;case "clearHistory":return b(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:h,dirtyLeaves:k,dirtyElements:n,tags:t})=>{const m=c.current,q=c.redoStack,p=c.undoStack, | ||
r=null===m?null:m.editorState;if(null===m||g!==r){k=e(h,g,m,k,n,t);if(1===k)0!==q.length&&(c.redoStack=[]),null!==m&&(p.push({...m,undoSelection:h.read(l.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;c.current={editor:a,editorState:g}}}))},[b,f,a,c])}function K(a,d,f=1E3){return J(a,d,f)}module.exports=function(a,d){G(a,!0);K(a,d)}; |
@@ -1,31 +0,30 @@ | ||
'use strict';var h=require("lexical"),w=require("lexical/HeadingNode"),x=require("lexical/ListNode"),z=require("lexical/QuoteNode"),A=require("lexical/CodeNode"),B=require("lexical/ListItemNode"),C=require("react"),D=require("lexical/LinkNode"),E=require("@lexical/react/withSubscriptions"); | ||
function F(a){C.useEffect(()=>{const c=f=>{var d=a.getRootElement();if(document.activeElement===d&&(d=f.data,"string"===typeof d)){try{var e=JSON.parse(d)}catch(b){return}if(e&&"nuanria_messaging"===e.protocol&&"request"===e.type&&(e=e.payload)&&"makeChanges"===e.functionId&&(e=e.args)){const [b,g,k,l,p]=e;a.update(()=>{h.$log("useLexicalDragonSupport");const n=h.$getSelection();if(null!==n){var m=n.anchor;let r=m.getNode(),q=0,t=0;h.$isTextNode(r)&&0<=b&&0<=g&&(q=b,t=b+g,n.setTextNodeRange(r,q,r, | ||
t));if(q!==t||""!==k)n.insertRawText(k),r=m.getNode();h.$isTextNode(r)&&(q=l,t=l+p,m=r.getTextContentSize(),q=q>m?m:q,t=t>m?m:t,n.setTextNodeRange(r,q,r,t));f.stopImmediatePropagation()}})}}};window.addEventListener("message",c,!0);return()=>{window.removeEventListener("message",c,!0)}},[a])} | ||
function G(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;h.$isElementNode(a)&&h.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):h.$isTextNode(a)&&h.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):h.$isDecoratorNode(a)&&h.$isDecoratorNode(c)&&(c.__state=a.__state);return c} | ||
function H(a,c,f,d,e){for(var b=c;null!==a;){for(c=a.getParent();null!==c&&c.excludeFromCopy();)c=c.getParent();if(null===c)break;if(!h.$isElementNode(a)||!a.excludeFromCopy()){const g=a.getKey();let k=e.get(g);const l=void 0===k;l&&(k=G(a),e.set(g,k));!h.$isTextNode(k)||k.isSegmented()||k.isToken()?h.$isElementNode(k)&&(k.__children=k.__children.slice(f?b:0,f?void 0:b+1)):k.__text=k.__text.slice(f?b:0,f?void 0:b);if(h.$isRootNode(c)){l&&d.push(g);break}}b=e.get(c.getKey());b=h.$isElementNode(b)? | ||
'use strict';var k=require("lexical"),w=require("react"),x=require("@lexical/list"),z=require("lexical/HeadingNode"),A=require("lexical/LinkNode"),B=require("lexical/CodeNode"),C=require("@lexical/react/withSubscriptions"); | ||
function D(a){w.useEffect(()=>{const c=f=>{var d=a.getRootElement();if(document.activeElement===d&&(d=f.data,"string"===typeof d)){try{var e=JSON.parse(d)}catch(b){return}if(e&&"nuanria_messaging"===e.protocol&&"request"===e.type&&(e=e.payload)&&"makeChanges"===e.functionId&&(e=e.args)){const [b,h,g,l,n]=e;a.update(()=>{k.$log("useLexicalDragonSupport");const p=k.$getSelection();if(null!==p){var m=p.anchor;let r=m.getNode(),q=0,t=0;k.$isTextNode(r)&&0<=b&&0<=h&&(q=b,t=b+h,p.setTextNodeRange(r,q,r, | ||
t));if(q!==t||""!==g)p.insertRawText(g),r=m.getNode();k.$isTextNode(r)&&(q=l,t=l+n,m=r.getTextContentSize(),q=q>m?m:q,t=t>m?m:t,p.setTextNodeRange(r,q,r,t));f.stopImmediatePropagation()}})}}};window.addEventListener("message",c,!0);return()=>{window.removeEventListener("message",c,!0)}},[a])} | ||
function E(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;k.$isElementNode(a)&&k.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):k.$isTextNode(a)&&k.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):k.$isDecoratorNode(a)&&k.$isDecoratorNode(c)&&(c.__state=a.__state);return c} | ||
function F(a,c,f,d,e){for(var b=c;null!==a;){for(c=a.getParent();null!==c&&c.excludeFromCopy();)c=c.getParent();if(null===c)break;if(!k.$isElementNode(a)||!a.excludeFromCopy()){const h=a.getKey();let g=e.get(h);const l=void 0===g;l&&(g=E(a),e.set(h,g));!k.$isTextNode(g)||g.isSegmented()||g.isToken()?k.$isElementNode(g)&&(g.__children=g.__children.slice(f?b:0,f?void 0:b+1)):g.__text=g.__text.slice(f?b:0,f?void 0:b);if(k.$isRootNode(c)){l&&d.push(h);break}}b=e.get(c.getKey());b=k.$isElementNode(b)? | ||
b.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=c}} | ||
const I={ul:()=>({node:x.$createListNode("ul")}),ol:()=>({node:x.$createListNode("ol")}),li:()=>({node:B.$createListItemNode()}),h1:()=>({node:w.$createHeadingNode("h1")}),h2:()=>({node:w.$createHeadingNode("h2")}),h3:()=>({node:w.$createHeadingNode("h3")}),h4:()=>({node:w.$createHeadingNode("h4")}),h5:()=>({node:w.$createHeadingNode("h5")}),p:()=>({node:h.$createParagraphNode()}),br:()=>({node:h.$createLineBreakNode()}),a:a=>({node:a instanceof HTMLAnchorElement?D.$createLinkNode(a.href):h.$createTextNode(a.textContent)}), | ||
u:()=>({node:null,forChild:a=>{h.$isTextNode(a)&&a.toggleFormat("underline")}}),b:a=>{const c="normal"===a.style.fontWeight;return{node:null,forChild:f=>{h.$isTextNode(f)&&!c&&f.toggleFormat("bold")}}},strong:()=>({node:null,forChild:a=>{h.$isTextNode(a)&&a.toggleFormat("bold")}}),i:()=>({node:null,forChild:a=>{h.$isTextNode(a)&&a.toggleFormat("italic")}}),em:()=>({node:null,forChild:a=>{h.$isTextNode(a)&&a.toggleFormat("italic")}}),td:a=>{const c=a.classList.contains("js-file-line");return{node:null, | ||
after:f=>{c&&a.parentNode&&a.parentNode.nextSibling&&f.push(h.$createLineBreakNode());return f}}},table:a=>({node:a.classList.contains("js-file-line-container")?A.$createCodeNode():null}),span:a=>{const c="700"===a.style.fontWeight;return{node:null,forChild:f=>{h.$isTextNode(f)&&c&&f.toggleFormat("bold")}}},"#text":a=>({node:h.$createTextNode(a.textContent)}),pre:()=>({node:A.$createCodeNode()}),div:a=>({node:null!==a.style.fontFamily.match("monospace")?A.$createCodeNode():null,after:c=>{const f= | ||
a.parentNode;null!=f&&a!==f.lastChild&&c.push(h.$createLineBreakNode());return c}})}; | ||
function J(a,c,f,d=new Map){let e=[],b=null;var g=a.nodeName.toLowerCase(),k=(f._config.htmlTransforms||{})[g]||c[g],l=k?k(a):null;k=null;if(null!==l){k=l.after;b=l.node;if(null!==b){e.push(b);const p=Array.from(d.values());for(let n=0;n<p.length;n++)p[n](b)}null!=l.forChild&&d.set(g,l.forChild)}a=a.childNodes;g=[];for(l=0;l<a.length;l++)g.push(...J(a[l],c,f,d));null!=k&&(g=k(g));null==b?e=e.concat(g):h.$isElementNode(b)&&b.append(...g);return e} | ||
function K(a,c,f){var d=a.getData("application/x-lexical-editor");if(d){var e=f._config.namespace;try{const l=JSON.parse(d);if(l.namespace===e){const {range:p,nodeMap:n}=l.state;var b=new Map(n);d=[];for(e=0;e<p.length;e++){var g=b.get(p[e]);if(void 0!==g){var k=h.$createNodeFromParse(g,b);d.push(k)}}c.insertNodes(d);return}}catch(l){}}if(b=a.getData("text/html")){b=(new DOMParser).parseFromString(b,"text/html");a=[];b=b.body?Array.from(b.body.childNodes):[];g=b.length;for(k=0;k<g;k++)d=J(b[k],I, | ||
f),null!==d&&(a=a.concat(d));f=a;a=[];b=null;for(g=0;g<f.length;g++)k=f[g],!h.$isElementNode(k)||k.isInline()?(null===b&&(b=h.$createParagraphNode(),a.push(b)),null!==b&&b.append(k)):(a.push(k),b=null);c.insertNodes(a)}else f=a.getData("text/plain"),null!=f&&c.insertRawText(f)} | ||
function L(a,c){var f=a.focus;a=f.offset;"element"===f.type?c=f.getNode().getChildAtIndex(c?a-1:a):(f=f.getNode(),c=c&&0===a||!c&&a===f.getTextContentSize()?c?f.getPreviousSibling():f.getNextSibling():null);return h.$isDecoratorNode(c)}function M(a,c){a.preventDefault();c.update(()=>{h.$log("onPasteForRichText");const f=h.$getSelection(),d=a.clipboardData;null!=d&&null!==f&&K(d,f,c)})} | ||
function N(a,c){O(a,c);c.update(()=>{h.$log("onCutForRichText");const f=h.$getSelection();null!==f&&f.removeText()})} | ||
function O(a,c){a.preventDefault();c.update(()=>{h.$log("onCopyForRichText");const f=a.clipboardData;var d=h.$getSelection();if(null!==d&&null!=f){var e=window.getSelection();if(!e.isCollapsed){var b=e.getRangeAt(0);b&&(e=document.createElement("div"),b=b.cloneContents(),e.appendChild(b),f.setData("text/html",e.innerHTML));f.setData("text/plain",d.getTextContent());e=c._config.namespace;b=f.setData;var g=JSON,k=g.stringify;{var l=d.anchor,p=d.focus;var n=l.getCharacterOffset();const y=p.getCharacterOffset(); | ||
var m=l.getNode(),r=p.getNode(),q=m.getParentOrThrow();if(m===r&&h.$isTextNode(m)&&(q.canBeEmpty()||1<q.getChildrenSize()))d=G(m),m=y>n,d.__text=d.__text.slice(m?n:y,m?y:n),n=d.getKey(),n={range:[n],nodeMap:[[n,d]]};else if(d=d.getNodes(),0===d.length)n={range:[],nodeMap:[]};else{m=d.length;r=d[0];q=r.getParent();if(null!==q&&!q.canBeEmpty()){var t=q.__children;if(t.length===m){var u=!0;for(var v=0;v<t.length;v++)if(t[v]!==d[v].__key){u=!1;break}u&&(m++,d.push(q))}}q=d[m-1];l=l.isBefore(p);p=new Map; | ||
t=[];H(r,l?n:y,!0,t,p);for(r=0;r<m;r++)if(u=d[r],v=u.getKey(),!(p.has(v)||h.$isElementNode(u)&&u.excludeFromCopy())){const Q=G(u);h.$isRootNode(u.getParent())&&t.push(u.getKey());p.set(v,Q)}H(q,l?y:n,!1,t,p);n={range:t,nodeMap:Array.from(p.entries())}}}b.call(f,"application/x-lexical-editor",k.call(g,{namespace:e,state:n}))}}})}var P="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?C.useLayoutEffect:C.useEffect; | ||
function R(a,c){const f=h.$createParagraphNode();a.append(f);a=document.activeElement;(null!==h.$getSelection()||null!==a&&a===c.getRootElement())&&f.select()}function S(a){a.update(()=>{h.$log("initEditor");const c=h.$getRoot();null===c.getFirstChild()&&R(c,a)})}function T(a,c){a.update(()=>{h.$log("clearEditor");const f=h.$getRoot();f.clear();R(f,a)},{onUpdate:c})} | ||
function U(a,c){P(()=>{const f=E(a.registerNodes([w.HeadingNode,x.ListNode,z.QuoteNode,A.CodeNode,B.ListItemNode]),a.addListener("command",(d,e)=>{var b=h.$getSelection();if(null===b)return!1;switch(d){case "deleteCharacter":return b.deleteCharacter(e),!0;case "deleteWord":return b.deleteWord(e),!0;case "deleteLine":return b.deleteLine(e),!0;case "insertText":return"string"===typeof e?b.insertText(e):(d=e.dataTransfer,null!=d?K(d,b,a):(e=e.data)&&b.insertText(e)),!0;case "removeText":return b.removeText(), | ||
!0;case "formatText":return b.formatText(e),!0;case "formatElement":return b=b.anchor.getNode(),(h.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(e),!0;case "insertLineBreak":return b.insertLineBreak(e),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor, | ||
e=b.getNode(),d="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),d.canInsertTab()?"\t"===e.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==d.getIndent()&&d.setIndent(d.getIndent()-1),!0;case "keyArrowLeft":d=e.shiftKey;if(L(b,!0))return e.preventDefault(),e=d,d="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(),b.modify(e?"extend":"move",!d,"character"),!0;break;case "keyArrowRight":d=e.shiftKey;if(L(b,!1))return e.preventDefault(),e=d,d="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(), | ||
b.modify(e?"extend":"move",d,"character"),!0;break;case "keyBackspace":return e.preventDefault(),{anchor:e}=b,b.isCollapsed()&&0===e.offset&&0<("element"===e.type?e.getNode():e.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return e.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return e.preventDefault(),e.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return e.preventDefault(), | ||
a.execCommand(e.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),!0;case "clearEditor":T(a);break;case "copy":return O(e,a),!0;case "cut":return N(e,a),!0;case "paste":return M(e,a),!0;case "drop":case "dragstart":return e.preventDefault(),!0}return!1},0));c&&S(a);return f},[a,c]);F(a)} | ||
function V(a,c,f){c=Array.from(c);f=Array.from(f);a=a._nodeMap;const d=[];for(var e=0;e<c.length;e++){const b=a.get(c[e]);void 0!==b&&d.push(b)}for(c=0;c<f.length;c++)f[c][1]&&(e=a.get(f[c][0]),void 0===e||h.$isRootNode(e)||d.push(e));return d} | ||
function W(a,c,f,d,e){if(null===a||0===f.size&&0===d.size)return 0;var b=c._selection,g=a._selection;if(e)return 1;if(null===b||null===g||!g.isCollapsed()||!b.isCollapsed())return 0;f=V(c,f,d);if(0===f.length)return 0;if(1<f.length){c=c._nodeMap;g=c.get(g.anchor.key);const k=c.get(b.anchor.key);return h.$isTextNode(k)&&h.$isElementNode(g)&&!a._nodeMap.has(k.__key)&&1===k.__text.length&&1===b.anchor.offset?f.every(l=>l===k||!h.$isTextNode(l))?2:0:0}c=f[0];a=a._nodeMap.get(c.__key);if(!h.$isTextNode(a)|| | ||
!h.$isTextNode(c)||a.__mode!==c.__mode)return 0;a=a.__text;c=c.__text;if(a===c)return 0;b=b.anchor;g=g.anchor;if(b.key!==g.key||"text"!==b.type)return 0;b=b.offset;g=g.offset;a=c.length-a.length;return 1===a&&g===b-1?2:-1===a&&g===b+1?3:-1===a&&g===b?4:0} | ||
function X(a,c){let f=Date.now(),d=0;return(e,b,g,k,l,p)=>{const n=Date.now();if(p.has("historic"))return d=0,f=n,2;const m=W(e,b,k,l,a.isComposing()),r=(()=>{if(p.has("without-history"))return 0;if(null===e)return 1;var q=b._selection;const t=e._selection;if(!(0<k.size||0<l.size))return null===t&&null!==q?0:2;q=null===g||g.editor===a;return 0!==m&&m===d&&n<f+c&&q?0:1})();f=n;d=m;return r}} | ||
function Y(a,c,f=1E3){const d=C.useMemo(()=>c||{current:null,redoStack:[],undoStack:[]},[c]),e=C.useCallback(()=>{d.undoStack=[];d.redoStack=[];d.current=null},[d]);C.useEffect(()=>{const b=X(a,f);return E(a.addListener("command",g=>{switch(g){case "undo":g=d.redoStack;var k=d.undoStack;if(0!==k.length){var l=d.current;const p=k.pop();null!==l&&(g.push(l),a.execCommand("canRedo",!0));0===k.length&&a.execCommand("canUndo",!1);d.current=p;p.editor.setEditorState(p.editorState.clone(p.undoSelection), | ||
{tag:"historic"})}return!0;case "redo":return g=d.redoStack,k=d.undoStack,0!==g.length&&(l=d.current,null!==l&&(k.push(l),a.execCommand("canUndo",!0)),k=g.pop(),0===g.length&&a.execCommand("canRedo",!1),d.current=k,k.editor.setEditorState(k.editorState,{tag:"historic"})),!0;case "clearEditor":return e(),!1;case "clearHistory":return e(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:k,dirtyLeaves:l,dirtyElements:p,tags:n})=>{const m=d.current,r=d.redoStack,q=d.undoStack, | ||
t=null===m?null:m.editorState;if(null===m||g!==t){l=b(k,g,m,l,p,n);if(1===l)0!==r.length&&(d.redoStack=[]),null!==m&&(q.push({...m,undoSelection:k.read(h.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;d.current={editor:a,editorState:g}}}))},[e,f,a,d])}function Z(a,c,f=1E3){return Y(a,c,f)}module.exports=function(a,c){U(a,!0);Z(a,c)}; | ||
const G={ul:()=>({node:x.$createListNode("ul")}),ol:()=>({node:x.$createListNode("ol")}),li:()=>({node:x.$createListItemNode()}),h1:()=>({node:z.$createHeadingNode("h1")}),h2:()=>({node:z.$createHeadingNode("h2")}),h3:()=>({node:z.$createHeadingNode("h3")}),h4:()=>({node:z.$createHeadingNode("h4")}),h5:()=>({node:z.$createHeadingNode("h5")}),p:()=>({node:k.$createParagraphNode()}),br:()=>({node:k.$createLineBreakNode()}),a:a=>({node:a instanceof HTMLAnchorElement?A.$createLinkNode(a.href):k.$createTextNode(a.textContent)}), | ||
u:()=>({node:null,forChild:a=>{k.$isTextNode(a)&&a.toggleFormat("underline")}}),b:a=>{const c="normal"===a.style.fontWeight;return{node:null,forChild:f=>{k.$isTextNode(f)&&!c&&f.toggleFormat("bold")}}},strong:()=>({node:null,forChild:a=>{k.$isTextNode(a)&&a.toggleFormat("bold")}}),i:()=>({node:null,forChild:a=>{k.$isTextNode(a)&&a.toggleFormat("italic")}}),em:()=>({node:null,forChild:a=>{k.$isTextNode(a)&&a.toggleFormat("italic")}}),td:a=>{const c=a.classList.contains("js-file-line");return{node:null, | ||
after:f=>{c&&a.parentNode&&a.parentNode.nextSibling&&f.push(k.$createLineBreakNode());return f}}},table:a=>({node:a.classList.contains("js-file-line-container")?B.$createCodeNode():null}),span:a=>{const c="700"===a.style.fontWeight;return{node:null,forChild:f=>{k.$isTextNode(f)&&c&&f.toggleFormat("bold")}}},"#text":a=>({node:k.$createTextNode(a.textContent)}),pre:()=>({node:B.$createCodeNode()}),div:a=>({node:null!==a.style.fontFamily.match("monospace")?B.$createCodeNode():null,after:c=>{const f= | ||
a.parentNode;null!=f&&a!==f.lastChild&&c.push(k.$createLineBreakNode());return c}})}; | ||
function H(a,c,f,d=new Map){let e=[],b=null;var h=a.nodeName.toLowerCase(),g=(f._config.htmlTransforms||{})[h]||c[h],l=g?g(a):null;g=null;if(null!==l){g=l.after;b=l.node;if(null!==b){e.push(b);const n=Array.from(d.values());for(let p=0;p<n.length;p++)n[p](b)}null!=l.forChild&&d.set(h,l.forChild)}a=a.childNodes;h=[];for(l=0;l<a.length;l++)h.push(...H(a[l],c,f,d));null!=g&&(h=g(h));null==b?e=e.concat(h):k.$isElementNode(b)&&b.append(...h);return e} | ||
function I(a,c,f){var d=a.getData("application/x-lexical-editor");if(d){var e=f._config.namespace;try{const l=JSON.parse(d);if(l.namespace===e){const {range:n,nodeMap:p}=l.state;var b=new Map(p);d=[];for(e=0;e<n.length;e++){var h=b.get(n[e]);if(void 0!==h){var g=k.$createNodeFromParse(h,b);d.push(g)}}c.insertNodes(d);return}}catch(l){}}if(b=a.getData("text/html")){b=(new DOMParser).parseFromString(b,"text/html");a=[];b=b.body?Array.from(b.body.childNodes):[];h=b.length;for(g=0;g<h;g++)d=H(b[g],G, | ||
f),null!==d&&(a=a.concat(d));f=a;a=[];b=null;for(h=0;h<f.length;h++)g=f[h],!k.$isElementNode(g)||g.isInline()?(null===b&&(b=k.$createParagraphNode(),a.push(b)),null!==b&&b.append(g)):(a.push(g),b=null);c.insertNodes(a)}else f=a.getData("text/plain"),null!=f&&c.insertRawText(f)} | ||
function J(a,c){var f=a.focus;a=f.offset;"element"===f.type?c=f.getNode().getChildAtIndex(c?a-1:a):(f=f.getNode(),c=c&&0===a||!c&&a===f.getTextContentSize()?c?f.getPreviousSibling():f.getNextSibling():null);return k.$isDecoratorNode(c)}function K(a,c){a.preventDefault();c.update(()=>{k.$log("onPasteForRichText");const f=k.$getSelection(),d=a.clipboardData;null!=d&&null!==f&&I(d,f,c)})} | ||
function L(a,c){M(a,c);c.update(()=>{k.$log("onCutForRichText");const f=k.$getSelection();null!==f&&f.removeText()})} | ||
function M(a,c){a.preventDefault();c.update(()=>{k.$log("onCopyForRichText");const f=a.clipboardData;var d=k.$getSelection();if(null!==d&&null!=f){var e=window.getSelection();if(!e.isCollapsed){var b=e.getRangeAt(0);b&&(e=document.createElement("div"),b=b.cloneContents(),e.appendChild(b),f.setData("text/html",e.innerHTML));f.setData("text/plain",d.getTextContent());e=c._config.namespace;b=f.setData;var h=JSON,g=h.stringify;{var l=d.anchor,n=d.focus;var p=l.getCharacterOffset();const y=n.getCharacterOffset(); | ||
var m=l.getNode(),r=n.getNode(),q=m.getParentOrThrow();if(m===r&&k.$isTextNode(m)&&(q.canBeEmpty()||1<q.getChildrenSize()))d=E(m),m=y>p,d.__text=d.__text.slice(m?p:y,m?y:p),p=d.getKey(),p={range:[p],nodeMap:[[p,d]]};else if(d=d.getNodes(),0===d.length)p={range:[],nodeMap:[]};else{m=d.length;r=d[0];q=r.getParent();if(null!==q&&!q.canBeEmpty()){var t=q.__children;if(t.length===m){var u=!0;for(var v=0;v<t.length;v++)if(t[v]!==d[v].__key){u=!1;break}u&&(m++,d.push(q))}}q=d[m-1];l=l.isBefore(n);n=new Map; | ||
t=[];F(r,l?p:y,!0,t,n);for(r=0;r<m;r++)if(u=d[r],v=u.getKey(),!(n.has(v)||k.$isElementNode(u)&&u.excludeFromCopy())){const O=E(u);k.$isRootNode(u.getParent())&&t.push(u.getKey());n.set(v,O)}F(q,l?y:p,!1,t,n);p={range:t,nodeMap:Array.from(n.entries())}}}b.call(f,"application/x-lexical-editor",g.call(h,{namespace:e,state:p}))}}})}var N="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?w.useLayoutEffect:w.useEffect; | ||
function P(a,c){const f=k.$createParagraphNode();a.append(f);a=document.activeElement;(null!==k.$getSelection()||null!==a&&a===c.getRootElement())&&f.select()}function Q(a){a.update(()=>{k.$log("initEditor");const c=k.$getRoot();null===c.getFirstChild()&&P(c,a)})}function R(a,c){a.update(()=>{k.$log("clearEditor");const f=k.$getRoot();f.clear();P(f,a)},{onUpdate:c})} | ||
function S(a,c){N(()=>{const f=C(a.addListener("command",(d,e)=>{var b=k.$getSelection();if(null===b)return!1;switch(d){case "deleteCharacter":return b.deleteCharacter(e),!0;case "deleteWord":return b.deleteWord(e),!0;case "deleteLine":return b.deleteLine(e),!0;case "insertText":return"string"===typeof e?b.insertText(e):(d=e.dataTransfer,null!=d?I(d,b,a):(e=e.data)&&b.insertText(e)),!0;case "removeText":return b.removeText(),!0;case "formatText":return b.formatText(e),!0;case "formatElement":return b= | ||
b.anchor.getNode(),(k.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(e),!0;case "insertLineBreak":return b.insertLineBreak(e),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor,e=b.getNode(),d="element"===b.type?b.getNode():b.getNode().getParentOrThrow(), | ||
d.canInsertTab()?"\t"===e.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==d.getIndent()&&d.setIndent(d.getIndent()-1),!0;case "keyArrowLeft":d=e.shiftKey;if(J(b,!0))return e.preventDefault(),e=d,d="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(),b.modify(e?"extend":"move",!d,"character"),!0;break;case "keyArrowRight":d=e.shiftKey;if(J(b,!1))return e.preventDefault(),e=d,d="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(),b.modify(e?"extend":"move",d,"character"), | ||
!0;break;case "keyBackspace":return e.preventDefault(),{anchor:e}=b,b.isCollapsed()&&0===e.offset&&0<("element"===e.type?e.getNode():e.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return e.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return e.preventDefault(),e.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return e.preventDefault(),a.execCommand(e.shiftKey? | ||
"outdentContent":"indentContent");case "keyEscape":return a.blur(),!0;case "clearEditor":R(a);break;case "copy":return M(e,a),!0;case "cut":return L(e,a),!0;case "paste":return K(e,a),!0;case "drop":case "dragstart":return e.preventDefault(),!0}return!1},0));c&&Q(a);return f},[a,c]);D(a)} | ||
function T(a,c,f,d,e){if(null===a||0===f.size&&0===d.size)return 0;var b=c._selection,h=a._selection;if(e)return 1;if(null===b||null===h||!h.isCollapsed()||!b.isCollapsed())return 0;var g=Array.from(f);d=Array.from(d);f=c._nodeMap;e=[];for(var l=0;l<g.length;l++){const n=f.get(g[l]);void 0!==n&&e.push(n)}for(g=0;g<d.length;g++)d[g][1]&&(l=f.get(d[g][0]),void 0===l||k.$isRootNode(l)||e.push(l));if(0===e.length)return 0;if(1<e.length)return d=c._nodeMap,c=d.get(b.anchor.key),h=d.get(h.anchor.key),c&& | ||
h&&!a._nodeMap.has(c.__key)&&k.$isTextNode(c)&&1===c.__text.length&&1===b.anchor.offset?2:0;c=e[0];a=a._nodeMap.get(c.__key);if(!k.$isTextNode(a)||!k.$isTextNode(c)||a.__mode!==c.__mode)return 0;a=a.__text;c=c.__text;if(a===c)return 0;b=b.anchor;h=h.anchor;if(b.key!==h.key||"text"!==b.type)return 0;b=b.offset;h=h.offset;a=c.length-a.length;return 1===a&&h===b-1?2:-1===a&&h===b+1?3:-1===a&&h===b?4:0} | ||
function U(a,c){let f=Date.now(),d=0;return(e,b,h,g,l,n)=>{const p=Date.now();if(n.has("historic"))return d=0,f=p,2;const m=T(e,b,g,l,a.isComposing()),r=(()=>{if(n.has("without-history"))return 0;if(null===e)return 1;var q=b._selection;const t=e._selection;if(!(0<g.size||0<l.size))return null===t&&null!==q?0:2;q=null===h||h.editor===a;return 0!==m&&m===d&&p<f+c&&q?0:1})();f=p;d=m;return r}} | ||
function V(a,c,f=1E3){const d=w.useMemo(()=>c||{current:null,redoStack:[],undoStack:[]},[c]),e=w.useCallback(()=>{d.undoStack=[];d.redoStack=[];d.current=null},[d]);w.useEffect(()=>{const b=U(a,f);return C(a.addListener("command",h=>{switch(h){case "undo":h=d.redoStack;var g=d.undoStack;if(0!==g.length){var l=d.current;const n=g.pop();null!==l&&(h.push(l),a.execCommand("canRedo",!0));0===g.length&&a.execCommand("canUndo",!1);d.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection), | ||
{tag:"historic"})}return!0;case "redo":return h=d.redoStack,g=d.undoStack,0!==h.length&&(l=d.current,null!==l&&(g.push(l),a.execCommand("canUndo",!0)),g=h.pop(),0===h.length&&a.execCommand("canRedo",!1),d.current=g,g.editor.setEditorState(g.editorState,{tag:"historic"})),!0;case "clearEditor":return e(),!1;case "clearHistory":return e(),!0;default:return!1}},0),a.addListener("update",({editorState:h,prevEditorState:g,dirtyLeaves:l,dirtyElements:n,tags:p})=>{const m=d.current,r=d.redoStack,q=d.undoStack, | ||
t=null===m?null:m.editorState;if(null===m||h!==t){l=b(g,h,m,l,n,p);if(1===l)0!==r.length&&(d.redoStack=[]),null!==m&&(q.push({...m,undoSelection:g.read(k.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;d.current={editor:a,editorState:h}}}))},[e,f,a,d])}function W(a,c,f=1E3){return V(a,c,f)}module.exports=function(a,c){S(a,!0);W(a,c)}; |
@@ -1,12 +0,12 @@ | ||
'use strict';var l=require("@lexical/react/LexicalComposerContext"),m=require("lexical/CodeNode"),t=require("lexical/ListItemNode"),u=require("lexical"),w=require("react"),x=require("lexical/HeadingNode"),y=require("lexical/ListNode"),z=require("lexical/QuoteNode");function A(e){throw Error(`Minified Lexical error #${e}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");} | ||
const B={requiresParagraphStart:!1,nodeTransformationKind:null,regEx:/(?:)/,regExExpectedCaptureGroupCount:0},E={...B,requiresParagraphStart:!0},F=[{...B,nodeTransformationKind:"textBold",regEx:/(\*)(?:\s*\b)(?:[^\*]*)(?:\b\s*)(\*\s)$/,regExExpectedCaptureGroupCount:2}],G=[{...E,regEx:/(?:# )/,nodeTransformationKind:"paragraphH1"},{...E,regEx:/(?:## )/,nodeTransformationKind:"paragraphH2"},{...E,regEx:/(?:### )/,nodeTransformationKind:"paragraphH2"},{...E,regEx:/(?:> )/,nodeTransformationKind:"paragraphBlockQuote"}, | ||
{...E,regEx:/(?:- )/,nodeTransformationKind:"paragraphUnorderedList"},{...E,regEx:/(?:\* )/,nodeTransformationKind:"paragraphUnorderedList"},{...E,nodeTransformationKind:"paragraphOrderedList",regEx:/^(\d+)\.\s/,regExExpectedCaptureGroupCount:1},{...E,regEx:/(?:``` )/,nodeTransformationKind:"paragraphCodeBlock"},...F]; | ||
function H(e,h,b){const a={regExCaptureGroups:[],text:"",textIndex:-1,triggerState:null};e=e.match(h);if(null!==e&&0===e.index&&e.length===b+1){a.textIndex=e.index;a.text=e[0];for(b=1;b<e.length;++b)a.regExCaptureGroups.push(e[b]);return a}return null} | ||
function I(e,h){e.update(()=>{var b=u.$getSelection();if(null==b)b=null;else{var a=b.anchor.getNode();b=u.$isTextNode(a)?{node:a,offset:b.anchor.offset}:null}if(null!==b){b={textNodeWithOffset:b,trimmedParagraphText:null};a:{a=!1===h.isParentAListItemNode?G:F;var c=a.length;for(var f=0;f<c;++f){var d=a[f];if(!1===h.isCodeBlock||"paragraphCodeBlock"===d.nodeTransformationKind){var g=d,k=b;if(null!==g.requiresParagraphStart&&!0===g.requiresParagraphStart)b:{var n=k;k=n.textNodeWithOffset;if(null=== | ||
k.node.getPreviousSibling()&&(n=n.textNodeWithOffset.node.getTextContent(),g=H(n,g.regEx,g.regExExpectedCaptureGroupCount),null!=g&&0===g.textIndex&&g.textIndex+g.text.length===k.offset))break b;g=null}else{if(null==k.trimmedParagraphText){var p=k.textNodeWithOffset.node.getParentOrThrow();if(u.$isElementNode(p)){if(null==k.trimmedParagraphText){n=k;var J=k.textNodeWithOffset.node,C=k.textNodeWithOffset.offset;let r="";p=p.getChildren();const K=p.length;for(let v=0;v<K;++v){const q=p[v];if(u.$isTextNode(q)){const D= | ||
q.getTextContent();if(q.is(J)){C>D.length&&A(50,q.__key);r+=q.getTextContent().substr(0,C);break}else r+=D}else r+="\u0004"}n.trimmedParagraphText=r}H(k.trimmedParagraphText,g.regEx,g.regExExpectedCaptureGroupCount)}else A(52,p.__key)}g=null}if(null!=g){g.triggerState=h;a={autoFormatCriteria:d,matchResultContext:g};break a}}}a={autoFormatCriteria:null,matchResultContext:null}}c=a;if(null!==c.autoFormatCriteria&&null!==c.matchResultContext&&(a=c.autoFormatCriteria,c=c.matchResultContext,a.requiresParagraphStart)){f= | ||
b.textNodeWithOffset;b=f.node.getParentOrThrow();f=f.node.spliceText(0,c.text.length,"",!0);""===f.getTextContent()&&(f.selectPrevious(),f.remove());f=b.getChildren();d=null;if(null!=a.nodeTransformationKind)switch(a.nodeTransformationKind){case "paragraphH1":d=x.$createHeadingNode("h1");d.append(...f);break;case "paragraphH2":d=x.$createHeadingNode("h2");d.append(...f);break;case "paragraphH3":d=x.$createHeadingNode("h3");d.append(...f);break;case "paragraphBlockQuote":d=z.$createQuoteNode();d.append(...f); | ||
break;case "paragraphUnorderedList":d=y.$createListNode("ul");a=t.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphOrderedList":a=parseInt(1===c.regExCaptureGroups.length?c.regExCaptureGroups[0]:"1",10);d=y.$createListNode("ol",a);a=t.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphCodeBlock":d=null!=c.triggerState&&c.triggerState.isCodeBlock?u.$createParagraphNode():m.$createCodeNode(),d.append(...f)}a=d;null!==a&&b.replace(a)}}})} | ||
function L(e){let h=null;e.read(()=>{const b=u.$getSelection();if(null!=b&&b.isCollapsed()){var a=b.anchor.getNode(),c=a.getParent(),f=null!==c&&t.$isListItemNode(c);c=null!==c&&u.$isElementNode(c);h={anchorOffset:b.anchor.offset,isCodeBlock:m.$isCodeNode(a),isSelectionCollapsed:b.isCollapsed(),isSimpleText:u.$isTextNode(a)&&a.isSimpleText(),isParentAnElementNode:c,isParentAListItemNode:f,nodeKey:a.getKey(),textContent:a.getTextContent()}}});return h} | ||
function M(e){w.useEffect(()=>{let h=null;e.addListener("update",({tags:b})=>{if(!1===b.has("historic")){b=L(e.getEditorState());var a=b;var c=h;if(null==a||null==c)a=!1;else{var f=a.textContent.length,d=a.anchorOffset-1;a=!0===a.isParentAnElementNode&&a.isSimpleText&&a.isSelectionCollapsed&&a.nodeKey===c.nodeKey&&a.anchorOffset!==c.anchorOffset&&0<=d&&d+1<=f&&" "===a.textContent.substr(d,1)&&a.textContent!==c.textContent}a&&null!=b&&I(e,b);h=b}else h=null})},[e])} | ||
module.exports=function(){const [e]=l.useLexicalComposerContext();M(e);return null}; | ||
'use strict';var l=require("@lexical/react/LexicalComposerContext"),m=require("lexical/CodeNode"),q=require("@lexical/list"),u=require("lexical"),w=require("react"),x=require("lexical/HeadingNode"),y=require("lexical/QuoteNode");function z(e){throw Error(`Minified Lexical error #${e}; see codes.json for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");} | ||
const A={requiresParagraphStart:!1,nodeTransformationKind:null,regEx:/(?:)/,regExExpectedCaptureGroupCount:0},D={...A,requiresParagraphStart:!0},E=[{...A,nodeTransformationKind:"textBold",regEx:/(\*)(?:\s*\b)(?:[^\*]*)(?:\b\s*)(\*\s)$/,regExExpectedCaptureGroupCount:2}],F=[{...D,regEx:/(?:# )/,nodeTransformationKind:"paragraphH1"},{...D,regEx:/(?:## )/,nodeTransformationKind:"paragraphH2"},{...D,regEx:/(?:### )/,nodeTransformationKind:"paragraphH2"},{...D,regEx:/(?:> )/,nodeTransformationKind:"paragraphBlockQuote"}, | ||
{...D,regEx:/(?:- )/,nodeTransformationKind:"paragraphUnorderedList"},{...D,regEx:/(?:\* )/,nodeTransformationKind:"paragraphUnorderedList"},{...D,nodeTransformationKind:"paragraphOrderedList",regEx:/^(\d+)\.\s/,regExExpectedCaptureGroupCount:1},{...D,regEx:/(?:``` )/,nodeTransformationKind:"paragraphCodeBlock"},...E]; | ||
function G(e,h,b){const a={regExCaptureGroups:[],text:"",textIndex:-1,triggerState:null};e=e.match(h);if(null!==e&&0===e.index&&e.length===b+1){a.textIndex=e.index;a.text=e[0];for(b=1;b<e.length;++b)a.regExCaptureGroups.push(e[b]);return a}return null} | ||
function H(e,h){e.update(()=>{var b=u.$getSelection();if(null==b)b=null;else{var a=b.anchor.getNode();b=u.$isTextNode(a)?{node:a,offset:b.anchor.offset}:null}if(null!==b){b={textNodeWithOffset:b,trimmedParagraphText:null};a:{a=!1===h.isParentAListItemNode?F:E;var c=a.length;for(var f=0;f<c;++f){var d=a[f];if(!1===h.isCodeBlock||"paragraphCodeBlock"===d.nodeTransformationKind){var g=d,k=b;if(null!==g.requiresParagraphStart&&!0===g.requiresParagraphStart)b:{var n=k;k=n.textNodeWithOffset;if(null=== | ||
k.node.getPreviousSibling()&&(n=n.textNodeWithOffset.node.getTextContent(),g=G(n,g.regEx,g.regExExpectedCaptureGroupCount),null!=g&&0===g.textIndex&&g.textIndex+g.text.length===k.offset))break b;g=null}else{if(null==k.trimmedParagraphText){var p=k.textNodeWithOffset.node.getParentOrThrow();if(u.$isElementNode(p)){if(null==k.trimmedParagraphText){n=k;var I=k.textNodeWithOffset.node,B=k.textNodeWithOffset.offset;let t="";p=p.getChildren();const J=p.length;for(let v=0;v<J;++v){const r=p[v];if(u.$isTextNode(r)){const C= | ||
r.getTextContent();if(r.is(I)){B>C.length&&z(50,r.__key);t+=r.getTextContent().substr(0,B);break}else t+=C}else t+="\u0004"}n.trimmedParagraphText=t}G(k.trimmedParagraphText,g.regEx,g.regExExpectedCaptureGroupCount)}else z(52,p.__key)}g=null}if(null!=g){g.triggerState=h;a={autoFormatCriteria:d,matchResultContext:g};break a}}}a={autoFormatCriteria:null,matchResultContext:null}}c=a;if(null!==c.autoFormatCriteria&&null!==c.matchResultContext&&(a=c.autoFormatCriteria,c=c.matchResultContext,a.requiresParagraphStart)){f= | ||
b.textNodeWithOffset;b=f.node.getParentOrThrow();f=f.node.spliceText(0,c.text.length,"",!0);""===f.getTextContent()&&(f.selectPrevious(),f.remove());f=b.getChildren();d=null;if(null!=a.nodeTransformationKind)switch(a.nodeTransformationKind){case "paragraphH1":d=x.$createHeadingNode("h1");d.append(...f);break;case "paragraphH2":d=x.$createHeadingNode("h2");d.append(...f);break;case "paragraphH3":d=x.$createHeadingNode("h3");d.append(...f);break;case "paragraphBlockQuote":d=y.$createQuoteNode();d.append(...f); | ||
break;case "paragraphUnorderedList":d=q.$createListNode("ul");a=q.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphOrderedList":a=parseInt(1===c.regExCaptureGroups.length?c.regExCaptureGroups[0]:"1",10);d=q.$createListNode("ol",a);a=q.$createListItemNode();a.append(...f);d.append(a);break;case "paragraphCodeBlock":d=null!=c.triggerState&&c.triggerState.isCodeBlock?u.$createParagraphNode():m.$createCodeNode(),d.append(...f)}a=d;null!==a&&b.replace(a)}}})} | ||
function K(e){let h=null;e.read(()=>{const b=u.$getSelection();if(null!=b&&b.isCollapsed()){var a=b.anchor.getNode(),c=a.getParent(),f=null!==c&&q.$isListItemNode(c);c=null!==c&&u.$isElementNode(c);h={anchorOffset:b.anchor.offset,isCodeBlock:m.$isCodeNode(a),isSelectionCollapsed:b.isCollapsed(),isSimpleText:u.$isTextNode(a)&&a.isSimpleText(),isParentAnElementNode:c,isParentAListItemNode:f,nodeKey:a.getKey(),textContent:a.getTextContent()}}});return h} | ||
function L(e){w.useEffect(()=>{let h=null;e.addListener("update",({tags:b})=>{if(!1===b.has("historic")){b=K(e.getEditorState());var a=b;var c=h;if(null==a||null==c)a=!1;else{var f=a.textContent.length,d=a.anchorOffset-1;a=!0===a.isParentAnElementNode&&a.isSimpleText&&a.isSelectionCollapsed&&a.nodeKey===c.nodeKey&&a.anchorOffset!==c.anchorOffset&&0<=d&&d+1<=f&&" "===a.textContent.substr(d,1)&&a.textContent!==c.textContent}a&&null!=b&&H(e,b);h=b}else h=null})},[e])} | ||
module.exports=function(){const [e]=l.useLexicalComposerContext();L(e);return null}; |
'use strict';var h=require("lexical"),n=require("@lexical/react/LexicalComposerContext"),q=require("@lexical/react/withSubscriptions"),v=require("react"),w=require("lexical/AutoLinkNode");function x(a,b){for(let c=0;c<b.length;c++){const d=b[c](a);if(d)return d}return null}function y(a){a=a.getPreviousSibling();h.$isElementNode(a)&&(a=a.getLastDescendant());return null===a||h.$isLineBreakNode(a)||h.$isTextNode(a)&&a.getTextContent().endsWith(" ")} | ||
function C(a){a=a.getNextSibling();h.$isElementNode(a)&&(a=a.getFirstDescendant());return null===a||h.$isLineBreakNode(a)||h.$isTextNode(a)&&a.getTextContent().startsWith(" ")} | ||
function D(a,b,c){var d=a.getChildren();const e=d.length;for(let f=0;f<e;f++){const k=d[f];if(!h.$isTextNode(k)||!k.isSimpleText()){E(a);c(null,a.getURL());return}}d=a.getTextContent();b=x(d,b);null===b||b.text!==d?(E(a),c(null,a.getURL())):y(a)&&C(a)?(d=a.getURL(),null!==b&&d!==b.url&&(a.setURL(b.url),c(b.url,d))):(E(a),c(null,a.getURL()))}function E(a){const b=a.getChildren();var c=b.length;for(--c;0<=c;c--)a.insertAfter(b[c]);a.remove();return b.map(d=>d.getLatest())} | ||
function F(a,b,c){v.useEffect(()=>{const d=(...e)=>{c&&c(...e)};return q(a.registerNodes([w.AutoLinkNode]),a.addTransform(h.TextNode,e=>{var f=e.getParentOrThrow();if(w.$isAutoLinkNode(f))D(f,b,d);else{if(e.isSimpleText()){f=e.getTextContent();const G=f.length;let u=f,z=0,r=e;for(var k=0,g;(g=x(u,b))&&null!==g;){var t=g.index,l=z+t;const p=g.length;let A;A=0<l?" "===f[l-1]:y(e);let B;B=l+p<G?" "===f[l+p]:C(e);if(A&&B){var m=void 0;k=l-k;0===k?[m,r]=r.splitText(p):[,m,r]=r.splitText(k,k+p);l=w.$createAutoLinkNode(g.url); | ||
l.append(h.$createTextNode(g.text));m.replace(l);k+=p;d(g.url,null)}t+=p;u=u.substring(t);z+=t}}g=e.getPreviousSibling();m=e.getNextSibling();e=e.getTextContent();w.$isAutoLinkNode(g)&&!e.startsWith(" ")&&(E(g),d(null,g.getURL()));w.$isAutoLinkNode(m)&&!e.endsWith(" ")&&(E(m),d(null,m.getURL()))}}),a.addTransform(w.AutoLinkNode,e=>{D(e,b,d)}))},[a,b,c])}module.exports=function({matchers:a,onChange:b}){const [c]=n.useLexicalComposerContext();F(c,a,b);return null}; | ||
function F(a,b,c){v.useEffect(()=>{if(!a.hasNodes([w.AutoLinkNode]))throw Error("LexicalAutoLinkPlugin: AutoLinkNode, TableCellNode or TableRowNode not registered on editor");const d=(...e)=>{c&&c(...e)};return q(a.addTransform(h.TextNode,e=>{var f=e.getParentOrThrow();if(w.$isAutoLinkNode(f))D(f,b,d);else{if(e.isSimpleText()){f=e.getTextContent();const G=f.length;let u=f,z=0,r=e;for(var k=0,g;(g=x(u,b))&&null!==g;){var t=g.index,l=z+t;const p=g.length;let A;A=0<l?" "===f[l-1]:y(e);let B;B=l+p<G? | ||
" "===f[l+p]:C(e);if(A&&B){var m=void 0;k=l-k;0===k?[m,r]=r.splitText(p):[,m,r]=r.splitText(k,k+p);l=w.$createAutoLinkNode(g.url);l.append(h.$createTextNode(g.text));m.replace(l);k+=p;d(g.url,null)}t+=p;u=u.substring(t);z+=t}}g=e.getPreviousSibling();m=e.getNextSibling();e=e.getTextContent();w.$isAutoLinkNode(g)&&!e.startsWith(" ")&&(E(g),d(null,g.getURL()));w.$isAutoLinkNode(m)&&!e.endsWith(" ")&&(E(m),d(null,m.getURL()))}}),a.addTransform(w.AutoLinkNode,e=>{D(e,b,d)}))},[a,b,c])} | ||
module.exports=function({matchers:a,onChange:b}){const [c]=n.useLexicalComposerContext();F(c,a,b);return null}; |
@@ -1,10 +0,8 @@ | ||
'use strict';var l=require("@lexical/react/LexicalComposerContext"),p=require("lexical"),q=require("react"),r=require("@lexical/react/withSubscriptions");function t(a,e){for(e(a);null!==a;){if(p.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let f=null;for(;null===f&&null!==a;)f=a.getNextSibling(),a=null===f?a.getParent():f}null!==a&&(a=e(a))}}function u(){return p.$getRoot().getTextContent()} | ||
function w(a,e,f={}){const {strlen:h=c=>c.length,remainingCharacters:d=()=>{}}=f;q.useEffect(()=>a.registerNodes([x]),[a]);q.useEffect(()=>{let c=a.getEditorState().read(u),b=0;return r(a.addListener("textcontent",g=>{c=g}),a.addListener("update",({dirtyLeaves:g})=>{var k=a.isComposing();g=0<g.size;if(!k&&g){k=h(c);g=k>e||null!==b&&b>e;d(e-k);if(null===b||g){const n=y(c,e,h);a.update(()=>{p.$log("CharacterLimit");z(n)},{tag:"without-history"})}b=k}}))},[a,e,d,h])} | ||
function y(a,e,f){var h=Intl.Segmenter;let d=0;var c=0;if("function"===typeof h){a=(new h).segment(a);for(var {segment:b}of a){c+=f(b);if(c>e)break;d+=b.length}}else for(b=Array.from(a),a=b.length,h=0;h<a;h++){const g=b[h];c+=f(g);if(c>e)break;d+=g.length}return d} | ||
function z(a){const e=p.$getRoot();let f=0,h=e;t(e,d=>{if(d instanceof x){var c=f;if(f+d.getTextContentSize()<=a){var b=d.getParent();c=d.getPreviousSibling();var g=d.getNextSibling();A(d);d=p.$getSelection();null===d||d.anchor.getNode().isAttached()&&d.focus.getNode().isAttached()||(p.$isTextNode(c)?c.select():p.$isTextNode(g)?g.select():null!==b&&b.select());return h}if(c<a&&(b=d.getFirstDescendant(),g=null!==b?b.getTextContentSize():0,c+=g,b=p.$isTextNode(b)&&b.isSimpleText(),c=c<=a,b||c))return A(d), | ||
h}else if(p.$isLeafNode(d)&&(c=f,f+=d.getTextContentSize(),f>a&&!(d.getParent()instanceof x)&&(b=p.$getSelection(),c<a&&p.$isTextNode(d)&&d.isSimpleText()?([,c]=d.splitText(a-c),c=B(c)):c=B(d),null!==b&&p.$setSelection(b),b=c,g=b.getPreviousSibling(),g instanceof x))){var k=b.getFirstChild(),n=g.getChildren();c=n.length;if(null===k)b.append(...n);else for(var m=0;m<c;m++)k.insertBefore(n[m]);m=p.$getSelection();if(null!==m){k=m.anchor;n=k.getNode();m=m.focus;const v=k.getNode();n.is(g)?k.set(b.getKey(), | ||
k.offset,"element"):n.is(b)&&k.set(b.getKey(),c+k.offset,"element");v.is(g)?m.set(b.getKey(),m.offset,"element"):v.is(b)&&m.set(b.getKey(),c+m.offset,"element")}g.remove()}return h=d})} | ||
class x extends p.ElementNode{static getType(){return"overflow"}static clone(a){return new x(a.__key)}constructor(a){super(a);this.__type="overflow"}createDOM(a){const e=document.createElement("div");a=a.theme.characterLimit;"string"===typeof a&&(e.className=a);return e}updateDOM(){return!1}insertNewAfter(a){return this.getParentOrThrow().insertNewAfter(a)}excludeFromCopy(){return!0}}function B(a){const e=new x;a.insertBefore(e);e.append(a);return e} | ||
function A(a){const e=a.getChildren(),f=e.length;for(let h=0;h<f;h++)a.insertBefore(e[h]);a.remove();return 0<f?e[f-1]:null}let C=null; | ||
module.exports=function({charset:a="UTF-16"}){const [e]=l.useLexicalComposerContext(),[f,h]=q.useState(0),d=q.useMemo(()=>({remainingCharacters:h,strlen:c=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var b=null;else null===C&&(C=new window.TextEncoder),b=C;null===b?(b=encodeURIComponent(c).match(/%[89ABab]/g),c=c.length+(b?b.length:0)):c=b.encode(c).length;return c}if("UTF-16"===a)return c.length;throw Error("Unrecognized charset");}}),[a]);w(e,5,d);return q.createElement("span",{className:`characters-limit ${0> | ||
'use strict';var l=require("@lexical/react/LexicalComposerContext"),p=require("lexical"),q=require("react"),r=require("@lexical/react/withSubscriptions"),t=require("lexical/OverflowNode");function u(a,e){for(e(a);null!==a;){if(p.$isElementNode(a)&&0<a.getChildrenSize())a=a.getFirstChild();else{let f=null;for(;null===f&&null!==a;)f=a.getNextSibling(),a=null===f?a.getParent():f}null!==a&&(a=e(a))}}function w(){return p.$getRoot().getTextContent()} | ||
function x(a,e,f=Object.freeze({})){const {strlen:h=c=>c.length,remainingCharacters:d=()=>{}}=f;q.useEffect(()=>{if(!a.hasNodes([t.OverflowNode]))throw Error("useCharacterLimit: OverflowNode not registered on editor");},[a]);q.useEffect(()=>{let c=a.getEditorState().read(w),b=0;return r(a.addListener("textcontent",g=>{c=g}),a.addListener("update",({dirtyLeaves:g})=>{var k=a.isComposing();g=0<g.size;if(!k&&g){k=h(c);g=k>e||null!==b&&b>e;d(e-k);if(null===b||g){const n=y(c,e,h);a.update(()=>{p.$log("CharacterLimit"); | ||
z(n)},{tag:"without-history"})}b=k}}))},[a,e,d,h])}function y(a,e,f){var h=Intl.Segmenter;let d=0;var c=0;if("function"===typeof h){a=(new h).segment(a);for(var {segment:b}of a){c+=f(b);if(c>e)break;d+=b.length}}else for(b=Array.from(a),a=b.length,h=0;h<a;h++){const g=b[h];c+=f(g);if(c>e)break;d+=g.length}return d} | ||
function z(a){const e=p.$getRoot();let f=0,h=e;u(e,d=>{if(t.$isOverflowNode(d)){var c=f;if(f+d.getTextContentSize()<=a){var b=d.getParent();c=d.getPreviousSibling();var g=d.getNextSibling();A(d);d=p.$getSelection();null===d||d.anchor.getNode().isAttached()&&d.focus.getNode().isAttached()||(p.$isTextNode(c)?c.select():p.$isTextNode(g)?g.select():null!==b&&b.select());return h}if(c<a&&(b=d.getFirstDescendant(),g=null!==b?b.getTextContentSize():0,c+=g,b=p.$isTextNode(b)&&b.isSimpleText(),c=c<=a,b||c))return A(d), | ||
h}else if(p.$isLeafNode(d)&&(c=f,f+=d.getTextContentSize(),f>a&&!t.$isOverflowNode(d.getParent())&&(b=p.$getSelection(),c<a&&p.$isTextNode(d)&&d.isSimpleText()?([,c]=d.splitText(a-c),c=B(c)):c=B(d),null!==b&&p.$setSelection(b),b=c,g=b.getPreviousSibling(),t.$isOverflowNode(g)))){var k=b.getFirstChild(),n=g.getChildren();c=n.length;if(null===k)b.append(...n);else for(var m=0;m<c;m++)k.insertBefore(n[m]);m=p.$getSelection();if(null!==m){k=m.anchor;n=k.getNode();m=m.focus;const v=k.getNode();n.is(g)? | ||
k.set(b.getKey(),k.offset,"element"):n.is(b)&&k.set(b.getKey(),c+k.offset,"element");v.is(g)?m.set(b.getKey(),m.offset,"element"):v.is(b)&&m.set(b.getKey(),c+m.offset,"element")}g.remove()}return h=d})}function B(a){const e=t.$createOverflowNode();a.insertBefore(e);e.append(a);return e}function A(a){const e=a.getChildren(),f=e.length;for(let h=0;h<f;h++)a.insertBefore(e[h]);a.remove();return 0<f?e[f-1]:null}let C=null; | ||
module.exports=function({charset:a="UTF-16"}){const [e]=l.useLexicalComposerContext(),[f,h]=q.useState(0),d=q.useMemo(()=>({remainingCharacters:h,strlen:c=>{if("UTF-8"===a){if(void 0===window.TextEncoder)var b=null;else null===C&&(C=new window.TextEncoder),b=C;null===b?(b=encodeURIComponent(c).match(/%[89ABab]/g),c=c.length+(b?b.length:0)):c=b.encode(c).length;return c}if("UTF-16"===a)return c.length;throw Error("Unrecognized charset");}}),[a]);x(e,5,d);return q.createElement("span",{className:`characters-limit ${0> | ||
f?"characters-limit-exceeded":""}`},f)}; |
@@ -1,2 +0,3 @@ | ||
'use strict';var e=require("lexical"),f=require("@lexical/react/LexicalComposerContext"),h=require("react"); | ||
module.exports=function({namespace:k,children:l,initialEditor:m,theme:g}){const c=h.useContext(f.LexicalComposerContext),n=h.useMemo(()=>{if(null!=g)var b=g;else if(null!=c){var d=c[0];var a=c[1].getTheme();null!=a&&(b=a)}d={theme:b||{},namespace:k,parentEditor:d};b=f.createLexicalComposerContext(c,b);a=m||null;null===a?a=e.createEditor({...d,context:b}):a._config={...a._config,...d,context:b};return[a,b]},[g]);return h.createElement(f.LexicalComposerContext.Provider,{value:n},l)}; | ||
'use strict';var e=require("lexical"),f=require("@lexical/react/LexicalComposerContext"),l=require("react");function m(g){throw g;} | ||
module.exports=function({initialConfig:g={},children:n}){const b=l.useContext(f.LexicalComposerContext),u=l.useMemo(()=>{let c,h;const {theme:k,namespace:p,editor:q,nodes:r,onError:t}=g;if(null!=k)c=k;else if(null!=b){h=b[0];var a=b[1].getTheme();null!=a&&(c=a)}a=f.createLexicalComposerContext(b,c);let d=q||null;null===d&&(d=e.createEditor({namespace:p,nodes:r,theme:c,parentEditor:h,context:a}),d.addListener("error",t||m));return[d,a]},[]);return l.createElement(f.LexicalComposerContext.Provider, | ||
{value:u},n)}; |
@@ -1,4 +0,4 @@ | ||
'use strict';var c=require("lexical"),h=require("@lexical/react/LexicalComposerContext"),k=require("react"),l=require("lexical/HashtagNode"),m=RegExp; | ||
const n=String.fromCharCode,p="A-Za-z\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u0241\u0250-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ee\u037a\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03f5\u03f7-\u0481\u048a-\u04ce\u04d0-\u04f9\u0500-\u050f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u064a\u066e-\u066f\u0671-\u06d3\u06d5\u06e5-\u06e6\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u076d\u0780-\u07a5\u07b1\u0904-\u0939\u093d\u0950\u0958-\u0961\u097d\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0-\u0ae1\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edd\u0f00\u0f40-\u0f47\u0f49-\u0f6a\u0f88-\u0f8b\u1000-\u1021\u1023-\u1027\u1029-\u102a\u1050-\u1055\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u1a00-\u1a16\u1d00-\u1dbf\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2131\u2133-\u2139\u213c-\u213f\u2145-\u2149\u2c00-\u2c2e\u2c30-\u2c5e\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312c\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fbb\ua000-\ua48c\ua800-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\uac00-\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc\u0300-\u036f\u0483-\u0486\u0591-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u0615\u064b-\u065e\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u0901-\u0903\u093c\u093e-\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d82-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2-\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f3f\u0f71-\u0f84\u0f86-\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102c-\u1032\u1036-\u1039\u1056-\u1059\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8-\u19c9\u1a17-\u1a1b\u1dc0-\u1dc3\u20d0-\u20dc\u20e1\u20e5-\u20eb\u302a-\u302f\u3099-\u309a\ua802\ua806\ua80b\ua823-\ua827\ufb1e\ufe00-\ufe0f\ufe20-\ufe23\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0750-\u077f\u08a0\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff"+(n(173824)+ | ||
"-"+n(177983)+n(177984)+"-"+n(178207)+n(194560)+"-"+n(195103)+"\u3003\u3005\u303b"),{alpha:q,alphanumeric:r,hashChars:t}={alpha:p,alphanumeric:p+"0-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\uff10-\uff19_",hashChars:"#\\uFF03"},u="["+r+"]",v=new m("(^|$|[^&/"+(r+"])([")+(t+"])(")+u+"*["+(q+"]")+ | ||
u+"*)","ig");function w(a){if(a.isSimpleText())for(var e=a.getTextContent(),d=0;;){var b=v.exec(e);if(null===b)break;const f=b.index+b[1].length-d;b=f+(b[3].length+1);let g;0===f?[g,a]=a.splitText(b):[,g,a]=a.splitText(f,b);d+=b;l.$toggleHashtag(g)}}function x(a){k.useEffect(()=>{const e=a.registerNodes([l.HashtagNode]),d=a.addTransform(c.TextNode,w);return()=>{e();d()}},[a])}module.exports=function(){const [a]=h.useLexicalComposerContext();x(a);return null}; | ||
'use strict';var c=require("lexical"),f=require("@lexical/react/LexicalComposerContext"),g=require("react"),h=require("lexical/HashtagNode"),l=RegExp; | ||
const m=String.fromCharCode,n="A-Za-z\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u0241\u0250-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ee\u037a\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03f5\u03f7-\u0481\u048a-\u04ce\u04d0-\u04f9\u0500-\u050f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u064a\u066e-\u066f\u0671-\u06d3\u06d5\u06e5-\u06e6\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u076d\u0780-\u07a5\u07b1\u0904-\u0939\u093d\u0950\u0958-\u0961\u097d\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc-\u09dd\u09df-\u09e1\u09f0-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0-\u0ae1\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60-\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0-\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60-\u0d61\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edd\u0f00\u0f40-\u0f47\u0f49-\u0f6a\u0f88-\u0f8b\u1000-\u1021\u1023-\u1027\u1029-\u102a\u1050-\u1055\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u1a00-\u1a16\u1d00-\u1dbf\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2131\u2133-\u2139\u213c-\u213f\u2145-\u2149\u2c00-\u2c2e\u2c30-\u2c5e\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312c\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fbb\ua000-\ua48c\ua800-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\uac00-\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc\u0300-\u036f\u0483-\u0486\u0591-\u05b9\u05bb-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u0615\u064b-\u065e\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u0901-\u0903\u093c\u093e-\u094d\u0951-\u0954\u0962-\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7-\u09c8\u09cb-\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a70-\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47-\u0b48\u0b4b-\u0b4d\u0b56-\u0b57\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c82-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5-\u0cd6\u0d02-\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d82-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2-\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f3f\u0f71-\u0f84\u0f86-\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102c-\u1032\u1036-\u1039\u1056-\u1059\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8-\u19c9\u1a17-\u1a1b\u1dc0-\u1dc3\u20d0-\u20dc\u20e1\u20e5-\u20eb\u302a-\u302f\u3099-\u309a\ua802\ua806\ua80b\ua823-\ua827\ufb1e\ufe00-\ufe0f\ufe20-\ufe23\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0100-\u024f\u0253-\u0254\u0256-\u0257\u0259\u025b\u0263\u0268\u026f\u0272\u0289\u028b\u02bb\u0300-\u036f\u1e00-\u1eff\u0400-\u04ff\u0500-\u0527\u2de0-\u2dff\ua640-\ua69f\u0591-\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f4\ufb12-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4f\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06de-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0750-\u077f\u08a0\u08a2-\u08ac\u08e4-\u08fe\ufb50-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\u200c-\u200c\u0e01-\u0e3a\u0e40-\u0e4e\u1100-\u11ff\u3130-\u3185\ua960-\ua97f\uac00-\ud7af\ud7b0-\ud7ff\uffa1-\uffdc\u30a1-\u30fa\u30fc-\u30fe\uff66-\uff9f\uff10-\uff19\uff21-\uff3a\uff41-\uff5a\u3041-\u3096\u3099-\u309e\u3400-\u4dbf\u4e00-\u9fff"+(m(173824)+ | ||
"-"+m(177983)+m(177984)+"-"+m(178207)+m(194560)+"-"+m(195103)+"\u3003\u3005\u303b"),{alpha:p,alphanumeric:q,hashChars:r}={alpha:n,alphanumeric:n+"0-9\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\uff10-\uff19_",hashChars:"#\\uFF03"},t="["+q+"]",u=new l("(^|$|[^&/"+(q+"])([")+(r+"])(")+t+"*["+(p+"]")+ | ||
t+"*)","ig");function v(a){if(a.isSimpleText())for(var w=a.getTextContent(),k=0;;){var b=u.exec(w);if(null===b)break;const d=b.index+b[1].length-k;b=d+(b[3].length+1);let e;0===d?[e,a]=a.splitText(b):[,e,a]=a.splitText(d,b);k+=b;h.$toggleHashtag(e)}}function x(a){g.useEffect(()=>a.addTransform(c.TextNode,v),[a])}module.exports=function(){const [a]=f.useLexicalComposerContext();x(a);return null}; |
@@ -1,7 +0,7 @@ | ||
'use strict';var n=require("@lexical/react/LexicalComposerContext"),r=require("lexical"),v=require("react"),w=require("@lexical/react/withSubscriptions");function x(a,b,f){b=Array.from(b);f=Array.from(f);a=a._nodeMap;const c=[];for(var h=0;h<b.length;h++){const e=a.get(b[h]);void 0!==e&&c.push(e)}for(b=0;b<f.length;b++)f[b][1]&&(h=a.get(f[b][0]),void 0===h||r.$isRootNode(h)||c.push(h));return c} | ||
function y(a,b,f,c,h){if(null===a||0===f.size&&0===c.size)return 0;var e=b._selection,d=a._selection;if(h)return 1;if(null===e||null===d||!d.isCollapsed()||!e.isCollapsed())return 0;f=x(b,f,c);if(0===f.length)return 0;if(1<f.length){b=b._nodeMap;d=b.get(d.anchor.key);const g=b.get(e.anchor.key);return r.$isTextNode(g)&&r.$isElementNode(d)&&!a._nodeMap.has(g.__key)&&1===g.__text.length&&1===e.anchor.offset?f.every(k=>k===g||!r.$isTextNode(k))?2:0:0}b=f[0];a=a._nodeMap.get(b.__key);if(!r.$isTextNode(a)|| | ||
!r.$isTextNode(b)||a.__mode!==b.__mode)return 0;a=a.__text;b=b.__text;if(a===b)return 0;e=e.anchor;d=d.anchor;if(e.key!==d.key||"text"!==e.type)return 0;e=e.offset;d=d.offset;a=b.length-a.length;return 1===a&&d===e-1?2:-1===a&&d===e+1?3:-1===a&&d===e?4:0} | ||
function z(a,b){let f=Date.now(),c=0;return(h,e,d,g,k,m)=>{const p=Date.now();if(m.has("historic"))return c=0,f=p,2;const l=y(h,e,g,k,a.isComposing()),u=(()=>{if(m.has("without-history"))return 0;if(null===h)return 1;var q=e._selection;const t=h._selection;if(!(0<g.size||0<k.size))return null===t&&null!==q?0:2;q=null===d||d.editor===a;return 0!==l&&l===c&&p<f+b&&q?0:1})();f=p;c=l;return u}} | ||
function A(a,b,f=1E3){const c=v.useMemo(()=>b||B(),[b]),h=v.useCallback(()=>{c.undoStack=[];c.redoStack=[];c.current=null},[c]);v.useEffect(()=>{const e=z(a,f);return w(a.addListener("command",d=>{switch(d){case "undo":d=c.redoStack;var g=c.undoStack;if(0!==g.length){var k=c.current;const m=g.pop();null!==k&&(d.push(k),a.execCommand("canRedo",!0));0===g.length&&a.execCommand("canUndo",!1);c.current=m;m.editor.setEditorState(m.editorState.clone(m.undoSelection),{tag:"historic"})}return!0;case "redo":return d= | ||
c.redoStack,g=c.undoStack,0!==d.length&&(k=c.current,null!==k&&(g.push(k),a.execCommand("canUndo",!0)),g=d.pop(),0===d.length&&a.execCommand("canRedo",!1),c.current=g,g.editor.setEditorState(g.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),a.addListener("update",({editorState:d,prevEditorState:g,dirtyLeaves:k,dirtyElements:m,tags:p})=>{const l=c.current,u=c.redoStack,q=c.undoStack,t=null===l?null:l.editorState;if(null===l|| | ||
d!==t){k=e(g,d,l,k,m,p);if(1===k)0!==u.length&&(c.redoStack=[]),null!==l&&(q.push({...l,undoSelection:g.read(r.$getSelection)}),a.execCommand("canUndo",!0));else if(2===k)return;c.current={editor:a,editorState:d}}}))},[h,f,a,c])}function B(){return{current:null,redoStack:[],undoStack:[]}}exports.HistoryPlugin=function({externalHistoryState:a}){const [b]=n.useLexicalComposerContext();A(b,a);return null};exports.createEmptyHistoryState=B; | ||
'use strict';var n=require("@lexical/react/LexicalComposerContext"),r=require("lexical"),v=require("react"),w=require("@lexical/react/withSubscriptions"); | ||
function x(b,d,k,a,h){if(null===b||0===k.size&&0===a.size)return 0;var g=d._selection,c=b._selection;if(h)return 1;if(null===g||null===c||!c.isCollapsed()||!g.isCollapsed())return 0;var e=Array.from(k);a=Array.from(a);k=d._nodeMap;h=[];for(var f=0;f<e.length;f++){const l=k.get(e[f]);void 0!==l&&h.push(l)}for(e=0;e<a.length;e++)a[e][1]&&(f=k.get(a[e][0]),void 0===f||r.$isRootNode(f)||h.push(f));if(0===h.length)return 0;if(1<h.length)return a=d._nodeMap,d=a.get(g.anchor.key),c=a.get(c.anchor.key),d&& | ||
c&&!b._nodeMap.has(d.__key)&&r.$isTextNode(d)&&1===d.__text.length&&1===g.anchor.offset?2:0;d=h[0];b=b._nodeMap.get(d.__key);if(!r.$isTextNode(b)||!r.$isTextNode(d)||b.__mode!==d.__mode)return 0;b=b.__text;d=d.__text;if(b===d)return 0;g=g.anchor;c=c.anchor;if(g.key!==c.key||"text"!==g.type)return 0;g=g.offset;c=c.offset;b=d.length-b.length;return 1===b&&c===g-1?2:-1===b&&c===g+1?3:-1===b&&c===g?4:0} | ||
function y(b,d){let k=Date.now(),a=0;return(h,g,c,e,f,l)=>{const p=Date.now();if(l.has("historic"))return a=0,k=p,2;const m=x(h,g,e,f,b.isComposing()),u=(()=>{if(l.has("without-history"))return 0;if(null===h)return 1;var q=g._selection;const t=h._selection;if(!(0<e.size||0<f.size))return null===t&&null!==q?0:2;q=null===c||c.editor===b;return 0!==m&&m===a&&p<k+d&&q?0:1})();k=p;a=m;return u}} | ||
function z(b,d,k=1E3){const a=v.useMemo(()=>d||A(),[d]),h=v.useCallback(()=>{a.undoStack=[];a.redoStack=[];a.current=null},[a]);v.useEffect(()=>{const g=y(b,k);return w(b.addListener("command",c=>{switch(c){case "undo":c=a.redoStack;var e=a.undoStack;if(0!==e.length){var f=a.current;const l=e.pop();null!==f&&(c.push(f),b.execCommand("canRedo",!0));0===e.length&&b.execCommand("canUndo",!1);a.current=l;l.editor.setEditorState(l.editorState.clone(l.undoSelection),{tag:"historic"})}return!0;case "redo":return c= | ||
a.redoStack,e=a.undoStack,0!==c.length&&(f=a.current,null!==f&&(e.push(f),b.execCommand("canUndo",!0)),e=c.pop(),0===c.length&&b.execCommand("canRedo",!1),a.current=e,e.editor.setEditorState(e.editorState,{tag:"historic"})),!0;case "clearEditor":return h(),!1;case "clearHistory":return h(),!0;default:return!1}},0),b.addListener("update",({editorState:c,prevEditorState:e,dirtyLeaves:f,dirtyElements:l,tags:p})=>{const m=a.current,u=a.redoStack,q=a.undoStack,t=null===m?null:m.editorState;if(null===m|| | ||
c!==t){f=g(e,c,m,f,l,p);if(1===f)0!==u.length&&(a.redoStack=[]),null!==m&&(q.push({...m,undoSelection:e.read(r.$getSelection)}),b.execCommand("canUndo",!0));else if(2===f)return;a.current={editor:b,editorState:c}}}))},[h,k,b,a])}function A(){return{current:null,redoStack:[],undoStack:[]}}exports.HistoryPlugin=function({externalHistoryState:b}){const [d]=n.useLexicalComposerContext();z(d,b);return null};exports.createEmptyHistoryState=A; |
'use strict';var h=require("@lexical/react/LexicalComposerContext"),k=require("react"),m=require("lexical"),n=require("lexical/LinkNode"); | ||
function p(g){var b=m.$getSelection();m.$log("toggleLink");null!==b&&m.$setSelection(b);b=m.$getSelection();if(null!==b)if(b=b.extract(),null===g)b.forEach(c=>{c=c.getParent();if(n.$isLinkNode(c)){const a=c.getChildren();for(let d=0;d<a.length;d++)c.insertBefore(a[d]);c.remove()}});else{let c=null,a=null;if(1===b.length){var f=b[0];if(n.$isLinkNode(f)){f.setURL(g);return}f=f.getParent();if(n.$isLinkNode(f)){a=f;f.setURL(g);return}}b.forEach(d=>{var e=d.getParent();if(e!==a&&null!==e)if(e.is(c)||(c= | ||
e,a=n.$createLinkNode(g),n.$isLinkNode(e)?null===d.getPreviousSibling()?e.insertBefore(a):e.insertAfter(a):d.insertBefore(a)),n.$isLinkNode(d)){if(null!==a){e=d.getChildren();for(let l=0;l<e.length;l++)a.append(e[l])}d.remove()}else null!==a&&a.append(d)})}}module.exports=function(){const [g]=h.useLexicalComposerContext();k.useEffect(()=>{const b=g.addListener("command",(c,a)=>"toggleLink"===c?(p(a),!0):!1,0),f=g.registerNodes([n.LinkNode]);return()=>{b();f()}},[g]);return null}; | ||
function p(g){var b=m.$getSelection();m.$log("toggleLink");null!==b&&m.$setSelection(b);b=m.$getSelection();if(null!==b)if(b=b.extract(),null===g)b.forEach(e=>{e=e.getParent();if(n.$isLinkNode(e)){const a=e.getChildren();for(let c=0;c<a.length;c++)e.insertBefore(a[c]);e.remove()}});else{let e=null,a=null;if(1===b.length){var f=b[0];if(n.$isLinkNode(f)){f.setURL(g);return}f=f.getParent();if(n.$isLinkNode(f)){a=f;f.setURL(g);return}}b.forEach(c=>{var d=c.getParent();if(d!==a&&null!==d)if(d.is(e)||(e= | ||
d,a=n.$createLinkNode(g),n.$isLinkNode(d)?null===c.getPreviousSibling()?d.insertBefore(a):d.insertAfter(a):c.insertBefore(a)),n.$isLinkNode(c)){if(null!==a){d=c.getChildren();for(let l=0;l<d.length;l++)a.append(d[l])}c.remove()}else null!==a&&a.append(c)})}}module.exports=function(){const [g]=h.useLexicalComposerContext();k.useEffect(()=>g.addListener("command",(b,f)=>"toggleLink"===b?(p(f),!0):!1,0),[g]);return null}; |
@@ -1,12 +0,2 @@ | ||
'use strict';var g=require("@lexical/react/LexicalComposerContext"),l=require("react"),m=require("lexical"),p=require("lexical/ListItemNode"),q=require("lexical/ListNode");function r(d){d=d.getParent();if(!q.$isListNode(d))throw Error("Minified Lexical error #2; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");let a=d;for(;null!==a;)a=a.getParent(),q.$isListNode(a)&&(d=a);return d} | ||
function t(d){let a=[];d=d.getChildren().filter(p.$isListItemNode);for(let b=0;b<d.length;b++){const c=d[b],e=c.getFirstChild();q.$isListNode(e)?a=a.concat(t(e)):a.push(c)}return a}function u(d,a){for(;null!=d&&!(d instanceof a);)d=d.getParent();return d} | ||
function v(d){d.update(()=>{m.$log("removeList");var a=m.$getSelection();if(null!==a){const c=new Set,e=a.getNodes();a=a.anchor.getNode();if(0===e.length&&p.$isListItemNode(a))c.add(r(a));else for(a=0;a<e.length;a++){var b=e[a];m.$isLeafNode(b)&&(b=u(b,p.ListItemNode),null!=b&&c.add(r(b)))}c.forEach(f=>{let h=f;t(f).forEach(k=>{if(null!=k){const n=m.$createParagraphNode();n.append(...k.getChildren());h.insertAfter(n);h=n;k.remove()}});f.remove()})}})} | ||
function w(d,a){if(q.$isListNode(d))return d;const b=d.getPreviousSibling(),c=d.getNextSibling(),e=p.$createListItemNode();if(q.$isListNode(b)&&a===b.getTag())return e.append(d),b.append(e),q.$isListNode(c)&&a===c.getTag()&&(b.append(...c.getChildren()),c.remove()),b;if(q.$isListNode(c)&&a===c.getTag())return e.append(d),c.getFirstChildOrThrow().insertBefore(e),c;a=q.$createListNode(a);a.append(e);d.replace(a);e.append(d);return a} | ||
function x(d,a){d.update(()=>{m.$log("formatList");var b=m.$getSelection();if(null!==b){var c=b.getNodes();b=b.anchor.getNode();var e=b.getParent();if(0===c.length)c=q.$createListNode(a),m.$isRootNode(e)?(b.replace(c),b=p.$createListItemNode(),c.append(b)):p.$isListItemNode(b)&&(b=b.getParentOrThrow(),c.append(...b.getChildren()),b.replace(c));else for(b=new Set,e=0;e<c.length;e++){var f=c[e];if(m.$isElementNode(f)&&f.isEmpty()&&!b.has(f.getKey()))w(f,a);else if(m.$isLeafNode(f))for(f=f.getParent();null!= | ||
f;){const k=f.getKey();if(q.$isListNode(f)){if(!b.has(k)){var h=q.$createListNode(a);h.append(...f.getChildren());f.replace(h);b.add(k)}break}else{h=f.getParent();if(m.$isRootNode(h)&&!b.has(k)){b.add(k);w(f,a);break}f=h}}}}})} | ||
function y(d){var a=m.$getSelection();if(null===a)return!1;var b=a.getNodes(),c=[];0===b.length&&b.push(a.anchor.getNode());if(1===b.length){a:{for(b=b[0];null!==b;){if(p.$isListItemNode(b))break a;b=b.getParent()}b=null}null!==b&&(c=[b])}else{c=new Set;for(a=0;a<b.length;a++){const e=b[a];p.$isListItemNode(e)&&c.add(e)}c=Array.from(c)}return 0<c.length?("indent"===d?z(c):A(c),!0):!1}function B(d){return p.$isListItemNode(d)&&q.$isListNode(d.getFirstChild())} | ||
function z(d){d.forEach(a=>{if(!B(a)){var b=a.getParent(),c=a.getNextSibling(),e=a.getPreviousSibling();if(B(c)&&B(e))e=e.getFirstChild(),q.$isListNode(e)&&(e.append(a),a=c.getFirstChild(),q.$isListNode(a)&&(c=a.getChildren(),e.append(...c),a.remove()),e.getChildren().forEach(f=>f.markDirty()));else if(B(c))c=c.getFirstChild(),q.$isListNode(c)&&(e=c.getFirstChild(),null!==e&&e.insertBefore(a),c.getChildren().forEach(f=>f.markDirty()));else if(B(e))c=e.getFirstChild(),q.$isListNode(c)&&(c.append(a), | ||
c.getChildren().forEach(f=>f.markDirty()));else if(q.$isListNode(b)){const f=p.$createListItemNode(),h=q.$createListNode(b.getTag());f.append(h);h.append(a);e?e.insertAfter(f):c?c.insertBefore(f):b.append(f)}q.$isListNode(b)&&b.getChildren().forEach(f=>f.markDirty())}})} | ||
function A(d){d.forEach(a=>{if(!B(a)){var b=a.getParent(),c=b?b.getParent():void 0,e=c?c.getParent():void 0;if(q.$isListNode(e)&&p.$isListItemNode(c)&&q.$isListNode(b)){var f=b?b.getFirstChild():void 0,h=b?b.getLastChild():void 0;if(a.is(f))c.insertBefore(a),b.isEmpty()&&c.remove();else if(a.is(h))c.insertAfter(a),b.isEmpty()&&c.remove();else{var k=b.getTag();f=p.$createListItemNode();const n=q.$createListNode(k);f.append(n);a.getPreviousSiblings().forEach(C=>n.append(C));h=p.$createListItemNode(); | ||
k=q.$createListNode(k);h.append(k);k.append(...a.getNextSiblings());c.insertBefore(f);c.insertAfter(h);c.replace(a)}b.getChildren().forEach(n=>n.markDirty());e.getChildren().forEach(n=>n.markDirty())}}})} | ||
function D(d){l.useEffect(()=>d.addListener("command",a=>{if("indentContent"===a){if(y("indent"))return!0}else if("outdentContent"===a){if(y("outdent"))return!0}else{if("insertOrderedList"===a)return x(d,"ol"),!0;if("insertUnorderedList"===a)return x(d,"ul"),!0;if("removeList"===a)return v(d),!0}return!1},1),[d])}module.exports=function(){const [d]=g.useLexicalComposerContext();D(d);return null}; | ||
'use strict';var b=require("@lexical/react/LexicalComposerContext"),d=require("react"),e=require("@lexical/list");function f(a){d.useEffect(()=>a.addListener("command",c=>{if("indentContent"===c){if(e.indentList())return!0}else if("outdentContent"===c){if(e.outdentList())return!0}else{if("insertOrderedList"===c)return e.insertList(a,"ol"),!0;if("insertUnorderedList"===c)return e.insertList(a,"ul"),!0;if("removeList"===c)return e.removeList(a),!0}return!1},1),[a])} | ||
module.exports=function(){const [a]=b.useLexicalComposerContext();f(a);return null}; |
@@ -1,1 +0,2 @@ | ||
'use strict';var b=require("react"),e=require("@lexical/react/LexicalComposer"),f=require("@lexical/react/LexicalOnChangePlugin");module.exports=function({namespace:g,children:h,initialDecoratorEditor:a,theme:k}){const [c,l]=b.useState(null);b.useEffect(()=>{a.isEmpty()||null===c||a.init(c)},[a,c]);const n=b.useCallback((m,d)=>{m.isEmpty()?l(d):a.set(d)},[a]);return b.createElement(e,{namespace:g,initialEditor:a.editor,theme:k},b.createElement(f,{onChange:n}),h)}; | ||
'use strict';var a=require("react"),f=require("@lexical/react/LexicalComposer"),g=require("@lexical/react/LexicalOnChangePlugin"); | ||
module.exports=function({initialConfig:c={},children:h}){const [d,k]=a.useState(null),{decoratorEditor:b,namespace:l,theme:m,nodes:n,onError:p}=c;a.useEffect(()=>{b.isEmpty()||null===d||b.init(d)},[d]);c=a.useCallback((q,e)=>{q.isEmpty()?k(e):b.set(e)},[]);return a.createElement(f,{initialConfig:{namespace:l,editor:b.editor,nodes:n,theme:m,onError:p}},a.createElement(g,{onChange:c}),h)}; |
@@ -13,2 +13,2 @@ 'use strict';var g=require("react"),h=require("@lexical/react/LexicalComposerContext"),t=require("lexical"),u=require("@lexical/react/withSubscriptions"),w=require("react-dom"); | ||
function L(a){if(!K(a,!1))return!1;a=t.$getRoot().getChildren();const d=a.length;if(1<d)return!1;for(let e=0;e<d;e++){var c=a[e];if(t.$isElementNode(c)){if("paragraph"!==c.__type||0!==c.__indent)return!1;c=c.getChildren();const b=c.length;for(let f=0;f<b;f++)if(!t.$isTextNode(c[e]))return!1}}return!0}function M(a){return()=>L(a)} | ||
function N(a){const [d,c]=g.useState(a.getEditorState().read(M(a.isComposing())));D(()=>a.addListener("update",({editorState:e})=>{const b=a.isComposing();e=e.read(M(b));c(e)}),[a]);return d}function O(a){throw a;}module.exports=function({contentEditable:a,placeholder:d,skipInit:c,onError:e}){const [b]=h.useLexicalComposerContext(),f=N(b);I(b,!c);c=J(b);D(()=>b.addListener("error",e||O),[b,e]);return g.createElement(g.Fragment,null,a,f&&d,c)}; | ||
function N(a){const [d,c]=g.useState(a.getEditorState().read(M(a.isComposing())));D(()=>a.addListener("update",({editorState:e})=>{const b=a.isComposing();e=e.read(M(b));c(e)}),[a]);return d}module.exports=function({contentEditable:a,placeholder:d,skipInit:c}){const [e]=h.useLexicalComposerContext(),b=N(e);I(e,!c);c=J(e);return g.createElement(g.Fragment,null,a,b&&d,c)}; |
@@ -1,27 +0,27 @@ | ||
'use strict';var g=require("react"),v=require("@lexical/react/LexicalComposerContext"),x=require("lexical"),z=require("lexical/HeadingNode"),A=require("lexical/ListNode"),B=require("lexical/QuoteNode"),C=require("lexical/CodeNode"),D=require("lexical/ListItemNode"),E=require("lexical/LinkNode"),F=require("@lexical/react/withSubscriptions"),G=require("react-dom"); | ||
function H(a){g.useEffect(()=>{const c=e=>{var f=a.getRootElement();if(document.activeElement===f&&(f=e.data,"string"===typeof f)){try{var d=JSON.parse(f)}catch(b){return}if(d&&"nuanria_messaging"===d.protocol&&"request"===d.type&&(d=d.payload)&&"makeChanges"===d.functionId&&(d=d.args)){const [b,k,h,l,q]=d;a.update(()=>{x.$log("useLexicalDragonSupport");const m=x.$getSelection();if(null!==m){var n=m.anchor;let r=n.getNode(),p=0,t=0;x.$isTextNode(r)&&0<=b&&0<=k&&(p=b,t=b+k,m.setTextNodeRange(r,p,r, | ||
t));if(p!==t||""!==h)m.insertRawText(h),r=n.getNode();x.$isTextNode(r)&&(p=l,t=l+q,n=r.getTextContentSize(),p=p>n?n:p,t=t>n?n:t,m.setTextNodeRange(r,p,r,t));e.stopImmediatePropagation()}})}}};window.addEventListener("message",c,!0);return()=>{window.removeEventListener("message",c,!0)}},[a])} | ||
function I(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;x.$isElementNode(a)&&x.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):x.$isTextNode(a)&&x.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):x.$isDecoratorNode(a)&&x.$isDecoratorNode(c)&&(c.__state=a.__state);return c} | ||
function J(a,c,e,f,d){for(var b=c;null!==a;){for(c=a.getParent();null!==c&&c.excludeFromCopy();)c=c.getParent();if(null===c)break;if(!x.$isElementNode(a)||!a.excludeFromCopy()){const k=a.getKey();let h=d.get(k);const l=void 0===h;l&&(h=I(a),d.set(k,h));!x.$isTextNode(h)||h.isSegmented()||h.isToken()?x.$isElementNode(h)&&(h.__children=h.__children.slice(e?b:0,e?void 0:b+1)):h.__text=h.__text.slice(e?b:0,e?void 0:b);if(x.$isRootNode(c)){l&&f.push(k);break}}b=d.get(c.getKey());b=x.$isElementNode(b)? | ||
'use strict';var g=require("react"),v=require("@lexical/react/LexicalComposerContext"),x=require("lexical"),z=require("@lexical/list"),A=require("lexical/HeadingNode"),B=require("lexical/LinkNode"),C=require("lexical/CodeNode"),D=require("@lexical/react/withSubscriptions"),E=require("react-dom"); | ||
function F(a){g.useEffect(()=>{const c=f=>{var e=a.getRootElement();if(document.activeElement===e&&(e=f.data,"string"===typeof e)){try{var d=JSON.parse(e)}catch(b){return}if(d&&"nuanria_messaging"===d.protocol&&"request"===d.type&&(d=d.payload)&&"makeChanges"===d.functionId&&(d=d.args)){const [b,k,h,l,q]=d;a.update(()=>{x.$log("useLexicalDragonSupport");const m=x.$getSelection();if(null!==m){var n=m.anchor;let r=n.getNode(),p=0,t=0;x.$isTextNode(r)&&0<=b&&0<=k&&(p=b,t=b+k,m.setTextNodeRange(r,p,r, | ||
t));if(p!==t||""!==h)m.insertRawText(h),r=n.getNode();x.$isTextNode(r)&&(p=l,t=l+q,n=r.getTextContentSize(),p=p>n?n:p,t=t>n?n:t,m.setTextNodeRange(r,p,r,t));f.stopImmediatePropagation()}})}}};window.addEventListener("message",c,!0);return()=>{window.removeEventListener("message",c,!0)}},[a])} | ||
function G(a){a=a.getLatest();const c=a.constructor.clone(a);c.__parent=a.__parent;x.$isElementNode(a)&&x.$isElementNode(c)?(c.__children=Array.from(a.__children),c.__format=a.__format,c.__indent=a.__indent,c.__dir=a.__dir):x.$isTextNode(a)&&x.$isTextNode(c)?(c.__format=a.__format,c.__style=a.__style,c.__mode=a.__mode,c.__detail=a.__detail):x.$isDecoratorNode(a)&&x.$isDecoratorNode(c)&&(c.__state=a.__state);return c} | ||
function H(a,c,f,e,d){for(var b=c;null!==a;){for(c=a.getParent();null!==c&&c.excludeFromCopy();)c=c.getParent();if(null===c)break;if(!x.$isElementNode(a)||!a.excludeFromCopy()){const k=a.getKey();let h=d.get(k);const l=void 0===h;l&&(h=G(a),d.set(k,h));!x.$isTextNode(h)||h.isSegmented()||h.isToken()?x.$isElementNode(h)&&(h.__children=h.__children.slice(f?b:0,f?void 0:b+1)):h.__text=h.__text.slice(f?b:0,f?void 0:b);if(x.$isRootNode(c)){l&&e.push(k);break}}b=d.get(c.getKey());b=x.$isElementNode(b)? | ||
b.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=c}} | ||
const K={ul:()=>({node:A.$createListNode("ul")}),ol:()=>({node:A.$createListNode("ol")}),li:()=>({node:D.$createListItemNode()}),h1:()=>({node:z.$createHeadingNode("h1")}),h2:()=>({node:z.$createHeadingNode("h2")}),h3:()=>({node:z.$createHeadingNode("h3")}),h4:()=>({node:z.$createHeadingNode("h4")}),h5:()=>({node:z.$createHeadingNode("h5")}),p:()=>({node:x.$createParagraphNode()}),br:()=>({node:x.$createLineBreakNode()}),a:a=>({node:a instanceof HTMLAnchorElement?E.$createLinkNode(a.href):x.$createTextNode(a.textContent)}), | ||
u:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("underline")}}),b:a=>{const c="normal"===a.style.fontWeight;return{node:null,forChild:e=>{x.$isTextNode(e)&&!c&&e.toggleFormat("bold")}}},strong:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("bold")}}),i:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("italic")}}),em:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("italic")}}),td:a=>{const c=a.classList.contains("js-file-line");return{node:null, | ||
after:e=>{c&&a.parentNode&&a.parentNode.nextSibling&&e.push(x.$createLineBreakNode());return e}}},table:a=>({node:a.classList.contains("js-file-line-container")?C.$createCodeNode():null}),span:a=>{const c="700"===a.style.fontWeight;return{node:null,forChild:e=>{x.$isTextNode(e)&&c&&e.toggleFormat("bold")}}},"#text":a=>({node:x.$createTextNode(a.textContent)}),pre:()=>({node:C.$createCodeNode()}),div:a=>({node:null!==a.style.fontFamily.match("monospace")?C.$createCodeNode():null,after:c=>{const e= | ||
a.parentNode;null!=e&&a!==e.lastChild&&c.push(x.$createLineBreakNode());return c}})}; | ||
function L(a,c,e,f=new Map){let d=[],b=null;var k=a.nodeName.toLowerCase(),h=(e._config.htmlTransforms||{})[k]||c[k],l=h?h(a):null;h=null;if(null!==l){h=l.after;b=l.node;if(null!==b){d.push(b);const q=Array.from(f.values());for(let m=0;m<q.length;m++)q[m](b)}null!=l.forChild&&f.set(k,l.forChild)}a=a.childNodes;k=[];for(l=0;l<a.length;l++)k.push(...L(a[l],c,e,f));null!=h&&(k=h(k));null==b?d=d.concat(k):x.$isElementNode(b)&&b.append(...k);return d} | ||
function M(a,c,e){var f=a.getData("application/x-lexical-editor");if(f){var d=e._config.namespace;try{const l=JSON.parse(f);if(l.namespace===d){const {range:q,nodeMap:m}=l.state;var b=new Map(m);f=[];for(d=0;d<q.length;d++){var k=b.get(q[d]);if(void 0!==k){var h=x.$createNodeFromParse(k,b);f.push(h)}}c.insertNodes(f);return}}catch(l){}}if(b=a.getData("text/html")){b=(new DOMParser).parseFromString(b,"text/html");a=[];b=b.body?Array.from(b.body.childNodes):[];k=b.length;for(h=0;h<k;h++)f=L(b[h],K, | ||
e),null!==f&&(a=a.concat(f));e=a;a=[];b=null;for(k=0;k<e.length;k++)h=e[k],!x.$isElementNode(h)||h.isInline()?(null===b&&(b=x.$createParagraphNode(),a.push(b)),null!==b&&b.append(h)):(a.push(h),b=null);c.insertNodes(a)}else e=a.getData("text/plain"),null!=e&&c.insertRawText(e)} | ||
function N(a,c){var e=a.focus;a=e.offset;"element"===e.type?c=e.getNode().getChildAtIndex(c?a-1:a):(e=e.getNode(),c=c&&0===a||!c&&a===e.getTextContentSize()?c?e.getPreviousSibling():e.getNextSibling():null);return x.$isDecoratorNode(c)}function O(a,c){a.preventDefault();c.update(()=>{x.$log("onPasteForRichText");const e=x.$getSelection(),f=a.clipboardData;null!=f&&null!==e&&M(f,e,c)})} | ||
function P(a,c){Q(a,c);c.update(()=>{x.$log("onCutForRichText");const e=x.$getSelection();null!==e&&e.removeText()})} | ||
function Q(a,c){a.preventDefault();c.update(()=>{x.$log("onCopyForRichText");const e=a.clipboardData;var f=x.$getSelection();if(null!==f&&null!=e){var d=window.getSelection();if(!d.isCollapsed){var b=d.getRangeAt(0);b&&(d=document.createElement("div"),b=b.cloneContents(),d.appendChild(b),e.setData("text/html",d.innerHTML));e.setData("text/plain",f.getTextContent());d=c._config.namespace;b=e.setData;var k=JSON,h=k.stringify;{var l=f.anchor,q=f.focus;var m=l.getCharacterOffset();const y=q.getCharacterOffset(); | ||
var n=l.getNode(),r=q.getNode(),p=n.getParentOrThrow();if(n===r&&x.$isTextNode(n)&&(p.canBeEmpty()||1<p.getChildrenSize()))f=I(n),n=y>m,f.__text=f.__text.slice(n?m:y,n?y:m),m=f.getKey(),m={range:[m],nodeMap:[[m,f]]};else if(f=f.getNodes(),0===f.length)m={range:[],nodeMap:[]};else{n=f.length;r=f[0];p=r.getParent();if(null!==p&&!p.canBeEmpty()){var t=p.__children;if(t.length===n){var u=!0;for(var w=0;w<t.length;w++)if(t[w]!==f[w].__key){u=!1;break}u&&(n++,f.push(p))}}p=f[n-1];l=l.isBefore(q);q=new Map; | ||
t=[];J(r,l?m:y,!0,t,q);for(r=0;r<n;r++)if(u=f[r],w=u.getKey(),!(q.has(w)||x.$isElementNode(u)&&u.excludeFromCopy())){const U=I(u);x.$isRootNode(u.getParent())&&t.push(u.getKey());q.set(w,U)}J(p,l?y:m,!1,t,q);m={range:t,nodeMap:Array.from(q.entries())}}}b.call(e,"application/x-lexical-editor",h.call(k,{namespace:d,state:m}))}}})}var R="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect; | ||
function S(a,c){const e=x.$createParagraphNode();a.append(e);a=document.activeElement;(null!==x.$getSelection()||null!==a&&a===c.getRootElement())&&e.select()}function T(a){a.update(()=>{x.$log("initEditor");const c=x.$getRoot();null===c.getFirstChild()&&S(c,a)})}function V(a,c){a.update(()=>{x.$log("clearEditor");const e=x.$getRoot();e.clear();S(e,a)},{onUpdate:c})} | ||
function W(a,c){R(()=>{const e=F(a.registerNodes([z.HeadingNode,A.ListNode,B.QuoteNode,C.CodeNode,D.ListItemNode]),a.addListener("command",(f,d)=>{var b=x.$getSelection();if(null===b)return!1;switch(f){case "deleteCharacter":return b.deleteCharacter(d),!0;case "deleteWord":return b.deleteWord(d),!0;case "deleteLine":return b.deleteLine(d),!0;case "insertText":return"string"===typeof d?b.insertText(d):(f=d.dataTransfer,null!=f?M(f,b,a):(d=d.data)&&b.insertText(d)),!0;case "removeText":return b.removeText(), | ||
!0;case "formatText":return b.formatText(d),!0;case "formatElement":return b=b.anchor.getNode(),(x.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(d),!0;case "insertLineBreak":return b.insertLineBreak(d),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor, | ||
d=b.getNode(),f="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),f.canInsertTab()?"\t"===d.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==f.getIndent()&&f.setIndent(f.getIndent()-1),!0;case "keyArrowLeft":f=d.shiftKey;if(N(b,!0))return d.preventDefault(),d=f,f="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(),b.modify(d?"extend":"move",!f,"character"),!0;break;case "keyArrowRight":f=d.shiftKey;if(N(b,!1))return d.preventDefault(),d=f,f="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(), | ||
b.modify(d?"extend":"move",f,"character"),!0;break;case "keyBackspace":return d.preventDefault(),{anchor:d}=b,b.isCollapsed()&&0===d.offset&&0<("element"===d.type?d.getNode():d.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return d.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return d.preventDefault(),d.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return d.preventDefault(), | ||
a.execCommand(d.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),!0;case "clearEditor":V(a);break;case "copy":return Q(d,a),!0;case "cut":return P(d,a),!0;case "paste":return O(d,a),!0;case "drop":case "dragstart":return d.preventDefault(),!0}return!1},0));c&&T(a);return e},[a,c]);H(a)} | ||
function X(a){const [c,e]=g.useState(()=>a.getDecorators());R(()=>a.addListener("decorator",f=>{G.flushSync(()=>{e(f)})}),[a]);return g.useMemo(()=>{const f=[],d=Object.keys(c);for(let k=0;k<d.length;k++){var b=d[k];const h=c[b];b=a.getElementByKey(b);null!==b&&f.push(G.createPortal(h,b))}return f},[c,a])}function Y(a,c=!0){if(a)return!1;a=x.$getRoot().getTextContent();c&&(a=a.trim());return""===a} | ||
function aa(a){if(!Y(a,!1))return!1;a=x.$getRoot().getChildren();const c=a.length;if(1<c)return!1;for(let f=0;f<c;f++){var e=a[f];if(x.$isElementNode(e)){if("paragraph"!==e.__type||0!==e.__indent)return!1;e=e.getChildren();const d=e.length;for(let b=0;b<d;b++)if(!x.$isTextNode(e[f]))return!1}}return!0}function Z(a){return()=>aa(a)} | ||
function ba(a){const [c,e]=g.useState(a.getEditorState().read(Z(a.isComposing())));R(()=>a.addListener("update",({editorState:f})=>{const d=a.isComposing();f=f.read(Z(d));e(f)}),[a]);return c}function ca(a){throw a;}module.exports=function({contentEditable:a,placeholder:c,skipInit:e,onError:f}){const [d]=v.useLexicalComposerContext(),b=ba(d);W(d,!e);e=X(d);R(()=>d.addListener("error",f||ca),[d,f]);return g.createElement(g.Fragment,null,a,b&&c,e)}; | ||
const I={ul:()=>({node:z.$createListNode("ul")}),ol:()=>({node:z.$createListNode("ol")}),li:()=>({node:z.$createListItemNode()}),h1:()=>({node:A.$createHeadingNode("h1")}),h2:()=>({node:A.$createHeadingNode("h2")}),h3:()=>({node:A.$createHeadingNode("h3")}),h4:()=>({node:A.$createHeadingNode("h4")}),h5:()=>({node:A.$createHeadingNode("h5")}),p:()=>({node:x.$createParagraphNode()}),br:()=>({node:x.$createLineBreakNode()}),a:a=>({node:a instanceof HTMLAnchorElement?B.$createLinkNode(a.href):x.$createTextNode(a.textContent)}), | ||
u:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("underline")}}),b:a=>{const c="normal"===a.style.fontWeight;return{node:null,forChild:f=>{x.$isTextNode(f)&&!c&&f.toggleFormat("bold")}}},strong:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("bold")}}),i:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("italic")}}),em:()=>({node:null,forChild:a=>{x.$isTextNode(a)&&a.toggleFormat("italic")}}),td:a=>{const c=a.classList.contains("js-file-line");return{node:null, | ||
after:f=>{c&&a.parentNode&&a.parentNode.nextSibling&&f.push(x.$createLineBreakNode());return f}}},table:a=>({node:a.classList.contains("js-file-line-container")?C.$createCodeNode():null}),span:a=>{const c="700"===a.style.fontWeight;return{node:null,forChild:f=>{x.$isTextNode(f)&&c&&f.toggleFormat("bold")}}},"#text":a=>({node:x.$createTextNode(a.textContent)}),pre:()=>({node:C.$createCodeNode()}),div:a=>({node:null!==a.style.fontFamily.match("monospace")?C.$createCodeNode():null,after:c=>{const f= | ||
a.parentNode;null!=f&&a!==f.lastChild&&c.push(x.$createLineBreakNode());return c}})}; | ||
function J(a,c,f,e=new Map){let d=[],b=null;var k=a.nodeName.toLowerCase(),h=(f._config.htmlTransforms||{})[k]||c[k],l=h?h(a):null;h=null;if(null!==l){h=l.after;b=l.node;if(null!==b){d.push(b);const q=Array.from(e.values());for(let m=0;m<q.length;m++)q[m](b)}null!=l.forChild&&e.set(k,l.forChild)}a=a.childNodes;k=[];for(l=0;l<a.length;l++)k.push(...J(a[l],c,f,e));null!=h&&(k=h(k));null==b?d=d.concat(k):x.$isElementNode(b)&&b.append(...k);return d} | ||
function K(a,c,f){var e=a.getData("application/x-lexical-editor");if(e){var d=f._config.namespace;try{const l=JSON.parse(e);if(l.namespace===d){const {range:q,nodeMap:m}=l.state;var b=new Map(m);e=[];for(d=0;d<q.length;d++){var k=b.get(q[d]);if(void 0!==k){var h=x.$createNodeFromParse(k,b);e.push(h)}}c.insertNodes(e);return}}catch(l){}}if(b=a.getData("text/html")){b=(new DOMParser).parseFromString(b,"text/html");a=[];b=b.body?Array.from(b.body.childNodes):[];k=b.length;for(h=0;h<k;h++)e=J(b[h],I, | ||
f),null!==e&&(a=a.concat(e));f=a;a=[];b=null;for(k=0;k<f.length;k++)h=f[k],!x.$isElementNode(h)||h.isInline()?(null===b&&(b=x.$createParagraphNode(),a.push(b)),null!==b&&b.append(h)):(a.push(h),b=null);c.insertNodes(a)}else f=a.getData("text/plain"),null!=f&&c.insertRawText(f)} | ||
function L(a,c){var f=a.focus;a=f.offset;"element"===f.type?c=f.getNode().getChildAtIndex(c?a-1:a):(f=f.getNode(),c=c&&0===a||!c&&a===f.getTextContentSize()?c?f.getPreviousSibling():f.getNextSibling():null);return x.$isDecoratorNode(c)}function M(a,c){a.preventDefault();c.update(()=>{x.$log("onPasteForRichText");const f=x.$getSelection(),e=a.clipboardData;null!=e&&null!==f&&K(e,f,c)})} | ||
function N(a,c){O(a,c);c.update(()=>{x.$log("onCutForRichText");const f=x.$getSelection();null!==f&&f.removeText()})} | ||
function O(a,c){a.preventDefault();c.update(()=>{x.$log("onCopyForRichText");const f=a.clipboardData;var e=x.$getSelection();if(null!==e&&null!=f){var d=window.getSelection();if(!d.isCollapsed){var b=d.getRangeAt(0);b&&(d=document.createElement("div"),b=b.cloneContents(),d.appendChild(b),f.setData("text/html",d.innerHTML));f.setData("text/plain",e.getTextContent());d=c._config.namespace;b=f.setData;var k=JSON,h=k.stringify;{var l=e.anchor,q=e.focus;var m=l.getCharacterOffset();const y=q.getCharacterOffset(); | ||
var n=l.getNode(),r=q.getNode(),p=n.getParentOrThrow();if(n===r&&x.$isTextNode(n)&&(p.canBeEmpty()||1<p.getChildrenSize()))e=G(n),n=y>m,e.__text=e.__text.slice(n?m:y,n?y:m),m=e.getKey(),m={range:[m],nodeMap:[[m,e]]};else if(e=e.getNodes(),0===e.length)m={range:[],nodeMap:[]};else{n=e.length;r=e[0];p=r.getParent();if(null!==p&&!p.canBeEmpty()){var t=p.__children;if(t.length===n){var u=!0;for(var w=0;w<t.length;w++)if(t[w]!==e[w].__key){u=!1;break}u&&(n++,e.push(p))}}p=e[n-1];l=l.isBefore(q);q=new Map; | ||
t=[];H(r,l?m:y,!0,t,q);for(r=0;r<n;r++)if(u=e[r],w=u.getKey(),!(q.has(w)||x.$isElementNode(u)&&u.excludeFromCopy())){const S=G(u);x.$isRootNode(u.getParent())&&t.push(u.getKey());q.set(w,S)}H(p,l?y:m,!1,t,q);m={range:t,nodeMap:Array.from(q.entries())}}}b.call(f,"application/x-lexical-editor",h.call(k,{namespace:d,state:m}))}}})}var P="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect; | ||
function Q(a,c){const f=x.$createParagraphNode();a.append(f);a=document.activeElement;(null!==x.$getSelection()||null!==a&&a===c.getRootElement())&&f.select()}function R(a){a.update(()=>{x.$log("initEditor");const c=x.$getRoot();null===c.getFirstChild()&&Q(c,a)})}function T(a,c){a.update(()=>{x.$log("clearEditor");const f=x.$getRoot();f.clear();Q(f,a)},{onUpdate:c})} | ||
function U(a,c){P(()=>{const f=D(a.addListener("command",(e,d)=>{var b=x.$getSelection();if(null===b)return!1;switch(e){case "deleteCharacter":return b.deleteCharacter(d),!0;case "deleteWord":return b.deleteWord(d),!0;case "deleteLine":return b.deleteLine(d),!0;case "insertText":return"string"===typeof d?b.insertText(d):(e=d.dataTransfer,null!=e?K(e,b,a):(d=d.data)&&b.insertText(d)),!0;case "removeText":return b.removeText(),!0;case "formatText":return b.formatText(d),!0;case "formatElement":return b= | ||
b.anchor.getNode(),(x.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(d),!0;case "insertLineBreak":return b.insertLineBreak(d),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor,d=b.getNode(),e="element"===b.type?b.getNode():b.getNode().getParentOrThrow(), | ||
e.canInsertTab()?"\t"===d.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==e.getIndent()&&e.setIndent(e.getIndent()-1),!0;case "keyArrowLeft":e=d.shiftKey;if(L(b,!0))return d.preventDefault(),d=e,e="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(),b.modify(d?"extend":"move",!e,"character"),!0;break;case "keyArrowRight":e=d.shiftKey;if(L(b,!1))return d.preventDefault(),d=e,e="rtl"===b.anchor.getNode().getParentOrThrow().getDirection(),b.modify(d?"extend":"move",e,"character"), | ||
!0;break;case "keyBackspace":return d.preventDefault(),{anchor:d}=b,b.isCollapsed()&&0===d.offset&&0<("element"===d.type?d.getNode():d.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return d.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return d.preventDefault(),d.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return d.preventDefault(),a.execCommand(d.shiftKey? | ||
"outdentContent":"indentContent");case "keyEscape":return a.blur(),!0;case "clearEditor":T(a);break;case "copy":return O(d,a),!0;case "cut":return N(d,a),!0;case "paste":return M(d,a),!0;case "drop":case "dragstart":return d.preventDefault(),!0}return!1},0));c&&R(a);return f},[a,c]);F(a)} | ||
function V(a){const [c,f]=g.useState(()=>a.getDecorators());P(()=>a.addListener("decorator",e=>{E.flushSync(()=>{f(e)})}),[a]);return g.useMemo(()=>{const e=[],d=Object.keys(c);for(let k=0;k<d.length;k++){var b=d[k];const h=c[b];b=a.getElementByKey(b);null!==b&&e.push(E.createPortal(h,b))}return e},[c,a])}function W(a,c=!0){if(a)return!1;a=x.$getRoot().getTextContent();c&&(a=a.trim());return""===a} | ||
function X(a){if(!W(a,!1))return!1;a=x.$getRoot().getChildren();const c=a.length;if(1<c)return!1;for(let e=0;e<c;e++){var f=a[e];if(x.$isElementNode(f)){if("paragraph"!==f.__type||0!==f.__indent)return!1;f=f.getChildren();const d=f.length;for(let b=0;b<d;b++)if(!x.$isTextNode(f[e]))return!1}}return!0}function Y(a){return()=>X(a)} | ||
function Z(a){const [c,f]=g.useState(a.getEditorState().read(Y(a.isComposing())));P(()=>a.addListener("update",({editorState:e})=>{const d=a.isComposing();e=e.read(Y(d));f(e)}),[a]);return c}module.exports=function({contentEditable:a,placeholder:c,skipInit:f}){const [e]=v.useLexicalComposerContext(),d=Z(e);U(e,!f);f=V(e);return g.createElement(g.Fragment,null,a,d&&c,f)}; |
@@ -1,3 +0,3 @@ | ||
'use strict';var c=require("react"),k=require("@lexical/react/LexicalComposerContext"),l=require("lexical"),m=require("lexical/TableNode"),q=require("lexical/TableCellNode"),r=require("lexical/TableRowNode");function t(d,g,h=!0){const a=m.$createTableNode();for(let b=0;b<d;b++){const e=r.$createTableRowNode();for(let f=0;f<g;f++){const n=q.$createTableCellNode(0===b&&h),p=l.$createParagraphNode();p.append(l.$createTextNode());n.append(p);e.append(n)}a.append(e)}return a} | ||
module.exports=function(){const [d]=k.useLexicalComposerContext();c.useEffect(()=>{const g=d.addListener("command",(a,b)=>{if("insertTable"===a){const {columns:e,rows:f}=b;l.$log("handleAddTable");a=l.$getSelection();if(null===a)return!0;a=a.focus.getNode();null!==a&&(a=a.getTopLevelElementOrThrow(),b=t(f,e),a.insertAfter(b),b.insertAfter(l.$createParagraphNode()),b.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0}return!1},0),h=d.registerNodes([m.TableNode,q.TableCellNode,r.TableRowNode]); | ||
return()=>{g();h()}},[d]);return null}; | ||
'use strict';var c=require("react"),g=require("@lexical/react/LexicalComposerContext"),h=require("lexical"),k=require("lexical/TableNode"),q=require("lexical/TableRowNode"),r=require("lexical/TableCellNode");function t(d,a,b=!0){const f=k.$createTableNode();for(let e=0;e<d;e++){const l=q.$createTableRowNode();for(let m=0;m<a;m++){const n=r.$createTableCellNode(0===e&&b),p=h.$createParagraphNode();p.append(h.$createTextNode());n.append(p);l.append(n)}f.append(l)}return f} | ||
module.exports=function(){const [d]=g.useLexicalComposerContext();c.useEffect(()=>{if(!d.hasNodes([k.TableNode,r.TableCellNode,q.TableRowNode]))throw Error("TablePlugin: TableNode, TableCellNode or TableRowNode not registered on editor");return d.addListener("command",(a,b)=>{if("insertTable"===a){const {columns:f,rows:e}=b;h.$log("handleAddTable");a=h.$getSelection();if(null===a)return!0;a=a.focus.getNode();null!==a&&(a=a.getTopLevelElementOrThrow(),b=t(e,f),a.insertAfter(b),b.insertAfter(h.$createParagraphNode()), | ||
b.getFirstChildOrThrow().getFirstChildOrThrow().select());return!0}return!1},0)},[d]);return null}; |
'use strict';var k=require("lexical"),q=require("react");const w=Object.freeze({"\n":"\\n","\t":"\\t"}),D=new RegExp(Object.keys(w).join("|"),"g"),E=Object.freeze({hasNextSibling:"\u251c",isLastChild:"\u2514",ancestorHasNextSibling:"|",ancestorIsLastChild:" ",selectedChar:"^",selectedLine:">"}); | ||
function F(a){let b="";const c=G(a),g=a.anchor;a=a.focus;const d=g.offset,e=a.offset;b=b+`${""!==c?" - "+c:""}`+`\n \u251c anchor { key: ${g.key}, offset: ${null===d?"null":d}, type: ${g.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===e?"null":e}, type: ${a.type} }`} | ||
function H(a){let b=" root\n";a=a.read(()=>{const c=k.$getSelection();J(k.$getRoot(),(g,d)=>{const e=`(${g.getKey()})`,f=g.getType()||"",m=g.isSelected();var v=b,t=m?E.selectedLine:" ",r=d.join(" ");if(k.$isTextNode(g)){var n=g.getTextContent(!0);n=0===n.length?"(empty)":`"${K(n)}"`;const l=L(g);n=[n,0!==l.length?`- ${l}`:null].filter(Boolean).join(" ").trim()}else n="";b=v+`${t} ${r} ${e} ${f} ${n}\n`;b+=M({isSelected:m,indent:d,node:g,nodeKeyDisplay:e,selection:c,typeDisplay:f})});return null=== | ||
c?": null":F(c)});return b+"\n selection"+a}function J(a,b,c=[]){a=a.getChildren();const g=a.length;a.forEach((d,e)=>{b(d,c.concat(e===g-1?E.isLastChild:E.hasNextSibling));k.$isElementNode(d)&&J(d,b,c.concat(e===g-1?E.ancestorIsLastChild:E.ancestorHasNextSibling))})}function K(a){return Object.entries(w).reduce((b,[c,g])=>b.replace(new RegExp(c,"g"),String(g)),a)} | ||
const N=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("underline")&&"Underline"],O=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert",a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"];function L(a){return[...N,...O].map(b=>b(a)).filter(Boolean).join(", ")}function G(a){return N.map(b=>b(a)).filter(Boolean).join(", ")} | ||
function M({indent:a,isSelected:b,node:c,nodeKeyDisplay:g,selection:d,typeDisplay:e}){if(!k.$isTextNode(c)||null===d||!b||k.$isElementNode(c))return"";b=d.anchor;var f=d.focus;if(""===c.getTextContent()||b.getNode()===d.focus.getNode()&&b.offset===f.offset)return"";f=d.anchor;const m=d.focus,v=c.getTextContent(!0),t=v.length;b=d=-1;if("text"===f.type&&"text"===m.type){const l=f.getNode(),u=m.getNode();l===u&&c===l&&f.offset!==m.offset?[d,b]=f.offset<m.offset?[f.offset,m.offset]:[m.offset,f.offset]: | ||
c===l?[d,b]=l.isBefore(u)?[f.offset,t]:[0,f.offset]:c===u?[d,b]=u.isBefore(l)?[m.offset,t]:[0,m.offset]:[d,b]=[0,t]}c=(v.slice(0,d).match(D)||[]).length;f=(v.slice(d,b).match(D)||[]).length;const [r,n]=[d+c,b+c+f];if(r===n)return"";c=a[a.length-1]===E.hasNextSibling?E.ancestorHasNextSibling:E.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(r).fill(" ");d=Array(n-r).fill(E.selectedChar);g=Array(g.length+(e.length+3)).fill(" ");return[E.selectedLine,a.join(" "),[...g,...c,...d].join("")].join(" ")+ | ||
function F(a){let b="";const c=G(a),e=a.anchor;a=a.focus;const d=e.offset,f=a.offset;b=b+`: range ${""!==c?`{ ${c} }`:""}`+`\n \u251c anchor { key: ${e.key}, offset: ${null===d?"null":d}, type: ${e.type} }`;return b+=`\n \u2514 focus { key: ${a.key}, offset: ${null===f?"null":f}, type: ${a.type} }`} | ||
function H(a){let b=" root\n";a=a.read(()=>{const c=k.$getSelection();J(k.$getRoot(),(e,d)=>{const f=`(${e.getKey()})`,g=e.getType()||"",m=e.isSelected();var v=b,t=m?E.selectedLine:" ",r=d.join(" ");if(k.$isTextNode(e)){var l=e.getTextContent(!0);const n=0===l.length?"(empty)":`"${K(l)}"`;l=[G(e),L(e),M(e)].filter(Boolean).join(", ");l=[n,0!==l.length?`{ ${l} }`:null].filter(Boolean).join(" ").trim()}else l="";b=v+`${t} ${r} ${f} ${g} ${l}\n`;b+=N({isSelected:m,indent:d,node:e,nodeKeyDisplay:f,selection:c, | ||
typeDisplay:g})});return null===c?": null":F(c)});return b+"\n selection"+a}function J(a,b,c=[]){a=a.getChildren();const e=a.length;a.forEach((d,f)=>{b(d,c.concat(f===e-1?E.isLastChild:E.hasNextSibling));k.$isElementNode(d)&&J(d,b,c.concat(f===e-1?E.ancestorIsLastChild:E.ancestorHasNextSibling))})}function K(a){return Object.entries(w).reduce((b,[c,e])=>b.replace(new RegExp(c,"g"),String(e)),a)} | ||
const O=[a=>a.hasFormat("bold")&&"Bold",a=>a.hasFormat("code")&&"Code",a=>a.hasFormat("italic")&&"Italic",a=>a.hasFormat("strikethrough")&&"Strikethrough",a=>a.hasFormat("underline")&&"Underline"],P=[a=>a.isDirectionless()&&"Directionless",a=>a.isUnmergeable()&&"Unmergeable"],Q=[a=>a.isToken()&&"Token",a=>a.isSegmented()&&"Segmented",a=>a.isInert()&&"Inert"];function L(a){let b=P.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="detail: "+b);return b} | ||
function M(a){let b=Q.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="mode: "+b);return b}function G(a){let b=O.map(c=>c(a)).filter(Boolean).join(", ").toLocaleLowerCase();""!==b&&(b="format: "+b);return b} | ||
function N({indent:a,isSelected:b,node:c,nodeKeyDisplay:e,selection:d,typeDisplay:f}){if(!k.$isTextNode(c)||null===d||!b||k.$isElementNode(c))return"";b=d.anchor;var g=d.focus;if(""===c.getTextContent()||b.getNode()===d.focus.getNode()&&b.offset===g.offset)return"";g=d.anchor;const m=d.focus,v=c.getTextContent(!0),t=v.length;b=d=-1;if("text"===g.type&&"text"===m.type){const n=g.getNode(),u=m.getNode();n===u&&c===n&&g.offset!==m.offset?[d,b]=g.offset<m.offset?[g.offset,m.offset]:[m.offset,g.offset]: | ||
c===n?[d,b]=n.isBefore(u)?[g.offset,t]:[0,g.offset]:c===u?[d,b]=u.isBefore(n)?[m.offset,t]:[0,m.offset]:[d,b]=[0,t]}c=(v.slice(0,d).match(D)||[]).length;g=(v.slice(d,b).match(D)||[]).length;const [r,l]=[d+c,b+c+g];if(r===l)return"";c=a[a.length-1]===E.hasNextSibling?E.ancestorHasNextSibling:E.ancestorIsLastChild;a=[...a.slice(0,a.length-1),c];c=Array(r).fill(" ");d=Array(l-r).fill(E.selectedChar);e=Array(e.length+(f.length+3)).fill(" ");return[E.selectedLine,a.join(" "),[...e,...c,...d].join("")].join(" ")+ | ||
"\n"} | ||
module.exports=function({timeTravelButtonClassName:a,timeTravelPanelSliderClassName:b,timeTravelPanelButtonClassName:c,viewClassName:g,timeTravelPanelClassName:d,editor:e}){const [f,m]=q.useState([]),[v,t]=q.useState(""),[r,n]=q.useState(!1),l=q.useRef(0),u=q.useRef(null),B=q.useRef(null),[z,C]=q.useState(!1);q.useEffect(()=>{t(H(e.getEditorState()));return e.addListener("update",({editorState:h})=>{const p=e._compositionKey,x=H(e.getEditorState());t([x,null!==p&&`Composition key: ${p}`].filter(Boolean).join("\n\n"));r|| | ||
m(A=>[...A,[Date.now(),h]])})},[r,e]);const y=f.length;q.useEffect(()=>{if(z){let h;const p=()=>{const x=l.current;x===y-1?C(!1):h=setTimeout(()=>{l.current++;const A=l.current,I=B.current;null!==I&&(I.value=String(A));e.setEditorState(f[A][1]);p()},f[x+1][0]-f[x][0])};p();return()=>{window.clearTimeout(h)}}},[f,z,e,y]);q.useEffect(()=>{u.current&&(u.current.__lexicalEditor=e)},[e]);return q.createElement("div",{className:g},!r&&2<y&&q.createElement("button",{onClick:()=>{const h=e.getRootElement(); | ||
null!==h&&(h.contentEditable="false",l.current=y-1,n(!0))},className:a},"Time Travel"),q.createElement("pre",{ref:u},v),r&&q.createElement("div",{className:d},q.createElement("button",{className:c,onClick:()=>{C(!z)}},z?"Pause":"Play"),q.createElement("input",{className:b,ref:B,onChange:h=>{h=Number(h.target.value);const p=f[h];p&&(l.current=h,e.setEditorState(p[1]))},type:"range",min:"1",max:y-1}),q.createElement("button",{className:c,onClick:()=>{var h=e.getRootElement();if(null!==h){h.contentEditable= | ||
"true";h=f.length-1;e.setEditorState(f[h][1]);const p=B.current;null!==p&&(p.value=String(h));n(!1);C(!1)}}},"Exit")))}; | ||
module.exports=function({timeTravelButtonClassName:a,timeTravelPanelSliderClassName:b,timeTravelPanelButtonClassName:c,viewClassName:e,timeTravelPanelClassName:d,editor:f}){const [g,m]=q.useState([]),[v,t]=q.useState(""),[r,l]=q.useState(!1),n=q.useRef(0),u=q.useRef(null),B=q.useRef(null),[z,C]=q.useState(!1);q.useEffect(()=>{t(H(f.getEditorState()));return f.addListener("update",({editorState:h})=>{const p=f._compositionKey,x=H(f.getEditorState());t([x,null!==p&&`Composition key: ${p}`].filter(Boolean).join("\n\n"));r|| | ||
m(A=>[...A,[Date.now(),h]])})},[r,f]);const y=g.length;q.useEffect(()=>{if(z){let h;const p=()=>{const x=n.current;x===y-1?C(!1):h=setTimeout(()=>{n.current++;const A=n.current,I=B.current;null!==I&&(I.value=String(A));f.setEditorState(g[A][1]);p()},g[x+1][0]-g[x][0])};p();return()=>{window.clearTimeout(h)}}},[g,z,f,y]);q.useEffect(()=>{u.current&&(u.current.__lexicalEditor=f)},[f]);return q.createElement("div",{className:e},!r&&2<y&&q.createElement("button",{onClick:()=>{const h=f.getRootElement(); | ||
null!==h&&(h.contentEditable="false",n.current=y-1,l(!0))},className:a},"Time Travel"),q.createElement("pre",{ref:u},v),r&&q.createElement("div",{className:d},q.createElement("button",{className:c,onClick:()=>{C(!z)}},z?"Pause":"Play"),q.createElement("input",{className:b,ref:B,onChange:h=>{h=Number(h.target.value);const p=g[h];p&&(n.current=h,f.setEditorState(p[1]))},type:"range",min:"1",max:y-1}),q.createElement("button",{className:c,onClick:()=>{var h=f.getRootElement();if(null!==h){h.contentEditable= | ||
"true";h=g.length-1;f.setEditorState(g[h][1]);const p=B.current;null!==p&&(p.value=String(h));l(!1);C(!1)}}},"Exit")))}; |
@@ -15,7 +15,7 @@ { | ||
"license": "MIT", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"peerDependencies": { | ||
"lexical": "0.1.6", | ||
"@lexical/helpers": "0.1.6", | ||
"@lexical/yjs": "0.1.6", | ||
"lexical": "0.1.7", | ||
"@lexical/helpers": "0.1.7", | ||
"@lexical/yjs": "0.1.7", | ||
"react": ">=17.x", | ||
@@ -22,0 +22,0 @@ "react-dom": ">=17.x" |
@@ -66,11 +66,15 @@ # `@lexical/react` | ||
function Editor() { | ||
const initialConfig = { | ||
theme, | ||
onError, | ||
}; | ||
return ( | ||
<LexicalComposer theme={theme}> | ||
<LexicalComposer initialConfig={initialConfig}> | ||
<LexicalPlainTextPlugin | ||
contentEditable={<LexicalContentEditable className="editor-input" />} | ||
contentEditable={<LexicalContentEditable />} | ||
placeholder={<div>Enter some text...</div>} | ||
onError={onError} | ||
/> | ||
<LexicalOnChangePlugin onChange={onChange} /> | ||
<LexicalHistoryPlugin /> | ||
<HistoryPlugin /> | ||
<MyCustomAutoFocusPlugin /> | ||
@@ -80,2 +84,2 @@ </LexicalComposer> | ||
} | ||
``` | ||
``` |
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
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 2 instances in 1 package
30
84
88400
401