@etrepum/lexical-builder 0.0.4 → 0.0.6-nightly.20240603.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/dist/AutoFocusPlan.d.ts +12 -0
  2. package/dist/AutoFocusPlan.d.ts.map +1 -0
  3. package/dist/DragonPlan.d.ts +9 -0
  4. package/dist/DragonPlan.d.ts.map +1 -0
  5. package/dist/HistoryPlan.d.ts +8 -0
  6. package/dist/HistoryPlan.d.ts.map +1 -0
  7. package/dist/LexicalBuilder.d.ts +20 -0
  8. package/dist/LexicalBuilder.d.ts.map +1 -0
  9. package/dist/PlainTextPlan.d.ts +2 -0
  10. package/dist/PlainTextPlan.d.ts.map +1 -0
  11. package/dist/PlanRep.d.ts +15 -0
  12. package/dist/PlanRep.d.ts.map +1 -0
  13. package/dist/ReactPlan.d.ts +40 -0
  14. package/dist/ReactPlan.d.ts.map +1 -0
  15. package/dist/ReactPluginHostPlan.d.ts +23 -0
  16. package/dist/ReactPluginHostPlan.d.ts.map +1 -0
  17. package/dist/RichTextPlan.d.ts +9 -0
  18. package/dist/RichTextPlan.d.ts.map +1 -0
  19. package/dist/__tests__/unit/LexicalBuilder.test.d.ts +9 -0
  20. package/dist/__tests__/unit/LexicalBuilder.test.d.ts.map +1 -0
  21. package/dist/deepThemeMergeInPlace.d.ts +9 -0
  22. package/dist/deepThemeMergeInPlace.d.ts.map +1 -0
  23. package/dist/definePlan.d.ts +6 -0
  24. package/dist/definePlan.d.ts.map +1 -0
  25. package/dist/index.d.ts +24 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +696 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/initializeEditor.d.ts +5 -0
  30. package/dist/initializeEditor.d.ts.map +1 -0
  31. package/dist/registerShowPlaceholder.d.ts +6 -0
  32. package/dist/registerShowPlaceholder.d.ts.map +1 -0
  33. package/dist/registerSubscription.d.ts +11 -0
  34. package/dist/registerSubscription.d.ts.map +1 -0
  35. package/dist/safeCast.d.ts +9 -0
  36. package/dist/safeCast.d.ts.map +1 -0
  37. package/dist/shallowMergeConfig.d.ts +4 -0
  38. package/dist/shallowMergeConfig.d.ts.map +1 -0
  39. package/dist/shared/invariant.d.ts +9 -0
  40. package/dist/shared/invariant.d.ts.map +1 -0
  41. package/dist/shared/useLayoutEffect.d.ts +5 -0
  42. package/dist/shared/useLayoutEffect.d.ts.map +1 -0
  43. package/dist/types.d.ts +111 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/useReactDecorators.d.ts +10 -0
  46. package/dist/useReactDecorators.d.ts.map +1 -0
  47. package/dist/useRegisterSubscription.d.ts +4 -0
  48. package/dist/useRegisterSubscription.d.ts.map +1 -0
  49. package/package.json +7 -10
  50. package/dist/index.d.mts +0 -248
  51. package/dist/index.d.mts.map +0 -1
  52. package/dist/index.mjs +0 -31656
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/definePlan.ts","../src/safeCast.ts","../src/AutoFocusPlan.ts","../src/DragonPlan.ts","../src/HistoryPlan.ts","../src/shared/invariant.ts","../src/deepThemeMergeInPlace.ts","../src/initializeEditor.ts","../src/shallowMergeConfig.ts","../src/PlanRep.ts","../src/LexicalBuilder.ts","../src/PlainTextPlan.ts","../src/registerShowPlaceholder.ts","../src/shared/useLayoutEffect.ts","../src/useReactDecorators.tsx","../src/useRegisterSubscription.ts","../src/ReactPlan.tsx","../src/ReactPluginHostPlan.tsx","../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// TypeScript 4.9's satisfies operator is not supported by our version of prettier\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\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\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 */\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 {\n AnyLexicalPlan,\n LexicalPlanConfig,\n} from \"./types\";\nimport type { LexicalPlanRegistry } from \"@etrepum/lexical-builder\";\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\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 const dispose = mergeRegister(\n () => buildersForEditors.delete(editor),\n this.registerEditor(editor),\n );\n return { dispose, editor };\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 */\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 type { LexicalEditor } from \"lexical\";\n\nimport { $canShowPlaceholderCurry } from \"@lexical/text\";\nimport { mergeRegister } from \"@lexical/utils\";\n\nimport {\n RegisterLexicalSubscription,\n registerLexicalSubscription,\n} from \"./registerSubscription\";\n\nfunction canShowPlaceholderFromCurrentEditorState(\n editor: LexicalEditor,\n): boolean {\n const currentCanShowPlaceholder = editor\n .getEditorState()\n .read($canShowPlaceholderCurry(editor.isComposing()));\n\n return currentCanShowPlaceholder;\n}\n\nfunction subscribe(\n editor: LexicalEditor,\n onChange: (canShow: boolean) => void,\n) {\n const resetCanShowPlaceholder = () =>\n onChange(canShowPlaceholderFromCurrentEditorState(editor));\n return mergeRegister(\n editor.registerUpdateListener(resetCanShowPlaceholder),\n editor.registerEditableListener(resetCanShowPlaceholder),\n );\n}\n\nexport const canShowPlaceholder: RegisterLexicalSubscription<boolean> = {\n initialValueFn: canShowPlaceholderFromCurrentEditorState,\n subscribe,\n};\n\nexport function registerCanShowPlaceholder(\n editor: LexicalEditor,\n onChange: (canShow: boolean) => void,\n): () => void {\n return registerLexicalSubscription(editor, canShowPlaceholder, onChange);\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 { useEffect, useLayoutEffect } from \"react\";\nimport { CAN_USE_DOM } from \"@lexical/utils\";\n\nconst useLayoutEffectImpl: typeof useLayoutEffect = CAN_USE_DOM\n ? useLayoutEffect\n : useEffect;\n\nexport default useLayoutEffectImpl;\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 { LexicalEditor, NodeKey } from \"lexical\";\n\nimport { Suspense, useEffect, useMemo, useState } from \"react\";\nimport * as React from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport useLayoutEffect from \"./shared/useLayoutEffect\";\nimport invariant from \"./shared/invariant\";\n\nexport type ErrorBoundaryProps = {\n children: JSX.Element;\n onError: (error: Error) => void;\n};\n\nexport type ErrorBoundaryType =\n | React.ComponentClass<ErrorBoundaryProps>\n | React.FC<ErrorBoundaryProps>;\n\nexport function useReactDecorators(\n editor: LexicalEditor,\n ErrorBoundary: ErrorBoundaryType,\n): Array<JSX.Element> {\n const [decorators, setDecorators] = useState<Record<NodeKey, JSX.Element>>(\n () => editor.getDecorators<JSX.Element>(),\n );\n\n // Subscribe to changes\n useLayoutEffect(() => {\n return editor.registerDecoratorListener<JSX.Element>((nextDecorators) => {\n flushSync(() => {\n setDecorators(nextDecorators);\n });\n });\n }, [editor]);\n\n useEffect(() => {\n // If the content editable mounts before the subscription is added, then\n // nothing will be rendered on initial pass. We can get around that by\n // ensuring that we set the value.\n setDecorators(editor.getDecorators());\n }, [editor]);\n\n // Return decorators defined as React Portals\n return useMemo(() => {\n const decoratedPortals = [];\n const decoratorKeys = Object.keys(decorators);\n\n for (let i = 0; i < decoratorKeys.length; i++) {\n const nodeKey = decoratorKeys[i];\n invariant(\n nodeKey !== undefined,\n \"useReactDecorators: decoratorKeys[%s] must be defined\",\n String(i),\n );\n const element = editor.getElementByKey(nodeKey);\n\n if (element !== null) {\n const reactDecorator = (\n <ErrorBoundary onError={(e) => editor._onError(e)}>\n <Suspense fallback={null}>{decorators[nodeKey]}</Suspense>\n </ErrorBoundary>\n );\n decoratedPortals.push(createPortal(reactDecorator, element, nodeKey));\n }\n }\n\n return decoratedPortals;\n }, [ErrorBoundary, decorators, editor]);\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 { RegisterLexicalSubscription } from \"./registerSubscription\";\n\nimport useLexicalSubscription from \"@lexical/react/useLexicalSubscription\";\nimport { LexicalEditor } from \"lexical\";\nimport { useCallback } from \"react\";\n\nexport function useRegisterSubscription<T>(\n subscription: RegisterLexicalSubscription<T>,\n): T {\n const sub = useCallback(\n (editor: LexicalEditor) => {\n return {\n initialValueFn: subscription.initialValueFn.bind(subscription, editor),\n subscribe: subscription.subscribe.bind(subscription, editor),\n };\n },\n [subscription],\n );\n return useLexicalSubscription(sub);\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 { AnyLexicalPlanArgument } from \"./types\";\n\nimport {\n LexicalComposerContext,\n type LexicalComposerContextWithEditor,\n} from \"@lexical/react/LexicalComposerContext\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport useLexicalEditable from \"@lexical/react/useLexicalEditable\";\nimport * as React from \"react\";\nimport { Suspense, useEffect, useMemo, useRef } from \"react\";\n\nimport { definePlan } from \"./definePlan\";\nimport { LexicalBuilder, buildEditorFromPlans } from \"./LexicalBuilder\";\nimport { canShowPlaceholder } from \"./registerShowPlaceholder\";\nimport { shallowMergeConfig } from \"./shallowMergeConfig\";\nimport {\n type ErrorBoundaryType,\n useReactDecorators,\n} from \"./useReactDecorators\";\nimport { useRegisterSubscription } from \"./useRegisterSubscription\";\nimport invariant from \"./shared/invariant\";\n\nexport interface EditorChildrenComponentProps {\n context: LexicalComposerContextWithEditor;\n placeholder: null | JSX.Element;\n contentEditable: null | JSX.Element;\n children?: React.ReactNode;\n}\n\nexport type EditorChildrenComponentType = (\n props: EditorChildrenComponentProps,\n) => JSX.Element | null;\n\nexport interface DecoratorComponentProps {\n context: LexicalComposerContextWithEditor;\n}\nexport type DecoratorComponentType =\n | JSX.Element\n | ((props: DecoratorComponentProps) => JSX.Element | null);\n\nexport interface EditorComponentProps {\n EditorChildrenComponent: EditorChildrenComponentType;\n children?: React.ReactNode;\n placeholder:\n | ((isEditable: boolean) => null | JSX.Element)\n | null\n | JSX.Element;\n contentEditable: JSX.Element | null;\n ErrorBoundary: ErrorBoundaryType;\n}\n\nexport type EditorComponentType = (\n props: Partial<EditorComponentProps>,\n) => JSX.Element;\n\nexport interface ReactConfig {\n contentEditable: JSX.Element | null;\n placeholder:\n | ((isEditable: boolean) => null | JSX.Element)\n | null\n | JSX.Element;\n ErrorBoundary: ErrorBoundaryType;\n EditorChildrenComponent: EditorChildrenComponentType;\n Component: EditorComponentType;\n getContext: () => LexicalComposerContextWithEditor;\n decorators: readonly DecoratorComponentType[];\n}\n\nexport interface LexicalPlanComposerProps {\n plan: AnyLexicalPlanArgument;\n children: React.ReactNode;\n}\n\nconst scheduleMicrotask =\n \"queueMicrotask\" in globalThis\n ? queueMicrotask\n : (fn: () => void) => Promise.resolve().then(fn);\n\nexport function LexicalPlanComposer({\n plan,\n children,\n}: LexicalPlanComposerProps) {\n const componentRef = useRef<EditorComponentType | undefined>(undefined);\n const handle = useMemo(() => {\n return buildEditorFromPlans(\n definePlan({\n name: \"@lexical/builder/LexicalPlanComposer\",\n config: {},\n dependencies: [ReactPlan],\n register(_editor, _config, state) {\n componentRef.current = state.getDependencyConfig(ReactPlan).Component;\n return () => {\n componentRef.current = undefined;\n };\n },\n }),\n plan,\n );\n }, [plan]);\n useEffect(() => {\n // This is an awful trick to detect StrictMode\n let didMount = false;\n scheduleMicrotask(() => {\n didMount = true;\n });\n return () => {\n if (didMount) {\n handle.dispose();\n }\n };\n }, [handle]);\n const EditorComponent = componentRef.current;\n return EditorComponent ? <EditorComponent>{children}</EditorComponent> : null;\n}\n\nfunction DefaultEditorChildrenComponent({\n contentEditable,\n placeholder,\n children,\n}: EditorChildrenComponentProps) {\n return (\n <>\n {contentEditable}\n {placeholder && <Placeholder content={placeholder} />}\n {children}\n </>\n );\n}\n\nfunction buildEditorComponent(config: ReactConfig) {\n const context = config.getContext();\n const [editor] = context;\n const rawConfigDecorators = config.decorators.map((El) =>\n typeof El === \"function\" ? <El context={context} /> : El,\n );\n return function EditorComponent(props: Partial<EditorComponentProps>) {\n const {\n EditorChildrenComponent = config.EditorChildrenComponent,\n ErrorBoundary = config.ErrorBoundary,\n contentEditable = config.contentEditable,\n placeholder = config.placeholder,\n children,\n } = props;\n const decorators = useReactDecorators(editor, ErrorBoundary);\n const configDecorators = useMemo(\n () =>\n rawConfigDecorators.map((decorator, i) => (\n <ErrorBoundary onError={(e) => editor._onError(e)} key={i}>\n <Suspense fallback={null}>{decorator}</Suspense>\n </ErrorBoundary>\n )),\n [ErrorBoundary],\n );\n return (\n <LexicalComposerContext.Provider value={context}>\n <EditorChildrenComponent\n context={context}\n contentEditable={contentEditable}\n placeholder={placeholder && <Placeholder content={placeholder} />}\n >\n {children}\n {configDecorators}\n {decorators}\n </EditorChildrenComponent>\n </LexicalComposerContext.Provider>\n );\n };\n}\n\nfunction WithEditable({\n content,\n}: {\n content: (isEditable: boolean) => null | JSX.Element;\n}) {\n return content(useLexicalEditable());\n}\n\nfunction Placeholder({\n content,\n}: {\n content: ((isEditable: boolean) => null | JSX.Element) | JSX.Element;\n}): null | JSX.Element {\n const showPlaceholder = useRegisterSubscription(canShowPlaceholder);\n if (!showPlaceholder) {\n return null;\n } else if (typeof content === \"function\") {\n return <WithEditable content={content} />;\n } else {\n return content;\n }\n}\n\nconst initialConfig: ReactConfig = {\n EditorChildrenComponent: DefaultEditorChildrenComponent,\n ErrorBoundary: LexicalErrorBoundary,\n contentEditable: <ContentEditable />,\n decorators: [],\n placeholder: null,\n // Initialized on registration\n Component(): JSX.Element {\n invariant(false, \"ReactPlan used before register\");\n },\n // Initialized on registration\n getContext() {\n invariant(false, \"ReactPlan used before register\");\n },\n};\n\nexport const ReactPlan = definePlan({\n config: initialConfig,\n mergeConfig(a, b) {\n const config = shallowMergeConfig(a, b);\n if (b && b.decorators && b.decorators.length > 0) {\n config.decorators = [...a.decorators, ...b.decorators];\n }\n return config;\n },\n name: \"@etrepum/lexical-builder/ReactPlan\",\n register(editor, config) {\n const context: LexicalComposerContextWithEditor = [\n editor,\n { getTheme: () => editor._config.theme },\n ];\n config.getContext = () => context;\n config.Component = buildEditorComponent(config);\n return () => {\n config.getContext = initialConfig.getContext;\n config.Component = initialConfig.Component;\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 { mergeRegister } from \"@lexical/utils\";\nimport {\n COMMAND_PRIORITY_CRITICAL,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n LexicalEditor,\n} from \"lexical\";\nimport { Suspense, useEffect, useState } from \"react\";\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { createRoot, Root } from \"react-dom/client\";\n\nimport { configPlan, definePlan } from \"./definePlan\";\nimport { ReactPlan } from \"./ReactPlan\";\n\nexport interface HostMountCommandArg {\n root: Root;\n}\n\nexport type Container = Element | DocumentFragment;\n\nexport interface MountPluginCommandArg {\n key: string;\n element: JSX.Element | null;\n domNode?: Container | null;\n}\n\nexport function mountReactPluginComponent<\n P extends Record<never, never> = Record<never, never>,\n>(\n editor: LexicalEditor,\n opts: {\n Component: null | React.ComponentType<P>;\n props: (P & React.Attributes) | null;\n } & Omit<MountPluginCommandArg, \"element\">,\n) {\n const { Component, props, ...rest } = opts;\n return mountReactPluginElement(editor, {\n ...rest,\n element: Component && props ? <Component {...props} /> : null,\n });\n}\n\nexport function mountReactPluginElement(\n editor: LexicalEditor,\n opts: MountPluginCommandArg,\n) {\n editor.dispatchCommand(REACT_MOUNT_PLUGIN_COMMAND, opts);\n}\n\nexport function mountReactPluginHost(\n editor: LexicalEditor,\n container: Container,\n) {\n editor.dispatchCommand(REACT_PLUGIN_HOST_MOUNT_COMMAND, {\n root: createRoot(container),\n });\n}\n\nexport const REACT_PLUGIN_HOST_MOUNT_COMMAND =\n createCommand<HostMountCommandArg>(\"REACT_PLUGIN_HOST_MOUNT_COMMAND\");\nexport const REACT_MOUNT_PLUGIN_COMMAND = createCommand<MountPluginCommandArg>(\n \"REACT_MOUNT_PLUGIN_COMMAND\",\n);\n\nexport const ReactPluginHostPlan = definePlan({\n config: {},\n dependencies: [\n configPlan(ReactPlan, {\n contentEditable: null,\n }),\n ],\n name: \"@etrepum/lexical-builder/ReactPluginHostPlan\",\n register(editor, _config, state) {\n let root: Root | undefined;\n const mountedPlugins = new Map<\n MountPluginCommandArg[\"key\"],\n MountPluginCommandArg\n >();\n const { ErrorBoundary, Component } = state.getDependencyConfig(ReactPlan);\n function renderMountedPlugins() {\n const children: JSX.Element[] = [];\n for (const { key, element, domNode } of mountedPlugins.values()) {\n if (!element) {\n continue;\n }\n const wrapped = (\n <ErrorBoundary onError={(e) => editor._onError(e)} key={key}>\n <Suspense fallback={null}>{element}</Suspense>\n </ErrorBoundary>\n );\n children.push(domNode ? createPortal(wrapped, domNode, key) : wrapped);\n }\n return children.length > 0 ? <>{children}</> : null;\n }\n function PluginHost() {\n const [children, setChildren] = useState(renderMountedPlugins);\n useEffect(() => {\n return editor.registerCommand(\n REACT_MOUNT_PLUGIN_COMMAND,\n () => {\n setChildren(renderMountedPlugins);\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\n );\n }, []);\n return children;\n }\n return mergeRegister(\n () => {\n if (root) {\n root.unmount();\n }\n },\n editor.registerCommand(\n REACT_MOUNT_PLUGIN_COMMAND,\n (arg) => {\n mountedPlugins.set(arg.key, arg);\n return false;\n },\n COMMAND_PRIORITY_CRITICAL,\n ),\n editor.registerCommand(\n REACT_PLUGIN_HOST_MOUNT_COMMAND,\n (arg) => {\n root = arg.root;\n root.render(\n <Component>\n <PluginHost />\n </Component>,\n );\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\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 { 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/** An open interface for Name -> Config mappings */\nexport interface LexicalPlanRegistry {}\nexport const PACKAGE_VERSION = import.meta.env.PACKAGE_VERSION;\n\nexport { type AutoFocusConfig, AutoFocusPlan } from \"./AutoFocusPlan\";\nexport { configPlan, definePlan, defineRootPlan } from \"./definePlan\";\nexport { DragonPlan } from \"./DragonPlan\";\nexport { type HistoryConfig, HistoryPlan } from \"./HistoryPlan\";\nexport { LexicalBuilder, buildEditorFromPlans } from \"./LexicalBuilder\";\nexport { PlainTextPlan } from \"./PlainTextPlan\";\nexport {\n type DecoratorComponentProps,\n type DecoratorComponentType,\n type EditorChildrenComponentProps,\n type EditorChildrenComponentType,\n type EditorComponentProps,\n type EditorComponentType,\n LexicalPlanComposer,\n type LexicalPlanComposerProps,\n type ReactConfig,\n ReactPlan,\n} from \"./ReactPlan\";\nexport {\n type HostMountCommandArg,\n type MountPluginCommandArg,\n type Container,\n mountReactPluginComponent,\n mountReactPluginElement,\n mountReactPluginHost,\n REACT_MOUNT_PLUGIN_COMMAND,\n REACT_PLUGIN_HOST_MOUNT_COMMAND,\n ReactPluginHostPlan,\n} from \"./ReactPluginHostPlan\";\nexport { RichTextPlan } from \"./RichTextPlan\";\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 {\n type ErrorBoundaryType,\n type ErrorBoundaryProps,\n} from \"./useReactDecorators\";\nexport { safeCast } from \"./safeCast\";\n"],"names":["useLayoutEffect"],"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;ACvBO,SAAS,SAAY,OAAa;AAChC,SAAA;AACT;ACIO,MAAM,gBAAgB,WAAW;AAAA,EACtC,QAAQ,SAA0B,EAAE;AAAA,EACpC,MAAM;AAAA,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;AC3BM,MAAM,aAAa,WAAW;AAAA,EACnC,QAAQ,CAAC;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACKM,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;ACnBuB,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,GACd;AAAA,UAAA;AAEK,iBAAA;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;ACrIM,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;ACRY,MAAA,kBAAkB;"}
@@ -0,0 +1,5 @@
1
+ import { InitialEditorStateType } from './types';
2
+ import { LexicalEditor } from 'lexical';
3
+
4
+ export declare function initializeEditor(editor: LexicalEditor, $initialEditorState?: InitialEditorStateType): void;
5
+ //# sourceMappingURL=initializeEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initializeEditor.d.ts","sourceRoot":"","sources":["../src/initializeEditor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAW7E,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,mBAAmB,GAAE,sBAA4C,GAChE,IAAI,CAkBN"}
@@ -0,0 +1,6 @@
1
+ import { LexicalEditor } from 'lexical';
2
+ import { RegisterLexicalSubscription } from './registerSubscription';
3
+
4
+ export declare const canShowPlaceholder: RegisterLexicalSubscription<boolean>;
5
+ export declare function registerCanShowPlaceholder(editor: LexicalEditor, onChange: (canShow: boolean) => void): () => void;
6
+ //# sourceMappingURL=registerShowPlaceholder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerShowPlaceholder.d.ts","sourceRoot":"","sources":["../src/registerShowPlaceholder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C,OAAO,EACL,2BAA2B,EAE5B,MAAM,wBAAwB,CAAC;AAwBhC,eAAO,MAAM,kBAAkB,EAAE,2BAA2B,CAAC,OAAO,CAGnE,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GACnC,MAAM,IAAI,CAEZ"}
@@ -0,0 +1,11 @@
1
+ import { LexicalEditor } from 'lexical';
2
+
3
+ export interface RegisterLexicalSubscription<T> {
4
+ initialValueFn: (editor: LexicalEditor) => T;
5
+ subscribe: (editor: LexicalEditor, onChange: (value: T) => void) => () => void;
6
+ }
7
+ /**
8
+ * Shortcut to Lexical subscriptions when values are used for render.
9
+ */
10
+ export declare function registerLexicalSubscription<T>(editor: LexicalEditor, subscription: RegisterLexicalSubscription<T>, onChange: (value: T) => void): () => void;
11
+ //# sourceMappingURL=registerSubscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerSubscription.d.ts","sourceRoot":"","sources":["../src/registerSubscription.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,2BAA2B,CAAC,CAAC;IAC5C,cAAc,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,CAAC,CAAC;IAC7C,SAAS,EAAE,CACT,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KACzB,MAAM,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,2BAA2B,CAAC,CAAC,CAAC,EAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAC3B,MAAM,IAAI,CAUZ"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare function safeCast<T>(value: T): T;
9
+ //# sourceMappingURL=safeCast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeCast.d.ts","sourceRoot":"","sources":["../src/safeCast.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvC"}
@@ -0,0 +1,4 @@
1
+ import { PlanConfigBase } from './types';
2
+
3
+ export declare function shallowMergeConfig<T extends PlanConfigBase>(a: T, b?: Partial<T>): T;
4
+ //# sourceMappingURL=shallowMergeConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shallowMergeConfig.d.ts","sourceRoot":"","sources":["../src/shallowMergeConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,cAAc,EACzD,CAAC,EAAE,CAAC,EACJ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACb,CAAC,CAUH"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export default function invariant(cond?: boolean, message?: string, ...args: string[]): asserts cond;
9
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../src/shared/invariant.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAQd"}
@@ -0,0 +1,5 @@
1
+ import { useLayoutEffect } from 'react';
2
+
3
+ declare const useLayoutEffectImpl: typeof useLayoutEffect;
4
+ export default useLayoutEffectImpl;
5
+ //# sourceMappingURL=useLayoutEffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/shared/useLayoutEffect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAa,eAAe,EAAE,MAAM,OAAO,CAAC;AAGnD,QAAA,MAAM,mBAAmB,EAAE,OAAO,eAErB,CAAC;AAEd,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { CreateEditorArgs, EditorState, LexicalEditor } from 'lexical';
2
+ import { LexicalPlanRegistry } from '@etrepum/lexical-builder';
3
+
4
+ export type AnyLexicalPlan = LexicalPlan<any, string>;
5
+ export type AnyLexicalPlanArgument = LexicalPlanArgument<any, string>;
6
+ export type PlanConfigBase = Record<never, never>;
7
+ export type NormalizedLexicalPlanArgument<Config extends PlanConfigBase, Name extends string> = [LexicalPlan<Config, Name>, Config, ...Config[]];
8
+ export interface RegisterState {
9
+ signal: AbortSignal;
10
+ getPeerConfig<Name extends keyof LexicalPlanRegistry>(name: string): undefined | LexicalPlanConfig<LexicalPlanRegistry[Name]>;
11
+ getDependencyConfig<Dependency extends AnyLexicalPlan>(dep: Dependency): LexicalPlanConfig<Dependency>;
12
+ }
13
+ export type LexicalPlanArgument<Config extends PlanConfigBase, Name extends string> = LexicalPlan<Config, Name> | NormalizedLexicalPlanArgument<Config, Name>;
14
+ export interface LexicalPlan<Config extends PlanConfigBase = PlanConfigBase, Name extends string = string> {
15
+ /** The name of the Plan, must be unique */
16
+ name: Name;
17
+ /** Plan names that must not be loaded with this Plan */
18
+ conflictsWith?: string[];
19
+ /** Other Plans that this Plan depends on, can also be used to configure them */
20
+ dependencies?: AnyLexicalPlanArgument[];
21
+ /**
22
+ * Other Plans, by name, that this Plan can optionally depend on or
23
+ * configure, if they are directly depended on by another Plan
24
+ */
25
+ peerDependencies?: {
26
+ [k in keyof LexicalPlanRegistry]?: LexicalPeerConfig<k>;
27
+ };
28
+ /**
29
+ * @internal Disable root element events (for internal Meta use)
30
+ */
31
+ disableEvents?: CreateEditorArgs["disableEvents"];
32
+ /**
33
+ * Used when this editor is nested inside of another editor
34
+ */
35
+ parentEditor?: CreateEditorArgs["parentEditor"];
36
+ /**
37
+ * The namespace of this Editor. If two editors share the same
38
+ * namespace, JSON will be the clipboard interchange format.
39
+ * Otherwise HTML will be used.
40
+ */
41
+ namespace?: CreateEditorArgs["namespace"];
42
+ /**
43
+ * The nodes that this Plan adds to the Editor configuration, will be merged with other Plans
44
+ */
45
+ nodes?: CreateEditorArgs["nodes"];
46
+ /**
47
+ * EditorThemeClasses that will be deep merged with other Plans
48
+ */
49
+ theme?: CreateEditorArgs["theme"];
50
+ /**
51
+ * Overrides for HTML serialization (exportDOM) and
52
+ * deserialization (importDOM) that does not require subclassing and node
53
+ * replacement
54
+ */
55
+ html?: CreateEditorArgs["html"];
56
+ /**
57
+ * Whether the initial state of the editor is editable or not
58
+ */
59
+ editable?: CreateEditorArgs["editable"];
60
+ /**
61
+ * The editor will catch errors that happen during updates and
62
+ * reconciliation and call this. It defaults to
63
+ * `(error) => console.error(error)`.
64
+ *
65
+ * @param error The Error object
66
+ * @param editor The editor that this error came from
67
+ */
68
+ onError?: (error: Error, editor: LexicalEditor) => void;
69
+ /**
70
+ * The initial EditorState as a JSON string, an EditorState, or a function
71
+ * to update the editor once.
72
+ */
73
+ $initialEditorState?: InitialEditorStateType;
74
+ /**
75
+ * The default configuration specific to this Plan
76
+ */
77
+ config: Config;
78
+ /**
79
+ * By default, Config is shallow merged `{...a, ...b}`, if your Plan
80
+ * requires other strategies (such as concatenating an Array) you can
81
+ * implement it here.
82
+ *
83
+ * @param a The current configuration
84
+ * @param b The partial configuration to merge
85
+ * @returns The merged configuration
86
+ */
87
+ mergeConfig?: (a: Config, b?: Partial<Config>) => Config;
88
+ /**
89
+ * Add behavior to the editor (register transforms, listeners, etc.) after
90
+ * the Editor is created.
91
+ *
92
+ * @param editor The editor this Plan is being registered with
93
+ * @param config The merged configuration specific to this Plan
94
+ * @param state An object containing an AbortSignal that can be
95
+ * used, and methods for accessing the merged configuration of
96
+ * dependencies and peerDependencies
97
+ * @returns A clean-up function
98
+ */
99
+ register?: (editor: LexicalEditor, config: Config, state: RegisterState) => () => void;
100
+ }
101
+ export type LexicalPeerConfig<Name extends keyof LexicalPlanRegistry | string> = [
102
+ Name
103
+ ] extends [keyof LexicalPlanRegistry] ? LexicalPlanRegistry[Name] : PlanConfigBase;
104
+ export type LexicalPlanConfig<Plan extends AnyLexicalPlan> = Plan["config"];
105
+ export type LexicalPlanName<Plan extends AnyLexicalPlan> = Plan["name"];
106
+ export interface EditorHandle {
107
+ editor: LexicalEditor;
108
+ dispose: () => void;
109
+ }
110
+ export type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
111
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,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,cAAc,EAC7B,IAAI,SAAS,MAAM,IACjB,CAAC,WAAW,CAAC,M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,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { LexicalEditor } from 'lexical';
2
+
3
+ import * as React from "react";
4
+ export type ErrorBoundaryProps = {
5
+ children: JSX.Element;
6
+ onError: (error: Error) => void;
7
+ };
8
+ export type ErrorBoundaryType = React.ComponentClass<ErrorBoundaryProps> | React.FC<ErrorBoundaryProps>;
9
+ export declare function useReactDecorators(editor: LexicalEditor, ErrorBoundary: ErrorBoundaryType): Array<JSX.Element>;
10
+ //# sourceMappingURL=useReactDecorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReactDecorators.d.ts","sourceRoot":"","sources":["../src/useReactDecorators.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAW,MAAM,SAAS,CAAC;AAGtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,GACxC,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;AAEjC,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,iBAAiB,GAC/B,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CA+CpB"}
@@ -0,0 +1,4 @@
1
+ import { RegisterLexicalSubscription } from './registerSubscription';
2
+
3
+ export declare function useRegisterSubscription<T>(subscription: RegisterLexicalSubscription<T>): T;
4
+ //# sourceMappingURL=useRegisterSubscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRegisterSubscription.d.ts","sourceRoot":"","sources":["../src/useRegisterSubscription.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAM1E,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,YAAY,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAC3C,CAAC,CAWH"}
package/package.json CHANGED
@@ -12,12 +12,12 @@
12
12
  "plug-in"
13
13
  ],
14
14
  "scripts": {
15
- "build": "rollup -c",
16
- "dev": "rollup -c -w",
15
+ "build": "vite build",
16
+ "dev": "vite build -w",
17
17
  "test": "vitest run",
18
18
  "test:watch": "vitest"
19
19
  },
20
- "version": "0.0.4",
20
+ "version": "0.0.6-nightly.20240603.0",
21
21
  "license": "MIT",
22
22
  "repository": {
23
23
  "type": "git",
@@ -41,17 +41,14 @@
41
41
  },
42
42
  "sideEffects": false,
43
43
  "devDependencies": {
44
- "@rollup/plugin-commonjs": "^25.0.7",
45
- "@rollup/plugin-node-resolve": "^15.2.3",
46
- "rollup": "^4.17.2",
47
- "rollup-plugin-node-externals": "^7.1.2",
48
- "rollup-plugin-ts": "^3.4.5",
49
44
  "tslib": "^2.6.2",
50
45
  "typescript": "^5.4.5",
46
+ "vite": "^5.2.11",
47
+ "vite-plugin-package-version": "^1.1.0",
51
48
  "vitest": "^1.6.0"
52
49
  },
53
- "module": "dist/index.mjs",
54
- "types": "dist/index.d.mts",
50
+ "module": "dist/index.js",
51
+ "types": "dist/index.d.ts",
55
52
  "files": [
56
53
  "dist"
57
54
  ]