@lexical/rich-text 0.4.1 → 0.5.0
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/LexicalRichText.dev.js +8 -63
- package/LexicalRichText.js.flow +1 -9
- package/LexicalRichText.prod.js +22 -23
- package/README.md +1 -1
- package/index.d.ts +2 -3
- package/package.json +5 -5
package/LexicalRichText.dev.js
CHANGED
|
@@ -31,14 +31,7 @@ const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !w
|
|
|
31
31
|
|
|
32
32
|
/** @module @lexical/rich-text */
|
|
33
33
|
|
|
34
|
-
// Convoluted logic to make this work with Flow. Order matters.
|
|
35
|
-
const options = {
|
|
36
|
-
tag: 'history-merge'
|
|
37
|
-
};
|
|
38
|
-
const setEditorOptions = options;
|
|
39
|
-
const updateOptions = options;
|
|
40
34
|
/** @noInheritDoc */
|
|
41
|
-
|
|
42
35
|
class QuoteNode extends lexical.ElementNode {
|
|
43
36
|
static getType() {
|
|
44
37
|
return 'quote';
|
|
@@ -283,60 +276,13 @@ function $isHeadingNode(node) {
|
|
|
283
276
|
return node instanceof HeadingNode;
|
|
284
277
|
}
|
|
285
278
|
|
|
286
|
-
function initializeEditor(editor, initialEditorState) {
|
|
287
|
-
if (initialEditorState === null) {
|
|
288
|
-
return;
|
|
289
|
-
} else if (initialEditorState === undefined) {
|
|
290
|
-
editor.update(() => {
|
|
291
|
-
const root = lexical.$getRoot();
|
|
292
|
-
|
|
293
|
-
if (root.isEmpty()) {
|
|
294
|
-
const paragraph = lexical.$createParagraphNode();
|
|
295
|
-
root.append(paragraph);
|
|
296
|
-
const activeElement = document.activeElement;
|
|
297
|
-
|
|
298
|
-
if (lexical.$getSelection() !== null || activeElement !== null && activeElement === editor.getRootElement()) {
|
|
299
|
-
paragraph.select();
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}, updateOptions);
|
|
303
|
-
} else if (initialEditorState !== null) {
|
|
304
|
-
switch (typeof initialEditorState) {
|
|
305
|
-
case 'string':
|
|
306
|
-
{
|
|
307
|
-
const parsedEditorState = editor.parseEditorState(initialEditorState);
|
|
308
|
-
editor.setEditorState(parsedEditorState, setEditorOptions);
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
case 'object':
|
|
313
|
-
{
|
|
314
|
-
editor.setEditorState(initialEditorState, setEditorOptions);
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
case 'function':
|
|
319
|
-
{
|
|
320
|
-
editor.update(() => {
|
|
321
|
-
const root = lexical.$getRoot();
|
|
322
|
-
|
|
323
|
-
if (root.isEmpty()) {
|
|
324
|
-
initialEditorState(editor);
|
|
325
|
-
}
|
|
326
|
-
}, updateOptions);
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
279
|
function onPasteForRichText(event, editor) {
|
|
334
280
|
event.preventDefault();
|
|
335
281
|
editor.update(() => {
|
|
336
282
|
const selection = lexical.$getSelection();
|
|
337
|
-
const clipboardData = event instanceof InputEvent ? null : event.clipboardData;
|
|
283
|
+
const clipboardData = event instanceof InputEvent || event instanceof KeyboardEvent ? null : event.clipboardData;
|
|
338
284
|
|
|
339
|
-
if (clipboardData != null && (lexical.$isRangeSelection(selection) || lexical
|
|
285
|
+
if (clipboardData != null && (lexical.$isRangeSelection(selection) || lexical.DEPRECATED_$isGridSelection(selection))) {
|
|
340
286
|
clipboard.$insertDataTransferForRichText(clipboardData, selection, editor);
|
|
341
287
|
}
|
|
342
288
|
}, {
|
|
@@ -426,7 +372,7 @@ function isTargetWithinDecorator(target) {
|
|
|
426
372
|
return lexical.$isDecoratorNode(node);
|
|
427
373
|
}
|
|
428
374
|
|
|
429
|
-
function registerRichText(editor
|
|
375
|
+
function registerRichText(editor) {
|
|
430
376
|
const removeListener = utils.mergeRegister(editor.registerCommand(lexical.CLICK_COMMAND, payload => {
|
|
431
377
|
const selection = lexical.$getSelection();
|
|
432
378
|
|
|
@@ -469,9 +415,9 @@ function registerRichText(editor, initialEditorState) {
|
|
|
469
415
|
if (typeof eventOrText === 'string') {
|
|
470
416
|
if (lexical.$isRangeSelection(selection)) {
|
|
471
417
|
selection.insertText(eventOrText);
|
|
472
|
-
} else if (lexical
|
|
418
|
+
} else if (lexical.DEPRECATED_$isGridSelection(selection)) ;
|
|
473
419
|
} else {
|
|
474
|
-
if (!lexical.$isRangeSelection(selection) && !lexical
|
|
420
|
+
if (!lexical.$isRangeSelection(selection) && !lexical.DEPRECATED_$isGridSelection(selection)) {
|
|
475
421
|
return false;
|
|
476
422
|
}
|
|
477
423
|
|
|
@@ -589,7 +535,7 @@ function registerRichText(editor, initialEditorState) {
|
|
|
589
535
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, event => {
|
|
590
536
|
const selection = lexical.$getSelection();
|
|
591
537
|
|
|
592
|
-
if (lexical.$isNodeSelection(selection)
|
|
538
|
+
if (lexical.$isNodeSelection(selection)) {
|
|
593
539
|
// If selection is on a node, let's try and move selection
|
|
594
540
|
// back to being a range selection.
|
|
595
541
|
const nodes = selection.getNodes();
|
|
@@ -604,7 +550,7 @@ function registerRichText(editor, initialEditorState) {
|
|
|
604
550
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, event => {
|
|
605
551
|
const selection$1 = lexical.$getSelection();
|
|
606
552
|
|
|
607
|
-
if (lexical.$isNodeSelection(selection$1)
|
|
553
|
+
if (lexical.$isNodeSelection(selection$1)) {
|
|
608
554
|
// If selection is on a node, let's try and move selection
|
|
609
555
|
// back to being a range selection.
|
|
610
556
|
const nodes = selection$1.getNodes();
|
|
@@ -767,14 +713,13 @@ function registerRichText(editor, initialEditorState) {
|
|
|
767
713
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.PASTE_COMMAND, event => {
|
|
768
714
|
const selection = lexical.$getSelection();
|
|
769
715
|
|
|
770
|
-
if (lexical.$isRangeSelection(selection) || lexical
|
|
716
|
+
if (lexical.$isRangeSelection(selection) || lexical.DEPRECATED_$isGridSelection(selection)) {
|
|
771
717
|
onPasteForRichText(event, editor);
|
|
772
718
|
return true;
|
|
773
719
|
}
|
|
774
720
|
|
|
775
721
|
return false;
|
|
776
722
|
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
777
|
-
initializeEditor(editor, initialEditorState);
|
|
778
723
|
return removeListener;
|
|
779
724
|
}
|
|
780
725
|
|
package/LexicalRichText.js.flow
CHANGED
|
@@ -16,11 +16,6 @@ import type {
|
|
|
16
16
|
LexicalEditor,
|
|
17
17
|
} from 'lexical';
|
|
18
18
|
import {ElementNode} from 'lexical';
|
|
19
|
-
export type InitialEditorStateType =
|
|
20
|
-
| null
|
|
21
|
-
| string
|
|
22
|
-
| EditorState
|
|
23
|
-
| ((editor: LexicalEditor) => void);
|
|
24
19
|
|
|
25
20
|
declare export class QuoteNode extends ElementNode {
|
|
26
21
|
static getType(): string;
|
|
@@ -54,7 +49,4 @@ declare export function $createHeadingNode(
|
|
|
54
49
|
declare export function $isHeadingNode(
|
|
55
50
|
node: ?LexicalNode,
|
|
56
51
|
): boolean %checks(node instanceof HeadingNode);
|
|
57
|
-
declare export function registerRichText(
|
|
58
|
-
editor: LexicalEditor,
|
|
59
|
-
initialEditorState?: InitialEditorStateType,
|
|
60
|
-
): () => void;
|
|
52
|
+
declare export function registerRichText(editor: LexicalEditor): () => void;
|
package/LexicalRichText.prod.js
CHANGED
|
@@ -4,26 +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"),
|
|
8
|
-
let
|
|
9
|
-
class
|
|
10
|
-
|
|
11
|
-
class
|
|
12
|
-
priority:0}),h6:()=>({conversion:
|
|
13
|
-
return a}collapseAtStart(){let a=
|
|
14
|
-
function
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
exports
|
|
19
|
-
|
|
20
|
-
a.registerCommand(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
c.
|
|
24
|
-
!0)
|
|
25
|
-
|
|
26
|
-
c
|
|
27
|
-
c.preventDefault();return a.dispatchCommand(
|
|
28
|
-
c.preventDefault();return
|
|
29
|
-
if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.COPY_COMMAND,c=>{E(c,a);return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.CUT_COMMAND,c=>{F(c,a);return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.PASTE_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(D(c,a),!0):!1},l.COMMAND_PRIORITY_EDITOR));C(a,e);return f}
|
|
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);
|
|
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))}
|
package/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
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
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/
|
|
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/packages/lexical-plain-text) instead.
|
package/index.d.ts
CHANGED
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
import type { DOMConversionMap, EditorConfig,
|
|
9
|
+
import type { DOMConversionMap, EditorConfig, LexicalEditor, LexicalNode, NodeKey, ParagraphNode, SerializedElementNode, Spread } from 'lexical';
|
|
10
10
|
import { ElementNode } from 'lexical';
|
|
11
|
-
export declare type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
|
|
12
11
|
export declare type SerializedHeadingNode = Spread<{
|
|
13
12
|
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
14
13
|
type: 'heading';
|
|
@@ -53,4 +52,4 @@ export declare class HeadingNode extends ElementNode {
|
|
|
53
52
|
}
|
|
54
53
|
export declare function $createHeadingNode(headingTag: HeadingTagType): HeadingNode;
|
|
55
54
|
export declare function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode;
|
|
56
|
-
export declare function registerRichText(editor: LexicalEditor
|
|
55
|
+
export declare function registerRichText(editor: LexicalEditor): () => void;
|
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"rich-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.5.0",
|
|
11
11
|
"main": "LexicalRichText.js",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"lexical": "0.
|
|
14
|
-
"@lexical/selection": "0.
|
|
15
|
-
"@lexical/clipboard": "0.
|
|
16
|
-
"@lexical/utils": "0.
|
|
13
|
+
"lexical": "0.5.0",
|
|
14
|
+
"@lexical/selection": "0.5.0",
|
|
15
|
+
"@lexical/clipboard": "0.5.0",
|
|
16
|
+
"@lexical/utils": "0.5.0"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|