@lexical/rich-text 0.3.1 → 0.3.4
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 +32 -4
- package/LexicalRichText.js.flow +6 -2
- package/LexicalRichText.prod.js +21 -20
- package/index.d.ts +52 -0
- package/package.json +5 -5
- package/LexicalRichText.d.ts +0 -77
package/LexicalRichText.dev.js
CHANGED
|
@@ -38,6 +38,7 @@ const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && //
|
|
|
38
38
|
* LICENSE file in the root directory of this source tree.
|
|
39
39
|
*
|
|
40
40
|
*/
|
|
41
|
+
|
|
41
42
|
// Convoluted logic to make this work with Flow. Order matters.
|
|
42
43
|
const options = {
|
|
43
44
|
tag: 'history-merge'
|
|
@@ -173,6 +174,10 @@ class HeadingNode extends lexical.ElementNode {
|
|
|
173
174
|
h5: node => ({
|
|
174
175
|
conversion: convertHeadingElement,
|
|
175
176
|
priority: 0
|
|
177
|
+
}),
|
|
178
|
+
h6: node => ({
|
|
179
|
+
conversion: convertHeadingElement,
|
|
180
|
+
priority: 0
|
|
176
181
|
})
|
|
177
182
|
};
|
|
178
183
|
}
|
|
@@ -220,7 +225,7 @@ function convertHeadingElement(domNode) {
|
|
|
220
225
|
const nodeName = domNode.nodeName.toLowerCase();
|
|
221
226
|
let node = null;
|
|
222
227
|
|
|
223
|
-
if (nodeName === 'h1' || nodeName === 'h2' || nodeName === 'h3' || nodeName === 'h4' || nodeName === 'h5') {
|
|
228
|
+
if (nodeName === 'h1' || nodeName === 'h2' || nodeName === 'h3' || nodeName === 'h4' || nodeName === 'h5' || nodeName === 'h6') {
|
|
224
229
|
node = $createHeadingNode(nodeName);
|
|
225
230
|
}
|
|
226
231
|
|
|
@@ -249,9 +254,8 @@ function initializeEditor(editor, initialEditorState) {
|
|
|
249
254
|
} else if (initialEditorState === undefined) {
|
|
250
255
|
editor.update(() => {
|
|
251
256
|
const root = lexical.$getRoot();
|
|
252
|
-
const firstChild = root.getFirstChild();
|
|
253
257
|
|
|
254
|
-
if (
|
|
258
|
+
if (root.isEmpty()) {
|
|
255
259
|
const paragraph = lexical.$createParagraphNode();
|
|
256
260
|
root.append(paragraph);
|
|
257
261
|
const activeElement = document.activeElement;
|
|
@@ -278,7 +282,13 @@ function initializeEditor(editor, initialEditorState) {
|
|
|
278
282
|
|
|
279
283
|
case 'function':
|
|
280
284
|
{
|
|
281
|
-
editor.update(
|
|
285
|
+
editor.update(() => {
|
|
286
|
+
const root = lexical.$getRoot();
|
|
287
|
+
|
|
288
|
+
if (root.isEmpty()) {
|
|
289
|
+
initialEditorState(editor);
|
|
290
|
+
}
|
|
291
|
+
}, updateOptions);
|
|
282
292
|
break;
|
|
283
293
|
}
|
|
284
294
|
}
|
|
@@ -304,12 +314,17 @@ function onCopyForRichText(event, editor) {
|
|
|
304
314
|
if (selection !== null) {
|
|
305
315
|
const clipboardData = event.clipboardData;
|
|
306
316
|
const htmlString = clipboard.$getHtmlContent(editor);
|
|
317
|
+
const lexicalString = clipboard.$getLexicalContent(editor);
|
|
307
318
|
|
|
308
319
|
if (clipboardData != null) {
|
|
309
320
|
if (htmlString !== null) {
|
|
310
321
|
clipboardData.setData('text/html', htmlString);
|
|
311
322
|
}
|
|
312
323
|
|
|
324
|
+
if (lexicalString !== null) {
|
|
325
|
+
clipboardData.setData('application/x-lexical-editor', lexicalString);
|
|
326
|
+
}
|
|
327
|
+
|
|
313
328
|
const plainString = selection.getTextContent();
|
|
314
329
|
clipboardData.setData('text/plain', plainString);
|
|
315
330
|
} else {
|
|
@@ -369,6 +384,11 @@ function handleIndentAndOutdent(insertTab, indentOrOutdent) {
|
|
|
369
384
|
}
|
|
370
385
|
}
|
|
371
386
|
|
|
387
|
+
function isTargetWithinDecorator(target) {
|
|
388
|
+
const node = lexical.$getNearestNodeFromDOMNode(target);
|
|
389
|
+
return lexical.$isDecoratorNode(node);
|
|
390
|
+
}
|
|
391
|
+
|
|
372
392
|
function registerRichText(editor, initialEditorState) {
|
|
373
393
|
const removeListener = utils.mergeRegister(editor.registerCommand(lexical.CLICK_COMMAND, payload => {
|
|
374
394
|
const selection = lexical.$getSelection();
|
|
@@ -547,6 +567,10 @@ function registerRichText(editor, initialEditorState) {
|
|
|
547
567
|
|
|
548
568
|
return false;
|
|
549
569
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_BACKSPACE_COMMAND, event => {
|
|
570
|
+
if (isTargetWithinDecorator(event.target)) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
|
|
550
574
|
const selection = lexical.$getSelection();
|
|
551
575
|
|
|
552
576
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -568,6 +592,10 @@ function registerRichText(editor, initialEditorState) {
|
|
|
568
592
|
|
|
569
593
|
return editor.dispatchCommand(lexical.DELETE_CHARACTER_COMMAND, true);
|
|
570
594
|
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_DELETE_COMMAND, event => {
|
|
595
|
+
if (isTargetWithinDecorator(event.target)) {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
|
|
571
599
|
const selection = lexical.$getSelection();
|
|
572
600
|
|
|
573
601
|
if (!lexical.$isRangeSelection(selection)) {
|
package/LexicalRichText.js.flow
CHANGED
|
@@ -16,7 +16,11 @@ import type {
|
|
|
16
16
|
LexicalEditor,
|
|
17
17
|
} from 'lexical';
|
|
18
18
|
import {ElementNode} from 'lexical';
|
|
19
|
-
export type InitialEditorStateType =
|
|
19
|
+
export type InitialEditorStateType =
|
|
20
|
+
| null
|
|
21
|
+
| string
|
|
22
|
+
| EditorState
|
|
23
|
+
| ((editor: LexicalEditor) => void);
|
|
20
24
|
|
|
21
25
|
declare export class QuoteNode extends ElementNode {
|
|
22
26
|
static getType(): string;
|
|
@@ -31,7 +35,7 @@ declare export function $createQuoteNode(): QuoteNode;
|
|
|
31
35
|
declare export function $isQuoteNode(
|
|
32
36
|
node: ?LexicalNode,
|
|
33
37
|
): boolean %checks(node instanceof QuoteNode);
|
|
34
|
-
export type HeadingTagType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5';
|
|
38
|
+
export type HeadingTagType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
35
39
|
declare export class HeadingNode extends ElementNode {
|
|
36
40
|
__tag: HeadingTagType;
|
|
37
41
|
static getType(): string;
|
package/LexicalRichText.prod.js
CHANGED
|
@@ -4,24 +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
|
|
7
|
+
'use strict';var b=require("@lexical/clipboard"),h=require("@lexical/selection"),k=require("@lexical/utils"),l=require("lexical");let 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
8
|
let 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,t={tag:"history-merge"};
|
|
9
|
-
class u extends l.ElementNode{static getType(){return"quote"}static clone(
|
|
10
|
-
l.$createParagraphNode(),e=this.getDirection();
|
|
11
|
-
class y extends l.ElementNode{static getType(){return"heading"}static clone(
|
|
12
|
-
priority:0})}}static importJSON(
|
|
13
|
-
function z(
|
|
14
|
-
function B(
|
|
15
|
-
function C(
|
|
16
|
-
function D(
|
|
17
|
-
function F(
|
|
18
|
-
exports
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
0
|
|
25
|
-
|
|
26
|
-
l.$getSelection();if(!l.$isRangeSelection(
|
|
27
|
-
|
|
9
|
+
class u extends l.ElementNode{static getType(){return"quote"}static clone(a){return new u(a.__key)}constructor(a){super(a)}createDOM(a){let e=document.createElement("blockquote");k.addClassNamesToElement(e,a.theme.quote);return e}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:w,priority:0})}}static importJSON(a){let e=x();e.setFormat(a.format);e.setIndent(a.indent);e.setDirection(a.direction);return e}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(){let a=
|
|
10
|
+
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}}function x(){return new u}
|
|
11
|
+
class y extends l.ElementNode{static getType(){return"heading"}static clone(a){return new y(a.__tag,a.__key)}constructor(a,e){super(e);this.__tag=a}getTag(){return this.__tag}createDOM(a){let e=this.__tag,f=document.createElement(e);a=a.theme.heading;void 0!==a&&k.addClassNamesToElement(f,a[e]);return f}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:z,priority:0}),h2:()=>({conversion:z,priority:0}),h3:()=>({conversion:z,priority:0}),h4:()=>({conversion:z,priority:0}),h5:()=>({conversion:z,
|
|
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
|
+
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
|
+
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)))}}
|
|
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
|
+
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
|
+
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),
|
|
20
|
+
a.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),a.registerCommand(l.CONTROLLED_TEXT_INSERTION_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?b.$insertDataTransferForRichText(g,d,a):l.$isRangeSelection(d)&&(c=c.data)&&d.insertText(c)}return!0},
|
|
21
|
+
l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.REMOVE_TEXT_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.removeText();return!0},l.COMMAND_PRIORITY_EDITOR),a.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),a.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);
|
|
22
|
+
return!0},l.COMMAND_PRIORITY_EDITOR),a.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),a.registerCommand(l.INSERT_PARAGRAPH_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;c.insertParagraph();return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.INDENT_CONTENT_COMMAND,()=>{F(()=>{a.dispatchCommand(l.CONTROLLED_TEXT_INSERTION_COMMAND,"\t")},c=>{const d=
|
|
23
|
+
c.getIndent();10!==d&&c.setIndent(d+1)});return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.OUTDENT_CONTENT_COMMAND,()=>{F(c=>{l.$isTextNode(c)&&(c=c.getTextContent(),"\t"===c[c.length-1]&&a.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!0))},c=>{const d=c.getIndent();0!==d&&c.setIndent(d-1)});return!0},l.COMMAND_PRIORITY_EDITOR),a.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,
|
|
24
|
+
!0)?(c.preventDefault(),h.$moveCharacter(d,g,!0),!0):!1},l.COMMAND_PRIORITY_EDITOR),a.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),a.registerCommand(l.KEY_BACKSPACE_COMMAND,c=>{if(G(c.target))return!1;const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();({anchor:c}=
|
|
25
|
+
d);return d.isCollapsed()&&0===c.offset&&0<k.$getNearestBlockElementAncestorOrThrow(c.getNode()).getIndent()?a.dispatchCommand(l.OUTDENT_CONTENT_COMMAND,void 0):a.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!0)},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.KEY_DELETE_COMMAND,c=>{if(G(c.target))return!1;const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return a.dispatchCommand(l.DELETE_CHARACTER_COMMAND,!1)},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.KEY_ENTER_COMMAND,
|
|
26
|
+
c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;if(null!==c){if((r||q)&&p)return!1;c.preventDefault();if(c.shiftKey)return a.dispatchCommand(l.INSERT_LINE_BREAK_COMMAND,!1)}return a.dispatchCommand(l.INSERT_PARAGRAPH_COMMAND,void 0)},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.KEY_TAB_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return a.dispatchCommand(c.shiftKey?l.OUTDENT_CONTENT_COMMAND:l.INDENT_CONTENT_COMMAND,void 0)},l.COMMAND_PRIORITY_EDITOR),
|
|
27
|
+
a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{const c=l.$getSelection();if(!l.$isRangeSelection(c))return!1;a.blur();return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.DROP_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.DRAGSTART_COMMAND,c=>{const d=l.$getSelection();if(!l.$isRangeSelection(d))return!1;c.preventDefault();return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.COPY_COMMAND,c=>
|
|
28
|
+
{D(c,a);return!0},l.COMMAND_PRIORITY_EDITOR),a.registerCommand(l.CUT_COMMAND,c=>{E(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)?(C(c,a),!0):!1},l.COMMAND_PRIORITY_EDITOR));B(a,e);return f}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { DOMConversionMap, EditorConfig, EditorState, LexicalEditor, LexicalNode, NodeKey, ParagraphNode, SerializedElementNode, Spread } from 'lexical';
|
|
9
|
+
import { ElementNode } from 'lexical';
|
|
10
|
+
export declare type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
|
|
11
|
+
export declare type SerializedHeadingNode = Spread<{
|
|
12
|
+
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
13
|
+
type: 'heading';
|
|
14
|
+
version: 1;
|
|
15
|
+
}, SerializedElementNode>;
|
|
16
|
+
export declare type SerializedQuoteNode = Spread<{
|
|
17
|
+
type: 'quote';
|
|
18
|
+
version: 1;
|
|
19
|
+
}, SerializedElementNode>;
|
|
20
|
+
export declare class QuoteNode extends ElementNode {
|
|
21
|
+
static getType(): string;
|
|
22
|
+
static clone(node: QuoteNode): QuoteNode;
|
|
23
|
+
constructor(key?: NodeKey);
|
|
24
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
25
|
+
updateDOM(prevNode: QuoteNode, dom: HTMLElement): boolean;
|
|
26
|
+
static importDOM(): DOMConversionMap | null;
|
|
27
|
+
static importJSON(serializedNode: SerializedQuoteNode): QuoteNode;
|
|
28
|
+
exportJSON(): SerializedElementNode;
|
|
29
|
+
insertNewAfter(): ParagraphNode;
|
|
30
|
+
collapseAtStart(): true;
|
|
31
|
+
}
|
|
32
|
+
export declare function $createQuoteNode(): QuoteNode;
|
|
33
|
+
export declare function $isQuoteNode(node: LexicalNode | null | undefined): node is QuoteNode;
|
|
34
|
+
export declare type HeadingTagType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
35
|
+
export declare class HeadingNode extends ElementNode {
|
|
36
|
+
__tag: HeadingTagType;
|
|
37
|
+
static getType(): string;
|
|
38
|
+
static clone(node: HeadingNode): HeadingNode;
|
|
39
|
+
constructor(tag: HeadingTagType, key?: NodeKey);
|
|
40
|
+
getTag(): HeadingTagType;
|
|
41
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
42
|
+
updateDOM(prevNode: HeadingNode, dom: HTMLElement): boolean;
|
|
43
|
+
static importDOM(): DOMConversionMap | null;
|
|
44
|
+
static importJSON(serializedNode: SerializedHeadingNode): HeadingNode;
|
|
45
|
+
exportJSON(): SerializedHeadingNode;
|
|
46
|
+
insertNewAfter(): ParagraphNode;
|
|
47
|
+
collapseAtStart(): true;
|
|
48
|
+
extractWithChild(): boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function $createHeadingNode(headingTag: HeadingTagType): HeadingNode;
|
|
51
|
+
export declare function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode;
|
|
52
|
+
export declare function registerRichText(editor: LexicalEditor, initialEditorState?: InitialEditorStateType): () => void;
|
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"rich-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.3.
|
|
10
|
+
"version": "0.3.4",
|
|
11
11
|
"main": "LexicalRichText.js",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"lexical": "0.3.
|
|
14
|
-
"@lexical/selection": "0.3.
|
|
15
|
-
"@lexical/clipboard": "0.3.
|
|
16
|
-
"@lexical/utils": "0.3.
|
|
13
|
+
"lexical": "0.3.4",
|
|
14
|
+
"@lexical/selection": "0.3.4",
|
|
15
|
+
"@lexical/clipboard": "0.3.4",
|
|
16
|
+
"@lexical/utils": "0.3.4"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
package/LexicalRichText.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
DOMConversionMap,
|
|
11
|
-
EditorConfig,
|
|
12
|
-
EditorState,
|
|
13
|
-
LexicalNode,
|
|
14
|
-
NodeKey,
|
|
15
|
-
ParagraphNode,
|
|
16
|
-
LexicalEditor,
|
|
17
|
-
SerializedElementNode,
|
|
18
|
-
} from 'lexical';
|
|
19
|
-
import {ElementNode} from 'lexical';
|
|
20
|
-
import {Spread} from 'libdefs/globals';
|
|
21
|
-
|
|
22
|
-
export type InitialEditorStateType = null | string | EditorState | (() => void);
|
|
23
|
-
|
|
24
|
-
export declare class QuoteNode extends ElementNode {
|
|
25
|
-
static getType(): string;
|
|
26
|
-
static clone(node: QuoteNode): QuoteNode;
|
|
27
|
-
constructor(key?: NodeKey);
|
|
28
|
-
createDOM(config: EditorConfig): HTMLElement;
|
|
29
|
-
updateDOM(prevNode: QuoteNode, dom: HTMLElement): boolean;
|
|
30
|
-
insertNewAfter(): ParagraphNode;
|
|
31
|
-
collapseAtStart(): true;
|
|
32
|
-
importJSON(serializedNode: SerializedQuoteNode): QuoteNode;
|
|
33
|
-
}
|
|
34
|
-
export function $createQuoteNode(): QuoteNode;
|
|
35
|
-
export function $isQuoteNode(
|
|
36
|
-
node: LexicalNode | null | undefined,
|
|
37
|
-
): node is QuoteNode;
|
|
38
|
-
export type HeadingTagType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5';
|
|
39
|
-
export declare class HeadingNode extends ElementNode {
|
|
40
|
-
__tag: HeadingTagType;
|
|
41
|
-
static getType(): string;
|
|
42
|
-
static clone(node: HeadingNode): HeadingNode;
|
|
43
|
-
constructor(tag: HeadingTagType, key?: NodeKey);
|
|
44
|
-
getTag(): HeadingTagType;
|
|
45
|
-
createDOM(config: EditorConfig): HTMLElement;
|
|
46
|
-
updateDOM(prevNode: HeadingNode, dom: HTMLElement): boolean;
|
|
47
|
-
static importDOM(): DOMConversionMap | null;
|
|
48
|
-
insertNewAfter(): ParagraphNode;
|
|
49
|
-
collapseAtStart(): true;
|
|
50
|
-
importJSON(serializedNode: SerializedHeadingNode): QuoteNode;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function $createHeadingNode(headingTag: HeadingTagType): HeadingNode;
|
|
54
|
-
export function $isHeadingNode(
|
|
55
|
-
node: LexicalNode | null | undefined,
|
|
56
|
-
): node is HeadingNode;
|
|
57
|
-
export function registerRichText(
|
|
58
|
-
editor: LexicalEditor,
|
|
59
|
-
initialEditorState?: InitialEditorStateType,
|
|
60
|
-
): () => void;
|
|
61
|
-
|
|
62
|
-
export type SerializedHeadingNode = Spread<
|
|
63
|
-
{
|
|
64
|
-
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5';
|
|
65
|
-
type: 'heading';
|
|
66
|
-
version: 1;
|
|
67
|
-
},
|
|
68
|
-
SerializedElementNode
|
|
69
|
-
>;
|
|
70
|
-
|
|
71
|
-
export type SerializedQuoteNode = Spread<
|
|
72
|
-
{
|
|
73
|
-
type: 'quote';
|
|
74
|
-
version: 1;
|
|
75
|
-
},
|
|
76
|
-
SerializedElementNode
|
|
77
|
-
>;
|