@ekz/lexical-rich-text 0.40.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/EkzLexicalRichText.dev.js +854 -0
- package/EkzLexicalRichText.dev.mjs +843 -0
- package/EkzLexicalRichText.js +11 -0
- package/EkzLexicalRichText.mjs +21 -0
- package/EkzLexicalRichText.node.mjs +19 -0
- package/EkzLexicalRichText.prod.js +9 -0
- package/EkzLexicalRichText.prod.mjs +9 -0
- package/LICENSE +21 -0
- package/LexicalRichText.js.flow +72 -0
- package/README.md +5 -0
- package/index.d.ts +59 -0
- package/package.json +44 -0
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
'use strict'
|
|
10
|
+
const EkzLexicalRichText = process.env.NODE_ENV !== 'production' ? require('./EkzLexicalRichText.dev.js') : require('./EkzLexicalRichText.prod.js');
|
|
11
|
+
module.exports = EkzLexicalRichText;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 * as modDev from './EkzLexicalRichText.dev.mjs';
|
|
10
|
+
import * as modProd from './EkzLexicalRichText.prod.mjs';
|
|
11
|
+
const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
|
|
12
|
+
export const $createHeadingNode = mod.$createHeadingNode;
|
|
13
|
+
export const $createQuoteNode = mod.$createQuoteNode;
|
|
14
|
+
export const $isHeadingNode = mod.$isHeadingNode;
|
|
15
|
+
export const $isQuoteNode = mod.$isQuoteNode;
|
|
16
|
+
export const DRAG_DROP_PASTE = mod.DRAG_DROP_PASTE;
|
|
17
|
+
export const HeadingNode = mod.HeadingNode;
|
|
18
|
+
export const QuoteNode = mod.QuoteNode;
|
|
19
|
+
export const RichTextExtension = mod.RichTextExtension;
|
|
20
|
+
export const eventFiles = mod.eventFiles;
|
|
21
|
+
export const registerRichText = mod.registerRichText;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
const mod = await (process.env.NODE_ENV !== 'production' ? import('./EkzLexicalRichText.dev.mjs') : import('./EkzLexicalRichText.prod.mjs'));
|
|
10
|
+
export const $createHeadingNode = mod.$createHeadingNode;
|
|
11
|
+
export const $createQuoteNode = mod.$createQuoteNode;
|
|
12
|
+
export const $isHeadingNode = mod.$isHeadingNode;
|
|
13
|
+
export const $isQuoteNode = mod.$isQuoteNode;
|
|
14
|
+
export const DRAG_DROP_PASTE = mod.DRAG_DROP_PASTE;
|
|
15
|
+
export const HeadingNode = mod.HeadingNode;
|
|
16
|
+
export const QuoteNode = mod.QuoteNode;
|
|
17
|
+
export const RichTextExtension = mod.RichTextExtension;
|
|
18
|
+
export const eventFiles = mod.eventFiles;
|
|
19
|
+
export const registerRichText = mod.registerRichText;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
"use strict";var e=require("@ekz/lexical-clipboard"),t=require("@ekz/lexical-dragon"),n=require("@ekz/lexical-selection"),r=require("@ekz/lexical-utils"),o=require("@ekz/lexical");function i(e,t){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const s="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,a=s&&"documentMode"in document?document.documentMode:null,c=s&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),l=!(!s||!("InputEvent"in window)||a)&&"getTargetRanges"in new window.InputEvent("input"),u=s&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),d=s&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,g=s&&/^(?=.*Chrome).*/i.test(navigator.userAgent),O=s&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&c&&!g,R=o.createCommand("DRAG_DROP_PASTE_FILE");class N extends o.ElementNode{static getType(){return"quote"}static clone(e){return new N(e.__key)}createDOM(e){const t=document.createElement("blockquote");return r.addClassNamesToElement(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:f,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(r.isHTMLElement(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return D().updateFromJSON(e)}insertNewAfter(e,t){const n=o.$createParagraphNode(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){const e=o.$createParagraphNode();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function D(){return o.$applyNodeReplacement(new N)}class m extends o.ElementNode{__tag;static getType(){return"heading"}static clone(e){return new m(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}setTag(e){const t=this.getWritable();return this.__tag=e,t}createDOM(e){const t=this.__tag,n=document.createElement(t),o=e.theme.heading;if(void 0!==o){const e=o[t];r.addClassNamesToElement(n,e)}return n}updateDOM(e,t,n){return e.__tag!==this.__tag}static importDOM(){return{h1:e=>({conversion:_,priority:0}),h2:e=>({conversion:_,priority:0}),h3:e=>({conversion:_,priority:0}),h4:e=>({conversion:_,priority:0}),h5:e=>({conversion:_,priority:0}),h6:e=>({conversion:_,priority:0}),p:e=>{const t=e.firstChild;return null!==t&&M(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>M(e)?{conversion:e=>({node:T("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(r.isHTMLElement(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return T(e.tag).updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTag(e.tag)}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,r=this.getLastDescendant(),i=!r||e&&e.anchor.key===r.getKey()&&n===r.getTextContentSize()||!e?o.$createParagraphNode():T(this.getTag()),s=this.getDirection();if(i.setDirection(s),this.insertAfter(i,t),0===n&&!this.isEmpty()&&e){const e=o.$createParagraphNode();e.select(),this.replace(e,!0)}return i}collapseAtStart(){const e=this.isEmpty()?o.$createParagraphNode():T(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function M(e){return"span"===e.nodeName.toLowerCase()&&"26pt"===e.style.fontSize}function _(e){const t=e.nodeName.toLowerCase();let n=null;return"h1"!==t&&"h2"!==t&&"h3"!==t&&"h4"!==t&&"h5"!==t&&"h6"!==t||(n=T(t),null!==e.style&&(o.setNodeIndentFromDOM(e,n),n.setFormat(e.style.textAlign))),{node:n}}function f(e){const t=D();return null!==e.style&&(t.setFormat(e.style.textAlign),o.setNodeIndentFromDOM(e,t)),{node:t}}function T(e="h1"){return o.$applyNodeReplacement(new m(e))}function C(e){let t=null;if(r.objectKlassEquals(e,DragEvent)?t=e.dataTransfer:r.objectKlassEquals(e,ClipboardEvent)&&(t=e.clipboardData),null===t)return[!1,[],!1];const n=t.types,o=n.includes("Files"),i=n.includes("text/html")||n.includes("text/plain");return[o,Array.from(t.files),i]}function E(e){const t=o.$getSelection();if(!o.$isRangeSelection(t))return!1;const n=new Set,i=t.getNodes();for(let t=0;t<i.length;t++){const s=i[t],a=s.getKey();if(n.has(a))continue;const c=r.$findMatchingParent(s,e=>o.$isElementNode(e)&&!e.isInline());if(null===c)continue;const l=c.getKey();c.canIndent()&&!n.has(l)&&(n.add(l),e(c))}return n.size>0}function p(e){const t=o.$getNearestNodeFromDOMNode(e);return o.$isDecoratorNode(t)}function I(e){for(const t of["lowercase","uppercase","capitalize"])e.hasFormat(t)&&e.toggleFormat(t)}function A(t){return r.mergeRegister(t.registerCommand(o.CLICK_COMMAND,e=>{const t=o.$getSelection();return!!o.$isNodeSelection(t)&&(t.clear(),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.DELETE_CHARACTER_COMMAND,e=>{const t=o.$getSelection();return o.$isRangeSelection(t)?(t.deleteCharacter(e),!0):!!o.$isNodeSelection(t)&&(t.deleteNodes(),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.DELETE_WORD_COMMAND,e=>{const t=o.$getSelection();return!!o.$isRangeSelection(t)&&(t.deleteWord(e),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.DELETE_LINE_COMMAND,e=>{const t=o.$getSelection();return!!o.$isRangeSelection(t)&&(t.deleteLine(e),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.CONTROLLED_TEXT_INSERTION_COMMAND,n=>{const r=o.$getSelection();if("string"==typeof n)null!==r&&r.insertText(n);else{if(null===r)return!1;const i=n.dataTransfer;if(null!=i)e.$insertDataTransferForRichText(i,r,t);else if(o.$isRangeSelection(r)){const e=n.data;return e&&r.insertText(e),!0}}return!0},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.REMOVE_TEXT_COMMAND,()=>{const e=o.$getSelection();return!!o.$isRangeSelection(e)&&(e.removeText(),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.FORMAT_TEXT_COMMAND,e=>{const t=o.$getSelection();return!!o.$isRangeSelection(t)&&(t.formatText(e),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.FORMAT_ELEMENT_COMMAND,e=>{const t=o.$getSelection();if(!o.$isRangeSelection(t)&&!o.$isNodeSelection(t))return!1;const n=t.getNodes();for(const t of n){const n=r.$findMatchingParent(t,e=>o.$isElementNode(e)&&!e.isInline());null!==n&&n.setFormat(e)}return!0},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.INSERT_LINE_BREAK_COMMAND,e=>{const t=o.$getSelection();return!!o.$isRangeSelection(t)&&(t.insertLineBreak(e),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.INSERT_PARAGRAPH_COMMAND,()=>{const e=o.$getSelection();return!!o.$isRangeSelection(e)&&(e.insertParagraph(),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.INSERT_TAB_COMMAND,()=>(o.$insertNodes([o.$createTabNode()]),!0),o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.INDENT_CONTENT_COMMAND,()=>E(e=>{const t=e.getIndent();e.setIndent(t+1)}),o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.OUTDENT_CONTENT_COMMAND,()=>E(e=>{const t=e.getIndent();t>0&&e.setIndent(Math.max(0,t-1))}),o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_ARROW_UP_COMMAND,e=>{const t=o.$getSelection();if(o.$isNodeSelection(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}else if(o.$isRangeSelection(t)){const n=o.$getAdjacentNode(t.focus,!0);if(!e.shiftKey&&o.$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_ARROW_DOWN_COMMAND,e=>{const t=o.$getSelection();if(o.$isNodeSelection(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectNext(0,0),!0}else if(o.$isRangeSelection(t)){if(function(e){const t=e.focus;return"root"===t.key&&t.offset===o.$getRoot().getChildrenSize()}(t))return e.preventDefault(),!0;const n=o.$getAdjacentNode(t.focus,!1);if(!e.shiftKey&&o.$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_ARROW_LEFT_COMMAND,e=>{const t=o.$getSelection();if(o.$isNodeSelection(t)){const r=t.getNodes();if(r.length>0)return e.preventDefault(),n.$isParentRTL(r[0])?r[0].selectNext(0,0):r[0].selectPrevious(),!0}if(!o.$isRangeSelection(t))return!1;if(n.$shouldOverrideDefaultCharacterSelection(t,!0)){const r=e.shiftKey;return e.preventDefault(),n.$moveCharacter(t,r,!0),!0}return!1},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_ARROW_RIGHT_COMMAND,e=>{const t=o.$getSelection();if(o.$isNodeSelection(t)){const r=t.getNodes();if(r.length>0)return e.preventDefault(),n.$isParentRTL(r[0])?r[0].selectPrevious():r[0].selectNext(0,0),!0}if(!o.$isRangeSelection(t))return!1;const r=e.shiftKey;return!!n.$shouldOverrideDefaultCharacterSelection(t,!1)&&(e.preventDefault(),n.$moveCharacter(t,r,!1),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_BACKSPACE_COMMAND,e=>{if(p(e.target))return!1;const n=o.$getSelection();if(o.$isRangeSelection(n)){if(function(e){if(!e.isCollapsed())return!1;const{anchor:t}=e;if(0!==t.offset)return!1;const n=t.getNode();if(o.$isRootNode(n))return!1;const i=r.$getNearestBlockElementAncestorOrThrow(n);return i.getIndent()>0&&(i.is(n)||n.is(i.getFirstDescendant()))}(n))return e.preventDefault(),t.dispatchCommand(o.OUTDENT_CONTENT_COMMAND,void 0);if(d&&"ko-KR"===navigator.language)return!1}else if(!o.$isNodeSelection(n))return!1;return e.preventDefault(),t.dispatchCommand(o.DELETE_CHARACTER_COMMAND,!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_DELETE_COMMAND,e=>{if(p(e.target))return!1;const n=o.$getSelection();return!(!o.$isRangeSelection(n)&&!o.$isNodeSelection(n))&&(e.preventDefault(),t.dispatchCommand(o.DELETE_CHARACTER_COMMAND,!1))},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_ENTER_COMMAND,e=>{const n=o.$getSelection();if(!o.$isRangeSelection(n))return!1;if(I(n),null!==e){if((d||u||O)&&l)return!1;if(e.preventDefault(),e.shiftKey)return t.dispatchCommand(o.INSERT_LINE_BREAK_COMMAND,!1)}return t.dispatchCommand(o.INSERT_PARAGRAPH_COMMAND,void 0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_ESCAPE_COMMAND,()=>{const e=o.$getSelection();return!!o.$isRangeSelection(e)&&(t.blur(),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.DROP_COMMAND,e=>{const[,n]=C(e);if(n.length>0){const r=i(e.clientX,e.clientY);if(null!==r){const{offset:e,node:i}=r,s=o.$getNearestNodeFromDOMNode(i);if(null!==s){const t=o.$createRangeSelection();if(o.$isTextNode(s))t.anchor.set(s.getKey(),e,"text"),t.focus.set(s.getKey(),e,"text");else{const e=s.getParentOrThrow().getKey(),n=s.getIndexWithinParent()+1;t.anchor.set(e,n,"element"),t.focus.set(e,n,"element")}const n=o.$normalizeSelection__EXPERIMENTAL(t);o.$setSelection(n)}t.dispatchCommand(R,n)}return e.preventDefault(),!0}const r=o.$getSelection();return!!o.$isRangeSelection(r)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.DRAGSTART_COMMAND,e=>{const[t]=C(e),n=o.$getSelection();return!(t&&!o.$isRangeSelection(n))},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.DRAGOVER_COMMAND,e=>{const[t]=C(e),n=o.$getSelection();if(t&&!o.$isRangeSelection(n))return!1;const r=i(e.clientX,e.clientY);if(null!==r){const t=o.$getNearestNodeFromDOMNode(r.node);o.$isDecoratorNode(t)&&e.preventDefault()}return!0},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.SELECT_ALL_COMMAND,()=>(o.$selectAll(),!0),o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.COPY_COMMAND,n=>(e.copyToClipboard(t,r.objectKlassEquals(n,ClipboardEvent)?n:null),!0),o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.CUT_COMMAND,n=>(async function(t,n){await e.copyToClipboard(n,r.objectKlassEquals(t,ClipboardEvent)?t:null),n.update(()=>{const e=o.$getSelection();o.$isRangeSelection(e)?e.removeText():o.$isNodeSelection(e)&&e.getNodes().forEach(e=>e.remove())})}(n,t),!0),o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.PASTE_COMMAND,n=>{const[,i,s]=C(n);if(i.length>0&&!s)return t.dispatchCommand(R,i),!0;if(o.isDOMNode(n.target)&&o.isSelectionCapturedInDecoratorInput(n.target))return!1;return null!==o.$getSelection()&&(function(t,n){t.preventDefault(),n.update(()=>{const i=o.$getSelection(),s=r.objectKlassEquals(t,InputEvent)||r.objectKlassEquals(t,KeyboardEvent)?null:t.clipboardData;null!=s&&null!==i&&e.$insertDataTransferForRichText(s,i,n)},{tag:o.PASTE_TAG})}(n,t),!0)},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_SPACE_COMMAND,e=>{const t=o.$getSelection();return o.$isRangeSelection(t)&&I(t),!1},o.COMMAND_PRIORITY_EDITOR),t.registerCommand(o.KEY_TAB_COMMAND,e=>{const t=o.$getSelection();return o.$isRangeSelection(t)&&I(t),!1},o.COMMAND_PRIORITY_EDITOR))}const h=o.defineExtension({conflictsWith:["@ekz/lexical-plain-text"],dependencies:[t.DragonExtension],name:"@ekz/lexical-rich-text",nodes:()=>[m,N],register:A});exports.$createHeadingNode=T,exports.$createQuoteNode=D,exports.$isHeadingNode=function(e){return e instanceof m},exports.$isQuoteNode=function(e){return e instanceof N},exports.DRAG_DROP_PASTE=R,exports.HeadingNode=m,exports.QuoteNode=N,exports.RichTextExtension=h,exports.eventFiles=C,exports.registerRichText=A;
|
|
@@ -0,0 +1,9 @@
|
|
|
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{$insertDataTransferForRichText as e,copyToClipboard as t}from"@ekz/lexical-clipboard";import{DragonExtension as n}from"@ekz/lexical-dragon";import{$isParentRTL as r,$shouldOverrideDefaultCharacterSelection as o,$moveCharacter as i}from"@ekz/lexical-selection";import{mergeRegister as s,$findMatchingParent as a,objectKlassEquals as c,addClassNamesToElement as u,isHTMLElement as l,$getNearestBlockElementAncestorOrThrow as d}from"@ekz/lexical-utils";import{createCommand as m,defineExtension as f,CLICK_COMMAND as g,$getSelection as p,$isNodeSelection as h,COMMAND_PRIORITY_EDITOR as v,DELETE_CHARACTER_COMMAND as C,$isRangeSelection as y,DELETE_WORD_COMMAND as x,DELETE_LINE_COMMAND as D,CONTROLLED_TEXT_INSERTION_COMMAND as N,REMOVE_TEXT_COMMAND as w,FORMAT_TEXT_COMMAND as E,FORMAT_ELEMENT_COMMAND as _,$isElementNode as O,INSERT_LINE_BREAK_COMMAND as P,INSERT_PARAGRAPH_COMMAND as T,INSERT_TAB_COMMAND as A,$insertNodes as F,$createTabNode as S,INDENT_CONTENT_COMMAND as I,OUTDENT_CONTENT_COMMAND as M,KEY_ARROW_UP_COMMAND as k,$getAdjacentNode as b,$isDecoratorNode as K,KEY_ARROW_DOWN_COMMAND as z,KEY_ARROW_LEFT_COMMAND as J,KEY_ARROW_RIGHT_COMMAND as W,KEY_BACKSPACE_COMMAND as L,KEY_DELETE_COMMAND as R,KEY_ENTER_COMMAND as q,KEY_ESCAPE_COMMAND as X,DROP_COMMAND as Y,$getNearestNodeFromDOMNode as B,$createRangeSelection as G,$isTextNode as V,$normalizeSelection__EXPERIMENTAL as j,$setSelection as H,DRAGSTART_COMMAND as Q,DRAGOVER_COMMAND as U,SELECT_ALL_COMMAND as Z,$selectAll as $,COPY_COMMAND as ee,CUT_COMMAND as te,PASTE_COMMAND as ne,isDOMNode as re,isSelectionCapturedInDecoratorInput as oe,KEY_SPACE_COMMAND as ie,KEY_TAB_COMMAND as se,ElementNode as ae,$createParagraphNode as ce,$getRoot as ue,$isRootNode as le,PASTE_TAG as de,setNodeIndentFromDOM as me,$applyNodeReplacement as fe}from"@ekz/lexical";function ge(e,t){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const pe="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,he=pe&&"documentMode"in document?document.documentMode:null,ve=pe&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ce=!(!pe||!("InputEvent"in window)||he)&&"getTargetRanges"in new window.InputEvent("input"),ye=pe&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xe=pe&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,De=pe&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ne=pe&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&ve&&!De,we=m("DRAG_DROP_PASTE_FILE");class Ee extends ae{static getType(){return"quote"}static clone(e){return new Ee(e.__key)}createDOM(e){const t=document.createElement("blockquote");return u(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Fe,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(l(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return _e().updateFromJSON(e)}insertNewAfter(e,t){const n=ce(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){const e=ce();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function _e(){return fe(new Ee)}function Oe(e){return e instanceof Ee}class Pe extends ae{__tag;static getType(){return"heading"}static clone(e){return new Pe(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}setTag(e){const t=this.getWritable();return this.__tag=e,t}createDOM(e){const t=this.__tag,n=document.createElement(t),r=e.theme.heading;if(void 0!==r){const e=r[t];u(n,e)}return n}updateDOM(e,t,n){return e.__tag!==this.__tag}static importDOM(){return{h1:e=>({conversion:Ae,priority:0}),h2:e=>({conversion:Ae,priority:0}),h3:e=>({conversion:Ae,priority:0}),h4:e=>({conversion:Ae,priority:0}),h5:e=>({conversion:Ae,priority:0}),h6:e=>({conversion:Ae,priority:0}),p:e=>{const t=e.firstChild;return null!==t&&Te(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Te(e)?{conversion:e=>({node:Se("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(l(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return Se(e.tag).updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTag(e.tag)}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,r=this.getLastDescendant(),o=!r||e&&e.anchor.key===r.getKey()&&n===r.getTextContentSize()||!e?ce():Se(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,t),0===n&&!this.isEmpty()&&e){const e=ce();e.select(),this.replace(e,!0)}return o}collapseAtStart(){const e=this.isEmpty()?ce():Se(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function Te(e){return"span"===e.nodeName.toLowerCase()&&"26pt"===e.style.fontSize}function Ae(e){const t=e.nodeName.toLowerCase();let n=null;return"h1"!==t&&"h2"!==t&&"h3"!==t&&"h4"!==t&&"h5"!==t&&"h6"!==t||(n=Se(t),null!==e.style&&(me(e,n),n.setFormat(e.style.textAlign))),{node:n}}function Fe(e){const t=_e();return null!==e.style&&(t.setFormat(e.style.textAlign),me(e,t)),{node:t}}function Se(e="h1"){return fe(new Pe(e))}function Ie(e){return e instanceof Pe}function Me(e){let t=null;if(c(e,DragEvent)?t=e.dataTransfer:c(e,ClipboardEvent)&&(t=e.clipboardData),null===t)return[!1,[],!1];const n=t.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(t.files),o]}function ke(e){const t=p();if(!y(t))return!1;const n=new Set,r=t.getNodes();for(let t=0;t<r.length;t++){const o=r[t],i=o.getKey();if(n.has(i))continue;const s=a(o,e=>O(e)&&!e.isInline());if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),e(s))}return n.size>0}function be(e){const t=B(e);return K(t)}function Ke(e){for(const t of["lowercase","uppercase","capitalize"])e.hasFormat(t)&&e.toggleFormat(t)}function ze(n){return s(n.registerCommand(g,e=>{const t=p();return!!h(t)&&(t.clear(),!0)},v),n.registerCommand(C,e=>{const t=p();return y(t)?(t.deleteCharacter(e),!0):!!h(t)&&(t.deleteNodes(),!0)},v),n.registerCommand(x,e=>{const t=p();return!!y(t)&&(t.deleteWord(e),!0)},v),n.registerCommand(D,e=>{const t=p();return!!y(t)&&(t.deleteLine(e),!0)},v),n.registerCommand(N,t=>{const r=p();if("string"==typeof t)null!==r&&r.insertText(t);else{if(null===r)return!1;const o=t.dataTransfer;if(null!=o)e(o,r,n);else if(y(r)){const e=t.data;return e&&r.insertText(e),!0}}return!0},v),n.registerCommand(w,()=>{const e=p();return!!y(e)&&(e.removeText(),!0)},v),n.registerCommand(E,e=>{const t=p();return!!y(t)&&(t.formatText(e),!0)},v),n.registerCommand(_,e=>{const t=p();if(!y(t)&&!h(t))return!1;const n=t.getNodes();for(const t of n){const n=a(t,e=>O(e)&&!e.isInline());null!==n&&n.setFormat(e)}return!0},v),n.registerCommand(P,e=>{const t=p();return!!y(t)&&(t.insertLineBreak(e),!0)},v),n.registerCommand(T,()=>{const e=p();return!!y(e)&&(e.insertParagraph(),!0)},v),n.registerCommand(A,()=>(F([S()]),!0),v),n.registerCommand(I,()=>ke(e=>{const t=e.getIndent();e.setIndent(t+1)}),v),n.registerCommand(M,()=>ke(e=>{const t=e.getIndent();t>0&&e.setIndent(Math.max(0,t-1))}),v),n.registerCommand(k,e=>{const t=p();if(h(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}else if(y(t)){const n=b(t.focus,!0);if(!e.shiftKey&&K(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},v),n.registerCommand(z,e=>{const t=p();if(h(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectNext(0,0),!0}else if(y(t)){if(function(e){const t=e.focus;return"root"===t.key&&t.offset===ue().getChildrenSize()}(t))return e.preventDefault(),!0;const n=b(t.focus,!1);if(!e.shiftKey&&K(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},v),n.registerCommand(J,e=>{const t=p();if(h(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),r(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),!0}if(!y(t))return!1;if(o(t,!0)){const n=e.shiftKey;return e.preventDefault(),i(t,n,!0),!0}return!1},v),n.registerCommand(W,e=>{const t=p();if(h(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),r(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),!0}if(!y(t))return!1;const n=e.shiftKey;return!!o(t,!1)&&(e.preventDefault(),i(t,n,!1),!0)},v),n.registerCommand(L,e=>{if(be(e.target))return!1;const t=p();if(y(t)){if(function(e){if(!e.isCollapsed())return!1;const{anchor:t}=e;if(0!==t.offset)return!1;const n=t.getNode();if(le(n))return!1;const r=d(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(t))return e.preventDefault(),n.dispatchCommand(M,void 0);if(xe&&"ko-KR"===navigator.language)return!1}else if(!h(t))return!1;return e.preventDefault(),n.dispatchCommand(C,!0)},v),n.registerCommand(R,e=>{if(be(e.target))return!1;const t=p();return!(!y(t)&&!h(t))&&(e.preventDefault(),n.dispatchCommand(C,!1))},v),n.registerCommand(q,e=>{const t=p();if(!y(t))return!1;if(Ke(t),null!==e){if((xe||ye||Ne)&&Ce)return!1;if(e.preventDefault(),e.shiftKey)return n.dispatchCommand(P,!1)}return n.dispatchCommand(T,void 0)},v),n.registerCommand(X,()=>{const e=p();return!!y(e)&&(n.blur(),!0)},v),n.registerCommand(Y,e=>{const[,t]=Me(e);if(t.length>0){const r=ge(e.clientX,e.clientY);if(null!==r){const{offset:e,node:o}=r,i=B(o);if(null!==i){const t=G();if(V(i))t.anchor.set(i.getKey(),e,"text"),t.focus.set(i.getKey(),e,"text");else{const e=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;t.anchor.set(e,n,"element"),t.focus.set(e,n,"element")}const n=j(t);H(n)}n.dispatchCommand(we,t)}return e.preventDefault(),!0}const r=p();return!!y(r)},v),n.registerCommand(Q,e=>{const[t]=Me(e),n=p();return!(t&&!y(n))},v),n.registerCommand(U,e=>{const[t]=Me(e),n=p();if(t&&!y(n))return!1;const r=ge(e.clientX,e.clientY);if(null!==r){const t=B(r.node);K(t)&&e.preventDefault()}return!0},v),n.registerCommand(Z,()=>($(),!0),v),n.registerCommand(ee,e=>(t(n,c(e,ClipboardEvent)?e:null),!0),v),n.registerCommand(te,e=>(async function(e,n){await t(n,c(e,ClipboardEvent)?e:null),n.update(()=>{const e=p();y(e)?e.removeText():h(e)&&e.getNodes().forEach(e=>e.remove())})}(e,n),!0),v),n.registerCommand(ne,t=>{const[,r,o]=Me(t);if(r.length>0&&!o)return n.dispatchCommand(we,r),!0;if(re(t.target)&&oe(t.target))return!1;return null!==p()&&(function(t,n){t.preventDefault(),n.update(()=>{const r=p(),o=c(t,InputEvent)||c(t,KeyboardEvent)?null:t.clipboardData;null!=o&&null!==r&&e(o,r,n)},{tag:de})}(t,n),!0)},v),n.registerCommand(ie,e=>{const t=p();return y(t)&&Ke(t),!1},v),n.registerCommand(se,e=>{const t=p();return y(t)&&Ke(t),!1},v))}const Je=f({conflictsWith:["@ekz/lexical-plain-text"],dependencies:[n],name:"@ekz/lexical-rich-text",nodes:()=>[Pe,Ee],register:ze});export{Se as $createHeadingNode,_e as $createQuoteNode,Ie as $isHeadingNode,Oe as $isQuoteNode,we as DRAG_DROP_PASTE,Pe as HeadingNode,Ee as QuoteNode,Je as RichTextExtension,Me as eventFiles,ze as registerRichText};
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
import type {
|
|
10
|
+
DOMConversionMap,
|
|
11
|
+
EditorConfig,
|
|
12
|
+
EditorState,
|
|
13
|
+
LexicalNode,
|
|
14
|
+
NodeKey,
|
|
15
|
+
ParagraphNode,
|
|
16
|
+
LexicalEditor,
|
|
17
|
+
LexicalCommand,
|
|
18
|
+
RangeSelection,
|
|
19
|
+
LexicalExtension,
|
|
20
|
+
ExtensionConfigBase,
|
|
21
|
+
SerializedElementNode,
|
|
22
|
+
} from '@ekz/lexical';
|
|
23
|
+
import {ElementNode} from '@ekz/lexical';
|
|
24
|
+
|
|
25
|
+
declare export var DRAG_DROP_PASTE: LexicalCommand<Array<File>>;
|
|
26
|
+
declare export class QuoteNode extends ElementNode {
|
|
27
|
+
static getType(): string;
|
|
28
|
+
static clone(node: QuoteNode): QuoteNode;
|
|
29
|
+
constructor(key?: NodeKey): void;
|
|
30
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
31
|
+
insertNewAfter(
|
|
32
|
+
selection: RangeSelection,
|
|
33
|
+
restoreSelection?: boolean,
|
|
34
|
+
): ParagraphNode;
|
|
35
|
+
collapseAtStart(): true;
|
|
36
|
+
}
|
|
37
|
+
declare export function $createQuoteNode(): QuoteNode;
|
|
38
|
+
declare export function $isQuoteNode(
|
|
39
|
+
node: ?LexicalNode,
|
|
40
|
+
): node is QuoteNode;
|
|
41
|
+
export type HeadingTagType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
42
|
+
declare export class HeadingNode extends ElementNode {
|
|
43
|
+
__tag: HeadingTagType;
|
|
44
|
+
static getType(): string;
|
|
45
|
+
static clone(node: HeadingNode): HeadingNode;
|
|
46
|
+
constructor(tag: HeadingTagType, key?: NodeKey): void;
|
|
47
|
+
getTag(): HeadingTagType;
|
|
48
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
49
|
+
static importDOM(): DOMConversionMap | null;
|
|
50
|
+
insertNewAfter(
|
|
51
|
+
selection: RangeSelection,
|
|
52
|
+
restoreSelection?: boolean,
|
|
53
|
+
): ParagraphNode;
|
|
54
|
+
collapseAtStart(): true;
|
|
55
|
+
}
|
|
56
|
+
declare export function $createHeadingNode(
|
|
57
|
+
headingTag: HeadingTagType,
|
|
58
|
+
): HeadingNode;
|
|
59
|
+
declare export function $isHeadingNode(
|
|
60
|
+
node: ?LexicalNode,
|
|
61
|
+
): node is HeadingNode;
|
|
62
|
+
declare export function registerRichText(editor: LexicalEditor): () => void;
|
|
63
|
+
|
|
64
|
+
export type SerializedQuoteNode = SerializedElementNode;
|
|
65
|
+
export type SerializedHeadingNode = {
|
|
66
|
+
...SerializedElementNode,
|
|
67
|
+
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6',
|
|
68
|
+
...
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
declare export var RichTextExtension: LexicalExtension<ExtensionConfigBase, "@ekz/lexical-rich-text", void, void>;
|
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# `@lexical/rich-text`
|
|
2
|
+
|
|
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/packages/lexical-plain-text) instead.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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, DOMExportOutput, EditorConfig, LexicalCommand, LexicalEditor, LexicalNode, LexicalUpdateJSON, NodeKey, ParagraphNode, PasteCommandType, RangeSelection, SerializedElementNode, Spread } from '@ekz/lexical';
|
|
9
|
+
import { ElementNode } from '@ekz/lexical';
|
|
10
|
+
export type SerializedHeadingNode = Spread<{
|
|
11
|
+
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
12
|
+
}, SerializedElementNode>;
|
|
13
|
+
export declare const DRAG_DROP_PASTE: LexicalCommand<Array<File>>;
|
|
14
|
+
export type SerializedQuoteNode = SerializedElementNode;
|
|
15
|
+
/** @noInheritDoc */
|
|
16
|
+
export declare class QuoteNode extends ElementNode {
|
|
17
|
+
static getType(): string;
|
|
18
|
+
static clone(node: QuoteNode): QuoteNode;
|
|
19
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
20
|
+
updateDOM(prevNode: this, dom: HTMLElement): boolean;
|
|
21
|
+
static importDOM(): DOMConversionMap | null;
|
|
22
|
+
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
23
|
+
static importJSON(serializedNode: SerializedQuoteNode): QuoteNode;
|
|
24
|
+
insertNewAfter(_: RangeSelection, restoreSelection?: boolean): ParagraphNode;
|
|
25
|
+
collapseAtStart(): true;
|
|
26
|
+
canMergeWhenEmpty(): true;
|
|
27
|
+
}
|
|
28
|
+
export declare function $createQuoteNode(): QuoteNode;
|
|
29
|
+
export declare function $isQuoteNode(node: LexicalNode | null | undefined): node is QuoteNode;
|
|
30
|
+
export type HeadingTagType = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
31
|
+
/** @noInheritDoc */
|
|
32
|
+
export declare class HeadingNode extends ElementNode {
|
|
33
|
+
/** @internal */
|
|
34
|
+
__tag: HeadingTagType;
|
|
35
|
+
static getType(): string;
|
|
36
|
+
static clone(node: HeadingNode): HeadingNode;
|
|
37
|
+
constructor(tag: HeadingTagType, key?: NodeKey);
|
|
38
|
+
getTag(): HeadingTagType;
|
|
39
|
+
setTag(tag: HeadingTagType): this;
|
|
40
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
41
|
+
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
|
|
42
|
+
static importDOM(): DOMConversionMap | null;
|
|
43
|
+
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
44
|
+
static importJSON(serializedNode: SerializedHeadingNode): HeadingNode;
|
|
45
|
+
updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedHeadingNode>): this;
|
|
46
|
+
exportJSON(): SerializedHeadingNode;
|
|
47
|
+
insertNewAfter(selection?: RangeSelection, restoreSelection?: boolean): ParagraphNode | HeadingNode;
|
|
48
|
+
collapseAtStart(): true;
|
|
49
|
+
extractWithChild(): boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare function $createHeadingNode(headingTag?: HeadingTagType): HeadingNode;
|
|
52
|
+
export declare function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode;
|
|
53
|
+
export declare function eventFiles(event: DragEvent | PasteCommandType): [boolean, Array<File>, boolean];
|
|
54
|
+
export declare function registerRichText(editor: LexicalEditor): () => void;
|
|
55
|
+
/**
|
|
56
|
+
* An extension to register \@ekz/lexical-rich-text behavior and nodes
|
|
57
|
+
* ({@link HeadingNode}, {@link QuoteNode})
|
|
58
|
+
*/
|
|
59
|
+
export declare const RichTextExtension: import("@ekz/lexical").LexicalExtension<import("@ekz/lexical").ExtensionConfigBase, "@ekz/lexical-rich-text", unknown, unknown>;
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ekz/lexical-rich-text",
|
|
3
|
+
"description": "This package contains rich text helpers for Lexical.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"lexical",
|
|
6
|
+
"editor",
|
|
7
|
+
"rich-text"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"version": "0.40.0",
|
|
11
|
+
"main": "LexicalRichText.js",
|
|
12
|
+
"types": "index.d.ts",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/facebook/lexical.git",
|
|
16
|
+
"directory": "packages/lexical-rich-text"
|
|
17
|
+
},
|
|
18
|
+
"module": "LexicalRichText.mjs",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./index.d.ts",
|
|
24
|
+
"development": "./LexicalRichText.dev.mjs",
|
|
25
|
+
"production": "./LexicalRichText.prod.mjs",
|
|
26
|
+
"node": "./LexicalRichText.node.mjs",
|
|
27
|
+
"default": "./LexicalRichText.mjs"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"development": "./LexicalRichText.dev.js",
|
|
32
|
+
"production": "./LexicalRichText.prod.js",
|
|
33
|
+
"default": "./LexicalRichText.js"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@ekz/lexical-clipboard": "0.40.0",
|
|
39
|
+
"@ekz/lexical-dragon": "0.40.0",
|
|
40
|
+
"@ekz/lexical-selection": "0.40.0",
|
|
41
|
+
"@ekz/lexical-utils": "0.40.0",
|
|
42
|
+
"@ekz/lexical": "0.40.0"
|
|
43
|
+
}
|
|
44
|
+
}
|