@etrepum/lexical-builder 0.0.36-nightly.20250714.0 → 0.0.37-nightly.20250715.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.
Files changed (38) hide show
  1. package/dist/{AutoFocusPlan.d.ts → AutoFocusExtension.d.ts} +3 -3
  2. package/dist/AutoFocusExtension.d.ts.map +1 -0
  3. package/dist/{DragonPlan.d.ts → DragonExtension.d.ts} +2 -2
  4. package/dist/DragonExtension.d.ts.map +1 -0
  5. package/dist/ExtensionRep.d.ts +76 -0
  6. package/dist/ExtensionRep.d.ts.map +1 -0
  7. package/dist/{HistoryPlan.d.ts → HistoryExtension.d.ts} +3 -3
  8. package/dist/HistoryExtension.d.ts.map +1 -0
  9. package/dist/InitialStateExtension.d.ts +7 -0
  10. package/dist/InitialStateExtension.d.ts.map +1 -0
  11. package/dist/LexicalBuilder.d.ts +23 -23
  12. package/dist/LexicalBuilder.d.ts.map +1 -1
  13. package/dist/PlainTextExtension.d.ts +5 -0
  14. package/dist/PlainTextExtension.d.ts.map +1 -0
  15. package/dist/RichTextExtension.d.ts +13 -0
  16. package/dist/RichTextExtension.d.ts.map +1 -0
  17. package/dist/getExtensionDependencyFromEditor.d.ts +17 -0
  18. package/dist/getExtensionDependencyFromEditor.d.ts.map +1 -0
  19. package/dist/getPeerDependencyFromEditor.d.ts +20 -20
  20. package/dist/getPeerDependencyFromEditor.d.ts.map +1 -1
  21. package/dist/index.d.ts +9 -9
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +240 -234
  24. package/dist/index.js.map +1 -1
  25. package/package.json +8 -8
  26. package/dist/AutoFocusPlan.d.ts.map +0 -1
  27. package/dist/DragonPlan.d.ts.map +0 -1
  28. package/dist/HistoryPlan.d.ts.map +0 -1
  29. package/dist/InitialStatePlan.d.ts +0 -7
  30. package/dist/InitialStatePlan.d.ts.map +0 -1
  31. package/dist/PlainTextPlan.d.ts +0 -5
  32. package/dist/PlainTextPlan.d.ts.map +0 -1
  33. package/dist/PlanRep.d.ts +0 -76
  34. package/dist/PlanRep.d.ts.map +0 -1
  35. package/dist/RichTextPlan.d.ts +0 -13
  36. package/dist/RichTextPlan.d.ts.map +0 -1
  37. package/dist/getPlanDependencyFromEditor.d.ts +0 -17
  38. package/dist/getPlanDependencyFromEditor.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { shallowMergeConfig, definePlan, safeCast, provideOutput, configPlan } from "@etrepum/lexical-builder-core";
5
- import { configPlan as configPlan2, declarePeerDependency, definePlan as definePlan2, provideOutput as provideOutput2, safeCast as safeCast2, shallowMergeConfig as shallowMergeConfig2 } from "@etrepum/lexical-builder-core";
4
+ import { shallowMergeConfig, defineExtension, safeCast, provideOutput, configExtension } from "@etrepum/lexical-builder-core";
5
+ import { configExtension as configExtension2, declarePeerDependency, defineExtension as defineExtension2, provideOutput as provideOutput2, safeCast as safeCast2, shallowMergeConfig as shallowMergeConfig2 } from "@etrepum/lexical-builder-core";
6
6
  import { RootNode, TextNode, LineBreakNode, TabNode, ParagraphNode, $getRoot, $createParagraphNode, createEditor } from "lexical";
7
7
  import { mergeRegister } from "@lexical/utils";
8
8
  import { registerDragonSupport } from "@lexical/dragon";
9
9
  import { createEmptyHistoryState, registerHistory } from "@lexical/history";
10
10
  import { registerPlainText } from "@lexical/plain-text";
11
11
  import { HeadingNode, QuoteNode, registerRichText } from "@lexical/rich-text";
12
- const PACKAGE_VERSION = "0.0.36-nightly.20250714.0";
12
+ const PACKAGE_VERSION = "0.0.37-nightly.20250715.0";
13
13
  function invariant(cond, message, ...args) {
14
14
  if (cond) {
15
15
  return;
@@ -29,7 +29,7 @@ function deepThemeMergeInPlace(a, b) {
29
29
  }
30
30
  return b;
31
31
  }
32
- const PlanRepStateIds = {
32
+ const ExtensionRepStateIds = {
33
33
  unmarked: 0,
34
34
  temporary: 1,
35
35
  permanent: 2,
@@ -38,90 +38,94 @@ const PlanRepStateIds = {
38
38
  registered: 5,
39
39
  afterInitialization: 6
40
40
  };
41
- function isExactlyUnmarkedPlanRepState(state) {
42
- return state.id === PlanRepStateIds.unmarked;
41
+ function isExactlyUnmarkedExtensionRepState(state) {
42
+ return state.id === ExtensionRepStateIds.unmarked;
43
43
  }
44
- function isExactlyTemporaryPlanRepState(state) {
45
- return state.id === PlanRepStateIds.temporary;
44
+ function isExactlyTemporaryExtensionRepState(state) {
45
+ return state.id === ExtensionRepStateIds.temporary;
46
46
  }
47
- function isExactlyPermanentPlanRepState(state) {
48
- return state.id === PlanRepStateIds.permanent;
47
+ function isExactlyPermanentExtensionRepState(state) {
48
+ return state.id === ExtensionRepStateIds.permanent;
49
49
  }
50
- function isInitializedPlanRepState(state) {
51
- return state.id >= PlanRepStateIds.initialized;
50
+ function isInitializedExtensionRepState(state) {
51
+ return state.id >= ExtensionRepStateIds.initialized;
52
52
  }
53
- function isConfiguredPlanRepState(state) {
54
- return state.id >= PlanRepStateIds.configured;
53
+ function isConfiguredExtensionRepState(state) {
54
+ return state.id >= ExtensionRepStateIds.configured;
55
55
  }
56
- function isRegisteredPlanRepState(state) {
57
- return state.id >= PlanRepStateIds.registered;
56
+ function isRegisteredExtensionRepState(state) {
57
+ return state.id >= ExtensionRepStateIds.registered;
58
58
  }
59
59
  function isAfterInitializationState(state) {
60
- return state.id >= PlanRepStateIds.afterInitialization;
60
+ return state.id >= ExtensionRepStateIds.afterInitialization;
61
61
  }
62
62
  function applyTemporaryMark(state) {
63
63
  invariant(
64
- isExactlyUnmarkedPlanRepState(state),
65
- "LexicalBuilder: Can not apply a temporary mark to state"
64
+ isExactlyUnmarkedExtensionRepState(state),
65
+ "LexicalBuilder: Can not apply a temporary mark from state id %s (expected %s unmarked)",
66
+ String(state.id),
67
+ String(ExtensionRepStateIds.unmarked)
66
68
  );
67
- return Object.assign(state, { id: PlanRepStateIds.temporary });
69
+ return Object.assign(state, { id: ExtensionRepStateIds.temporary });
68
70
  }
69
71
  function applyPermanentMark(state) {
70
72
  invariant(
71
- isExactlyTemporaryPlanRepState(state),
72
- "LexicalBuilder: Can not apply a permanent mark to state"
73
+ isExactlyTemporaryExtensionRepState(state),
74
+ "LexicalBuilder: Can not apply a permanent mark from state id %s (expected %s temporary)",
75
+ String(state.id),
76
+ String(ExtensionRepStateIds.temporary)
73
77
  );
74
- return Object.assign(state, { id: PlanRepStateIds.permanent });
78
+ return Object.assign(state, { id: ExtensionRepStateIds.permanent });
75
79
  }
76
80
  function applyConfiguredState(state, config, registerState) {
77
81
  return Object.assign(state, {
78
- id: PlanRepStateIds.configured,
82
+ id: ExtensionRepStateIds.configured,
79
83
  config,
80
84
  registerState
81
85
  });
82
86
  }
83
87
  function applyInitializedState(state, initResult, registerState) {
84
88
  return Object.assign(state, {
85
- id: PlanRepStateIds.initialized,
89
+ id: ExtensionRepStateIds.initialized,
86
90
  initResult,
87
91
  registerState
88
92
  });
89
93
  }
90
94
  function applyRegisteredState(state, cleanup) {
91
95
  return Object.assign(state, {
92
- id: PlanRepStateIds.registered,
96
+ id: ExtensionRepStateIds.registered,
93
97
  output: cleanup ? cleanup.output : void 0
94
98
  });
95
99
  }
96
100
  function applyAfterInitializationState(state) {
97
- return Object.assign(state, { id: PlanRepStateIds.afterInitialization });
101
+ return Object.assign(state, { id: ExtensionRepStateIds.afterInitialization });
98
102
  }
99
103
  const emptySet = /* @__PURE__ */ new Set();
100
- class PlanRep {
101
- constructor(builder, plan) {
104
+ class ExtensionRep {
105
+ constructor(builder, extension) {
102
106
  __publicField(this, "builder");
103
107
  __publicField(this, "configs");
104
108
  __publicField(this, "_dependency");
105
109
  __publicField(this, "_output");
106
110
  __publicField(this, "_peerNameSet");
107
- __publicField(this, "plan");
111
+ __publicField(this, "extension");
108
112
  __publicField(this, "state");
109
113
  this.builder = builder;
110
- this.plan = plan;
114
+ this.extension = extension;
111
115
  this.configs = /* @__PURE__ */ new Set();
112
- this.state = { id: PlanRepStateIds.unmarked };
116
+ this.state = { id: ExtensionRepStateIds.unmarked };
113
117
  }
114
118
  afterInitialization(editor) {
115
119
  const state = this.state;
116
120
  invariant(
117
- state.id === PlanRepStateIds.registered,
118
- "PlanRep: afterInitialization called in state id %s (expected %s registered)",
121
+ state.id === ExtensionRepStateIds.registered,
122
+ "ExtensionRep: afterInitialization called in state id %s (expected %s registered)",
119
123
  String(state.id),
120
- String(PlanRepStateIds.registered)
124
+ String(ExtensionRepStateIds.registered)
121
125
  );
122
126
  let rval;
123
- if (this.plan.afterInitialization) {
124
- rval = this.plan.afterInitialization(
127
+ if (this.extension.afterInitialization) {
128
+ rval = this.extension.afterInitialization(
125
129
  editor,
126
130
  state.config,
127
131
  state.registerState
@@ -133,14 +137,14 @@ class PlanRep {
133
137
  register(editor) {
134
138
  const state = this.state;
135
139
  invariant(
136
- state.id === PlanRepStateIds.initialized,
137
- "PlanRep: register called in state id %s (expected %s initialized)",
140
+ state.id === ExtensionRepStateIds.initialized,
141
+ "ExtensionRep: register called in state id %s (expected %s initialized)",
138
142
  String(state.id),
139
- String(PlanRepStateIds.initialized)
143
+ String(ExtensionRepStateIds.initialized)
140
144
  );
141
145
  let cleanup;
142
- if (this.plan.register) {
143
- cleanup = this.plan.register(
146
+ if (this.extension.register) {
147
+ cleanup = this.extension.register(
144
148
  editor,
145
149
  state.config,
146
150
  state.registerState
@@ -152,8 +156,8 @@ class PlanRep {
152
156
  init(editorConfig, signal) {
153
157
  const initialState = this.state;
154
158
  invariant(
155
- isExactlyPermanentPlanRepState(initialState),
156
- "LexicalBuilder: Can not configure from state id %s",
159
+ isExactlyPermanentExtensionRepState(initialState),
160
+ "ExtensionRep: Can not configure from state id %s",
157
161
  String(initialState.id)
158
162
  );
159
163
  const initState = {
@@ -176,8 +180,8 @@ class PlanRep {
176
180
  );
177
181
  this.state = state;
178
182
  let initResult;
179
- if (this.plan.init) {
180
- initResult = this.plan.init(
183
+ if (this.extension.init) {
184
+ initResult = this.extension.init(
181
185
  editorConfig,
182
186
  state.config,
183
187
  initState
@@ -187,85 +191,87 @@ class PlanRep {
187
191
  }
188
192
  getInitResult() {
189
193
  invariant(
190
- this.plan.init !== void 0,
191
- "PlanRep: getInitResult() called for Plan %s that does not define init",
192
- this.plan.name
194
+ this.extension.init !== void 0,
195
+ "ExtensionRep: getInitResult() called for Extension %s that does not define init",
196
+ this.extension.name
193
197
  );
194
198
  const state = this.state;
195
199
  invariant(
196
- isInitializedPlanRepState(state),
197
- "PlanRep: getInitResult() called for PlanRep in state id %s < %s (initialized)",
200
+ isInitializedExtensionRepState(state),
201
+ "ExtensionRep: getInitResult() called for ExtensionRep in state id %s < %s (initialized)",
198
202
  String(state.id),
199
- String(PlanRepStateIds.initialized)
203
+ String(ExtensionRepStateIds.initialized)
200
204
  );
201
205
  return state.initResult;
202
206
  }
203
207
  getInitPeer(name) {
204
- const rep = this.builder.planNameMap.get(name);
205
- return rep ? rep.getPlanInitDependency() : void 0;
208
+ const rep = this.builder.extensionNameMap.get(name);
209
+ return rep ? rep.getExtensionInitDependency() : void 0;
206
210
  }
207
- getPlanInitDependency() {
211
+ getExtensionInitDependency() {
208
212
  const state = this.state;
209
213
  invariant(
210
- isConfiguredPlanRepState(state),
211
- "LexicalPlanBuilder: getPlanInitDependency called in state id %s (expected >= %s configured)",
214
+ isConfiguredExtensionRepState(state),
215
+ "ExtensionRep: getExtensionInitDependency called in state id %s (expected >= %s configured)",
212
216
  String(state.id),
213
- String(PlanRepStateIds.configured)
217
+ String(ExtensionRepStateIds.configured)
214
218
  );
215
219
  return { config: state.config };
216
220
  }
217
221
  getPeer(name) {
218
- const rep = this.builder.planNameMap.get(name);
219
- return rep ? rep.getPlanDependency() : void 0;
222
+ const rep = this.builder.extensionNameMap.get(name);
223
+ return rep ? rep.getExtensionDependency() : void 0;
220
224
  }
221
225
  getInitDependency(dep) {
222
- const rep = this.builder.getPlanRep(dep);
226
+ const rep = this.builder.getExtensionRep(dep);
223
227
  invariant(
224
228
  rep !== void 0,
225
- "LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry",
226
- this.plan.name,
229
+ "LexicalExtensionBuilder: Extension %s missing dependency extension %s to be in registry",
230
+ this.extension.name,
227
231
  dep.name
228
232
  );
229
- return rep.getPlanInitDependency();
233
+ return rep.getExtensionInitDependency();
230
234
  }
231
235
  getDependency(dep) {
232
- const rep = this.builder.getPlanRep(dep);
236
+ const rep = this.builder.getExtensionRep(dep);
233
237
  invariant(
234
238
  rep !== void 0,
235
- "LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry",
236
- this.plan.name,
239
+ "LexicalExtensionBuilder: Extension %s missing dependency extension %s to be in registry",
240
+ this.extension.name,
237
241
  dep.name
238
242
  );
239
- return rep.getPlanDependency();
243
+ return rep.getExtensionDependency();
240
244
  }
241
245
  getState() {
242
246
  const state = this.state;
243
247
  invariant(
244
248
  isAfterInitializationState(state),
245
- "PlanRep getState called in state id %s (expected %s afterInitialization)",
249
+ "ExtensionRep getState called in state id %s (expected %s afterInitialization)",
246
250
  String(state.id),
247
- String(PlanRepStateIds.afterInitialization)
251
+ String(ExtensionRepStateIds.afterInitialization)
248
252
  );
249
253
  return state;
250
254
  }
251
255
  getDirectDependentNames() {
252
- return this.builder.incomingEdges.get(this.plan.name) || emptySet;
256
+ return this.builder.incomingEdges.get(this.extension.name) || emptySet;
253
257
  }
254
258
  getPeerNameSet() {
255
259
  let s = this._peerNameSet;
256
260
  if (!s) {
257
- s = new Set((this.plan.peerDependencies || []).map(([name]) => name));
261
+ s = new Set(
262
+ (this.extension.peerDependencies || []).map(([name]) => name)
263
+ );
258
264
  this._peerNameSet = s;
259
265
  }
260
266
  return s;
261
267
  }
262
- getPlanDependency() {
268
+ getExtensionDependency() {
263
269
  if (!this._dependency) {
264
270
  const state = this.state;
265
271
  invariant(
266
- isRegisteredPlanRepState(state),
267
- "Plan %s used as a dependency before registration",
268
- this.plan.name
272
+ isRegisteredExtensionRepState(state),
273
+ "Extension %s used as a dependency before registration",
274
+ this.extension.name
269
275
  );
270
276
  this._dependency = {
271
277
  config: state.config,
@@ -275,8 +281,8 @@ class PlanRep {
275
281
  return this._dependency;
276
282
  }
277
283
  mergeConfigs() {
278
- let config = this.plan.config || {};
279
- const mergeConfig = this.plan.mergeConfig ? this.plan.mergeConfig.bind(this.plan) : shallowMergeConfig;
284
+ let config = this.extension.config || {};
285
+ const mergeConfig = this.extension.mergeConfig ? this.extension.mergeConfig.bind(this.extension) : shallowMergeConfig;
280
286
  for (const cfg of this.configs) {
281
287
  config = mergeConfig(config, cfg);
282
288
  }
@@ -290,10 +296,10 @@ function $defaultInitializer() {
290
296
  root.append($createParagraphNode());
291
297
  }
292
298
  }
293
- const InitialStatePlan = definePlan({
299
+ const InitialStateExtension = defineExtension({
294
300
  name: "@etrepum/lexical-builder/InitialState",
295
301
  // These are automatically added by createEditor, we add them here so they are
296
- // visible during planRep.init so plans can see all known types before the
302
+ // visible during extensionRep.init so extensions can see all known types before the
297
303
  // editor is created.
298
304
  // (excluding ArtificialNode__DO_NOT_USE because it isn't really public API
299
305
  // and shouldn't change anything)
@@ -331,8 +337,8 @@ const InitialStatePlan = definePlan({
331
337
  }
332
338
  });
333
339
  const builderSymbol = Symbol.for("@etrepum/lexical-builder");
334
- function buildEditorFromPlans(...plans) {
335
- return LexicalBuilder.fromPlans(plans).buildEditor();
340
+ function buildEditorFromExtensions(...extensions) {
341
+ return LexicalBuilder.fromExtensions(extensions).buildEditor();
336
342
  }
337
343
  function noop() {
338
344
  }
@@ -342,32 +348,32 @@ function defaultOnError(err) {
342
348
  function maybeWithBuilder(editor) {
343
349
  return editor;
344
350
  }
345
- function normalizePlanArgument(arg) {
351
+ function normalizeExtensionArgument(arg) {
346
352
  return Array.isArray(arg) ? arg : [arg];
347
353
  }
348
354
  class LexicalBuilder {
349
355
  constructor(roots) {
350
356
  __publicField(this, "roots");
351
- __publicField(this, "planNameMap");
357
+ __publicField(this, "extensionNameMap");
352
358
  __publicField(this, "outgoingConfigEdges");
353
359
  __publicField(this, "incomingEdges");
354
360
  __publicField(this, "conflicts");
355
- __publicField(this, "_sortedPlanReps");
361
+ __publicField(this, "_sortedExtensionReps");
356
362
  __publicField(this, "PACKAGE_VERSION");
357
363
  this.outgoingConfigEdges = /* @__PURE__ */ new Map();
358
364
  this.incomingEdges = /* @__PURE__ */ new Map();
359
- this.planNameMap = /* @__PURE__ */ new Map();
365
+ this.extensionNameMap = /* @__PURE__ */ new Map();
360
366
  this.conflicts = /* @__PURE__ */ new Map();
361
367
  this.PACKAGE_VERSION = PACKAGE_VERSION;
362
368
  this.roots = roots;
363
- for (const plan of roots) {
364
- this.addPlan(plan);
369
+ for (const extension of roots) {
370
+ this.addExtension(extension);
365
371
  }
366
372
  }
367
- static fromPlans(plans) {
368
- const roots = [normalizePlanArgument(InitialStatePlan)];
369
- for (const plan of plans) {
370
- roots.push(normalizePlanArgument(plan));
373
+ static fromExtensions(extensions) {
374
+ const roots = [normalizeExtensionArgument(InitialStateExtension)];
375
+ for (const extension of extensions) {
376
+ roots.push(normalizeExtensionArgument(extension));
371
377
  }
372
378
  return new LexicalBuilder(roots);
373
379
  }
@@ -427,126 +433,126 @@ class LexicalBuilder {
427
433
  );
428
434
  return editor;
429
435
  }
430
- getPlanRep(plan) {
431
- const rep = this.planNameMap.get(plan.name);
436
+ getExtensionRep(extension) {
437
+ const rep = this.extensionNameMap.get(extension.name);
432
438
  if (rep) {
433
439
  invariant(
434
- rep.plan === plan,
435
- "LexicalBuilder: A registered plan with name %s exists but does not match the given plan",
436
- plan.name
440
+ rep.extension === extension,
441
+ "LexicalBuilder: A registered extension with name %s exists but does not match the given extension",
442
+ extension.name
437
443
  );
438
444
  return rep;
439
445
  }
440
446
  }
441
- addEdge(fromPlanName, toPlanName, configs) {
442
- const outgoing = this.outgoingConfigEdges.get(fromPlanName);
447
+ addEdge(fromExtensionName, toExtensionName, configs) {
448
+ const outgoing = this.outgoingConfigEdges.get(fromExtensionName);
443
449
  if (outgoing) {
444
- outgoing.set(toPlanName, configs);
450
+ outgoing.set(toExtensionName, configs);
445
451
  } else {
446
452
  this.outgoingConfigEdges.set(
447
- fromPlanName,
448
- /* @__PURE__ */ new Map([[toPlanName, configs]])
453
+ fromExtensionName,
454
+ /* @__PURE__ */ new Map([[toExtensionName, configs]])
449
455
  );
450
456
  }
451
- const incoming = this.incomingEdges.get(toPlanName);
457
+ const incoming = this.incomingEdges.get(toExtensionName);
452
458
  if (incoming) {
453
- incoming.add(fromPlanName);
459
+ incoming.add(fromExtensionName);
454
460
  } else {
455
- this.incomingEdges.set(toPlanName, /* @__PURE__ */ new Set([fromPlanName]));
461
+ this.incomingEdges.set(toExtensionName, /* @__PURE__ */ new Set([fromExtensionName]));
456
462
  }
457
463
  }
458
- addPlan(arg) {
464
+ addExtension(arg) {
459
465
  invariant(
460
- this._sortedPlanReps === void 0,
461
- "LexicalBuilder: addPlan called after finalization"
466
+ this._sortedExtensionReps === void 0,
467
+ "LexicalBuilder: addExtension called after finalization"
462
468
  );
463
- const normalized = normalizePlanArgument(arg);
464
- const [plan] = normalized;
469
+ const normalized = normalizeExtensionArgument(arg);
470
+ const [extension] = normalized;
465
471
  invariant(
466
- typeof plan.name === "string",
467
- "LexicalBuilder: plan name must be string, not %s",
468
- typeof plan.name
472
+ typeof extension.name === "string",
473
+ "LexicalBuilder: extension name must be string, not %s",
474
+ typeof extension.name
469
475
  );
470
- let planRep = this.planNameMap.get(plan.name);
476
+ let extensionRep = this.extensionNameMap.get(extension.name);
471
477
  invariant(
472
- planRep === void 0 || planRep.plan === plan,
473
- "LexicalBuilder: Multiple plans registered with name %s, names must be unique",
474
- plan.name
478
+ extensionRep === void 0 || extensionRep.extension === extension,
479
+ "LexicalBuilder: Multiple extensions registered with name %s, names must be unique",
480
+ extension.name
475
481
  );
476
- if (!planRep) {
477
- planRep = new PlanRep(this, plan);
478
- this.planNameMap.set(plan.name, planRep);
479
- const hasConflict = this.conflicts.get(plan.name);
482
+ if (!extensionRep) {
483
+ extensionRep = new ExtensionRep(this, extension);
484
+ this.extensionNameMap.set(extension.name, extensionRep);
485
+ const hasConflict = this.conflicts.get(extension.name);
480
486
  if (typeof hasConflict === "string") {
481
487
  invariant(
482
488
  false,
483
- "LexicalBuilder: plan %s conflicts with %s",
484
- plan.name,
489
+ "LexicalBuilder: extension %s conflicts with %s",
490
+ extension.name,
485
491
  hasConflict
486
492
  );
487
493
  }
488
- for (const name of plan.conflictsWith || []) {
494
+ for (const name of extension.conflictsWith || []) {
489
495
  invariant(
490
- !this.planNameMap.has(name),
491
- "LexicalBuilder: plan %s conflicts with %s",
492
- plan.name,
496
+ !this.extensionNameMap.has(name),
497
+ "LexicalBuilder: extension %s conflicts with %s",
498
+ extension.name,
493
499
  name
494
500
  );
495
- this.conflicts.set(name, plan.name);
501
+ this.conflicts.set(name, extension.name);
496
502
  }
497
- for (const dep of plan.dependencies || []) {
498
- const normDep = normalizePlanArgument(dep);
499
- this.addEdge(plan.name, normDep[0].name, normDep.slice(1));
500
- this.addPlan(normDep);
503
+ for (const dep of extension.dependencies || []) {
504
+ const normDep = normalizeExtensionArgument(dep);
505
+ this.addEdge(extension.name, normDep[0].name, normDep.slice(1));
506
+ this.addExtension(normDep);
501
507
  }
502
- for (const [depName, config] of plan.peerDependencies || []) {
503
- this.addEdge(plan.name, depName, config ? [config] : []);
508
+ for (const [depName, config] of extension.peerDependencies || []) {
509
+ this.addEdge(extension.name, depName, config ? [config] : []);
504
510
  }
505
511
  }
506
512
  }
507
- sortedPlanReps() {
508
- if (this._sortedPlanReps) {
509
- return this._sortedPlanReps;
513
+ sortedExtensionReps() {
514
+ if (this._sortedExtensionReps) {
515
+ return this._sortedExtensionReps;
510
516
  }
511
- const sortedPlanReps = [];
512
- const visit = (rep, fromPlanName) => {
517
+ const sortedExtensionReps = [];
518
+ const visit = (rep, fromExtensionName) => {
513
519
  let mark = rep.state;
514
- if (isExactlyPermanentPlanRepState(mark)) {
520
+ if (isExactlyPermanentExtensionRepState(mark)) {
515
521
  return;
516
522
  }
517
- const planName = rep.plan.name;
523
+ const extensionName = rep.extension.name;
518
524
  invariant(
519
- isExactlyUnmarkedPlanRepState(mark),
520
- "LexicalBuilder: Circular dependency detected for Plan %s from %s",
521
- planName,
522
- fromPlanName || "[unknown]"
525
+ isExactlyUnmarkedExtensionRepState(mark),
526
+ "LexicalBuilder: Circular dependency detected for Extension %s from %s",
527
+ extensionName,
528
+ fromExtensionName || "[unknown]"
523
529
  );
524
530
  mark = applyTemporaryMark(mark);
525
531
  rep.state = mark;
526
- const outgoingConfigEdges = this.outgoingConfigEdges.get(planName);
532
+ const outgoingConfigEdges = this.outgoingConfigEdges.get(extensionName);
527
533
  if (outgoingConfigEdges) {
528
- for (const toPlanName of outgoingConfigEdges.keys()) {
529
- const toRep = this.planNameMap.get(toPlanName);
534
+ for (const toExtensionName of outgoingConfigEdges.keys()) {
535
+ const toRep = this.extensionNameMap.get(toExtensionName);
530
536
  if (toRep) {
531
- visit(toRep, planName);
537
+ visit(toRep, extensionName);
532
538
  }
533
539
  }
534
540
  }
535
541
  mark = applyPermanentMark(mark);
536
542
  rep.state = mark;
537
- sortedPlanReps.push(rep);
543
+ sortedExtensionReps.push(rep);
538
544
  };
539
- for (const rep of this.planNameMap.values()) {
540
- if (isExactlyUnmarkedPlanRepState(rep.state)) {
545
+ for (const rep of this.extensionNameMap.values()) {
546
+ if (isExactlyUnmarkedExtensionRepState(rep.state)) {
541
547
  visit(rep);
542
548
  }
543
549
  }
544
- for (const rep of sortedPlanReps) {
545
- for (const [toPlanName, configs] of this.outgoingConfigEdges.get(
546
- rep.plan.name
550
+ for (const rep of sortedExtensionReps) {
551
+ for (const [toExtensionName, configs] of this.outgoingConfigEdges.get(
552
+ rep.extension.name
547
553
  ) || []) {
548
554
  if (configs.length > 0) {
549
- const toRep = this.planNameMap.get(toPlanName);
555
+ const toRep = this.extensionNameMap.get(toExtensionName);
550
556
  if (toRep) {
551
557
  for (const config of configs) {
552
558
  toRep.configs.add(config);
@@ -555,33 +561,33 @@ class LexicalBuilder {
555
561
  }
556
562
  }
557
563
  }
558
- for (const [plan, ...configs] of this.roots) {
564
+ for (const [extension, ...configs] of this.roots) {
559
565
  if (configs.length > 0) {
560
- const toRep = this.planNameMap.get(plan.name);
566
+ const toRep = this.extensionNameMap.get(extension.name);
561
567
  invariant(
562
568
  toRep !== void 0,
563
- "LexicalBuilder: Expecting existing PlanRep for %s",
564
- plan.name
569
+ "LexicalBuilder: Expecting existing ExtensionRep for %s",
570
+ extension.name
565
571
  );
566
572
  for (const config of configs) {
567
573
  toRep.configs.add(config);
568
574
  }
569
575
  }
570
576
  }
571
- this._sortedPlanReps = sortedPlanReps;
572
- return this._sortedPlanReps;
577
+ this._sortedExtensionReps = sortedExtensionReps;
578
+ return this._sortedExtensionReps;
573
579
  }
574
580
  registerEditor(editor, controller) {
575
581
  const cleanups = [];
576
- const planReps = this.sortedPlanReps();
577
- for (const planRep of planReps) {
578
- const cleanup = planRep.register(editor);
582
+ const extensionReps = this.sortedExtensionReps();
583
+ for (const extensionRep of extensionReps) {
584
+ const cleanup = extensionRep.register(editor);
579
585
  if (cleanup) {
580
586
  cleanups.push(cleanup);
581
587
  }
582
588
  }
583
- for (const planRep of planReps) {
584
- const cleanup = planRep.afterInitialization(editor);
589
+ for (const extensionRep of extensionReps) {
590
+ const cleanup = extensionRep.afterInitialization(editor);
585
591
  if (cleanup) {
586
592
  cleanups.push(cleanup);
587
593
  }
@@ -607,57 +613,57 @@ class LexicalBuilder {
607
613
  const htmlExport = /* @__PURE__ */ new Map();
608
614
  const htmlImport = {};
609
615
  const theme = {};
610
- const planReps = this.sortedPlanReps();
611
- for (const planRep of planReps) {
612
- const { plan } = planRep;
613
- if (plan.onError !== void 0) {
614
- config.onError = plan.onError;
616
+ const extensionReps = this.sortedExtensionReps();
617
+ for (const extensionRep of extensionReps) {
618
+ const { extension } = extensionRep;
619
+ if (extension.onError !== void 0) {
620
+ config.onError = extension.onError;
615
621
  }
616
- if (plan.disableEvents !== void 0) {
617
- config.disableEvents = plan.disableEvents;
622
+ if (extension.disableEvents !== void 0) {
623
+ config.disableEvents = extension.disableEvents;
618
624
  }
619
- if (plan.parentEditor !== void 0) {
620
- config.parentEditor = plan.parentEditor;
625
+ if (extension.parentEditor !== void 0) {
626
+ config.parentEditor = extension.parentEditor;
621
627
  }
622
- if (plan.editable !== void 0) {
623
- config.editable = plan.editable;
628
+ if (extension.editable !== void 0) {
629
+ config.editable = extension.editable;
624
630
  }
625
- if (plan.namespace !== void 0) {
626
- config.namespace = plan.namespace;
631
+ if (extension.namespace !== void 0) {
632
+ config.namespace = extension.namespace;
627
633
  }
628
- if (plan.$initialEditorState !== void 0) {
629
- config.$initialEditorState = plan.$initialEditorState;
634
+ if (extension.$initialEditorState !== void 0) {
635
+ config.$initialEditorState = extension.$initialEditorState;
630
636
  }
631
- if (plan.nodes) {
632
- for (const node of plan.nodes) {
637
+ if (extension.nodes) {
638
+ for (const node of extension.nodes) {
633
639
  if (typeof node !== "function") {
634
- const conflictPlan = replacedNodes.get(node.replace);
635
- if (conflictPlan) {
640
+ const conflictExtension = replacedNodes.get(node.replace);
641
+ if (conflictExtension) {
636
642
  invariant(
637
643
  false,
638
- "LexicalBuilder: Plan %s can not register replacement for node %s because %s already did",
639
- plan.name,
644
+ "LexicalBuilder: Extension %s can not register replacement for node %s because %s already did",
645
+ extension.name,
640
646
  node.replace.name,
641
- conflictPlan.plan.name
647
+ conflictExtension.extension.name
642
648
  );
643
649
  }
644
- replacedNodes.set(node.replace, planRep);
650
+ replacedNodes.set(node.replace, extensionRep);
645
651
  }
646
652
  nodes.add(node);
647
653
  }
648
654
  }
649
- if (plan.html) {
650
- if (plan.html.export) {
651
- for (const [k, v] of plan.html.export.entries()) {
655
+ if (extension.html) {
656
+ if (extension.html.export) {
657
+ for (const [k, v] of extension.html.export.entries()) {
652
658
  htmlExport.set(k, v);
653
659
  }
654
660
  }
655
- if (plan.html.import) {
656
- Object.assign(htmlImport, plan.html.import);
661
+ if (extension.html.import) {
662
+ Object.assign(htmlImport, extension.html.import);
657
663
  }
658
664
  }
659
- if (plan.theme) {
660
- deepThemeMergeInPlace(theme, plan.theme);
665
+ if (extension.theme) {
666
+ deepThemeMergeInPlace(theme, extension.theme);
661
667
  }
662
668
  }
663
669
  if (Object.keys(theme).length > 0) {
@@ -677,8 +683,8 @@ class LexicalBuilder {
677
683
  config.html.export = htmlExport;
678
684
  }
679
685
  }
680
- for (const planRep of planReps) {
681
- planRep.init(config, signal);
686
+ for (const extensionRep of extensionReps) {
687
+ extensionRep.init(config, signal);
682
688
  }
683
689
  if (!config.onError) {
684
690
  config.onError = defaultOnError;
@@ -686,27 +692,27 @@ class LexicalBuilder {
686
692
  return config;
687
693
  }
688
694
  }
689
- function getPlanDependencyFromEditor(editor, plan) {
695
+ function getExtensionDependencyFromEditor(editor, extension) {
690
696
  const builder = LexicalBuilder.fromEditor(editor);
691
- const rep = builder.getPlanRep(plan);
697
+ const rep = builder.getExtensionRep(extension);
692
698
  invariant(
693
699
  rep !== void 0,
694
- "getPlanFromEditor: Plan %s was not built when creating this editor",
695
- plan.name
700
+ "getExtensionDependencyFromEditor: Extension %s was not built when creating this editor",
701
+ extension.name
696
702
  );
697
- return rep.getPlanDependency();
703
+ return rep.getExtensionDependency();
698
704
  }
699
- function getPeerDependencyFromEditor(editor, planName) {
705
+ function getPeerDependencyFromEditor(editor, extensionName) {
700
706
  const builder = LexicalBuilder.fromEditor(editor);
701
- const peer = builder.planNameMap.get(planName);
702
- return peer ? peer.getPlanDependency() : void 0;
707
+ const peer = builder.extensionNameMap.get(extensionName);
708
+ return peer ? peer.getExtensionDependency() : void 0;
703
709
  }
704
- function getPeerDependencyFromEditorOrThrow(editor, planName) {
705
- const dep = getPeerDependencyFromEditor(editor, planName);
710
+ function getPeerDependencyFromEditorOrThrow(editor, extensionName) {
711
+ const dep = getPeerDependencyFromEditor(editor, extensionName);
706
712
  invariant(
707
713
  dep !== void 0,
708
- "getPeerDependencyFromEditorOrThrow: Editor was not build with Plan %s",
709
- planName
714
+ "getPeerDependencyFromEditorOrThrow: Editor was not built with Extension %s",
715
+ extensionName
710
716
  );
711
717
  return dep;
712
718
  }
@@ -720,7 +726,7 @@ function getKnownTypesAndNodes(config) {
720
726
  }
721
727
  return { types, nodes };
722
728
  }
723
- const AutoFocusPlan = definePlan({
729
+ const AutoFocusExtension = defineExtension({
724
730
  config: safeCast({}),
725
731
  name: "@etrepum/lexical-builder/AutoFocus",
726
732
  register(editor, { defaultSelection }) {
@@ -797,7 +803,7 @@ function disabledToggle(opts) {
797
803
  registerStoreToggle(disabled, (v) => !v, opts.register)
798
804
  ];
799
805
  }
800
- const DragonPlan = definePlan({
806
+ const DragonExtension = defineExtension({
801
807
  name: "@lexical/dragon",
802
808
  config: safeCast({ disabled: typeof window === "undefined" }),
803
809
  register: (editor, config) => provideOutput(
@@ -807,7 +813,7 @@ const DragonPlan = definePlan({
807
813
  })
808
814
  )
809
815
  });
810
- const HistoryPlan = definePlan({
816
+ const HistoryExtension = defineExtension({
811
817
  config: safeCast({
812
818
  createInitialHistoryState: createEmptyHistoryState,
813
819
  delay: 300,
@@ -827,13 +833,13 @@ const HistoryPlan = definePlan({
827
833
  }
828
834
  });
829
835
  function getHistoryPeer(editor) {
830
- return editor ? getPeerDependencyFromEditor(editor, HistoryPlan.name) : null;
836
+ return editor ? getPeerDependencyFromEditor(editor, HistoryExtension.name) : null;
831
837
  }
832
- const SharedHistoryPlan = definePlan({
838
+ const SharedHistoryExtension = defineExtension({
833
839
  name: "@etrepum/lexical-builder/SharedHistory",
834
- dependencies: [configPlan(HistoryPlan, { disabled: true })],
840
+ dependencies: [configExtension(HistoryExtension, { disabled: true })],
835
841
  init(editorConfig, _config, state) {
836
- const { config } = state.getDependency(HistoryPlan);
842
+ const { config } = state.getDependency(HistoryExtension);
837
843
  const parentPeer = getHistoryPeer(editorConfig.parentEditor);
838
844
  if (parentPeer) {
839
845
  config.delay = parentPeer.config.delay;
@@ -847,43 +853,43 @@ const SharedHistoryPlan = definePlan({
847
853
  return () => {
848
854
  };
849
855
  }
850
- const disabled = state.getDependency(HistoryPlan).output.disabled;
856
+ const disabled = state.getDependency(HistoryExtension).output.disabled;
851
857
  return parentPeer.output.disabled.subscribe(disabled.set.bind(disabled));
852
858
  }
853
859
  });
854
- const PlainTextPlan = definePlan({
860
+ const PlainTextExtension = defineExtension({
855
861
  conflictsWith: ["@lexical/rich-text"],
856
862
  name: "@lexical/plain-text",
857
- dependencies: [DragonPlan],
863
+ dependencies: [DragonExtension],
858
864
  register: registerPlainText
859
865
  });
860
- const RichTextPlan = definePlan({
866
+ const RichTextExtension = defineExtension({
861
867
  conflictsWith: ["@lexical/plain-text"],
862
868
  name: "@lexical/rich-text",
863
869
  nodes: [HeadingNode, QuoteNode],
864
- dependencies: [DragonPlan],
870
+ dependencies: [DragonExtension],
865
871
  register: registerRichText
866
872
  });
867
873
  export {
868
- AutoFocusPlan,
869
- DragonPlan,
870
- HistoryPlan,
871
- InitialStatePlan,
874
+ AutoFocusExtension,
875
+ DragonExtension,
876
+ HistoryExtension,
877
+ InitialStateExtension,
872
878
  LexicalBuilder,
873
879
  PACKAGE_VERSION,
874
- PlainTextPlan,
875
- RichTextPlan,
876
- SharedHistoryPlan,
880
+ PlainTextExtension,
881
+ RichTextExtension,
882
+ SharedHistoryExtension,
877
883
  Store,
878
- buildEditorFromPlans,
879
- configPlan2 as configPlan,
884
+ buildEditorFromExtensions,
885
+ configExtension2 as configExtension,
880
886
  declarePeerDependency,
881
- definePlan2 as definePlan,
887
+ defineExtension2 as defineExtension,
882
888
  disabledToggle,
889
+ getExtensionDependencyFromEditor,
883
890
  getKnownTypesAndNodes,
884
891
  getPeerDependencyFromEditor,
885
892
  getPeerDependencyFromEditorOrThrow,
886
- getPlanDependencyFromEditor,
887
893
  provideOutput2 as provideOutput,
888
894
  registerStoreToggle,
889
895
  safeCast2 as safeCast,