@react-fabric/lexical 1.0.0-beta.56 → 1.0.0-beta.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/_lexical.css +4 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +33 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +11 -11
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +525 -194
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +26 -23
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +3 -3
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +95 -38
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +11 -10
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +387 -124
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +22 -18
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +54 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +107 -8
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +4 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +23 -20
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +420 -137
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +50 -45
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +61 -65
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +2 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +47 -46
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +34 -2
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +524 -196
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +4 -4
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +96 -40
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +387 -127
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +5 -4
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +56 -31
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +4 -4
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +106 -10
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +3 -1
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +417 -139
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +3 -3
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +62 -67
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +2 -1
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +3 -1
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +20 -10
- package/package.json +12 -12
- package/src/hooks/useFormatWatcher.ts +3 -1
- package/src/plugins/ToolbarPlugin.tsx +5 -10
|
@@ -11,7 +11,7 @@ var LexicalSelection = require('../selection/LexicalSelection.js');
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
function
|
|
14
|
+
function N(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const M="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,R=M&&"documentMode"in document?document.documentMode:null,T=M&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),B=M&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),_=!(!M||!("InputEvent"in window)||R)&&"getTargetRanges"in new window.InputEvent("input"),k=M&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),K=M&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,H=M&&/Android/.test(navigator.userAgent),O=M&&/^(?=.*Chrome).*/i.test(navigator.userAgent),$=M&&H&&O,D=M&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!O;function I(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function j(...t){return ()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0;}}function F(t){return `${t}px`}const U={attributes:!0,characterData:!0,childList:!0,subtree:!0};function z(e,n,o){let r=null,i=null,l=null,u=[];const s=document.createElement("div");function c(){null===r&&N(182),null===i&&N(183);const{left:t,top:l}=i.getBoundingClientRect(),c=LexicalSelection.createRectsFromDOMRange(e,n);var f,a;s.isConnected||(a=s,(f=i).insertBefore(a,f.firstChild));let d=!1;for(let e=0;e<c.length;e++){const n=c[e],o=u[e]||document.createElement("div"),r=o.style;"absolute"!==r.position&&(r.position="absolute",d=!0);const i=F(n.left-t);r.left!==i&&(r.left=i,d=!0);const f=F(n.top-l);r.top!==f&&(o.style.top=f,d=!0);const a=F(n.width);r.width!==a&&(o.style.width=a,d=!0);const g=F(n.height);r.height!==g&&(o.style.height=g,d=!0),o.parentNode!==s&&(s.append(o),d=!0),u[e]=o;}for(;u.length>c.length;)u.pop();d&&o(u);}function f(){i=null,r=null,null!==l&&l.disconnect(),l=null,s.remove();for(const t of u)t.remove();u=[];}s.style.position="relative";const a=e.registerRootListener((function n(){const o=e.getRootElement();if(null===o)return f();const u=o.parentElement;if(!lexical.isHTMLElement(u))return f();f(),r=o,i=u,l=new MutationObserver((t=>{const o=e.getRootElement(),l=o&&o.parentElement;if(o!==r||l!==i)return n();for(const e of t)if(!s.contains(e.target))return c()})),l.observe(u,U),c();}));return ()=>{a(),f();}}function V(t,e,n){if("text"!==t.type&&lexical.$isElementNode(e)){const o=e.getDOMSlot(n);return [o.element,o.getFirstChildOffset()+t.offset]}return [lexical.getDOMTextNode(n)||n,t.offset]}function W(t,o){let r=null,i=null,l=null,u=null,s=null,c=null,f=()=>{};function a(a){a.read((()=>{const a=lexical.$getSelection();if(!lexical.$isRangeSelection(a))return r=null,l=null,u=null,c=null,f(),void(f=()=>{});const[d,g]=function(t){const e=t.getStartEndPoints();return t.isBackward()?[e[1],e[0]]:e}(a),p=d.getNode(),m=p.getKey(),h=d.offset,v=g.getNode(),y=v.getKey(),w=g.offset,x=t.getElementByKey(m),E=t.getElementByKey(y),S=null===r||x!==i||h!==l||m!==r.getKey(),A=null===u||E!==s||w!==c||y!==u.getKey();if((S||A)&&null!==x&&null!==E){const e=function(t,e,n,o,r,i,l){const u=(t._window?t._window.document:document).createRange();return u.setStart(...V(e,n,o)),u.setEnd(...V(r,i,l)),u}(t,d,p,x,g,v,E);f(),f=z(t,e,(t=>{if(void 0===o)for(const e of t){const t=e.style;"Highlight"!==t.background&&(t.background="Highlight"),"HighlightText"!==t.color&&(t.color="HighlightText"),t.marginTop!==F(-1.5)&&(t.marginTop=F(-1.5)),t.paddingTop!==F(4)&&(t.paddingTop=F(4)),t.paddingBottom!==F(0)&&(t.paddingBottom=F(0));}else o(t);}));}r=p,i=x,l=h,u=v,s=E,c=w;}));}return a(t.getEditorState()),j(t.registerUpdateListener((({editorState:t})=>a(t))),(()=>{f();}))}function G(t){let e=null;const n=()=>{const n=getSelection(),o=n&&n.anchorNode,r=t.getRootElement();null!==o&&null!==r&&r.contains(o)?null!==e&&(e(),e=null):null===e&&(e=W(t));};return document.addEventListener("selectionchange",n),()=>{null!==e&&e(),document.removeEventListener("selectionchange",n);}}const q=_,J=M,Q=H,X=$,Y=T,Z=D,tt=O,et=B,nt=K,ot=k;function rt(t,...e){const n=I(...e);n.length>0&&t.classList.add(...n);}function it(t,...e){const n=I(...e);n.length>0&&t.classList.remove(...n);}function lt(t,e){for(const n of e)if(t.type.startsWith(n))return !0;return !1}function ut(t,e){const n=t[Symbol.iterator]();return new Promise(((t,o)=>{const r=[],i=()=>{const{done:l,value:u}=n.next();if(l)return t(r);const s=new FileReader;s.addEventListener("error",o),s.addEventListener("load",(()=>{const t=s.result;"string"==typeof t&&r.push({file:u,result:t}),i();})),lt(u,e)?s.readAsDataURL(u):i();};i();}))}function st(t,e){return Array.from(at(t,e))}function ct(t){return t?t.getAdjacentCaret():null}function ft(t,e){return Array.from(ht(t,e))}function at(t,e){return dt("next",t,e)}function dt(t,e,n){const r=lexical.$getRoot(),d=e||r,g=lexical.$isElementNode(d)?lexical.$getChildCaret(d,t):lexical.$getSiblingCaret(d,t),p=pt(d),m=n?lexical.$getAdjacentChildCaret(lexical.$getChildCaretOrSelf(lexical.$getSiblingCaret(n,t))):function(t,e){const n=$t(lexical.$getSiblingCaret(t,e));return n&&n[0]}(d,t);let h=p;return lexical.makeStepwiseIterator({hasNext:t=>null!==t,initial:g,map:t=>({depth:h,node:t.origin}),step:t=>{if(t.isSameNodeCaret(m))return null;lexical.$isChildCaret(t)&&h++;const e=$t(t);return !e||e[0].isSameNodeCaret(m)?null:(h+=e[1],e[0])}})}function gt(t){const e=$t(lexical.$getSiblingCaret(t,"next"));return e&&[e[0].origin,e[1]]}function pt(t){let e=-1;for(let n=t;null!==n;n=n.getParent())e++;return e}function mt(t){const e=$t(lexical.$getChildCaretOrSelf(lexical.$getSiblingCaret(t,"previous")),"root");return e&&e[0].origin}function ht(t,e){return dt("previous",t,e)}function vt(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent();}return null}function yt(t){const e=wt(t,(t=>lexical.$isElementNode(t)&&!t.isInline()));return lexical.$isElementNode(e)||N(4,t.__key),e}const wt=(t,e)=>{let n=t;for(;n!==lexical.$getRoot()&&null!=n;){if(e(n))return n;n=n.getParent();}return null};function xt(t,e,n,o){const r=t=>t instanceof e;return t.registerNodeTransform(e,(t=>{const e=(t=>{const e=t.getChildren();for(let t=0;t<e.length;t++){const n=e[t];if(r(n))return null}let n=t,o=t;for(;null!==n;)if(o=n,n=n.getParent(),r(n))return {child:o,parent:n};return null})(t);if(null!==e){const{child:r,parent:i}=e;if(r.is(t)){o(i,t);const e=r.getNextSiblings(),l=e.length;if(i.insertAfter(r),0!==l){const t=n(i);r.insertAfter(t);for(let n=0;n<l;n++)t.append(e[n]);}i.canBeEmpty()||0!==i.getChildrenSize()||i.remove();}}}))}function Et(t,e){const n=new Map,o=t._pendingEditorState;for(const[t,o]of e._nodeMap)n.set(t,lexical.$cloneWithProperties(o));o&&(o._nodeMap=n),t._dirtyType=2;const r=e._selection;lexical.$setSelection(null===r?null:r.clone());}function St(t){const o=lexical.$getSelection()||lexical.$getPreviousSelection();let r;if(lexical.$isRangeSelection(o))r=lexical.$caretFromPoint(o.focus,"next");else {if(null!=o){const t=o.getNodes(),e=t[t.length-1];e&&(r=lexical.$getSiblingCaret(e,"next"));}r=r||lexical.$getChildCaret(lexical.$getRoot(),"previous").getFlipped().insert(lexical.$createParagraphNode());}const c=At(t,r),f=lexical.$getAdjacentChildCaret(c),d=lexical.$isChildCaret(f)?lexical.$normalizeCaret(f):c;return lexical.$setSelectionFromCaretRange(lexical.$getCollapsedCaretRange(d)),t.getLatest()}function At(t,e,n){let o=lexical.$getCaretInDirection(e,"next");for(let t=o;t;t=lexical.$splitAtPointCaretNext(t,n))o=t;return lexical.$isTextPointCaret(o)&&N(283),o.insert(t.isInline()?lexical.$createParagraphNode().append(t):t),lexical.$getCaretInDirection(lexical.$getSiblingCaret(t.getLatest(),"next"),e.direction)}function Ct(t,e){const n=e();return t.replace(n),n.append(t),n}function Lt(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Pt(t,e){const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);null!==r&&n.push(r);}return n}function bt(t,e){lexical.$getChildCaret(t,"next").insert(e);}let Nt=!(et||!J)&&void 0;function Mt(t){let e=1;if(function(){if(void 0===Nt){const t=document.createElement("div");t.style.cssText="position: absolute; opacity: 0; width: 100px; left: -1000px;",document.body.appendChild(t);const e=t.getBoundingClientRect();t.style.setProperty("zoom","2"),Nt=t.getBoundingClientRect().width===e.width,document.body.removeChild(t);}return Nt}())for(;t;)e*=Number(window.getComputedStyle(t).getPropertyValue("zoom")),t=t.parentElement;return e}function Rt(t){return null!==t._parentEditor}function Tt(t,e){return Bt(t,e,null)}function Bt(t,e,n){let r=!1;for(const i of Kt(t))e(i)?null!==n&&n(i):(r=!0,lexical.$isElementNode(i)&&Bt(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function _t(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if(lexical.$isElementNode(t))for(const e of Kt(t))r.push(e);return n}function kt(t){return Ht(lexical.$getChildCaret(t,"next"))}function Kt(t){return Ht(lexical.$getChildCaret(t,"previous"))}function Ht(t){return lexical.makeStepwiseIterator({hasNext:lexical.$isSiblingCaret,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})}function Ot(t){lexical.$rewindSiblingCaret(lexical.$getSiblingCaret(t,"next")).splice(1,t.getChildren());}function $t(t,e="root"){let n=0,o=t,r=lexical.$getAdjacentChildCaret(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=lexical.$getAdjacentChildCaret(o);}return r&&[r,n]}function Dt(t){const e=e=>lexical.$getState(e,t),n=(e,n)=>lexical.$setState(e,t,n);return {$get:e,$set:n,accessors:[e,n],makeGetterMethod:()=>function(){return e(this)},makeSetterMethod:()=>function(t){return n(this,t)},stateConfig:t}}
|
|
15
15
|
|
|
16
16
|
Object.defineProperty(exports, "$splitNode", {
|
|
17
17
|
enumerable: true,
|
|
@@ -33,48 +33,49 @@ Object.defineProperty(exports, "isInlineDomNode", {
|
|
|
33
33
|
enumerable: true,
|
|
34
34
|
get: function () { return lexical.isInlineDomNode; }
|
|
35
35
|
});
|
|
36
|
-
exports.$descendantsMatching =
|
|
37
|
-
exports.$dfs =
|
|
38
|
-
exports.$dfsIterator =
|
|
39
|
-
exports.$filter =
|
|
40
|
-
exports.$findMatchingParent =
|
|
41
|
-
exports.$firstToLastIterator =
|
|
42
|
-
exports.$getAdjacentCaret =
|
|
43
|
-
exports.$getAdjacentSiblingOrParentSiblingCaret =
|
|
44
|
-
exports.$getDepth =
|
|
45
|
-
exports.$getNearestBlockElementAncestorOrThrow =
|
|
46
|
-
exports.$getNearestNodeOfType =
|
|
47
|
-
exports.$getNextRightPreorderNode =
|
|
48
|
-
exports.$getNextSiblingOrParentSibling =
|
|
49
|
-
exports.$insertFirst =
|
|
50
|
-
exports.$insertNodeToNearestRoot =
|
|
51
|
-
exports.$
|
|
52
|
-
exports.$
|
|
53
|
-
exports.$
|
|
54
|
-
exports.$
|
|
55
|
-
exports.$
|
|
56
|
-
exports.$
|
|
57
|
-
exports.$
|
|
58
|
-
exports.$
|
|
59
|
-
exports
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
62
|
-
exports.
|
|
63
|
-
exports.
|
|
64
|
-
exports.
|
|
65
|
-
exports.
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
71
|
-
exports.
|
|
72
|
-
exports.
|
|
73
|
-
exports.
|
|
74
|
-
exports.
|
|
75
|
-
exports.
|
|
76
|
-
exports.
|
|
77
|
-
exports.
|
|
78
|
-
exports.
|
|
79
|
-
exports.
|
|
80
|
-
exports.
|
|
36
|
+
exports.$descendantsMatching = _t;
|
|
37
|
+
exports.$dfs = st;
|
|
38
|
+
exports.$dfsIterator = at;
|
|
39
|
+
exports.$filter = Pt;
|
|
40
|
+
exports.$findMatchingParent = wt;
|
|
41
|
+
exports.$firstToLastIterator = kt;
|
|
42
|
+
exports.$getAdjacentCaret = ct;
|
|
43
|
+
exports.$getAdjacentSiblingOrParentSiblingCaret = $t;
|
|
44
|
+
exports.$getDepth = pt;
|
|
45
|
+
exports.$getNearestBlockElementAncestorOrThrow = yt;
|
|
46
|
+
exports.$getNearestNodeOfType = vt;
|
|
47
|
+
exports.$getNextRightPreorderNode = mt;
|
|
48
|
+
exports.$getNextSiblingOrParentSibling = gt;
|
|
49
|
+
exports.$insertFirst = bt;
|
|
50
|
+
exports.$insertNodeToNearestRoot = St;
|
|
51
|
+
exports.$insertNodeToNearestRootAtCaret = At;
|
|
52
|
+
exports.$isEditorIsNestedEditor = Rt;
|
|
53
|
+
exports.$lastToFirstIterator = Kt;
|
|
54
|
+
exports.$restoreEditorState = Et;
|
|
55
|
+
exports.$reverseDfs = ft;
|
|
56
|
+
exports.$reverseDfsIterator = ht;
|
|
57
|
+
exports.$unwrapAndFilterDescendants = Tt;
|
|
58
|
+
exports.$unwrapNode = Ot;
|
|
59
|
+
exports.$wrapNodeInElement = Ct;
|
|
60
|
+
exports.CAN_USE_BEFORE_INPUT = q;
|
|
61
|
+
exports.CAN_USE_DOM = J;
|
|
62
|
+
exports.IS_ANDROID = Q;
|
|
63
|
+
exports.IS_ANDROID_CHROME = X;
|
|
64
|
+
exports.IS_APPLE = Y;
|
|
65
|
+
exports.IS_APPLE_WEBKIT = Z;
|
|
66
|
+
exports.IS_CHROME = tt;
|
|
67
|
+
exports.IS_FIREFOX = et;
|
|
68
|
+
exports.IS_IOS = nt;
|
|
69
|
+
exports.IS_SAFARI = ot;
|
|
70
|
+
exports.addClassNamesToElement = rt;
|
|
71
|
+
exports.calculateZoomLevel = Mt;
|
|
72
|
+
exports.isMimeType = lt;
|
|
73
|
+
exports.makeStateWrapper = Dt;
|
|
74
|
+
exports.markSelection = W;
|
|
75
|
+
exports.mediaFileReader = ut;
|
|
76
|
+
exports.mergeRegister = j;
|
|
77
|
+
exports.objectKlassEquals = Lt;
|
|
78
|
+
exports.positionNodeOnRange = z;
|
|
79
|
+
exports.registerNestedElementResolver = xt;
|
|
80
|
+
exports.removeClassNamesFromElement = it;
|
|
81
|
+
exports.selectionAlwaysOnDisplay = G;
|
|
@@ -160,7 +160,9 @@ var useFormatWatcher = function useFormatWatcher() {
|
|
|
160
160
|
setIsSubscript(selection.hasFormat("subscript"));
|
|
161
161
|
setIsSuperscript(selection.hasFormat("superscript"));
|
|
162
162
|
setIsCode(selection.hasFormat("code"));
|
|
163
|
-
|
|
163
|
+
editor.read(function () {
|
|
164
|
+
setIsRTL(LexicalSelection.$isParentElementRTL(selection));
|
|
165
|
+
});
|
|
164
166
|
|
|
165
167
|
// Update links
|
|
166
168
|
var node = getSelectedNode(selection);
|
|
@@ -135,9 +135,11 @@ var ToolbarPlugin = function ToolbarPlugin() {
|
|
|
135
135
|
variant: "link",
|
|
136
136
|
children: [/*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
|
|
137
137
|
value: "start",
|
|
138
|
-
rtlFlip: true,
|
|
139
138
|
label: t("tool.alignStart"),
|
|
140
|
-
icon:
|
|
139
|
+
icon: {
|
|
140
|
+
icon: core.CoreIcons.alignLeft,
|
|
141
|
+
rtlFlip: true
|
|
142
|
+
},
|
|
141
143
|
onClick: function onClick() {
|
|
142
144
|
return watch.activeEditor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, "start");
|
|
143
145
|
}
|
|
@@ -150,33 +152,41 @@ var ToolbarPlugin = function ToolbarPlugin() {
|
|
|
150
152
|
}
|
|
151
153
|
}), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
|
|
152
154
|
value: "end",
|
|
153
|
-
rtlFlip: true,
|
|
154
155
|
label: t("tool.alignEnd"),
|
|
155
|
-
icon:
|
|
156
|
+
icon: {
|
|
157
|
+
icon: core.CoreIcons.alignRight,
|
|
158
|
+
rtlFlip: true
|
|
159
|
+
},
|
|
156
160
|
onClick: function onClick() {
|
|
157
161
|
return watch.activeEditor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, "end");
|
|
158
162
|
}
|
|
159
163
|
}), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
|
|
160
164
|
value: "justify",
|
|
161
|
-
rtlFlip: true,
|
|
162
165
|
label: t("tool.alignJustify"),
|
|
163
|
-
icon:
|
|
166
|
+
icon: {
|
|
167
|
+
icon: core.CoreIcons.alignJustify,
|
|
168
|
+
rtlFlip: true
|
|
169
|
+
},
|
|
164
170
|
onClick: function onClick() {
|
|
165
171
|
return watch.activeEditor.dispatchCommand(lexical.FORMAT_ELEMENT_COMMAND, "justify");
|
|
166
172
|
}
|
|
167
173
|
}), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
|
|
168
174
|
value: "justify",
|
|
169
|
-
rtlFlip: true,
|
|
170
175
|
label: t("tool.indentOut"),
|
|
171
|
-
icon:
|
|
176
|
+
icon: {
|
|
177
|
+
icon: core.CoreIcons.formatIndentDecrease,
|
|
178
|
+
rtlFlip: true
|
|
179
|
+
},
|
|
172
180
|
onClick: function onClick() {
|
|
173
181
|
return watch.outdent();
|
|
174
182
|
}
|
|
175
183
|
}), /*#__PURE__*/jsxRuntime.jsx(ButtonWrapper, {
|
|
176
184
|
value: "justify",
|
|
177
|
-
rtlFlip: true,
|
|
178
185
|
label: t("tool.identIn"),
|
|
179
|
-
icon:
|
|
186
|
+
icon: {
|
|
187
|
+
icon: core.CoreIcons.formatIndentIncrease,
|
|
188
|
+
rtlFlip: true
|
|
189
|
+
},
|
|
180
190
|
onClick: function onClick() {
|
|
181
191
|
return watch.indent();
|
|
182
192
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { $generateHtmlFromNodes, $generateNodesFromDOM } from '../html/LexicalHtml.js';
|
|
4
4
|
import { $addNodeStyle, $sliceSelectedTextNodeContent } from '../selection/LexicalSelection.js';
|
|
5
5
|
import { objectKlassEquals } from '../utils/LexicalUtils.js';
|
|
6
|
-
import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $
|
|
6
|
+
import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $caretFromPoint, $isTextPointCaret, $getCaretRange, $getChildCaret, $getRoot, $isTextNode, $isElementNode, $parseSerializedNode, getDOMSelection, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor, $cloneWithProperties } from 'lexical';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -184,9 +184,41 @@ function $insertGeneratedNodes(editor, nodes, selection) {
|
|
|
184
184
|
selection
|
|
185
185
|
})) {
|
|
186
186
|
selection.insertNodes(nodes);
|
|
187
|
+
$updateSelectionOnInsert(selection);
|
|
187
188
|
}
|
|
188
189
|
return;
|
|
189
190
|
}
|
|
191
|
+
function $updateSelectionOnInsert(selection) {
|
|
192
|
+
if ($isRangeSelection(selection) && selection.isCollapsed()) {
|
|
193
|
+
const anchor = selection.anchor;
|
|
194
|
+
let nodeToInspect = null;
|
|
195
|
+
const anchorCaret = $caretFromPoint(anchor, 'previous');
|
|
196
|
+
if (anchorCaret) {
|
|
197
|
+
if ($isTextPointCaret(anchorCaret)) {
|
|
198
|
+
nodeToInspect = anchorCaret.origin;
|
|
199
|
+
} else {
|
|
200
|
+
const range = $getCaretRange(anchorCaret, $getChildCaret($getRoot(), 'next').getFlipped());
|
|
201
|
+
for (const caret of range) {
|
|
202
|
+
if ($isTextNode(caret.origin)) {
|
|
203
|
+
nodeToInspect = caret.origin;
|
|
204
|
+
break;
|
|
205
|
+
} else if ($isElementNode(caret.origin) && !caret.origin.isInline()) {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (nodeToInspect && $isTextNode(nodeToInspect)) {
|
|
212
|
+
const newFormat = nodeToInspect.getFormat();
|
|
213
|
+
const newStyle = nodeToInspect.getStyle();
|
|
214
|
+
if (selection.format !== newFormat || selection.style !== newStyle) {
|
|
215
|
+
selection.format = newFormat;
|
|
216
|
+
selection.style = newStyle;
|
|
217
|
+
selection.dirty = true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
190
222
|
function exportNodeToJSON(node) {
|
|
191
223
|
const serializedNode = node.exportJSON();
|
|
192
224
|
const nodeClass = node.constructor;
|
|
@@ -275,7 +307,7 @@ function $generateJSONFromSelectedNodes(editor, selection) {
|
|
|
275
307
|
}
|
|
276
308
|
|
|
277
309
|
/**
|
|
278
|
-
* This method takes an array of objects conforming to the
|
|
310
|
+
* This method takes an array of objects conforming to the BaseSerializedNode interface and returns
|
|
279
311
|
* an Array containing instances of the corresponding LexicalNode classes registered on the editor.
|
|
280
312
|
* Normally, you'd get an Array of BaseSerialized nodes from {@link $generateJSONFromSelectedNodes}
|
|
281
313
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { $generateHtmlFromNodes, $generateNodesFromDOM } from '../html/LexicalHtml.js';
|
|
4
4
|
import { $addNodeStyle, $sliceSelectedTextNodeContent } from '../selection/LexicalSelection.js';
|
|
5
5
|
import { objectKlassEquals } from '../utils/LexicalUtils.js';
|
|
6
|
-
import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $
|
|
6
|
+
import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $caretFromPoint, $isTextPointCaret, $getCaretRange, $getChildCaret, $getRoot, $isTextNode, $isElementNode, $parseSerializedNode, getDOMSelection, COPY_COMMAND, COMMAND_PRIORITY_CRITICAL, isSelectionWithinEditor, $getEditor, $cloneWithProperties } from 'lexical';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -13,6 +13,6 @@ import { $isRangeSelection, $getSelection, $createTabNode, SELECTION_INSERT_CLIP
|
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function D(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function N(e,n=$getSelection()){return null==n&&D(166),$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":$generateHtmlFromNodes(e,n)}function S(t,e=$getSelection()){return null==e&&D(166),$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(E(t,e))}function R(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n);}function A(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return P(o,L(t.nodes),n)}}catch(t){}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return P(o,$generateNodesFromDOM(o,t),n)}catch(t){}const u=a||t.getData("text/uri-list");if(null!=u)if($isRangeSelection(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=$getSelection();if($isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([$createTabNode()]):n.insertText(o);}}}else n.insertRawText(u);}function P(t,e,n){t.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||(n.insertNodes(e),function(t){if($isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor;let n=null;const o=$caretFromPoint(e,"previous");if(o)if($isTextPointCaret(o))n=o.origin;else {const t=$getCaretRange(o,$getChildCaret($getRoot(),"next").getFlipped());for(const e of t){if($isTextNode(e.origin)){n=e.origin;break}if($isElementNode(e.origin)&&!e.origin.isInline())break}}if(n&&$isTextNode(n)){const e=n.getFormat(),o=n.getStyle();t.format===e&&t.style===o||(t.format=e,t.style=o,t.dirty=!0);}}}(n));}function _(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=$isElementNode(n)&&n.excludeFromCopy("html");let s=n;if(null!==e){let t=$cloneWithProperties(n);t=$isTextNode(t)&&null!==e?$sliceSelectedTextNodeContent(e,t):t,s=t;}const c=$isElementNode(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&D(58,n.name),$isElementNode(t)){const t=e.children;Array.isArray(t)||D(59,n.name);}return e}(s);if($isTextNode(s)){const t=s.__text;t.length>0?a.text=t:i=!1;}for(let o=0;o<c.length;o++){const r=c[o],l=_(t,e,r,a.children);!i&&$isElementNode(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=!0);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function E(t,e){const n=[],o=$getRoot().getChildren();for(let r=0;r<o.length;r++){_(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function L(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=$parseSerializedNode(r);$isTextNode(i)&&$addNodeStyle(i),e.push(i);}return e}let b=null;async function F(t,e,n){if(null!==b)return !1;if(null!==e)return new Promise(((o,r)=>{t.update((()=>{o(M(t,e,n));}));}));const o=t.getRootElement(),i=t._window||window,l=window.document,s=getDOMSelection(i);if(null===o||null===s)return !1;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise(((e,o)=>{const i=t.registerCommand(COPY_COMMAND,(o=>(objectKlassEquals(o,ClipboardEvent)&&(i(),null!==b&&(window.clearTimeout(b),b=null),e(M(t,o,n))),!0)),COMMAND_PRIORITY_CRITICAL);b=window.setTimeout((()=>{i(),b=null,e(!1);}),50),l.execCommand("copy"),c.remove();}))}function M(t,e,n){if(void 0===n){const e=getDOMSelection(t._window);if(!e)return !1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!isSelectionWithinEditor(t,o,r))return !1;const i=$getSelection();if(null===i)return !1;n=J(i);}e.preventDefault();const o=e.clipboardData;return null!==o&&(k(o,n),!0)}const O=[["text/html",N],["application/x-lexical-editor",S]];function J(t=$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=$getEditor();for(const[o,r]of O){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function k(t,e){for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
|
|
17
17
|
|
|
18
|
-
export {
|
|
18
|
+
export { E as $generateJSONFromSelectedNodes, L as $generateNodesFromSerializedNodes, J as $getClipboardDataFromSelection, N as $getHtmlContent, S as $getLexicalContent, R as $insertDataTransferForPlainText, A as $insertDataTransferForRichText, P as $insertGeneratedNodes, F as copyToClipboard, k as setLexicalClipboardDataTransfer };
|