@lexical/rich-text 0.2.4 → 0.2.5
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.d.ts +2 -3
- package/LexicalRichText.dev.js +65 -50
- package/LexicalRichText.js.flow +2 -2
- package/LexicalRichText.prod.js +18 -18
- package/package.json +5 -5
package/LexicalRichText.d.ts
CHANGED
|
@@ -15,14 +15,13 @@ import type {
|
|
|
15
15
|
LexicalEditor,
|
|
16
16
|
} from 'lexical';
|
|
17
17
|
import {ElementNode} from 'lexical';
|
|
18
|
-
|
|
19
18
|
export type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
20
19
|
|
|
21
20
|
export declare class QuoteNode extends ElementNode {
|
|
22
21
|
static getType(): string;
|
|
23
22
|
static clone(node: QuoteNode): QuoteNode;
|
|
24
23
|
constructor(key?: NodeKey);
|
|
25
|
-
createDOM
|
|
24
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
26
25
|
updateDOM(prevNode: QuoteNode, dom: HTMLElement): boolean;
|
|
27
26
|
insertNewAfter(): ParagraphNode;
|
|
28
27
|
collapseAtStart(): true;
|
|
@@ -36,7 +35,7 @@ export declare class HeadingNode extends ElementNode {
|
|
|
36
35
|
static clone(node: HeadingNode): HeadingNode;
|
|
37
36
|
constructor(tag: HeadingTagType, key?: NodeKey);
|
|
38
37
|
getTag(): HeadingTagType;
|
|
39
|
-
createDOM
|
|
38
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
40
39
|
updateDOM(prevNode: HeadingNode, dom: HTMLElement): boolean;
|
|
41
40
|
static importDOM(): DOMConversionMap | null;
|
|
42
41
|
insertNewAfter(): ParagraphNode;
|
package/LexicalRichText.dev.js
CHANGED
|
@@ -32,8 +32,8 @@ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !==
|
|
|
32
32
|
const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
|
|
33
33
|
CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
34
34
|
CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
35
|
-
CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
|
|
36
|
-
CAN_USE_DOM && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
|
|
35
|
+
const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false;
|
|
36
|
+
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
|
|
37
37
|
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; // Keep these in case we need to use them in the future.
|
|
38
38
|
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
|
|
39
39
|
// export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
|
|
@@ -251,7 +251,7 @@ function onPasteForRichText(event, editor) {
|
|
|
251
251
|
const selection = lexical.$getSelection();
|
|
252
252
|
const clipboardData = event.clipboardData;
|
|
253
253
|
|
|
254
|
-
if (clipboardData != null && lexical.$isRangeSelection(selection)) {
|
|
254
|
+
if (clipboardData != null && lexical.$isRangeSelection(selection) || lexical.$isGridSelection(selection)) {
|
|
255
255
|
clipboard.$insertDataTransferForRichText(clipboardData, selection, editor);
|
|
256
256
|
}
|
|
257
257
|
});
|
|
@@ -293,6 +293,35 @@ function onCutForRichText(event, editor) {
|
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
function handleIndentAndOutdent(insertTab, indentOrOutdent) {
|
|
297
|
+
const selection = lexical.$getSelection();
|
|
298
|
+
|
|
299
|
+
if (!lexical.$isRangeSelection(selection)) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const alreadyHandled = new Set();
|
|
304
|
+
const nodes = selection.getNodes();
|
|
305
|
+
|
|
306
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
307
|
+
const node = nodes[i];
|
|
308
|
+
const key = node.getKey();
|
|
309
|
+
|
|
310
|
+
if (alreadyHandled.has(key)) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
alreadyHandled.add(key);
|
|
315
|
+
const parentBlock = utils.$getNearestBlockElementAncestorOrThrow(node);
|
|
316
|
+
|
|
317
|
+
if (parentBlock.canInsertTab()) {
|
|
318
|
+
insertTab(node);
|
|
319
|
+
} else if (parentBlock.canIndent()) {
|
|
320
|
+
indentOrOutdent(parentBlock);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
296
325
|
function registerRichText(editor, initialEditorState) {
|
|
297
326
|
const removeListener = utils.mergeRegister(editor.registerCommand(lexical.CLICK_COMMAND, payload => {
|
|
298
327
|
const selection = lexical.$getSelection();
|
|
@@ -303,14 +332,13 @@ function registerRichText(editor, initialEditorState) {
|
|
|
303
332
|
}
|
|
304
333
|
|
|
305
334
|
return false;
|
|
306
|
-
}, 0), editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND,
|
|
335
|
+
}, 0), editor.registerCommand(lexical.DELETE_CHARACTER_COMMAND, isBackward => {
|
|
307
336
|
const selection = lexical.$getSelection();
|
|
308
337
|
|
|
309
338
|
if (!lexical.$isRangeSelection(selection)) {
|
|
310
339
|
return false;
|
|
311
340
|
}
|
|
312
341
|
|
|
313
|
-
const isBackward = payload;
|
|
314
342
|
selection.deleteCharacter(isBackward);
|
|
315
343
|
return true;
|
|
316
344
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.DELETE_WORD_COMMAND, payload => {
|
|
@@ -335,21 +363,22 @@ function registerRichText(editor, initialEditorState) {
|
|
|
335
363
|
return true;
|
|
336
364
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INSERT_TEXT_COMMAND, payload => {
|
|
337
365
|
const selection = lexical.$getSelection();
|
|
338
|
-
|
|
339
|
-
if (!lexical.$isRangeSelection(selection)) {
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
366
|
const eventOrText = payload;
|
|
344
367
|
|
|
345
368
|
if (typeof eventOrText === 'string') {
|
|
346
|
-
selection
|
|
369
|
+
if (lexical.$isRangeSelection(selection)) {
|
|
370
|
+
selection.insertText(eventOrText);
|
|
371
|
+
} else if (lexical.$isGridSelection(selection)) ;
|
|
347
372
|
} else {
|
|
373
|
+
if (!lexical.$isRangeSelection(selection) && !lexical.$isGridSelection(selection)) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
|
|
348
377
|
const dataTransfer = eventOrText.dataTransfer;
|
|
349
378
|
|
|
350
379
|
if (dataTransfer != null) {
|
|
351
380
|
clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor);
|
|
352
|
-
} else {
|
|
381
|
+
} else if (lexical.$isRangeSelection(selection)) {
|
|
353
382
|
const data = eventOrText.data;
|
|
354
383
|
|
|
355
384
|
if (data) {
|
|
@@ -415,50 +444,33 @@ function registerRichText(editor, initialEditorState) {
|
|
|
415
444
|
selection.insertParagraph();
|
|
416
445
|
return true;
|
|
417
446
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, payload => {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (!lexical.$isRangeSelection(selection)) {
|
|
421
|
-
return false;
|
|
422
|
-
} // Handle code blocks
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const anchor = selection.anchor;
|
|
426
|
-
const parentBlock = utils.$getNearestBlockElementAncestorOrThrow(anchor.getNode());
|
|
427
|
-
|
|
428
|
-
if (parentBlock.canInsertTab()) {
|
|
447
|
+
handleIndentAndOutdent(() => {
|
|
429
448
|
editor.dispatchCommand(lexical.INSERT_TEXT_COMMAND, '\t');
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
parentBlock.setIndent(parentBlock.getIndent() + 1);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
449
|
+
}, block => {
|
|
450
|
+
const indent = block.getIndent();
|
|
435
451
|
|
|
452
|
+
if (indent !== 10) {
|
|
453
|
+
block.setIndent(indent + 1);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
436
456
|
return true;
|
|
437
457
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, payload => {
|
|
438
|
-
|
|
458
|
+
handleIndentAndOutdent(node => {
|
|
459
|
+
if (lexical.$isTextNode(node)) {
|
|
460
|
+
const textContent = node.getTextContent();
|
|
461
|
+
const character = textContent[textContent.length - 1];
|
|
439
462
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
const anchor = selection.anchor;
|
|
446
|
-
const anchorNode = anchor.getNode();
|
|
447
|
-
const parentBlock = utils.$getNearestBlockElementAncestorOrThrow(anchor.getNode());
|
|
448
|
-
|
|
449
|
-
if (parentBlock.canInsertTab()) {
|
|
450
|
-
const textContent = anchorNode.getTextContent();
|
|
451
|
-
const character = textContent[anchor.offset - 1];
|
|
452
|
-
|
|
453
|
-
if (character === '\t') {
|
|
454
|
-
editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, true);
|
|
455
|
-
}
|
|
456
|
-
} else {
|
|
457
|
-
if (parentBlock.getIndent() !== 0) {
|
|
458
|
-
parentBlock.setIndent(parentBlock.getIndent() - 1);
|
|
463
|
+
if (character === '\t') {
|
|
464
|
+
editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, true);
|
|
465
|
+
}
|
|
459
466
|
}
|
|
460
|
-
}
|
|
467
|
+
}, block => {
|
|
468
|
+
const indent = block.getIndent();
|
|
461
469
|
|
|
470
|
+
if (indent !== 0) {
|
|
471
|
+
block.setIndent(indent - 1);
|
|
472
|
+
}
|
|
473
|
+
});
|
|
462
474
|
return true;
|
|
463
475
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_ARROW_LEFT_COMMAND, payload => {
|
|
464
476
|
const selection$1 = lexical.$getSelection();
|
|
@@ -538,7 +550,10 @@ function registerRichText(editor, initialEditorState) {
|
|
|
538
550
|
// the default behavior. This ensures that the iOS can
|
|
539
551
|
// intercept that we're actually inserting a paragraph,
|
|
540
552
|
// and autocomplete, autocapitialize etc work as intended.
|
|
541
|
-
|
|
553
|
+
// This can also cause a strange performance issue in
|
|
554
|
+
// Safari, where there is a noticeable pause due to
|
|
555
|
+
// preventing the key down of enter.
|
|
556
|
+
if ((IS_IOS || IS_SAFARI) && CAN_USE_BEFORE_INPUT) {
|
|
542
557
|
return false;
|
|
543
558
|
}
|
|
544
559
|
|
package/LexicalRichText.js.flow
CHANGED
|
@@ -22,7 +22,7 @@ declare export class QuoteNode extends ElementNode {
|
|
|
22
22
|
static getType(): string;
|
|
23
23
|
static clone(node: QuoteNode): QuoteNode;
|
|
24
24
|
constructor(key?: NodeKey): void;
|
|
25
|
-
createDOM
|
|
25
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
26
26
|
updateDOM(prevNode: QuoteNode, dom: HTMLElement): boolean;
|
|
27
27
|
insertNewAfter(): ParagraphNode;
|
|
28
28
|
collapseAtStart(): true;
|
|
@@ -38,7 +38,7 @@ declare export class HeadingNode extends ElementNode {
|
|
|
38
38
|
static clone(node: HeadingNode): HeadingNode;
|
|
39
39
|
constructor(tag: HeadingTagType, key?: NodeKey): void;
|
|
40
40
|
getTag(): HeadingTagType;
|
|
41
|
-
createDOM
|
|
41
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
42
42
|
updateDOM(prevNode: HeadingNode, dom: HTMLElement): boolean;
|
|
43
43
|
static importDOM(): DOMConversionMap | null;
|
|
44
44
|
insertNewAfter(): ParagraphNode;
|
package/LexicalRichText.prod.js
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
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
|
-
var a=require("@lexical/clipboard"),h=require("@lexical/selection"),k=require("@lexical/utils"),l=require("lexical");const m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,n=m&&"documentMode"in document?document.documentMode:null;m&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);m&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
8
|
-
m&&/Version\/[\d\.]+.*Safari/.test(navigator.userAgent)
|
|
9
|
-
class
|
|
10
|
-
class
|
|
11
|
-
({conversion:
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function
|
|
7
|
+
var a=require("@lexical/clipboard"),h=require("@lexical/selection"),k=require("@lexical/utils"),l=require("lexical");const m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,n=m&&"documentMode"in document?document.documentMode:null;m&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);m&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
8
|
+
const p=m&&"InputEvent"in window&&!n?"getTargetRanges"in new window.InputEvent("input"):!1,q=m&&/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),r=m&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,u={tag:"history-merge"};
|
|
9
|
+
class v extends l.ElementNode{static getType(){return"quote"}static clone(b){return new v(b.__key)}constructor(b){super(b)}createDOM(b){const e=document.createElement("blockquote");k.addClassNamesToElement(e,b.theme.quote);return e}updateDOM(){return!1}insertNewAfter(){const b=l.$createParagraphNode(),e=this.getDirection();b.setDirection(e);this.insertAfter(b);return b}collapseAtStart(){const b=l.$createParagraphNode();this.getChildren().forEach(e=>b.append(e));this.replace(b);return!0}}
|
|
10
|
+
class w extends l.ElementNode{static getType(){return"heading"}static clone(b){return new w(b.__tag,b.__key)}constructor(b,e){super(e);this.__tag=b}getTag(){return this.__tag}createDOM(b){const e=this.__tag,f=document.createElement(e);b=b.theme.heading;void 0!==b&&k.addClassNamesToElement(f,b[e]);return f}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:x,priority:0}),h2:()=>({conversion:x,priority:0}),h3:()=>({conversion:x,priority:0}),h4:()=>({conversion:x,priority:0}),h5:()=>
|
|
11
|
+
({conversion:x,priority:0})}}insertNewAfter(){const b=l.$createParagraphNode(),e=this.getDirection();b.setDirection(e);this.insertAfter(b);return b}collapseAtStart(){const b=l.$createParagraphNode();this.getChildren().forEach(e=>b.append(e));this.replace(b);return!0}}function x(b){b=b.nodeName.toLowerCase();let e=null;if("h1"===b||"h2"===b||"h3"===b||"h4"===b||"h5"===b)e=y(b);return{node:e}}function y(b){return new w(b)}
|
|
12
|
+
function z(b,e){if(null!==e)if(void 0===e)b.update(()=>{var f=l.$getRoot();if(null===f.getFirstChild()){const c=l.$createParagraphNode();f.append(c);f=document.activeElement;(null!==l.$getSelection()||null!==f&&f===b.getRootElement())&&c.select()}},u);else if(null!==e)switch(typeof e){case "string":e=b.parseEditorState(e);b.setEditorState(e,u);break;case "object":b.setEditorState(e,u);break;case "function":b.update(e,u)}}
|
|
13
|
+
function A(b,e){b.preventDefault();e.update(()=>{const f=l.$getSelection(),c=b.clipboardData;(null!=c&&l.$isRangeSelection(f)||l.$isGridSelection(f))&&a.$insertDataTransferForRichText(c,f,e)})}function B(b,e){b.preventDefault();e.update(()=>{const f=b.clipboardData,c=l.$getSelection();if(null!==c&&null!=f){const d=a.getHtmlContent(e),g=a.$getLexicalContent(e);null!==d&&f.setData("text/html",d);null!==g&&f.setData("application/x-lexical-editor",g);f.setData("text/plain",c.getTextContent())}})}
|
|
14
|
+
function C(b,e){B(b,e);e.update(()=>{const f=l.$getSelection();l.$isRangeSelection(f)&&f.removeText()})}function D(b,e){var f=l.$getSelection();if(l.$isRangeSelection(f)){var c=new Set;f=f.getNodes();for(let g=0;g<f.length;g++){const t=f[g];var d=t.getKey();c.has(d)||(c.add(d),d=k.$getNearestBlockElementAncestorOrThrow(t),d.canInsertTab()?b(t):d.canIndent()&&e(d))}}}exports.$createHeadingNode=y;exports.$createQuoteNode=function(){return new v};
|
|
15
|
+
exports.$isHeadingNode=function(b){return b instanceof w};exports.$isQuoteNode=function(b){return b instanceof v};exports.HeadingNode=w;exports.QuoteNode=v;
|
|
15
16
|
exports.registerRichText=function(b,e){const f=k.mergeRegister(b.registerCommand(l.CLICK_COMMAND,()=>{const c=l.$getSelection();return l.$isNodeSelection(c)?(c.clear(),!0):!1},0),b.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),b.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),
|
|
16
|
-
b.registerCommand(l.DELETE_LINE_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.deleteLine(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INSERT_TEXT_COMMAND,c=>{const d=l.$getSelection();if(
|
|
17
|
-
if(!l.$isRangeSelection(c))return!1;c.removeText();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.FORMAT_TEXT_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.formatText(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.FORMAT_ELEMENT_COMMAND,c=>{var d=l.$getSelection();if(!l.$isRangeSelection(d)&&!l.$isNodeSelection(d))return!1;d=d.getNodes();for(const g of d)k.$getNearestBlockElementAncestorOrThrow(g).setFormat(c);
|
|
18
|
-
b.registerCommand(l.INSERT_LINE_BREAK_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.insertLineBreak(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INSERT_PARAGRAPH_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.insertParagraph();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INDENT_CONTENT_COMMAND,()=>{
|
|
19
|
-
|
|
20
|
-
l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.
|
|
21
|
-
|
|
22
|
-
c.preventDefault();return b.dispatchCommand(l.
|
|
23
|
-
c
|
|
24
|
-
|
|
25
|
-
l.$isGridSelection(d)?(x(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR));w(b,e);return f};
|
|
17
|
+
b.registerCommand(l.DELETE_LINE_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.deleteLine(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INSERT_TEXT_COMMAND,c=>{const d=l.$getSelection();if("string"===typeof c)l.$isRangeSelection(d)?d.insertText(c):l.$isGridSelection(d);else{if(!l.$isRangeSelection(d)&&!l.$isGridSelection(d))return!1;const g=c.dataTransfer;null!=g?a.$insertDataTransferForRichText(g,d,b):l.$isRangeSelection(d)&&(c=c.data)&&d.insertText(c)}return!0},
|
|
18
|
+
l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.REMOVE_TEXT_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.removeText();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.FORMAT_TEXT_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.formatText(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.FORMAT_ELEMENT_COMMAND,c=>{var d=l.$getSelection();if(!l.$isRangeSelection(d)&&!l.$isNodeSelection(d))return!1;d=d.getNodes();for(const g of d)k.$getNearestBlockElementAncestorOrThrow(g).setFormat(c);
|
|
19
|
+
return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INSERT_LINE_BREAK_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;d.insertLineBreak(c);return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INSERT_PARAGRAPH_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.insertParagraph();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.INDENT_CONTENT_COMMAND,()=>{D(()=>{b.dispatchCommand(l.INSERT_TEXT_COMMAND,"\t")},c=>{const d=c.getIndent();
|
|
20
|
+
10!==d&&c.setIndent(d+1)});return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.OUTDENT_CONTENT_COMMAND,()=>{D(c=>{l.$isTextNode(c)&&(c=c.getTextContent(),"\t"===c[c.length-1]&&b.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!0))},c=>{const d=c.getIndent();0!==d&&c.setIndent(d-1)});return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;const g=c.shiftKey;return h.$shouldOverrideDefaultCharacterSelection(d,
|
|
21
|
+
!0)?(c.preventDefault(),h.$moveCharacter(d,g,!0),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ARROW_RIGHT_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;const g=c.shiftKey;return h.$shouldOverrideDefaultCharacterSelection(d,!1)?(c.preventDefault(),h.$moveCharacter(d,g,!1),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_BACKSPACE_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();({anchor:c}=d);return d.isCollapsed()&&
|
|
22
|
+
0===c.offset&&0<k.$getNearestBlockElementAncestorOrThrow(c.getNode()).getIndent()?b.dispatchCommand(l.OUTDENT_CONTENT_COMMAND):b.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!0)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_DELETE_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return b.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!1)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ENTER_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;
|
|
23
|
+
if(null!==c){if((r||q)&&p)return!1;c.preventDefault();if(c.shiftKey)return b.dispatchCommand(l.INSERT_LINE_BREAK_COMMAND)}return b.dispatchCommand(l.INSERT_PARAGRAPH_COMMAND)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_TAB_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return b.dispatchCommand(c.shiftKey?l.OUTDENT_CONTENT_COMMAND:l.INDENT_CONTENT_COMMAND)},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{const c=l.$getSelection();
|
|
24
|
+
if(!l.$isRangeSelection(c))return!1;b.blur();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.DROP_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.DRAGSTART_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.COPY_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?
|
|
25
|
+
(B(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.CUT_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(C(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR),b.registerCommand(l.PASTE_COMMAND,c=>{const d=l.$getSelection();return l.$isRangeSelection(d)||l.$isGridSelection(d)?(A(c,b),!0):!1},l.COMMAND_PRIORITY_EDITOR));z(b,e);return f};
|
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"rich-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.2.
|
|
10
|
+
"version": "0.2.5",
|
|
11
11
|
"main": "LexicalRichText.js",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"lexical": "0.2.
|
|
14
|
-
"@lexical/selection": "0.2.
|
|
15
|
-
"@lexical/clipboard": "0.2.
|
|
16
|
-
"@lexical/utils": "0.2.
|
|
13
|
+
"lexical": "0.2.5",
|
|
14
|
+
"@lexical/selection": "0.2.5",
|
|
15
|
+
"@lexical/clipboard": "0.2.5",
|
|
16
|
+
"@lexical/utils": "0.2.5"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|