@lexical/extension 0.50.1-nightly.20260916.0 → 0.51.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/dist/HorizontalRuleExtension.d.ts +10 -1
- package/dist/LexicalExtension.flowtest.js.flow +97 -0
- package/dist/LexicalExtensionDecoratorTextExtension.dev.js +2 -2
- package/dist/LexicalExtensionDecoratorTextExtension.prod.js +1 -1
- package/dist/LexicalExtensionHorizontalRuleExtension.dev.js +1 -5
- package/dist/LexicalExtensionHorizontalRuleExtension.prod.js +1 -1
- package/dist/LexicalExtensionLexicalBuilder.dev.js +3 -3
- package/dist/LexicalExtensionLexicalBuilder.prod.js +1 -1
- package/package.json +4 -4
- package/src/DecoratorTextExtension.ts +2 -1
- package/src/HorizontalRuleExtension.ts +1 -5
|
@@ -20,6 +20,7 @@ export declare const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
|
|
|
20
20
|
export declare class HorizontalRuleNode extends DecoratorNode<unknown> {
|
|
21
21
|
$config(): import("lexical").BaseStaticNodeConfig & {
|
|
22
22
|
readonly horizontalrule?: {
|
|
23
|
+
readonly extends: typeof DecoratorNode;
|
|
23
24
|
readonly importDOM: {
|
|
24
25
|
readonly hr: () => {
|
|
25
26
|
conversion: typeof $convertHorizontalRuleElement;
|
|
@@ -27,7 +28,15 @@ export declare class HorizontalRuleNode extends DecoratorNode<unknown> {
|
|
|
27
28
|
};
|
|
28
29
|
};
|
|
29
30
|
} | undefined;
|
|
30
|
-
}
|
|
31
|
+
} & import("lexical").StaticNodeTypeAccessor<"horizontalrule"> & import("lexical").StaticNodeConfigAccessor<{
|
|
32
|
+
readonly extends: typeof DecoratorNode;
|
|
33
|
+
readonly importDOM: {
|
|
34
|
+
readonly hr: () => {
|
|
35
|
+
conversion: typeof $convertHorizontalRuleElement;
|
|
36
|
+
priority: 0;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
31
40
|
exportDOM(): DOMExportOutput;
|
|
32
41
|
createDOM(config: EditorConfig): HTMLElement;
|
|
33
42
|
getTextContent(): string;
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Type-only smoke test for the hand-maintained `@lexical/extension` Flow
|
|
12
|
+
* declarations, in the spirit of `packages/lexical/flow/Lexical.flowtest.js.flow`:
|
|
13
|
+
* `pnpm lint-flow` checks that the names match the generated `.d.ts` and
|
|
14
|
+
* `pnpm flow` checks that the declarations are internally consistent, but
|
|
15
|
+
* neither one ever composes the API the way an application does.
|
|
16
|
+
*
|
|
17
|
+
* Everything below is what building a nested editor from extensions looks like
|
|
18
|
+
* downstream. None of it type-checked before: `dependencies` could not hold a
|
|
19
|
+
* single extension, `configExtension` could not be called, and
|
|
20
|
+
* `ReactProviderExtension` was declared nowhere at all.
|
|
21
|
+
*
|
|
22
|
+
* See that file's header for why the `.js.flow` extension is load-bearing.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type {LexicalEditor, LexicalEditorWithDispose} from 'lexical';
|
|
26
|
+
|
|
27
|
+
import {
|
|
28
|
+
buildEditorFromExtensions,
|
|
29
|
+
configExtension,
|
|
30
|
+
defineExtension,
|
|
31
|
+
NestedEditorExtension,
|
|
32
|
+
} from '@lexical/extension';
|
|
33
|
+
import {ReactExtension} from '@lexical/react/ReactExtension';
|
|
34
|
+
import {ReactProviderExtension} from '@lexical/react/ReactProviderExtension';
|
|
35
|
+
|
|
36
|
+
// A dependency list holding a bare extension. `LexicalExtension` was invariant
|
|
37
|
+
// in `Name`, so no concrete extension was a subtype of the
|
|
38
|
+
// `LexicalExtension<any, string, any, any>` the list is declared over, and a
|
|
39
|
+
// single-element `dependencies` was an error.
|
|
40
|
+
const dependsOnAnExtension = defineExtension({
|
|
41
|
+
dependencies: [ReactProviderExtension],
|
|
42
|
+
name: '@lexical/flow-smoke-test/DependsOnAnExtension',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// A dependency carrying a config override. `configExtension` returns the
|
|
46
|
+
// `[extension, ...Partial<Config>[]]` tuple type, whose trailing array spread
|
|
47
|
+
// Flow rejects outright ("Cannot spread non-tuple into tuple type"), so the
|
|
48
|
+
// call could not be written at all.
|
|
49
|
+
const configuresItsDependency = defineExtension({
|
|
50
|
+
dependencies: [configExtension(ReactExtension, {contentEditable: null})],
|
|
51
|
+
name: '@lexical/flow-smoke-test/ConfiguresItsDependency',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// The same override written inline, which is the tuple the normalized argument
|
|
55
|
+
// type exists to describe.
|
|
56
|
+
const configuresInline = defineExtension({
|
|
57
|
+
dependencies: [[ReactExtension, {contentEditable: null}]],
|
|
58
|
+
name: '@lexical/flow-smoke-test/ConfiguresInline',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// `NestedEditorExtension`'s own config, and the editor a nested surface
|
|
62
|
+
// actually builds: the extension's parent hook plus React hosting.
|
|
63
|
+
export function flowBuildsNestedEditor(
|
|
64
|
+
parentEditor: LexicalEditor,
|
|
65
|
+
): LexicalEditorWithDispose {
|
|
66
|
+
return buildEditorFromExtensions(
|
|
67
|
+
defineExtension({
|
|
68
|
+
dependencies: [
|
|
69
|
+
ReactProviderExtension,
|
|
70
|
+
configExtension(ReactExtension, {contentEditable: null}),
|
|
71
|
+
configExtension(NestedEditorExtension, {
|
|
72
|
+
$getParentEditor: () => parentEditor,
|
|
73
|
+
inheritEditableFromParent: true,
|
|
74
|
+
}),
|
|
75
|
+
],
|
|
76
|
+
name: '@lexical/flow-smoke-test/NestedEditor',
|
|
77
|
+
namespace: 'flow-smoke-test-nested',
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// `buildEditorFromExtensions` is variadic over the same argument type, so a
|
|
83
|
+
// config override passed straight to it has to work too.
|
|
84
|
+
export function flowBuildsFromArguments(): LexicalEditorWithDispose {
|
|
85
|
+
return buildEditorFromExtensions(
|
|
86
|
+
ReactProviderExtension,
|
|
87
|
+
configExtension(ReactExtension, {contentEditable: null}),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function flowExtensionNames(): string {
|
|
92
|
+
return [
|
|
93
|
+
dependsOnAnExtension.name,
|
|
94
|
+
configuresItsDependency.name,
|
|
95
|
+
configuresInline.name,
|
|
96
|
+
].join(',');
|
|
97
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { DecoratorNode, $getState, toggleTextFormatType, $setState, $getDocument, TEXT_TYPE_TO_FORMAT, createState } from 'lexical';
|
|
9
|
+
import { DecoratorNode, $getState, toggleTextFormatType, $setState, $getDocument, TEXT_TYPE_TO_FORMAT, createState, numberValue } from 'lexical';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -17,7 +17,7 @@ import { DecoratorNode, $getState, toggleTextFormatType, $setState, $getDocument
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
const formatState = /* @__PURE__ */createState('format', {
|
|
20
|
-
parse:
|
|
20
|
+
parse: /* @__PURE__ */numberValue()
|
|
21
21
|
});
|
|
22
22
|
class DecoratorTextNode extends DecoratorNode {
|
|
23
23
|
/** @internal */
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{DecoratorNode as t,$getState as e,toggleTextFormatType as r,$setState as o,$getDocument as n,TEXT_TYPE_TO_FORMAT as s,createState as a}from"lexical";const
|
|
9
|
+
import{DecoratorNode as t,$getState as e,toggleTextFormatType as r,$setState as o,$getDocument as n,TEXT_TYPE_TO_FORMAT as s,createState as a,numberValue as i}from"lexical";const l=/* @__PURE__ */a("format",{parse:/* @__PURE__ */i()});class c extends t{get __isInlineFormattable(){return!0}$config(){return this.config("decorator-text",{extends:t,stateConfigs:[{flat:!0,stateConfig:l}]})}getFormat(t){return e(this,l,t)}getFormatFlags(t,e){return r(this.getFormat(),t,e)}hasFormat(t){const e=s[t];return 0!==(this.getFormat()&e)}setFormat(t){return o(this,l,t)}toggleFormat(t){const e=this.getFormat(),o=r(e,t,null);return this.setFormat(o)}isInline(){return!0}createDOM(t,e){return n().createElement("span")}}function u(t){return t instanceof c}function g(t,e,r){const o=e.fontWeight,n=e.textDecoration.split(" "),s="700"===o||"bold"===o,a=n.includes("line-through"),i="italic"===e.fontStyle,l=n.includes("underline"),c=e.verticalAlign;return s&&!t.hasFormat("bold")&&t.toggleFormat("bold"),a&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),i&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),r&&!t.hasFormat(r)&&t.toggleFormat(r),t}function m(t,e,r=d){let o=e;for(const[e,n]of Object.entries(r))t.hasFormat(n)&&(o=F(o,e));return o}const h=m;function F(t,e){const r=t.ownerDocument.createElement(e);return r.appendChild(t),r}const d={b:"bold",code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},p={name:"@lexical/extension/DecoratorText",nodes:()=>[c]};export{h as $applyFormatToDom,u as $isDecoratorTextNode,p as DecoratorTextExtension,c as DecoratorTextNode,g as applyFormatFromStyle,m as applyFormatToDom};
|
|
@@ -34,12 +34,8 @@ import { signal, batch, effect } from '@lexical/extension/signals';
|
|
|
34
34
|
const INSERT_HORIZONTAL_RULE_COMMAND = /* @__PURE__ */createCommand('INSERT_HORIZONTAL_RULE_COMMAND');
|
|
35
35
|
class HorizontalRuleNode extends DecoratorNode {
|
|
36
36
|
$config() {
|
|
37
|
-
// `extends` is intentionally left to the runtime default (the prototype
|
|
38
|
-
// parent) rather than declared explicitly: the deprecated
|
|
39
|
-
// `@lexical/react` HorizontalRuleNode subclasses this one and reuses the
|
|
40
|
-
// same 'horizontalrule' type, so both `$config()` overrides must infer a
|
|
41
|
-
// matching shape.
|
|
42
37
|
return this.config('horizontalrule', {
|
|
38
|
+
extends: DecoratorNode,
|
|
43
39
|
importDOM: {
|
|
44
40
|
hr: () => ({
|
|
45
41
|
conversion: $convertHorizontalRuleElement,
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{$insertNodeToNearestRoot as e}from"@lexical/utils";import{createCommand as t,DecoratorNode as n,$getDocument as o,addClassNamesToElement as r,$create as i,mergeRegister as s,$getSelection as l,$isRangeSelection as c,COMMAND_PRIORITY_EDITOR as
|
|
9
|
+
import{$insertNodeToNearestRoot as e}from"@lexical/utils";import{createCommand as t,DecoratorNode as n,$getDocument as o,addClassNamesToElement as r,$create as i,mergeRegister as s,$getSelection as l,$isRangeSelection as c,COMMAND_PRIORITY_EDITOR as d,CLICK_COMMAND as u,isDOMNode as a,$getNodeFromDOMNode as f,COMMAND_PRIORITY_LOW as m,removeClassNamesFromElement as g,$isNodeSelection as x,$createNodeSelection as p,$setSelection as h}from"lexical";import{EditorStateExtension as S}from"@lexical/extension/EditorStateExtension";import{NodeSelectionExtension as N}from"@lexical/extension/NodeSelectionExtension";import{signal as y,batch as E,effect as M}from"@lexical/extension/signals";const v=/* @__PURE__ */t("INSERT_HORIZONTAL_RULE_COMMAND");class O extends n{$config(){return this.config("horizontalrule",{extends:n,importDOM:{hr:()=>({conversion:D,priority:0})}})}exportDOM(){return{element:o().createElement("hr")}}createDOM(e){const t=o().createElement("hr");return r(t,e.theme.hr),t}getTextContent(){return"\n"}isInline(){return!1}updateDOM(){return!1}}function D(){return{node:C()}}function C(){return i(O)}function K(e){return e instanceof O}const R={dependencies:[S,N],name:"@lexical/extension/HorizontalRule",nodes:()=>[O],register(t,n,o){const{watchNodeKey:i}=o.getDependency(N).output,S=y({nodeSelections:new Map}),D=t._config.theme.hrSelected??"selected";return s(t.registerCommand(v,t=>{const n=l();if(!c(n))return!1;if(null!==n.focus.getNode()){const t=C();e(t)}return!0},d),t.registerCommand(u,e=>{if(a(e.target)){const t=f(e.target);if(K(t))return function(e,t=!1){const n=l(),o=e.isSelected(),r=e.getKey();let i;t&&x(n)?i=n:(i=p(),h(i)),o?i.delete(r):i.add(r)}(t,e.shiftKey),!0}return!1},m),t.registerMutationListener(O,(e,n)=>{E(()=>{let n=!1;const{nodeSelections:o}=S.peek();for(const[r,s]of e.entries())if("destroyed"===s)o.delete(r),n=!0;else{const e=o.get(r),s=t.getElementByKey(r);e?e.domNode.value=s:(n=!0,o.set(r,{domNode:y(s),selectedSignal:i(r)}))}n&&(S.value={nodeSelections:o})})}),M(()=>{const e=[];for(const{domNode:t,selectedSignal:n}of S.value.nodeSelections.values())e.push(M(()=>{const e=t.value;if(e){n.value?r(e,D):g(e,D)}}));return s(...e)}))}};export{C as $createHorizontalRuleNode,K as $isHorizontalRuleNode,R as HorizontalRuleExtension,O as HorizontalRuleNode,v as INSERT_HORIZONTAL_RULE_COMMAND};
|
|
@@ -33,9 +33,9 @@ function formatDevErrorMessage(message) {
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* `"0.
|
|
36
|
+
* `"0.51.0+dev.esm"` is statically replaced with the build-specific
|
|
37
37
|
* version string in a Rollup build, and a consumer's bundler `define` can
|
|
38
|
-
* inject it the same way — so the exact `"0.
|
|
38
|
+
* inject it the same way — so the exact `"0.51.0+dev.esm"` member
|
|
39
39
|
* expression must be preserved for that substitution to match. Reading it
|
|
40
40
|
* inside a try/catch lets the source be consumed directly (via the `source`
|
|
41
41
|
* export condition) in a browser bundle, where `process` is undefined and
|
|
@@ -53,7 +53,7 @@ function formatDevErrorMessage(message) {
|
|
|
53
53
|
function readLexicalVersion() {
|
|
54
54
|
let envLexicalVersion;
|
|
55
55
|
try {
|
|
56
|
-
envLexicalVersion = "0.
|
|
56
|
+
envLexicalVersion = "0.51.0+dev.esm";
|
|
57
57
|
} catch (_unused) {
|
|
58
58
|
// `process` is not defined in some browser bundles; use the fallback.
|
|
59
59
|
}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{shallowMergeConfig as t,createEditor as e,mergeRegister as n}from"lexical";import{getNodeConfig as i}from"@lexical/extension/config";import{InitialStateExtension as s}from"@lexical/extension/InitialStateExtension";function o(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function r(){let t;try{t="0.
|
|
9
|
+
import{shallowMergeConfig as t,createEditor as e,mergeRegister as n}from"lexical";import{getNodeConfig as i}from"@lexical/extension/config";import{InitialStateExtension as s}from"@lexical/extension/InitialStateExtension";function o(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function r(){let t;try{t="0.51.0+prod.esm"}catch(t){}return t??'"<unknown>+source"'}const a=/* @__PURE__ */r(),c=new Set(["__proto__","constructor","prototype"]);function d(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)!c.has(t)&&Object.prototype.hasOwnProperty.call(i,t)&&(n[t]=d(n[t],i[t]));return t}return e}const g=0,h=1,f=2,u=3,p=4,l=5,m=6,x=7;function E(t){return t.id===g}function S(t){return t.id===f}function b(t){return function(t){return t.id===h}(t)||o(305,String(t.id),String(h)),Object.assign(t,{id:f})}const y=new Set;class R{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:g}}mergeConfigs(){let e=this.extension.config||{};const n=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):t;for(const t of this.configs)e=n(e,t);return e}init(t){const e=this.state;S(e)||o(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},s=function(t,e,n){return Object.assign(t,{config:e,id:u,registerState:n})}(e,this.mergeConfigs(),n);let r;this.state=s,this.extension.init&&(r=this.extension.init(t,s.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:p,initResult:e,registerState:n})}(s,r,i)}build(t){const e=this.state;let n;e.id!==p&&o(307,String(e.id),String(l)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:l,output:e,registerState:n})}(e,n,i)}register(t,e){this._signal=e;const n=this.state;n.id!==l&&o(308,String(n.id),String(l));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:m})}(n),()=>{const t=this.state;t.id!==x&&o(309,String(n.id),String(x)),this.state=function(t){return Object.assign(t,{id:l})}(t),i&&i()}}afterRegistration(t){const e=this.state;let n;return e.id!==m&&o(310,String(e.id),String(m)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:x})}(e),n}getSignal(){return void 0===this._signal&&o(311),this._signal}getInitResult(){void 0===this.extension.init&&o(312,this.extension.name);const t=this.state;return function(t){return t.id>=p}(t)||o(313,String(t.id),String(p)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=u}(t)||o(314,String(t.id),String(u)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&o(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&o(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=x}(t)||o(316,String(t.id),String(x)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||y}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(t){return t.id>=l})(t)||o(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const v=Symbol.for("@lexical/extension/LexicalBuilder");function N(...t){return O.fromExtensions(t).buildEditor()}function _(){}function w(t){throw t}function M(t){return Array.isArray(t)?t:[t]}const D=a;class O{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=D,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[M(s)];for(const n of t)e.push(M(n));return new O(e)}static maybeFromEditor(t){const e=t[v];return e&&(e.PACKAGE_VERSION!==D&&o(292,e.PACKAGE_VERSION,D),e instanceof O||o(293)),e}static fromEditor(t){const e=O.maybeFromEditor(t);return void 0===e&&o(294),e}constructEditor(){const{$initialEditorState:t,onError:n,onWarn:i,...s}=this.buildCreateEditorArgs(),o=Object.assign(e({...s,...n?{onError:t=>{n(t,o)}}:{},...i?{onWarn:t=>{i(t,o)}}:{}}),{[v]:this});for(const t of this.sortedExtensionReps())t.build(o);return o}buildEditor(){let t=_;function e(){try{t()}finally{t=_}}const i=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=n(this.registerEditor(i),()=>i.setRootElement(null)),i}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&o(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);if(i){const t=i.get(e);t?t.push(...n):i.set(e,n)}else this.outgoingConfigEdges.set(t,new Map([[e,n]]));const s=this.incomingEdges.get(e);s?s.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){void 0!==this._sortedExtensionReps&&o(296);const e=M(t),[n]=e;"string"!=typeof n.name&&o(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&o(298,n.name),!i){i=new R(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&o(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&o(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=M(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e)}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let s=n.state;if(S(s))return;const r=n.extension.name;var a;E(s)||o(300,r,i||"[unknown]"),E(a=s)||o(304,String(a.id),String(g)),s=Object.assign(a,{id:h}),n.state=s;const c=this.outgoingConfigEdges.get(r);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,r)}s=b(s),n.state=s,t.push(n)};for(const t of this.extensionNameMap.values())E(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t)}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&o(301,t.name);for(const t of e)n.configs.add(t)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),i=new AbortController,s=[()=>i.abort()],o=i.signal;for(const n of e){const e=n.register(t,o);e&&s.push(e)}for(const n of e){const e=n.afterRegistration(t);e&&s.push(e)}return n(...s)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,s=new Map,r={},a={},c=this.sortedExtensionReps();for(const g of c){const{extension:c}=g;if(void 0!==c.onError&&(t.onError=c.onError),void 0!==c.onWarn&&(t.onWarn=c.onWarn),void 0!==c.disableEvents&&(t.disableEvents=c.disableEvents),void 0!==c.parentEditor&&(t.parentEditor=c.parentEditor),void 0!==c.editable&&(t.editable=c.editable),void 0!==c.namespace&&(t.namespace=c.namespace),void 0!==c.$initialEditorState&&(t.$initialEditorState=c.$initialEditorState),c.nodes)for(const t of i(c)){if("function"!=typeof t){const e=n.get(t.replace);e&&o(302,c.name,t.replace.name,e.extension.name),n.set(t.replace,g)}e.add(t)}if(c.html){if(c.html.export)for(const[t,e]of c.html.export.entries())s.set(t,e);c.html.import&&Object.assign(r,c.html.import)}c.theme&&d(a,c.theme)}Object.keys(a).length>0&&(t.theme=a),e.size&&(t.nodes=Array.from(e));const g=Object.keys(r).length>0,h=s.size>0;(g||h)&&(t.html={},g&&(t.html.import=r),h&&(t.html.export=s));for(const e of c)e.init(t);return t.onError||(t.onError=w),t}}export{O as LexicalBuilder,N as buildEditorFromExtensions,v as builderSymbol};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"extension",
|
|
7
7
|
"plugin"
|
|
8
8
|
],
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.51.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"description": "This package provides the extension functionality for Lexical.",
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@lexical/internal": "0.
|
|
25
|
-
"@lexical/utils": "0.
|
|
24
|
+
"@lexical/internal": "0.51.0",
|
|
25
|
+
"@lexical/utils": "0.51.0",
|
|
26
26
|
"@preact/signals-core": "^1.14.1",
|
|
27
|
-
"lexical": "0.
|
|
27
|
+
"lexical": "0.51.0"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
30
|
"./AutoFocusExtension": {
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type LexicalEditor,
|
|
19
19
|
type LexicalNode,
|
|
20
20
|
type NodeStateVersion,
|
|
21
|
+
numberValue,
|
|
21
22
|
type SerializedLexicalNode,
|
|
22
23
|
type Spread,
|
|
23
24
|
type StateConfigValue,
|
|
@@ -35,7 +36,7 @@ export type SerializedDecoratorTextNode = Spread<
|
|
|
35
36
|
>;
|
|
36
37
|
|
|
37
38
|
const formatState = createState('format', {
|
|
38
|
-
parse:
|
|
39
|
+
parse: numberValue(),
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
export class DecoratorTextNode
|
|
@@ -62,12 +62,8 @@ export const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void> =
|
|
|
62
62
|
|
|
63
63
|
export class HorizontalRuleNode extends DecoratorNode<unknown> {
|
|
64
64
|
$config() {
|
|
65
|
-
// `extends` is intentionally left to the runtime default (the prototype
|
|
66
|
-
// parent) rather than declared explicitly: the deprecated
|
|
67
|
-
// `@lexical/react` HorizontalRuleNode subclasses this one and reuses the
|
|
68
|
-
// same 'horizontalrule' type, so both `$config()` overrides must infer a
|
|
69
|
-
// matching shape.
|
|
70
65
|
return this.config('horizontalrule', {
|
|
66
|
+
extends: DecoratorNode,
|
|
71
67
|
importDOM: {
|
|
72
68
|
hr: () => ({
|
|
73
69
|
conversion: $convertHorizontalRuleElement,
|