@etrepum/lexical-builder 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/AutoFocusPlan.d.ts +2 -4
- package/dist/AutoFocusPlan.d.ts.map +1 -1
- package/dist/DragonPlan.d.ts +1 -1
- package/dist/DragonPlan.d.ts.map +1 -1
- package/dist/HistoryPlan.d.ts +2 -4
- package/dist/HistoryPlan.d.ts.map +1 -1
- package/dist/LexicalBuilder.d.ts.map +1 -1
- package/dist/PlainTextPlan.d.ts +1 -1
- package/dist/PlainTextPlan.d.ts.map +1 -1
- package/dist/PlanRep.d.ts +1 -2
- package/dist/PlanRep.d.ts.map +1 -1
- package/dist/RichTextPlan.d.ts +1 -1
- package/dist/RichTextPlan.d.ts.map +1 -1
- package/dist/index.d.ts +0 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -1
package/dist/AutoFocusPlan.d.ts
CHANGED
@@ -5,15 +5,13 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*/
|
8
|
-
declare const NAME = "@etrepum/lexical-builder/AutoFocusPlan";
|
9
8
|
declare module "@etrepum/lexical-builder" {
|
10
9
|
interface LexicalPlanRegistry {
|
11
|
-
[
|
10
|
+
[AutoFocusPlan.name]: typeof AutoFocusPlan;
|
12
11
|
}
|
13
12
|
}
|
14
13
|
export interface AutoFocusConfig {
|
15
14
|
defaultSelection?: "rootStart" | "rootEnd";
|
16
15
|
}
|
17
|
-
export declare const AutoFocusPlan: import('
|
18
|
-
export {};
|
16
|
+
export declare const AutoFocusPlan: import('./types').LexicalPlan<AutoFocusConfig, "@etrepum/lexical-builder/AutoFocusPlan">;
|
19
17
|
//# sourceMappingURL=AutoFocusPlan.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AutoFocusPlan.d.ts","sourceRoot":"","sources":["../src/AutoFocusPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
1
|
+
{"version":3,"file":"AutoFocusPlan.d.ts","sourceRoot":"","sources":["../src/AutoFocusPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,QAAQ,0BAA0B,CAAC;IACxC,UAAU,mBAAmB;QAC3B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,aAAa,CAAC;KAC5C;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC5C;AAED,eAAO,MAAM,aAAa,0FAwBxB,CAAC"}
|
package/dist/DragonPlan.d.ts
CHANGED
@@ -5,5 +5,5 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*/
|
8
|
-
export declare const DragonPlan: import('
|
8
|
+
export declare const DragonPlan: import('./types').LexicalPlan<{}, "@lexical/dragon">;
|
9
9
|
//# sourceMappingURL=DragonPlan.d.ts.map
|
package/dist/DragonPlan.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DragonPlan.d.ts","sourceRoot":"","sources":["../src/DragonPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,UAAU,
|
1
|
+
{"version":3,"file":"DragonPlan.d.ts","sourceRoot":"","sources":["../src/DragonPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,UAAU,sDAIrB,CAAC"}
|
package/dist/HistoryPlan.d.ts
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
import { HistoryState } from '@lexical/history';
|
2
2
|
|
3
|
-
declare const NAME = "@etrepum/lexical-builder/HistoryPlan";
|
4
3
|
declare module "@etrepum/lexical-builder" {
|
5
4
|
interface LexicalPlanRegistry {
|
6
|
-
[
|
5
|
+
[HistoryPlan.name]: typeof HistoryPlan;
|
7
6
|
}
|
8
7
|
}
|
9
8
|
export interface HistoryConfig {
|
10
9
|
delay: number;
|
11
10
|
createInitialHistoryState: () => HistoryState;
|
12
11
|
}
|
13
|
-
export declare const HistoryPlan: import('
|
14
|
-
export {};
|
12
|
+
export declare const HistoryPlan: import('./types').LexicalPlan<HistoryConfig, "@etrepum/lexical-builder/HistoryPlan">;
|
15
13
|
//# sourceMappingURL=HistoryPlan.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"HistoryPlan.d.ts","sourceRoot":"","sources":["../src/HistoryPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"HistoryPlan.d.ts","sourceRoot":"","sources":["../src/HistoryPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,QAAQ,0BAA0B,CAAC;IACxC,UAAU,mBAAmB;QAC3B,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,WAAW,CAAC;KACxC;CACF;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB,EAAE,MAAM,YAAY,CAAC;CAC/C;AAED,eAAO,MAAM,WAAW,sFAStB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LexicalBuilder.d.ts","sourceRoot":"","sources":["../src/LexicalBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EAEb,KAAK,gBAAgB,EAKtB,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,sBAAsB,EAC5B,GAAG,KAAK,EAAE,sBAAsB,EAAE,GACjC,YAAY,CAOd;
|
1
|
+
{"version":3,"file":"LexicalBuilder.d.ts","sourceRoot":"","sources":["../src/LexicalBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EAEb,KAAK,gBAAgB,EAKtB,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,sBAAsB,EAC5B,GAAG,KAAK,EAAE,sBAAsB,EAAE,GACjC,YAAY,CAOd;AA2BD,gBAAgB;AAChB,qBAAa,cAAc;IACzB,MAAM,EAAE,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;IACvD,OAAO,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAChE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAClD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;IAU/B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc;IASxD,WAAW,IAAI,YAAY;IAmB3B,OAAO,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM;IAsE3C,cAAc;IAMf,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI;IA6BjD,qBAAqB;CAsFtB"}
|
package/dist/PlainTextPlan.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const PlainTextPlan: import('
|
1
|
+
export declare const PlainTextPlan: import('./types').LexicalPlan<{}, "@lexical/plain-text">;
|
2
2
|
//# sourceMappingURL=PlainTextPlan.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PlainTextPlan.d.ts","sourceRoot":"","sources":["../src/PlainTextPlan.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,
|
1
|
+
{"version":3,"file":"PlainTextPlan.d.ts","sourceRoot":"","sources":["../src/PlainTextPlan.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,0DAKxB,CAAC"}
|
package/dist/PlanRep.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { LexicalBuilder } from './LexicalBuilder';
|
2
|
-
import { AnyLexicalPlan, LexicalPlanConfig } from './types';
|
3
|
-
import { LexicalPlanRegistry } from './';
|
2
|
+
import { AnyLexicalPlan, LexicalPlanConfig, LexicalPlanRegistry } from './types';
|
4
3
|
|
5
4
|
export declare class PlanRep<Plan extends AnyLexicalPlan> {
|
6
5
|
builder: LexicalBuilder;
|
package/dist/PlanRep.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PlanRep.d.ts","sourceRoot":"","sources":["../src/PlanRep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"PlanRep.d.ts","sourceRoot":"","sources":["../src/PlanRep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMnD,qBAAa,OAAO,CAAC,IAAI,SAAS,cAAc;IAC9C,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC;gBACC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI;IAK/C,aAAa,CAAC,IAAI,SAAS,MAAM,mBAAmB,EAClD,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAI3D,mBAAmB,CAAC,UAAU,SAAS,cAAc,EACnD,GAAG,EAAE,UAAU,GACd,iBAAiB,CAAC,UAAU,CAAC;IAUhC,SAAS,IAAI,iBAAiB,CAAC,IAAI,CAAC;CAcrC"}
|
package/dist/RichTextPlan.d.ts
CHANGED
@@ -5,5 +5,5 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*/
|
8
|
-
export declare const RichTextPlan: import('
|
8
|
+
export declare const RichTextPlan: import('./types').LexicalPlan<{}, "@lexical/rich-text">;
|
9
9
|
//# sourceMappingURL=RichTextPlan.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RichTextPlan.d.ts","sourceRoot":"","sources":["../src/RichTextPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,YAAY,
|
1
|
+
{"version":3,"file":"RichTextPlan.d.ts","sourceRoot":"","sources":["../src/RichTextPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,YAAY,yDAMvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
@@ -5,24 +5,6 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*
|
7
7
|
*/
|
8
|
-
/**
|
9
|
-
* An open interface for Name -> Config mappings. If you are defining a
|
10
|
-
* plan with non-empty config and it may be used as a peerDependency then
|
11
|
-
* you should extend this as follows:
|
12
|
-
*
|
13
|
-
* @example Extending LexicalPlanRegistry
|
14
|
-
* ```ts
|
15
|
-
* const NAME = "@some/plan";
|
16
|
-
* export const SomePlan = definePlan({ name: NAME, config: { className: "default" } });
|
17
|
-
* declare module '@etrepum/lexical-builder' {
|
18
|
-
* interface LexicalPlanRegistry {
|
19
|
-
* [NAME]: typeof SomePlan;
|
20
|
-
* }
|
21
|
-
* }
|
22
|
-
* ```
|
23
|
-
*/
|
24
|
-
export interface LexicalPlanRegistry {
|
25
|
-
}
|
26
8
|
export declare const PACKAGE_VERSION: any;
|
27
9
|
export { configPlan, definePlan, defineRootPlan } from './definePlan';
|
28
10
|
export { LexicalBuilder, buildEditorFromPlans } from './LexicalBuilder';
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,KAAkC,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,KAAK,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
@@ -121,12 +121,20 @@ function buildEditorFromPlans(plan, ...plans) {
|
|
121
121
|
}
|
122
122
|
return builder.buildEditor();
|
123
123
|
}
|
124
|
+
function noop() {
|
125
|
+
}
|
124
126
|
class DisposableEditorHandle {
|
125
127
|
constructor(editor, dispose) {
|
126
128
|
__publicField(this, "editor");
|
127
129
|
__publicField(this, "dispose");
|
128
130
|
this.editor = editor;
|
129
|
-
this.dispose =
|
131
|
+
this.dispose = () => {
|
132
|
+
try {
|
133
|
+
dispose();
|
134
|
+
} finally {
|
135
|
+
this.dispose = noop;
|
136
|
+
}
|
137
|
+
};
|
130
138
|
}
|
131
139
|
// This should be safe even if the runtime doesn't have Symbol.dispose
|
132
140
|
// because it will just be `handle[undefined] = dispose;`
|
@@ -134,6 +142,9 @@ class DisposableEditorHandle {
|
|
134
142
|
this.dispose();
|
135
143
|
}
|
136
144
|
}
|
145
|
+
function defaultOnError(err) {
|
146
|
+
throw err;
|
147
|
+
}
|
137
148
|
class LexicalBuilder {
|
138
149
|
constructor() {
|
139
150
|
__publicField(this, "phases");
|
@@ -165,6 +176,7 @@ class LexicalBuilder {
|
|
165
176
|
editor,
|
166
177
|
mergeRegister(
|
167
178
|
() => buildersForEditors.delete(editor),
|
179
|
+
() => editor.setRootElement(null),
|
168
180
|
this.registerEditor(editor)
|
169
181
|
)
|
170
182
|
);
|
@@ -271,7 +283,10 @@ class LexicalBuilder {
|
|
271
283
|
};
|
272
284
|
}
|
273
285
|
buildCreateEditorArgs() {
|
274
|
-
const config = {
|
286
|
+
const config = {
|
287
|
+
// Prefer throwing errors rather than console.error by default
|
288
|
+
onError: defaultOnError
|
289
|
+
};
|
275
290
|
const nodes = /* @__PURE__ */ new Set();
|
276
291
|
const replacedNodes = /* @__PURE__ */ new Map();
|
277
292
|
const htmlExport = /* @__PURE__ */ new Map();
|
@@ -349,10 +364,9 @@ class LexicalBuilder {
|
|
349
364
|
function safeCast(value) {
|
350
365
|
return value;
|
351
366
|
}
|
352
|
-
const NAME$1 = "@etrepum/lexical-builder/AutoFocusPlan";
|
353
367
|
const AutoFocusPlan = definePlan({
|
354
368
|
config: safeCast({}),
|
355
|
-
name:
|
369
|
+
name: "@etrepum/lexical-builder/AutoFocusPlan",
|
356
370
|
register(editor, { defaultSelection }) {
|
357
371
|
return editor.registerRootListener((rootElement) => {
|
358
372
|
editor.focus(
|
@@ -372,13 +386,12 @@ const DragonPlan = definePlan({
|
|
372
386
|
name: "@lexical/dragon",
|
373
387
|
register: registerDragonSupport
|
374
388
|
});
|
375
|
-
const NAME = "@etrepum/lexical-builder/HistoryPlan";
|
376
389
|
const HistoryPlan = definePlan({
|
377
390
|
config: safeCast({
|
378
391
|
createInitialHistoryState: createEmptyHistoryState,
|
379
392
|
delay: 300
|
380
393
|
}),
|
381
|
-
name:
|
394
|
+
name: "@etrepum/lexical-builder/HistoryPlan",
|
382
395
|
register(editor, { delay, createInitialHistoryState }) {
|
383
396
|
return registerHistory(editor, createInitialHistoryState(), delay);
|
384
397
|
}
|
@@ -396,7 +409,7 @@ const RichTextPlan = definePlan({
|
|
396
409
|
nodes: [HeadingNode, QuoteNode],
|
397
410
|
register: registerRichText
|
398
411
|
});
|
399
|
-
const PACKAGE_VERSION = "0.0.
|
412
|
+
const PACKAGE_VERSION = "0.0.9";
|
400
413
|
export {
|
401
414
|
AutoFocusPlan,
|
402
415
|
DragonPlan,
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/definePlan.ts","../src/shared/invariant.ts","../src/deepThemeMergeInPlace.ts","../src/initializeEditor.ts","../src/shallowMergeConfig.ts","../src/PlanRep.ts","../src/LexicalBuilder.ts","../src/safeCast.ts","../src/AutoFocusPlan.ts","../src/DragonPlan.ts","../src/HistoryPlan.ts","../src/PlainTextPlan.ts","../src/RichTextPlan.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {\n AnyLexicalPlan,\n LexicalPlan,\n LexicalPlanConfig,\n PlanConfigBase,\n} from \"./types\";\n\nexport function definePlan<Config extends PlanConfigBase, Name extends string>(\n plan: LexicalPlan<Config, Name>,\n): LexicalPlan<Config, Name> {\n return plan;\n}\n\nexport function defineRootPlan(\n plan: Omit<LexicalPlan<PlanConfigBase, string>, \"config\" | \"name\">,\n): LexicalPlan<PlanConfigBase, \"[root]\"> {\n return { ...plan, name: \"[root]\", config: {} };\n}\n\nexport function configPlan<Plan extends AnyLexicalPlan>(\n plan: Plan,\n config: Partial<LexicalPlanConfig<Plan>>,\n): [Plan, Partial<LexicalPlanConfig<Plan>>] {\n return [plan, config];\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n// invariant(condition, message) will refine types based on \"condition\", and\n// if \"condition\" is false will throw an error. This function is special-cased\n// in flow itself, so we can't name it anything else.\nexport default function invariant(\n cond?: boolean,\n message?: string,\n ...args: string[]\n): asserts cond {\n if (cond) {\n return;\n }\n\n throw new Error(\n args.reduce((msg, arg) => msg.replace(\"%s\", String(arg)), message || \"\"),\n );\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport function deepThemeMergeInPlace(a: unknown, b: unknown) {\n if (\n a &&\n b &&\n !Array.isArray(b) &&\n typeof a === \"object\" &&\n typeof b === \"object\"\n ) {\n const aObj = a as Record<string, unknown>;\n const bObj = b as Record<string, unknown>;\n for (const k in bObj) {\n aObj[k] = deepThemeMergeInPlace(aObj[k], bObj[k]);\n }\n return a;\n }\n return b;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { InitialEditorStateType } from \"./types\";\n\nimport { $createParagraphNode, $getRoot, type LexicalEditor } from \"lexical\";\n\nconst HISTORY_MERGE_OPTIONS = { tag: \"history-merge\" };\n\nfunction $defaultInitializer() {\n const root = $getRoot();\n if (root.isEmpty()) {\n root.append($createParagraphNode());\n }\n}\n\nexport function initializeEditor(\n editor: LexicalEditor,\n $initialEditorState: InitialEditorStateType = $defaultInitializer,\n): void {\n switch (typeof $initialEditorState) {\n case \"function\": {\n editor.update(() => $initialEditorState(editor), HISTORY_MERGE_OPTIONS);\n break;\n }\n case \"string\": {\n const parsedEditorState = editor.parseEditorState($initialEditorState);\n editor.setEditorState(parsedEditorState, HISTORY_MERGE_OPTIONS);\n break;\n }\n case \"object\": {\n if ($initialEditorState) {\n editor.setEditorState($initialEditorState, HISTORY_MERGE_OPTIONS);\n }\n break;\n }\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type { PlanConfigBase } from \"./types\";\n\nexport function shallowMergeConfig<T extends PlanConfigBase>(\n a: T,\n b?: Partial<T>,\n): T {\n if (!b || a === b) {\n return a;\n }\n for (const k in b) {\n if (b[k] !== a[k]) {\n return { ...a, ...b };\n }\n }\n return a;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { LexicalBuilder } from \"./LexicalBuilder\";\nimport type { AnyLexicalPlan, LexicalPlanConfig } from \"./types\";\nimport type { LexicalPlanRegistry } from \"./\";\n\nimport invariant from \"./shared/invariant\";\n\nimport { shallowMergeConfig } from \"./shallowMergeConfig\";\n\nexport class PlanRep<Plan extends AnyLexicalPlan> {\n builder: LexicalBuilder;\n configs: Set<LexicalPlanConfig<Plan>>;\n _config?: LexicalPlanConfig<Plan>;\n plan: Plan;\n constructor(builder: LexicalBuilder, plan: Plan) {\n this.builder = builder;\n this.plan = plan;\n this.configs = new Set();\n }\n getPeerConfig<Name extends keyof LexicalPlanRegistry>(\n name: string,\n ): undefined | LexicalPlanConfig<LexicalPlanRegistry[Name]> {\n const rep = this.builder.planNameMap.get(name);\n return rep && rep.getConfig();\n }\n getDependencyConfig<Dependency extends AnyLexicalPlan>(\n dep: Dependency,\n ): LexicalPlanConfig<Dependency> {\n const pair = this.builder.planMap.get(dep);\n invariant(\n pair !== undefined,\n \"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry\",\n this.plan.name,\n dep.name,\n );\n return pair[1].getConfig();\n }\n getConfig(): LexicalPlanConfig<Plan> {\n if (this._config) {\n return this._config;\n }\n let config = this.plan.config;\n const mergeConfig = this.plan.mergeConfig\n ? this.plan.mergeConfig.bind(this.plan)\n : shallowMergeConfig;\n for (const cfg of this.configs) {\n config = mergeConfig(config, cfg);\n }\n this._config = config;\n return config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type {\n AnyLexicalPlan,\n AnyLexicalPlanArgument,\n EditorHandle,\n} from \"./types\";\n\nimport {\n LexicalEditor,\n createEditor,\n type CreateEditorArgs,\n type EditorThemeClasses,\n type HTMLConfig,\n type KlassConstructor,\n type LexicalNode,\n} from \"lexical\";\nimport invariant from \"./shared/invariant\";\n\nimport { deepThemeMergeInPlace } from \"./deepThemeMergeInPlace\";\nimport { initializeEditor } from \"./initializeEditor\";\nimport { PlanRep } from \"./PlanRep\";\nimport { mergeRegister } from \"@lexical/utils\";\n\nconst buildersForEditors = new WeakMap<LexicalEditor, LexicalBuilder>();\n\nexport function buildEditorFromPlans(\n plan: AnyLexicalPlanArgument,\n ...plans: AnyLexicalPlanArgument[]\n): EditorHandle {\n const builder = new LexicalBuilder();\n builder.addPlan(plan);\n for (const otherPlan of plans) {\n builder.addPlan(otherPlan);\n }\n return builder.buildEditor();\n}\n\nclass DisposableEditorHandle implements EditorHandle {\n editor: LexicalEditor;\n dispose: () => void;\n constructor(editor: LexicalEditor, dispose: () => void) {\n this.editor = editor;\n this.dispose = dispose;\n }\n // This should be safe even if the runtime doesn't have Symbol.dispose\n // because it will just be `handle[undefined] = dispose;`\n [Symbol.dispose]() {\n this.dispose();\n }\n}\n\n/** @internal */\nexport class LexicalBuilder {\n phases: Map<AnyLexicalPlan, PlanRep<AnyLexicalPlan>>[];\n planMap: Map<AnyLexicalPlan, [number, PlanRep<AnyLexicalPlan>]>;\n planNameMap: Map<string, PlanRep<AnyLexicalPlan>>;\n conflicts: Map<string, string>;\n\n constructor() {\n // closure compiler can't handle class initializers\n this.phases = [new Map()];\n this.planMap = new Map();\n this.planNameMap = new Map();\n this.conflicts = new Map();\n }\n\n static fromEditor(editor: LexicalEditor): LexicalBuilder {\n const builder = buildersForEditors.get(editor);\n invariant(\n builder !== undefined,\n \"LexicalBuilder.fromEditor: editor was not created with this version of LexicalBuilder\",\n );\n return builder;\n }\n\n buildEditor(): EditorHandle {\n const { $initialEditorState, onError, ...editorConfig } =\n this.buildCreateEditorArgs();\n const editor = createEditor({\n ...editorConfig,\n ...(onError ? { onError: (err) => onError(err, editor) } : {}),\n });\n initializeEditor(editor, $initialEditorState);\n buildersForEditors.set(editor, this);\n return new DisposableEditorHandle(\n editor,\n mergeRegister(\n () => buildersForEditors.delete(editor),\n this.registerEditor(editor),\n ),\n );\n }\n\n addPlan(arg: AnyLexicalPlanArgument): number {\n let plan: AnyLexicalPlan;\n let configs: unknown[];\n if (Array.isArray(arg)) {\n [plan, ...configs] = arg;\n } else {\n plan = arg;\n configs = [];\n }\n let [phase, planRep] = this.planMap.get(plan) || [0, undefined];\n if (!planRep) {\n const hasConflict = this.conflicts.get(plan.name);\n if (typeof hasConflict === \"string\") {\n invariant(\n false,\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n hasConflict,\n );\n }\n for (const name of plan.conflictsWith || []) {\n invariant(\n !this.planNameMap.has(name),\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n name,\n );\n this.conflicts.set(name, plan.name);\n }\n // TODO detect circular dependencies\n for (const dep of plan.dependencies || []) {\n phase = Math.max(phase, 1 + this.addPlan(dep));\n }\n for (const [depName, cfg] of Object.entries(\n plan.peerDependencies || {},\n )) {\n const dep = this.planNameMap.get(depName);\n if (dep) {\n phase = Math.max(phase, 1 + this.addPlan([dep.plan, cfg]));\n }\n }\n invariant(\n this.phases.length >= phase,\n \"LexicalBuilder: Expected phase to be no greater than phases.length\",\n );\n if (this.phases.length === phase) {\n this.phases.push(new Map());\n }\n planRep = new PlanRep(this, plan);\n invariant(\n !this.planNameMap.has(plan.name),\n \"LexicalBuilder: Multiple plans registered with name %s, names must be unique\",\n plan.name,\n );\n this.planMap.set(plan, [phase, planRep]);\n this.planNameMap.set(plan.name, planRep);\n const currentPhaseMap = this.phases[phase];\n invariant(\n currentPhaseMap !== undefined,\n \"LexicalBuilder: Expecting phase map for phase %s\",\n String(phase),\n );\n currentPhaseMap.set(plan, planRep);\n }\n for (const config of configs) {\n planRep.configs.add(config);\n }\n return phase;\n }\n\n *sortedPlanReps() {\n for (const phase of this.phases) {\n yield* phase.values();\n }\n }\n\n registerEditor(editor: LexicalEditor): () => void {\n const cleanups: (() => void)[] = [];\n const controller = new AbortController();\n for (const planRep of this.sortedPlanReps()) {\n if (planRep.plan.register) {\n cleanups.push(\n planRep.plan.register(editor, planRep.getConfig(), {\n getDependencyConfig: planRep.getDependencyConfig.bind(planRep),\n getPeerConfig: planRep.getPeerConfig.bind(planRep),\n signal: controller.signal,\n }),\n );\n }\n }\n return () => {\n for (let i = cleanups.length - 1; i >= 0; i--) {\n const cleanupFun = cleanups[i];\n invariant(\n cleanupFun !== undefined,\n \"LexicalBuilder: Expecting cleanups[%s] to be defined\",\n String(i),\n );\n cleanupFun();\n }\n cleanups.length = 0;\n controller.abort();\n };\n }\n\n buildCreateEditorArgs() {\n const config: Pick<\n CreateEditorArgs,\n \"nodes\" | \"html\" | \"theme\" | \"disableEvents\" | \"editable\" | \"namespace\"\n > &\n Pick<AnyLexicalPlan, \"$initialEditorState\" | \"onError\"> = {};\n const nodes = new Set<NonNullable<CreateEditorArgs[\"nodes\"]>[number]>();\n const replacedNodes = new Map<\n KlassConstructor<typeof LexicalNode>,\n PlanRep<AnyLexicalPlan>\n >();\n const htmlExport: NonNullable<HTMLConfig[\"export\"]> = new Map();\n const htmlImport: NonNullable<HTMLConfig[\"import\"]> = {};\n const theme: EditorThemeClasses = {};\n for (const planRep of this.sortedPlanReps()) {\n const { plan } = planRep;\n if (plan.onError !== undefined) {\n config.onError = plan.onError;\n }\n if (plan.disableEvents !== undefined) {\n config.disableEvents = plan.disableEvents;\n }\n if (plan.editable !== undefined) {\n config.editable = plan.editable;\n }\n if (plan.namespace !== undefined) {\n config.namespace = plan.namespace;\n }\n if (plan.$initialEditorState !== undefined) {\n config.$initialEditorState = plan.$initialEditorState;\n }\n if (plan.nodes) {\n for (const node of plan.nodes) {\n if (typeof node !== \"function\") {\n const conflictPlan = replacedNodes.get(node.replace);\n if (conflictPlan) {\n invariant(\n false,\n \"LexicalBuilder: Plan %s can not register replacement for node %s because %s already did\",\n plan.name,\n node.replace.name,\n conflictPlan.plan.name,\n );\n }\n replacedNodes.set(node.replace, planRep);\n }\n nodes.add(node);\n }\n }\n if (plan.html) {\n if (plan.html.export) {\n for (const [k, v] of plan.html.export.entries()) {\n htmlExport.set(k, v);\n }\n }\n if (plan.html.import) {\n Object.assign(htmlImport, plan.html.import);\n }\n }\n if (plan.theme) {\n deepThemeMergeInPlace(theme, plan.theme);\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n if (Object.keys(theme).length > 0) {\n config.theme = theme;\n }\n if (nodes.size) {\n config.nodes = [...nodes];\n }\n const hasImport = Object.keys(htmlImport).length > 0;\n const hasExport = htmlExport.size > 0;\n if (hasImport || hasExport) {\n config.html = {};\n if (hasImport) {\n config.html.import = htmlImport;\n }\n if (hasExport) {\n config.html.export = htmlExport;\n }\n }\n return config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n/**\n * Explicitly and safely cast a value to a specific type when inference or\n * satisfies isn't going to work as expected (often useful for the config\n * property with definePlan)\n */\nexport function safeCast<T>(value: T): T {\n return value;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { definePlan } from \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nconst NAME = \"@etrepum/lexical-builder/AutoFocusPlan\";\ndeclare module \"@etrepum/lexical-builder\" {\n interface LexicalPlanRegistry {\n [NAME]: typeof AutoFocusPlan;\n }\n}\n\nexport interface AutoFocusConfig {\n defaultSelection?: \"rootStart\" | \"rootEnd\";\n}\n\nexport const AutoFocusPlan = definePlan({\n config: safeCast<AutoFocusConfig>({}),\n name: NAME,\n register(editor, { defaultSelection }) {\n return editor.registerRootListener((rootElement) => {\n editor.focus(\n () => {\n // If we try and move selection to the same point with setBaseAndExtent, it won't\n // trigger a re-focus on the element. So in the case this occurs, we'll need to correct it.\n // Normally this is fine, Selection API !== Focus API, but fore the intents of the naming\n // of this plugin, which should preserve focus too.\n const activeElement = document.activeElement;\n if (\n rootElement !== null &&\n (activeElement === null || !rootElement.contains(activeElement))\n ) {\n // Note: preventScroll won't work in Webkit.\n rootElement.focus({ preventScroll: true });\n }\n },\n { defaultSelection },\n );\n });\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { registerDragonSupport } from \"@lexical/dragon\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const DragonPlan = definePlan({\n config: {},\n name: \"@lexical/dragon\",\n register: registerDragonSupport,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport {\n createEmptyHistoryState,\n type HistoryState,\n registerHistory,\n} from \"@lexical/history\";\n\nimport { definePlan } from \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nconst NAME = \"@etrepum/lexical-builder/HistoryPlan\";\ndeclare module \"@etrepum/lexical-builder\" {\n interface LexicalPlanRegistry {\n [NAME]: typeof HistoryPlan;\n }\n}\n\nexport interface HistoryConfig {\n delay: number;\n createInitialHistoryState: () => HistoryState;\n}\n\nexport const HistoryPlan = definePlan({\n config: safeCast<HistoryConfig>({\n createInitialHistoryState: createEmptyHistoryState,\n delay: 300,\n }),\n name: NAME,\n register(editor, { delay, createInitialHistoryState }) {\n return registerHistory(editor, createInitialHistoryState(), delay);\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { registerPlainText } from \"@lexical/plain-text\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const PlainTextPlan = definePlan({\n config: {},\n conflictsWith: [\"@lexical/rich-text\"],\n name: \"@lexical/plain-text\",\n register: registerPlainText,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { HeadingNode, QuoteNode, registerRichText } from \"@lexical/rich-text\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const RichTextPlan = definePlan({\n config: {},\n conflictsWith: [\"@lexical/plain-text\"],\n name: \"@lexical/rich-text\",\n nodes: [HeadingNode, QuoteNode],\n register: registerRichText,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n/**\n * An open interface for Name -> Config mappings. If you are defining a\n * plan with non-empty config and it may be used as a peerDependency then\n * you should extend this as follows:\n *\n * @example Extending LexicalPlanRegistry\n * ```ts\n * const NAME = \"@some/plan\";\n * export const SomePlan = definePlan({ name: NAME, config: { className: \"default\" } });\n * declare module '@etrepum/lexical-builder' {\n * interface LexicalPlanRegistry {\n * [NAME]: typeof SomePlan;\n * }\n * }\n * ```\n */\nexport interface LexicalPlanRegistry {}\nexport const PACKAGE_VERSION = import.meta.env.PACKAGE_VERSION;\n\nexport { configPlan, definePlan, defineRootPlan } from \"./definePlan\";\nexport { LexicalBuilder, buildEditorFromPlans } from \"./LexicalBuilder\";\nexport {\n type AnyLexicalPlan,\n type AnyLexicalPlanArgument,\n type EditorHandle,\n type InitialEditorStateType,\n type LexicalPeerConfig,\n type LexicalPlan,\n type LexicalPlanArgument,\n type LexicalPlanConfig,\n type LexicalPlanName,\n type NormalizedLexicalPlanArgument,\n type PlanConfigBase,\n type RegisterState,\n} from \"./types\";\nexport { safeCast } from \"./safeCast\";\nexport { shallowMergeConfig } from \"./shallowMergeConfig\";\n// These plan definitions should all be colocated with their implementations, only here for convenience\nexport { type AutoFocusConfig, AutoFocusPlan } from \"./AutoFocusPlan\";\nexport { DragonPlan } from \"./DragonPlan\";\nexport { type HistoryConfig, HistoryPlan } from \"./HistoryPlan\";\nexport { PlainTextPlan } from \"./PlainTextPlan\";\nexport { RichTextPlan } from \"./RichTextPlan\";\n"],"names":["NAME"],"mappings":";;;;;;;;;;;;AAeO,SAAS,WACd,MAC2B;AACpB,SAAA;AACT;AAEO,SAAS,eACd,MACuC;AACvC,SAA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;AAAA,EACpC,MAAMA;AAAAA,EACN,SAAS,QAAQ,EAAE,oBAAoB;AAC9B,WAAA,OAAO,qBAAqB,CAAC,gBAAgB;AAC3C,aAAA;AAAA,QACL,MAAM;AAKJ,gBAAM,gBAAgB,SAAS;AAE7B,cAAA,gBAAgB,SACf,kBAAkB,QAAQ,CAAC,YAAY,SAAS,aAAa,IAC9D;AAEA,wBAAY,MAAM,EAAE,eAAe,KAAM,CAAA;AAAA,UAC3C;AAAA,QACF;AAAA,QACA,EAAE,iBAAiB;AAAA,MAAA;AAAA,IACrB,CACD;AAAA,EACH;AACF,CAAC;AClCM,MAAM,aAAa,WAAW;AAAA,EACnC,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACAD,MAAM,OAAO;AAYN,MAAM,cAAc,WAAW;AAAA,EACpC,QAAQ,SAAwB;AAAA,IAC9B,2BAA2B;AAAA,IAC3B,OAAO;AAAA,EAAA,CACR;AAAA,EACD,MAAM;AAAA,EACN,SAAS,QAAQ,EAAE,OAAO,6BAA6B;AACrD,WAAO,gBAAgB,QAAQ,0BAA0B,GAAG,KAAK;AAAA,EACnE;AACF,CAAC;AC1BM,MAAM,gBAAgB,WAAW;AAAA,EACtC,QAAQ,CAAC;AAAA,EACT,eAAe,CAAC,oBAAoB;AAAA,EACpC,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACJM,MAAM,eAAe,WAAW;AAAA,EACrC,QAAQ,CAAC;AAAA,EACT,eAAe,CAAC,qBAAqB;AAAA,EACrC,MAAM;AAAA,EACN,OAAO,CAAC,aAAa,SAAS;AAAA,EAC9B,UAAU;AACZ,CAAC;ACOY,MAAA,kBAAkB;"}
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/definePlan.ts","../src/shared/invariant.ts","../src/deepThemeMergeInPlace.ts","../src/initializeEditor.ts","../src/shallowMergeConfig.ts","../src/PlanRep.ts","../src/LexicalBuilder.ts","../src/safeCast.ts","../src/AutoFocusPlan.ts","../src/DragonPlan.ts","../src/HistoryPlan.ts","../src/PlainTextPlan.ts","../src/RichTextPlan.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {\n AnyLexicalPlan,\n LexicalPlan,\n LexicalPlanConfig,\n PlanConfigBase,\n} from \"./types\";\n\nexport function definePlan<Config extends PlanConfigBase, Name extends string>(\n plan: LexicalPlan<Config, Name>,\n): LexicalPlan<Config, Name> {\n return plan;\n}\n\nexport function defineRootPlan(\n plan: Omit<LexicalPlan<PlanConfigBase, string>, \"config\" | \"name\">,\n): LexicalPlan<PlanConfigBase, \"[root]\"> {\n return { ...plan, name: \"[root]\", config: {} };\n}\n\nexport function configPlan<Plan extends AnyLexicalPlan>(\n plan: Plan,\n config: Partial<LexicalPlanConfig<Plan>>,\n): [Plan, Partial<LexicalPlanConfig<Plan>>] {\n return [plan, config];\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n// invariant(condition, message) will refine types based on \"condition\", and\n// if \"condition\" is false will throw an error. This function is special-cased\n// in flow itself, so we can't name it anything else.\nexport default function invariant(\n cond?: boolean,\n message?: string,\n ...args: string[]\n): asserts cond {\n if (cond) {\n return;\n }\n\n throw new Error(\n args.reduce((msg, arg) => msg.replace(\"%s\", String(arg)), message || \"\"),\n );\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport function deepThemeMergeInPlace(a: unknown, b: unknown) {\n if (\n a &&\n b &&\n !Array.isArray(b) &&\n typeof a === \"object\" &&\n typeof b === \"object\"\n ) {\n const aObj = a as Record<string, unknown>;\n const bObj = b as Record<string, unknown>;\n for (const k in bObj) {\n aObj[k] = deepThemeMergeInPlace(aObj[k], bObj[k]);\n }\n return a;\n }\n return b;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { InitialEditorStateType } from \"./types\";\n\nimport { $createParagraphNode, $getRoot, type LexicalEditor } from \"lexical\";\n\nconst HISTORY_MERGE_OPTIONS = { tag: \"history-merge\" };\n\nfunction $defaultInitializer() {\n const root = $getRoot();\n if (root.isEmpty()) {\n root.append($createParagraphNode());\n }\n}\n\nexport function initializeEditor(\n editor: LexicalEditor,\n $initialEditorState: InitialEditorStateType = $defaultInitializer,\n): void {\n switch (typeof $initialEditorState) {\n case \"function\": {\n editor.update(() => $initialEditorState(editor), HISTORY_MERGE_OPTIONS);\n break;\n }\n case \"string\": {\n const parsedEditorState = editor.parseEditorState($initialEditorState);\n editor.setEditorState(parsedEditorState, HISTORY_MERGE_OPTIONS);\n break;\n }\n case \"object\": {\n if ($initialEditorState) {\n editor.setEditorState($initialEditorState, HISTORY_MERGE_OPTIONS);\n }\n break;\n }\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type { PlanConfigBase } from \"./types\";\n\nexport function shallowMergeConfig<T extends PlanConfigBase>(\n a: T,\n b?: Partial<T>,\n): T {\n if (!b || a === b) {\n return a;\n }\n for (const k in b) {\n if (b[k] !== a[k]) {\n return { ...a, ...b };\n }\n }\n return a;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { LexicalBuilder } from \"./LexicalBuilder\";\nimport type { AnyLexicalPlan, LexicalPlanConfig } from \"./types\";\nimport type { LexicalPlanRegistry } from \"./types\";\n\nimport invariant from \"./shared/invariant\";\n\nimport { shallowMergeConfig } from \"./shallowMergeConfig\";\n\nexport class PlanRep<Plan extends AnyLexicalPlan> {\n builder: LexicalBuilder;\n configs: Set<LexicalPlanConfig<Plan>>;\n _config?: LexicalPlanConfig<Plan>;\n plan: Plan;\n constructor(builder: LexicalBuilder, plan: Plan) {\n this.builder = builder;\n this.plan = plan;\n this.configs = new Set();\n }\n getPeerConfig<Name extends keyof LexicalPlanRegistry>(\n name: string,\n ): undefined | LexicalPlanConfig<LexicalPlanRegistry[Name]> {\n const rep = this.builder.planNameMap.get(name);\n return rep && rep.getConfig();\n }\n getDependencyConfig<Dependency extends AnyLexicalPlan>(\n dep: Dependency,\n ): LexicalPlanConfig<Dependency> {\n const pair = this.builder.planMap.get(dep);\n invariant(\n pair !== undefined,\n \"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry\",\n this.plan.name,\n dep.name,\n );\n return pair[1].getConfig();\n }\n getConfig(): LexicalPlanConfig<Plan> {\n if (this._config) {\n return this._config;\n }\n let config = this.plan.config;\n const mergeConfig = this.plan.mergeConfig\n ? this.plan.mergeConfig.bind(this.plan)\n : shallowMergeConfig;\n for (const cfg of this.configs) {\n config = mergeConfig(config, cfg);\n }\n this._config = config;\n return config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type {\n AnyLexicalPlan,\n AnyLexicalPlanArgument,\n EditorHandle,\n} from \"./types\";\n\nimport {\n LexicalEditor,\n createEditor,\n type CreateEditorArgs,\n type EditorThemeClasses,\n type HTMLConfig,\n type KlassConstructor,\n type LexicalNode,\n} from \"lexical\";\nimport invariant from \"./shared/invariant\";\n\nimport { deepThemeMergeInPlace } from \"./deepThemeMergeInPlace\";\nimport { initializeEditor } from \"./initializeEditor\";\nimport { PlanRep } from \"./PlanRep\";\nimport { mergeRegister } from \"@lexical/utils\";\n\nconst buildersForEditors = new WeakMap<LexicalEditor, LexicalBuilder>();\n\nexport function buildEditorFromPlans(\n plan: AnyLexicalPlanArgument,\n ...plans: AnyLexicalPlanArgument[]\n): EditorHandle {\n const builder = new LexicalBuilder();\n builder.addPlan(plan);\n for (const otherPlan of plans) {\n builder.addPlan(otherPlan);\n }\n return builder.buildEditor();\n}\n\nfunction noop() {}\nclass DisposableEditorHandle implements EditorHandle {\n editor: LexicalEditor;\n dispose: () => void;\n constructor(editor: LexicalEditor, dispose: () => void) {\n this.editor = editor;\n this.dispose = () => {\n try {\n dispose();\n } finally {\n this.dispose = noop;\n }\n };\n }\n // This should be safe even if the runtime doesn't have Symbol.dispose\n // because it will just be `handle[undefined] = dispose;`\n [Symbol.dispose]() {\n this.dispose();\n }\n}\n\nfunction defaultOnError(err: Error) {\n throw err;\n}\n\n/** @internal */\nexport class LexicalBuilder {\n phases: Map<AnyLexicalPlan, PlanRep<AnyLexicalPlan>>[];\n planMap: Map<AnyLexicalPlan, [number, PlanRep<AnyLexicalPlan>]>;\n planNameMap: Map<string, PlanRep<AnyLexicalPlan>>;\n conflicts: Map<string, string>;\n\n constructor() {\n // closure compiler can't handle class initializers\n this.phases = [new Map()];\n this.planMap = new Map();\n this.planNameMap = new Map();\n this.conflicts = new Map();\n }\n\n static fromEditor(editor: LexicalEditor): LexicalBuilder {\n const builder = buildersForEditors.get(editor);\n invariant(\n builder !== undefined,\n \"LexicalBuilder.fromEditor: editor was not created with this version of LexicalBuilder\",\n );\n return builder;\n }\n\n buildEditor(): EditorHandle {\n const { $initialEditorState, onError, ...editorConfig } =\n this.buildCreateEditorArgs();\n const editor = createEditor({\n ...editorConfig,\n ...(onError ? { onError: (err) => onError(err, editor) } : {}),\n });\n initializeEditor(editor, $initialEditorState);\n buildersForEditors.set(editor, this);\n return new DisposableEditorHandle(\n editor,\n mergeRegister(\n () => buildersForEditors.delete(editor),\n () => editor.setRootElement(null),\n this.registerEditor(editor),\n ),\n );\n }\n\n addPlan(arg: AnyLexicalPlanArgument): number {\n let plan: AnyLexicalPlan;\n let configs: unknown[];\n if (Array.isArray(arg)) {\n [plan, ...configs] = arg;\n } else {\n plan = arg;\n configs = [];\n }\n let [phase, planRep] = this.planMap.get(plan) || [0, undefined];\n if (!planRep) {\n const hasConflict = this.conflicts.get(plan.name);\n if (typeof hasConflict === \"string\") {\n invariant(\n false,\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n hasConflict,\n );\n }\n for (const name of plan.conflictsWith || []) {\n invariant(\n !this.planNameMap.has(name),\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n name,\n );\n this.conflicts.set(name, plan.name);\n }\n // TODO detect circular dependencies\n for (const dep of plan.dependencies || []) {\n phase = Math.max(phase, 1 + this.addPlan(dep));\n }\n for (const [depName, cfg] of Object.entries(\n plan.peerDependencies || {},\n )) {\n const dep = this.planNameMap.get(depName);\n if (dep) {\n phase = Math.max(phase, 1 + this.addPlan([dep.plan, cfg]));\n }\n }\n invariant(\n this.phases.length >= phase,\n \"LexicalBuilder: Expected phase to be no greater than phases.length\",\n );\n if (this.phases.length === phase) {\n this.phases.push(new Map());\n }\n planRep = new PlanRep(this, plan);\n invariant(\n !this.planNameMap.has(plan.name),\n \"LexicalBuilder: Multiple plans registered with name %s, names must be unique\",\n plan.name,\n );\n this.planMap.set(plan, [phase, planRep]);\n this.planNameMap.set(plan.name, planRep);\n const currentPhaseMap = this.phases[phase];\n invariant(\n currentPhaseMap !== undefined,\n \"LexicalBuilder: Expecting phase map for phase %s\",\n String(phase),\n );\n currentPhaseMap.set(plan, planRep);\n }\n for (const config of configs) {\n planRep.configs.add(config);\n }\n return phase;\n }\n\n *sortedPlanReps() {\n for (const phase of this.phases) {\n yield* phase.values();\n }\n }\n\n registerEditor(editor: LexicalEditor): () => void {\n const cleanups: (() => void)[] = [];\n const controller = new AbortController();\n for (const planRep of this.sortedPlanReps()) {\n if (planRep.plan.register) {\n cleanups.push(\n planRep.plan.register(editor, planRep.getConfig(), {\n getDependencyConfig: planRep.getDependencyConfig.bind(planRep),\n getPeerConfig: planRep.getPeerConfig.bind(planRep),\n signal: controller.signal,\n }),\n );\n }\n }\n return () => {\n for (let i = cleanups.length - 1; i >= 0; i--) {\n const cleanupFun = cleanups[i];\n invariant(\n cleanupFun !== undefined,\n \"LexicalBuilder: Expecting cleanups[%s] to be defined\",\n String(i),\n );\n cleanupFun();\n }\n cleanups.length = 0;\n controller.abort();\n };\n }\n\n buildCreateEditorArgs() {\n const config: Pick<\n CreateEditorArgs,\n \"nodes\" | \"html\" | \"theme\" | \"disableEvents\" | \"editable\" | \"namespace\"\n > &\n Pick<AnyLexicalPlan, \"$initialEditorState\" | \"onError\"> = {\n // Prefer throwing errors rather than console.error by default\n onError: defaultOnError\n };\n const nodes = new Set<NonNullable<CreateEditorArgs[\"nodes\"]>[number]>();\n const replacedNodes = new Map<\n KlassConstructor<typeof LexicalNode>,\n PlanRep<AnyLexicalPlan>\n >();\n const htmlExport: NonNullable<HTMLConfig[\"export\"]> = new Map();\n const htmlImport: NonNullable<HTMLConfig[\"import\"]> = {};\n const theme: EditorThemeClasses = {};\n for (const planRep of this.sortedPlanReps()) {\n const { plan } = planRep;\n if (plan.onError !== undefined) {\n config.onError = plan.onError;\n }\n if (plan.disableEvents !== undefined) {\n config.disableEvents = plan.disableEvents;\n }\n if (plan.editable !== undefined) {\n config.editable = plan.editable;\n }\n if (plan.namespace !== undefined) {\n config.namespace = plan.namespace;\n }\n if (plan.$initialEditorState !== undefined) {\n config.$initialEditorState = plan.$initialEditorState;\n }\n if (plan.nodes) {\n for (const node of plan.nodes) {\n if (typeof node !== \"function\") {\n const conflictPlan = replacedNodes.get(node.replace);\n if (conflictPlan) {\n invariant(\n false,\n \"LexicalBuilder: Plan %s can not register replacement for node %s because %s already did\",\n plan.name,\n node.replace.name,\n conflictPlan.plan.name,\n );\n }\n replacedNodes.set(node.replace, planRep);\n }\n nodes.add(node);\n }\n }\n if (plan.html) {\n if (plan.html.export) {\n for (const [k, v] of plan.html.export.entries()) {\n htmlExport.set(k, v);\n }\n }\n if (plan.html.import) {\n Object.assign(htmlImport, plan.html.import);\n }\n }\n if (plan.theme) {\n deepThemeMergeInPlace(theme, plan.theme);\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n if (Object.keys(theme).length > 0) {\n config.theme = theme;\n }\n if (nodes.size) {\n config.nodes = [...nodes];\n }\n const hasImport = Object.keys(htmlImport).length > 0;\n const hasExport = htmlExport.size > 0;\n if (hasImport || hasExport) {\n config.html = {};\n if (hasImport) {\n config.html.import = htmlImport;\n }\n if (hasExport) {\n config.html.export = htmlExport;\n }\n }\n return config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n/**\n * Explicitly and safely cast a value to a specific type when inference or\n * satisfies isn't going to work as expected (often useful for the config\n * property with definePlan)\n */\nexport function safeCast<T>(value: T): T {\n return value;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { definePlan } from \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nimport type {} from \"@etrepum/lexical-builder\";\ndeclare module \"@etrepum/lexical-builder\" {\n interface LexicalPlanRegistry {\n [AutoFocusPlan.name]: typeof AutoFocusPlan;\n }\n}\n\nexport interface AutoFocusConfig {\n defaultSelection?: \"rootStart\" | \"rootEnd\";\n}\n\nexport const AutoFocusPlan = definePlan({\n config: safeCast<AutoFocusConfig>({}),\n name: \"@etrepum/lexical-builder/AutoFocusPlan\",\n register(editor, { defaultSelection }) {\n return editor.registerRootListener((rootElement) => {\n editor.focus(\n () => {\n // If we try and move selection to the same point with setBaseAndExtent, it won't\n // trigger a re-focus on the element. So in the case this occurs, we'll need to correct it.\n // Normally this is fine, Selection API !== Focus API, but fore the intents of the naming\n // of this plugin, which should preserve focus too.\n const activeElement = document.activeElement;\n if (\n rootElement !== null &&\n (activeElement === null || !rootElement.contains(activeElement))\n ) {\n // Note: preventScroll won't work in Webkit.\n rootElement.focus({ preventScroll: true });\n }\n },\n { defaultSelection }\n );\n });\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { registerDragonSupport } from \"@lexical/dragon\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const DragonPlan = definePlan({\n config: {},\n name: \"@lexical/dragon\",\n register: registerDragonSupport,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport {\n createEmptyHistoryState,\n type HistoryState,\n registerHistory,\n} from \"@lexical/history\";\n\nimport { definePlan } from \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nimport type {} from \"@etrepum/lexical-builder\";\ndeclare module \"@etrepum/lexical-builder\" {\n interface LexicalPlanRegistry {\n [HistoryPlan.name]: typeof HistoryPlan;\n }\n}\n\nexport interface HistoryConfig {\n delay: number;\n createInitialHistoryState: () => HistoryState;\n}\n\nexport const HistoryPlan = definePlan({\n config: safeCast<HistoryConfig>({\n createInitialHistoryState: createEmptyHistoryState,\n delay: 300,\n }),\n name: \"@etrepum/lexical-builder/HistoryPlan\",\n register(editor, { delay, createInitialHistoryState }) {\n return registerHistory(editor, createInitialHistoryState(), delay);\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { registerPlainText } from \"@lexical/plain-text\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const PlainTextPlan = definePlan({\n config: {},\n conflictsWith: [\"@lexical/rich-text\"],\n name: \"@lexical/plain-text\",\n register: registerPlainText,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { HeadingNode, QuoteNode, registerRichText } from \"@lexical/rich-text\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const RichTextPlan = definePlan({\n config: {},\n conflictsWith: [\"@lexical/plain-text\"],\n name: \"@lexical/rich-text\",\n nodes: [HeadingNode, QuoteNode],\n register: registerRichText,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport const PACKAGE_VERSION = import.meta.env.PACKAGE_VERSION;\n\nexport { configPlan, definePlan, defineRootPlan } from \"./definePlan\";\nexport { LexicalBuilder, buildEditorFromPlans } from \"./LexicalBuilder\";\nexport {\n type AnyLexicalPlan,\n type AnyLexicalPlanArgument,\n type EditorHandle,\n type InitialEditorStateType,\n type LexicalPeerConfig,\n type LexicalPlan,\n type LexicalPlanArgument,\n type LexicalPlanConfig,\n type LexicalPlanName,\n type NormalizedLexicalPlanArgument,\n type PlanConfigBase,\n type RegisterState,\n} from \"./types\";\nexport { safeCast } from \"./safeCast\";\nexport { shallowMergeConfig } from \"./shallowMergeConfig\";\n// These plan definitions should all be colocated with their implementations, only here for convenience\nexport { type AutoFocusConfig, AutoFocusPlan } from \"./AutoFocusPlan\";\nexport { DragonPlan } from \"./DragonPlan\";\nexport { type HistoryConfig, HistoryPlan } from \"./HistoryPlan\";\nexport { PlainTextPlan } from \"./PlainTextPlan\";\nexport { RichTextPlan } from \"./RichTextPlan\";\n"],"names":[],"mappings":";;;;;;;;;;;;AAeO,SAAS,WACd,MAC2B;AACpB,SAAA;AACT;AAEO,SAAS,eACd,MACuC;AACvC,SAAO,EAAE,GAAG,MAAM,MAAM,UAAU,QAAQ,CAAA;AAC5C;AAEgB,SAAA,WACd,MACA,QAC0C;AACnC,SAAA,CAAC,MAAM,MAAM;AACtB;ACrBwB,SAAA,UACtB,MACA,YACG,MACW;AACd,MAAI,MAAM;AACR;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR,K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N,SAAS,QAAQ,EAAE,oBAAoB;AAC9B,WAAA,OAAO,qBAAqB,CAAC,gBAAgB;AAC3C,aAAA;AAAA,QACL,MAAM;AAKJ,gBAAM,gBAAgB,SAAS;AAE7B,cAAA,gBAAgB,SACf,kBAAkB,QAAQ,CAAC,YAAY,SAAS,aAAa,IAC9D;AAEA,wBAAY,MAAM,EAAE,eAAe,KAAM,CAAA;AAAA,UAC3C;AAAA,QACF;AAAA,QACA,EAAE,iBAAiB;AAAA,MAAA;AAAA,IACrB,CACD;AAAA,EACH;AACF,CAAC;AClCM,MAAM,aAAa,WAAW;AAAA,EACnC,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACYM,MAAM,cAAc,WAAW;AAAA,EACpC,QAAQ,SAAwB;AAAA,IAC9B,2BAA2B;AAAA,IAC3B,OAAO;AAAA,EAAA,CACR;AAAA,EACD,MAAM;AAAA,EACN,SAAS,QAAQ,EAAE,OAAO,6BAA6B;AACrD,WAAO,gBAAgB,QAAQ,0BAA0B,GAAG,KAAK;AAAA,EACnE;AACF,CAAC;AC1BM,MAAM,gBAAgB,WAAW;AAAA,EACtC,QAAQ,CAAC;AAAA,EACT,eAAe,CAAC,oBAAoB;AAAA,EACpC,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACJM,MAAM,eAAe,WAAW;AAAA,EACrC,QAAQ,CAAC;AAAA,EACT,eAAe,CAAC,qBAAqB;AAAA,EACrC,MAAM;AAAA,EACN,OAAO,CAAC,aAAa,SAAS;AAAA,EAC9B,UAAU;AACZ,CAAC;ACVY,MAAA,kBAAkB;"}
|
package/dist/types.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { CreateEditorArgs, EditorState, LexicalEditor } from 'lexical';
|
2
|
-
import { LexicalPlanRegistry } from './';
|
3
2
|
|
4
3
|
export type AnyLexicalPlan = LexicalPlan<any, string>;
|
5
4
|
export type AnyLexicalPlanArgument = LexicalPlanArgument<any, string>;
|
@@ -108,4 +107,21 @@ export interface EditorHandle extends Disposable {
|
|
108
107
|
dispose: () => void;
|
109
108
|
}
|
110
109
|
export type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
|
110
|
+
/**
|
111
|
+
* An open interface for Name -> Config mappings. If you are defining a
|
112
|
+
* plan with non-empty config and it may be used as a peerDependency then
|
113
|
+
* you should extend this as follows:
|
114
|
+
*
|
115
|
+
* @example Extending LexicalPlanRegistry
|
116
|
+
* ```ts
|
117
|
+
* export const SomePlan = definePlan({ name: "@some/plan", config: { className: "default" } });
|
118
|
+
* declare module '@etrepum/lexical-builder' {
|
119
|
+
* interface LexicalPlanRegistry {
|
120
|
+
* [SomePlan.name]: typeof SomePlan;
|
121
|
+
* }
|
122
|
+
* }
|
123
|
+
* ```
|
124
|
+
*/
|
125
|
+
export interface LexicalPlanRegistry {
|
126
|
+
}
|
111
127
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG5E,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAEtD,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACtE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAElD,MAAM,MAAM,6BAA6B,CACvC,MAAM,SAAS,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,MAAM,GACN,WAAW,GACX,CAAC,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC;AAEtC;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,mBAAmB;CAAG"}
|
package/package.json
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
"test": "vitest run",
|
18
18
|
"test:watch": "vitest"
|
19
19
|
},
|
20
|
-
"version": "0.0.
|
20
|
+
"version": "0.0.9",
|
21
21
|
"license": "MIT",
|
22
22
|
"repository": {
|
23
23
|
"type": "git",
|
@@ -39,6 +39,11 @@
|
|
39
39
|
},
|
40
40
|
"sideEffects": false,
|
41
41
|
"devDependencies": {
|
42
|
+
"@testing-library/dom": "^10.1.0",
|
43
|
+
"@testing-library/jest-dom": "^6.4.5",
|
44
|
+
"@testing-library/react": "^16.0.0",
|
45
|
+
"@testing-library/user-event": "^14.5.2",
|
46
|
+
"jsdom": "^24.1.0",
|
42
47
|
"tslib": "^2.6.2",
|
43
48
|
"typescript": "^5.4.5",
|
44
49
|
"vite": "^5.2.11",
|