@react-fabric/lexical 1.0.0-beta.57 → 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
package/css/_lexical.css
CHANGED
|
@@ -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 (lexical.$isRangeSelection(selection) && selection.isCollapsed()) {
|
|
193
|
+
const anchor = selection.anchor;
|
|
194
|
+
let nodeToInspect = null;
|
|
195
|
+
const anchorCaret = lexical.$caretFromPoint(anchor, 'previous');
|
|
196
|
+
if (anchorCaret) {
|
|
197
|
+
if (lexical.$isTextPointCaret(anchorCaret)) {
|
|
198
|
+
nodeToInspect = anchorCaret.origin;
|
|
199
|
+
} else {
|
|
200
|
+
const range = lexical.$getCaretRange(anchorCaret, lexical.$getChildCaret(lexical.$getRoot(), 'next').getFlipped());
|
|
201
|
+
for (const caret of range) {
|
|
202
|
+
if (lexical.$isTextNode(caret.origin)) {
|
|
203
|
+
nodeToInspect = caret.origin;
|
|
204
|
+
break;
|
|
205
|
+
} else if (lexical.$isElementNode(caret.origin) && !caret.origin.isInline()) {
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (nodeToInspect && lexical.$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
|
*
|
|
@@ -13,15 +13,15 @@ var lexical = require('lexical');
|
|
|
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=lexical.$getSelection()){return null==n&&D(166),lexical.$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":LexicalHtml.$generateHtmlFromNodes(e,n)}function S(t,e=lexical.$getSelection()){return null==e&&D(166),lexical.$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,LexicalHtml.$generateNodesFromDOM(o,t),n)}catch(t){}const u=a||t.getData("text/uri-list");if(null!=u)if(lexical.$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=lexical.$getSelection();if(lexical.$isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([lexical.$createTabNode()]):n.insertText(o);}}}else n.insertRawText(u);}function P(t,e,n){t.dispatchCommand(lexical.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||(n.insertNodes(e),function(t){if(lexical.$isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor;let n=null;const o=lexical.$caretFromPoint(e,"previous");if(o)if(lexical.$isTextPointCaret(o))n=o.origin;else {const t=lexical.$getCaretRange(o,lexical.$getChildCaret(lexical.$getRoot(),"next").getFlipped());for(const e of t){if(lexical.$isTextNode(e.origin)){n=e.origin;break}if(lexical.$isElementNode(e.origin)&&!e.origin.isInline())break}}if(n&&lexical.$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=lexical.$isElementNode(n)&&n.excludeFromCopy("html");let s=n;if(null!==e){let t=lexical.$cloneWithProperties(n);t=lexical.$isTextNode(t)&&null!==e?LexicalSelection.$sliceSelectedTextNodeContent(e,t):t,s=t;}const c=lexical.$isElementNode(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&D(58,n.name),lexical.$isElementNode(t)){const t=e.children;Array.isArray(t)||D(59,n.name);}return e}(s);if(lexical.$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&&lexical.$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=lexical.$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=lexical.$parseSerializedNode(r);lexical.$isTextNode(i)&&LexicalSelection.$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=lexical.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(lexical.COPY_COMMAND,(o=>(LexicalUtils.objectKlassEquals(o,ClipboardEvent)&&(i(),null!==b&&(window.clearTimeout(b),b=null),e(M(t,o,n))),!0)),lexical.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=lexical.getDOMSelection(t._window);if(!e)return !1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!lexical.isSelectionWithinEditor(t,o,r))return !1;const i=lexical.$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=lexical.$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=lexical.$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
|
-
exports.$generateJSONFromSelectedNodes =
|
|
19
|
-
exports.$generateNodesFromSerializedNodes =
|
|
20
|
-
exports.$getClipboardDataFromSelection =
|
|
21
|
-
exports.$getHtmlContent =
|
|
22
|
-
exports.$getLexicalContent =
|
|
23
|
-
exports.$insertDataTransferForPlainText =
|
|
24
|
-
exports.$insertDataTransferForRichText =
|
|
25
|
-
exports.$insertGeneratedNodes =
|
|
26
|
-
exports.copyToClipboard =
|
|
27
|
-
exports.setLexicalClipboardDataTransfer =
|
|
18
|
+
exports.$generateJSONFromSelectedNodes = E;
|
|
19
|
+
exports.$generateNodesFromSerializedNodes = L;
|
|
20
|
+
exports.$getClipboardDataFromSelection = J;
|
|
21
|
+
exports.$getHtmlContent = N;
|
|
22
|
+
exports.$getLexicalContent = S;
|
|
23
|
+
exports.$insertDataTransferForPlainText = R;
|
|
24
|
+
exports.$insertDataTransferForRichText = A;
|
|
25
|
+
exports.$insertGeneratedNodes = P;
|
|
26
|
+
exports.copyToClipboard = F;
|
|
27
|
+
exports.setLexicalClipboardDataTransfer = k;
|