@lexical/rich-text 0.5.0 → 0.5.1-next.1

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.
@@ -19,6 +19,14 @@ var lexical = require('lexical');
19
19
  *
20
20
  */
21
21
  const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
22
+
23
+ /**
24
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
25
+ *
26
+ * This source code is licensed under the MIT license found in the
27
+ * LICENSE file in the root directory of this source tree.
28
+ *
29
+ */
22
30
  const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
23
31
  CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
24
32
  CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
@@ -290,52 +298,21 @@ function onPasteForRichText(event, editor) {
290
298
  });
291
299
  }
292
300
 
293
- function onCopyForRichText(event, editor) {
294
- const selection = lexical.$getSelection();
295
-
296
- if (selection !== null) {
297
- event.preventDefault();
298
- const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
299
- const htmlString = clipboard.$getHtmlContent(editor);
300
- const lexicalString = clipboard.$getLexicalContent(editor);
301
-
302
- if (clipboardData != null) {
303
- if (htmlString !== null) {
304
- clipboardData.setData('text/html', htmlString);
305
- }
306
-
307
- if (lexicalString !== null) {
308
- clipboardData.setData('application/x-lexical-editor', lexicalString);
309
- }
310
-
311
- const plainString = selection.getTextContent();
312
- clipboardData.setData('text/plain', plainString);
313
- } else {
314
- const clipboard = navigator.clipboard;
315
-
316
- if (clipboard != null) {
317
- // Most browsers only support a single item in the clipboard at one time.
318
- // So we optimize by only putting in HTML.
319
- const data = [new ClipboardItem({
320
- 'text/html': new Blob([htmlString], {
321
- type: 'text/html'
322
- })
323
- })];
324
- clipboard.write(data);
325
- }
326
- }
301
+ async function onCutForRichText(event, editor) {
302
+ if (editor.getEditorState().read(() => lexical.$getSelection()) == null) {
303
+ return;
327
304
  }
328
- }
329
305
 
330
- function onCutForRichText(event, editor) {
331
- onCopyForRichText(event, editor);
332
- const selection = lexical.$getSelection();
306
+ await clipboard.copyToClipboard__EXPERIMENTAL(editor, event instanceof ClipboardEvent ? event : null);
307
+ editor.update(() => {
308
+ const selection = lexical.$getSelection();
333
309
 
334
- if (lexical.$isRangeSelection(selection)) {
335
- selection.removeText();
336
- } else if (lexical.$isNodeSelection(selection)) {
337
- selection.getNodes().forEach(node => node.remove());
338
- }
310
+ if (lexical.$isRangeSelection(selection)) {
311
+ selection.removeText();
312
+ } else if (lexical.$isNodeSelection(selection)) {
313
+ selection.getNodes().forEach(node => node.remove());
314
+ }
315
+ });
339
316
  }
340
317
 
341
318
  function handleIndentAndOutdent(insertTab, indentOrOutdent) {
@@ -705,7 +682,7 @@ function registerRichText(editor) {
705
682
  event.preventDefault();
706
683
  return true;
707
684
  }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.COPY_COMMAND, event => {
708
- onCopyForRichText(event, editor);
685
+ clipboard.copyToClipboard__EXPERIMENTAL(editor, event instanceof ClipboardEvent ? event : null);
709
686
  return true;
710
687
  }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.CUT_COMMAND, event => {
711
688
  onCutForRichText(event, editor);
@@ -4,25 +4,25 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- 'use strict';var b=require("@lexical/clipboard"),f=require("@lexical/selection"),g=require("@lexical/utils"),h=require("lexical");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,m=l&&"documentMode"in document?document.documentMode:null;l&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);l&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
7
+ 'use strict';var a=require("@lexical/clipboard"),f=require("@lexical/selection"),g=require("@lexical/utils"),h=require("lexical");let l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,m=l&&"documentMode"in document?document.documentMode:null;l&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);l&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
8
8
  let n=l&&"InputEvent"in window&&!m?"getTargetRanges"in new window.InputEvent("input"):!1,p=l&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),q=l&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;
9
- class r extends h.ElementNode{static getType(){return"quote"}static clone(a){return new r(a.__key)}constructor(a){super(a)}createDOM(a){let c=document.createElement("blockquote");g.addClassNamesToElement(c,a.theme.quote);return c}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:t,priority:0})}}static importJSON(a){let c=w();c.setFormat(a.format);c.setIndent(a.indent);c.setDirection(a.direction);return c}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(){let a=
10
- h.$createParagraphNode(),c=this.getDirection();a.setDirection(c);this.insertAfter(a);return a}collapseAtStart(){let a=h.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}}function w(){return new r}
11
- class x extends h.ElementNode{static getType(){return"heading"}static clone(a){return new x(a.__tag,a.__key)}constructor(a,c){super(c);this.__tag=a}getTag(){return this.__tag}createDOM(a){let c=this.__tag,d=document.createElement(c);a=a.theme.heading;void 0!==a&&g.addClassNamesToElement(d,a[c]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:y,priority:0}),h2:()=>({conversion:y,priority:0}),h3:()=>({conversion:y,priority:0}),h4:()=>({conversion:y,priority:0}),h5:()=>({conversion:y,
12
- priority:0}),h6:()=>({conversion:y,priority:0}),p:a=>{a=a.firstChild;return null!==a&&z(a)?{conversion:()=>({node:null}),priority:3}:null},span:a=>z(a)?{conversion:()=>({node:A("h1")}),priority:3}:null}}static importJSON(a){let c=A(a.tag);c.setFormat(a.format);c.setIndent(a.indent);c.setDirection(a.direction);return c}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(){let a=h.$createParagraphNode(),c=this.getDirection();a.setDirection(c);this.insertAfter(a);
13
- return a}collapseAtStart(){let a=h.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}extractWithChild(){return!0}}function z(a){return"span"===a.nodeName.toLowerCase()?"26pt"===a.style.fontSize:!1}function y(a){a=a.nodeName.toLowerCase();let c=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)c=A(a);return{node:c}}function t(){return{node:w()}}function A(a){return new x(a)}
14
- function B(a,c){a.preventDefault();c.update(()=>{let d=h.$getSelection(),e=a instanceof InputEvent||a instanceof KeyboardEvent?null:a.clipboardData;null!=e&&(h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d))&&b.$insertDataTransferForRichText(e,d,c)},{tag:"paste"})}
15
- function C(a,c){var d=h.$getSelection();if(null!==d){a.preventDefault();a=a instanceof KeyboardEvent?null:a.clipboardData;let e=b.$getHtmlContent(c);c=b.$getLexicalContent(c);null!=a?(null!==e&&a.setData("text/html",e),null!==c&&a.setData("application/x-lexical-editor",c),d=d.getTextContent(),a.setData("text/plain",d)):(d=navigator.clipboard,null!=d&&(a=[new ClipboardItem({"text/html":new Blob([e],{type:"text/html"})})],d.write(a)))}}
16
- function D(a,c){C(a,c);a=h.$getSelection();h.$isRangeSelection(a)?a.removeText():h.$isNodeSelection(a)&&a.getNodes().forEach(d=>d.remove())}function E(a,c){var d=h.$getSelection();if(h.$isRangeSelection(d)){var e=new Set;d=d.getNodes();for(let u=0;u<d.length;u++){let v=d[u];var k=v.getKey();e.has(k)||(e.add(k),k=g.$getNearestBlockElementAncestorOrThrow(v),k.canInsertTab()?a(v):k.canIndent()&&c(k))}}}function F(a){a=h.$getNearestNodeFromDOMNode(a);return h.$isDecoratorNode(a)}
17
- exports.$createHeadingNode=A;exports.$createQuoteNode=w;exports.$isHeadingNode=function(a){return a instanceof x};exports.$isQuoteNode=function(a){return a instanceof r};exports.HeadingNode=x;exports.QuoteNode=r;
18
- exports.registerRichText=function(a){return g.mergeRegister(a.registerCommand(h.CLICK_COMMAND,()=>{const c=h.$getSelection();return h.$isNodeSelection(c)?(c.clear(),!0):!1},0),a.registerCommand(h.DELETE_CHARACTER_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteCharacter(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.DELETE_WORD_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteWord(c);return!0},h.COMMAND_PRIORITY_EDITOR),
19
- a.registerCommand(h.DELETE_LINE_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteLine(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,c=>{const d=h.$getSelection();if("string"===typeof c)h.$isRangeSelection(d)?d.insertText(c):h.DEPRECATED_$isGridSelection(d);else{if(!h.$isRangeSelection(d)&&!h.DEPRECATED_$isGridSelection(d))return!1;const e=c.dataTransfer;null!=e?b.$insertDataTransferForRichText(e,d,a):h.$isRangeSelection(d)&&
20
- (c=c.data)&&d.insertText(c)}return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.REMOVE_TEXT_COMMAND,()=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.removeText();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.FORMAT_TEXT_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.formatText(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.FORMAT_ELEMENT_COMMAND,c=>{var d=h.$getSelection();if(!h.$isRangeSelection(d)&&!h.$isNodeSelection(d))return!1;
21
- d=d.getNodes();for(const e of d)g.$getNearestBlockElementAncestorOrThrow(e).setFormat(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.INSERT_LINE_BREAK_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.insertLineBreak(c);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.INSERT_PARAGRAPH_COMMAND,()=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;c.insertParagraph();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.INDENT_CONTENT_COMMAND,
22
- ()=>{E(()=>{a.dispatchCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,"\t")},c=>{const d=c.getIndent();10!==d&&c.setIndent(d+1)});return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.OUTDENT_CONTENT_COMMAND,()=>{E(c=>{h.$isTextNode(c)&&(c=c.getTextContent(),"\t"===c[c.length-1]&&a.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0))},c=>{const d=c.getIndent();0!==d&&c.setIndent(d-1)});return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_UP_COMMAND,c=>{const d=h.$getSelection();return h.$isNodeSelection(d)&&
23
- !F(c.target)&&(c=d.getNodes(),0<c.length)?(c[0].selectPrevious(),!0):!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_DOWN_COMMAND,()=>{var c=h.$getSelection();return h.$isNodeSelection(c)&&(c=c.getNodes(),0<c.length)?(c[0].selectNext(0,0),!0):!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_LEFT_COMMAND,c=>{const d=h.$getSelection();if(h.$isNodeSelection(d)){var e=d.getNodes();if(0<e.length)return c.preventDefault(),e[0].selectPrevious(),!0}return h.$isRangeSelection(d)?f.$shouldOverrideDefaultCharacterSelection(d,
24
- !0)?(e=c.shiftKey,c.preventDefault(),f.$moveCharacter(d,e,!0),!0):!1:!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ARROW_RIGHT_COMMAND,c=>{const d=h.$getSelection();if(h.$isNodeSelection(d)&&!F(c.target)){var e=d.getNodes();if(0<e.length)return c.preventDefault(),e[0].selectNext(0,0),!0}if(!h.$isRangeSelection(d))return!1;e=c.shiftKey;return f.$shouldOverrideDefaultCharacterSelection(d,!1)?(c.preventDefault(),f.$moveCharacter(d,e,!1),!0):!1},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_BACKSPACE_COMMAND,
25
- c=>{if(F(c.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;c.preventDefault();({anchor:c}=d);const e=c.getNode();return d.isCollapsed()&&0===c.offset&&!h.$isRootNode(e)&&0<g.$getNearestBlockElementAncestorOrThrow(e).getIndent()?a.dispatchCommand(h.OUTDENT_CONTENT_COMMAND,void 0):a.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_DELETE_COMMAND,c=>{if(F(c.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
26
- c.preventDefault();return a.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ENTER_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;if(null!==c){if((q||p)&&n)return!1;c.preventDefault();if(c.shiftKey)return a.dispatchCommand(h.INSERT_LINE_BREAK_COMMAND,!1)}return a.dispatchCommand(h.INSERT_PARAGRAPH_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_TAB_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
27
- c.preventDefault();return a.dispatchCommand(c.shiftKey?h.OUTDENT_CONTENT_COMMAND:h.INDENT_CONTENT_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.KEY_ESCAPE_COMMAND,()=>{const c=h.$getSelection();if(!h.$isRangeSelection(c))return!1;a.blur();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.DROP_COMMAND,c=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;c.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.DRAGSTART_COMMAND,c=>{const d=h.$getSelection();
28
- if(!h.$isRangeSelection(d))return!1;c.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.COPY_COMMAND,c=>{C(c,a);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.CUT_COMMAND,c=>{D(c,a);return!0},h.COMMAND_PRIORITY_EDITOR),a.registerCommand(h.PASTE_COMMAND,c=>{const d=h.$getSelection();return h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d)?(B(c,a),!0):!1},h.COMMAND_PRIORITY_EDITOR))}
9
+ class r extends h.ElementNode{static getType(){return"quote"}static clone(c){return new r(c.__key)}constructor(c){super(c)}createDOM(c){let b=document.createElement("blockquote");g.addClassNamesToElement(b,c.theme.quote);return b}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:t,priority:0})}}static importJSON(c){let b=w();b.setFormat(c.format);b.setIndent(c.indent);b.setDirection(c.direction);return b}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(){let c=
10
+ h.$createParagraphNode(),b=this.getDirection();c.setDirection(b);this.insertAfter(c);return c}collapseAtStart(){let c=h.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}}function w(){return new r}
11
+ class x extends h.ElementNode{static getType(){return"heading"}static clone(c){return new x(c.__tag,c.__key)}constructor(c,b){super(b);this.__tag=c}getTag(){return this.__tag}createDOM(c){let b=this.__tag,d=document.createElement(b);c=c.theme.heading;void 0!==c&&g.addClassNamesToElement(d,c[b]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:y,priority:0}),h2:()=>({conversion:y,priority:0}),h3:()=>({conversion:y,priority:0}),h4:()=>({conversion:y,priority:0}),h5:()=>({conversion:y,
12
+ priority:0}),h6:()=>({conversion:y,priority:0}),p:c=>{c=c.firstChild;return null!==c&&z(c)?{conversion:()=>({node:null}),priority:3}:null},span:c=>z(c)?{conversion:()=>({node:A("h1")}),priority:3}:null}}static importJSON(c){let b=A(c.tag);b.setFormat(c.format);b.setIndent(c.indent);b.setDirection(c.direction);return b}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(){let c=h.$createParagraphNode(),b=this.getDirection();c.setDirection(b);this.insertAfter(c);
13
+ return c}collapseAtStart(){let c=h.$createParagraphNode();this.getChildren().forEach(b=>c.append(b));this.replace(c);return!0}extractWithChild(){return!0}}function z(c){return"span"===c.nodeName.toLowerCase()?"26pt"===c.style.fontSize:!1}function y(c){c=c.nodeName.toLowerCase();let b=null;if("h1"===c||"h2"===c||"h3"===c||"h4"===c||"h5"===c||"h6"===c)b=A(c);return{node:b}}function t(){return{node:w()}}function A(c){return new x(c)}
14
+ function B(c,b){c.preventDefault();b.update(()=>{let d=h.$getSelection(),e=c instanceof InputEvent||c instanceof KeyboardEvent?null:c.clipboardData;null!=e&&(h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d))&&a.$insertDataTransferForRichText(e,d,b)},{tag:"paste"})}
15
+ async function C(c,b){null!=b.getEditorState().read(()=>h.$getSelection())&&(await a.copyToClipboard__EXPERIMENTAL(b,c instanceof ClipboardEvent?c:null),b.update(()=>{let d=h.$getSelection();h.$isRangeSelection(d)?d.removeText():h.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())}))}
16
+ function D(c,b){var d=h.$getSelection();if(h.$isRangeSelection(d)){var e=new Set;d=d.getNodes();for(let u=0;u<d.length;u++){let v=d[u];var k=v.getKey();e.has(k)||(e.add(k),k=g.$getNearestBlockElementAncestorOrThrow(v),k.canInsertTab()?c(v):k.canIndent()&&b(k))}}}function E(c){c=h.$getNearestNodeFromDOMNode(c);return h.$isDecoratorNode(c)}exports.$createHeadingNode=A;exports.$createQuoteNode=w;exports.$isHeadingNode=function(c){return c instanceof x};
17
+ exports.$isQuoteNode=function(c){return c instanceof r};exports.HeadingNode=x;exports.QuoteNode=r;
18
+ exports.registerRichText=function(c){return g.mergeRegister(c.registerCommand(h.CLICK_COMMAND,()=>{const b=h.$getSelection();return h.$isNodeSelection(b)?(b.clear(),!0):!1},0),c.registerCommand(h.DELETE_CHARACTER_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteCharacter(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.DELETE_WORD_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteWord(b);return!0},h.COMMAND_PRIORITY_EDITOR),
19
+ c.registerCommand(h.DELETE_LINE_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.deleteLine(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,b=>{const d=h.$getSelection();if("string"===typeof b)h.$isRangeSelection(d)?d.insertText(b):h.DEPRECATED_$isGridSelection(d);else{if(!h.$isRangeSelection(d)&&!h.DEPRECATED_$isGridSelection(d))return!1;const e=b.dataTransfer;null!=e?a.$insertDataTransferForRichText(e,d,c):h.$isRangeSelection(d)&&
20
+ (b=b.data)&&d.insertText(b)}return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.REMOVE_TEXT_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;b.removeText();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.FORMAT_TEXT_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.formatText(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.FORMAT_ELEMENT_COMMAND,b=>{var d=h.$getSelection();if(!h.$isRangeSelection(d)&&!h.$isNodeSelection(d))return!1;
21
+ d=d.getNodes();for(const e of d)g.$getNearestBlockElementAncestorOrThrow(e).setFormat(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.INSERT_LINE_BREAK_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;d.insertLineBreak(b);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.INSERT_PARAGRAPH_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;b.insertParagraph();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.INDENT_CONTENT_COMMAND,
22
+ ()=>{D(()=>{c.dispatchCommand(h.CONTROLLED_TEXT_INSERTION_COMMAND,"\t")},b=>{const d=b.getIndent();10!==d&&b.setIndent(d+1)});return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.OUTDENT_CONTENT_COMMAND,()=>{D(b=>{h.$isTextNode(b)&&(b=b.getTextContent(),"\t"===b[b.length-1]&&c.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0))},b=>{const d=b.getIndent();0!==d&&b.setIndent(d-1)});return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_UP_COMMAND,b=>{const d=h.$getSelection();return h.$isNodeSelection(d)&&
23
+ !E(b.target)&&(b=d.getNodes(),0<b.length)?(b[0].selectPrevious(),!0):!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_DOWN_COMMAND,()=>{var b=h.$getSelection();return h.$isNodeSelection(b)&&(b=b.getNodes(),0<b.length)?(b[0].selectNext(0,0),!0):!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_LEFT_COMMAND,b=>{const d=h.$getSelection();if(h.$isNodeSelection(d)){var e=d.getNodes();if(0<e.length)return b.preventDefault(),e[0].selectPrevious(),!0}return h.$isRangeSelection(d)?f.$shouldOverrideDefaultCharacterSelection(d,
24
+ !0)?(e=b.shiftKey,b.preventDefault(),f.$moveCharacter(d,e,!0),!0):!1:!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ARROW_RIGHT_COMMAND,b=>{const d=h.$getSelection();if(h.$isNodeSelection(d)&&!E(b.target)){var e=d.getNodes();if(0<e.length)return b.preventDefault(),e[0].selectNext(0,0),!0}if(!h.$isRangeSelection(d))return!1;e=b.shiftKey;return f.$shouldOverrideDefaultCharacterSelection(d,!1)?(b.preventDefault(),f.$moveCharacter(d,e,!1),!0):!1},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_BACKSPACE_COMMAND,
25
+ b=>{if(E(b.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;b.preventDefault();({anchor:b}=d);const e=b.getNode();return d.isCollapsed()&&0===b.offset&&!h.$isRootNode(e)&&0<g.$getNearestBlockElementAncestorOrThrow(e).getIndent()?c.dispatchCommand(h.OUTDENT_CONTENT_COMMAND,void 0):c.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!0)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_DELETE_COMMAND,b=>{if(E(b.target))return!1;const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
26
+ b.preventDefault();return c.dispatchCommand(h.DELETE_CHARACTER_COMMAND,!1)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ENTER_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;if(null!==b){if((q||p)&&n)return!1;b.preventDefault();if(b.shiftKey)return c.dispatchCommand(h.INSERT_LINE_BREAK_COMMAND,!1)}return c.dispatchCommand(h.INSERT_PARAGRAPH_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_TAB_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;
27
+ b.preventDefault();return c.dispatchCommand(b.shiftKey?h.OUTDENT_CONTENT_COMMAND:h.INDENT_CONTENT_COMMAND,void 0)},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.KEY_ESCAPE_COMMAND,()=>{const b=h.$getSelection();if(!h.$isRangeSelection(b))return!1;c.blur();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.DROP_COMMAND,b=>{const d=h.$getSelection();if(!h.$isRangeSelection(d))return!1;b.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.DRAGSTART_COMMAND,b=>{const d=h.$getSelection();
28
+ if(!h.$isRangeSelection(d))return!1;b.preventDefault();return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.COPY_COMMAND,b=>{a.copyToClipboard__EXPERIMENTAL(c,b instanceof ClipboardEvent?b:null);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.CUT_COMMAND,b=>{C(b,c);return!0},h.COMMAND_PRIORITY_EDITOR),c.registerCommand(h.PASTE_COMMAND,b=>{const d=h.$getSelection();return h.$isRangeSelection(d)||h.DEPRECATED_$isGridSelection(d)?(B(b,c),!0):!1},h.COMMAND_PRIORITY_EDITOR))}
package/package.json CHANGED
@@ -7,13 +7,13 @@
7
7
  "rich-text"
8
8
  ],
9
9
  "license": "MIT",
10
- "version": "0.5.0",
10
+ "version": "0.5.1-next.1",
11
11
  "main": "LexicalRichText.js",
12
12
  "peerDependencies": {
13
- "lexical": "0.5.0",
14
- "@lexical/selection": "0.5.0",
15
- "@lexical/clipboard": "0.5.0",
16
- "@lexical/utils": "0.5.0"
13
+ "lexical": "0.5.1-next.1",
14
+ "@lexical/selection": "0.5.1-next.1",
15
+ "@lexical/clipboard": "0.5.1-next.1",
16
+ "@lexical/utils": "0.5.1-next.1"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",