@lexical/rich-text 0.3.7 → 0.3.8

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.
@@ -299,7 +299,7 @@ function onPasteForRichText(event, editor) {
299
299
  event.preventDefault();
300
300
  editor.update(() => {
301
301
  const selection = lexical.$getSelection();
302
- const clipboardData = event.clipboardData;
302
+ const clipboardData = event instanceof InputEvent ? null : event.clipboardData;
303
303
 
304
304
  if (clipboardData != null && (lexical.$isRangeSelection(selection) || lexical.$isGridSelection(selection))) {
305
305
  clipboard.$insertDataTransferForRichText(clipboardData, selection, editor);
@@ -312,7 +312,7 @@ function onCopyForRichText(event, editor) {
312
312
  const selection = lexical.$getSelection();
313
313
 
314
314
  if (selection !== null) {
315
- const clipboardData = event.clipboardData;
315
+ const clipboardData = event instanceof KeyboardEvent ? null : event.clipboardData;
316
316
  const htmlString = clipboard.$getHtmlContent(editor);
317
317
  const lexicalString = clipboard.$getLexicalContent(editor);
318
318
 
@@ -12,8 +12,8 @@ class y extends l.ElementNode{static getType(){return"heading"}static clone(a){r
12
12
  priority:0}),h6:()=>({conversion:z,priority:0})}}static importJSON(a){let e=A(a.tag);e.setFormat(a.format);e.setIndent(a.indent);e.setDirection(a.direction);return e}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(){let a=l.$createParagraphNode(),e=this.getDirection();a.setDirection(e);this.insertAfter(a);return a}collapseAtStart(){let a=l.$createParagraphNode();this.getChildren().forEach(e=>a.append(e));this.replace(a);return!0}extractWithChild(){return!0}}
13
13
  function z(a){a=a.nodeName.toLowerCase();let e=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)e=A(a);return{node:e}}function w(){return{node:x()}}function A(a){return new y(a)}
14
14
  function B(a,e){if(null!==e)if(void 0===e)a.update(()=>{var f=l.$getRoot();if(f.isEmpty()){let c=l.$createParagraphNode();f.append(c);f=document.activeElement;(null!==l.$getSelection()||null!==f&&f===a.getRootElement())&&c.select()}},t);else if(null!==e)switch(typeof e){case "string":let f=a.parseEditorState(e);a.setEditorState(f,t);break;case "object":a.setEditorState(e,t);break;case "function":a.update(()=>{l.$getRoot().isEmpty()&&e(a)},t)}}
15
- function C(a,e){a.preventDefault();e.update(()=>{let f=l.$getSelection(),c=a.clipboardData;null!=c&&(l.$isRangeSelection(f)||l.$isGridSelection(f))&&b.$insertDataTransferForRichText(c,f,e)})}
16
- function D(a,e){a.preventDefault();var f=l.$getSelection();if(null!==f){a=a.clipboardData;let c=b.$getHtmlContent(e);e=b.$getLexicalContent(e);null!=a?(null!==c&&a.setData("text/html",c),null!==e&&a.setData("application/x-lexical-editor",e),f=f.getTextContent(),a.setData("text/plain",f)):(f=navigator.clipboard,null!=f&&(a=[new ClipboardItem({"text/html":new Blob([c],{type:"text/html"})})],f.write(a)))}}
15
+ function C(a,e){a.preventDefault();e.update(()=>{let f=l.$getSelection(),c=a instanceof InputEvent?null:a.clipboardData;null!=c&&(l.$isRangeSelection(f)||l.$isGridSelection(f))&&b.$insertDataTransferForRichText(c,f,e)})}
16
+ function D(a,e){a.preventDefault();var f=l.$getSelection();if(null!==f){a=a instanceof KeyboardEvent?null:a.clipboardData;let c=b.$getHtmlContent(e);e=b.$getLexicalContent(e);null!=a?(null!==c&&a.setData("text/html",c),null!==e&&a.setData("application/x-lexical-editor",e),f=f.getTextContent(),a.setData("text/plain",f)):(f=navigator.clipboard,null!=f&&(a=[new ClipboardItem({"text/html":new Blob([c],{type:"text/html"})})],f.write(a)))}}
17
17
  function E(a,e){D(a,e);a=l.$getSelection();l.$isRangeSelection(a)?a.removeText():l.$isNodeSelection(a)&&a.getNodes().forEach(f=>f.remove())}function F(a,e){var f=l.$getSelection();if(l.$isRangeSelection(f)){var c=new Set;f=f.getNodes();for(let g=0;g<f.length;g++){let v=f[g];var d=v.getKey();c.has(d)||(c.add(d),d=k.$getNearestBlockElementAncestorOrThrow(v),d.canInsertTab()?a(v):d.canIndent()&&e(d))}}}function G(a){a=l.$getNearestNodeFromDOMNode(a);return l.$isDecoratorNode(a)}
18
18
  exports.$createHeadingNode=A;exports.$createQuoteNode=x;exports.$isHeadingNode=function(a){return a instanceof y};exports.$isQuoteNode=function(a){return a instanceof u};exports.HeadingNode=y;exports.QuoteNode=u;
19
19
  exports.registerRichText=function(a,e){let f=k.mergeRegister(a.registerCommand(l.CLICK_COMMAND,()=>{const c=l.$getSelection();return l.$isNodeSelection(c)?(c.clear(),!0):!1},0),a.registerCommand(l.DELETE_CHARACTER_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.deleteCharacter(c);return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.DELETE_WORD_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.deleteWord(c);return!0},l.COMMAND_PRIORITY_EDITOR),
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # `@lexical/rich-text`
2
2
 
3
- This package contains rich text helpers for Lexical.
3
+ This package provides a starting point for Lexical users by registering listeners for a set of basic commands that cover simple text-editing behavior such as entering text, deleting characters, copy + paste, or changing the selection with arrow keys. It also provides default behavior for rich text features, such as headings, formatted, text and blockquotes.
4
+
5
+ You can use this package as a starting point, and then add additional command listeners to customize the functionality of your editor. If you don't want or need rich text functionality, you may want to consider using [@lexical/plain-text](https://lexical.dev/docs/api/lexical-plain-text) instead.
package/package.json CHANGED
@@ -7,13 +7,13 @@
7
7
  "rich-text"
8
8
  ],
9
9
  "license": "MIT",
10
- "version": "0.3.7",
10
+ "version": "0.3.8",
11
11
  "main": "LexicalRichText.js",
12
12
  "peerDependencies": {
13
- "lexical": "0.3.7",
14
- "@lexical/selection": "0.3.7",
15
- "@lexical/clipboard": "0.3.7",
16
- "@lexical/utils": "0.3.7"
13
+ "lexical": "0.3.8",
14
+ "@lexical/selection": "0.3.8",
15
+ "@lexical/clipboard": "0.3.8",
16
+ "@lexical/utils": "0.3.8"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",