@etrepum/lexical-builder 0.0.36-nightly.20250714.0 → 0.0.36

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