preact-intlayer 8.3.4 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/cjs/client/IntlayerProvider.cjs +1 -1
  2. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  3. package/dist/cjs/client/index.cjs +1 -1
  4. package/dist/cjs/client/useLocaleStorage.cjs +1 -1
  5. package/dist/cjs/editor/ContentSelector.cjs +2 -0
  6. package/dist/cjs/editor/ContentSelector.cjs.map +1 -0
  7. package/dist/cjs/editor/EditorProvider.cjs +1 -1
  8. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  9. package/dist/cjs/editor/useEditor.cjs +2 -0
  10. package/dist/cjs/editor/useEditor.cjs.map +1 -0
  11. package/dist/cjs/html/HTMLRenderer.cjs +1 -1
  12. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  13. package/dist/cjs/index.cjs +1 -1
  14. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs +1 -1
  15. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  16. package/dist/cjs/plugins.cjs +1 -1
  17. package/dist/cjs/plugins.cjs.map +1 -1
  18. package/dist/esm/client/IntlayerProvider.mjs +1 -1
  19. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  20. package/dist/esm/client/index.mjs +1 -1
  21. package/dist/esm/client/useLocaleStorage.mjs +1 -1
  22. package/dist/esm/editor/ContentSelector.mjs +2 -0
  23. package/dist/esm/editor/ContentSelector.mjs.map +1 -0
  24. package/dist/esm/editor/EditorProvider.mjs +1 -1
  25. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  26. package/dist/esm/editor/useEditor.mjs +2 -0
  27. package/dist/esm/editor/useEditor.mjs.map +1 -0
  28. package/dist/esm/html/HTMLRenderer.mjs +1 -1
  29. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  30. package/dist/esm/index.mjs +1 -1
  31. package/dist/esm/markdown/MarkdownRendererPlugin.mjs +1 -1
  32. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  33. package/dist/esm/plugins.mjs +1 -1
  34. package/dist/esm/plugins.mjs.map +1 -1
  35. package/dist/types/client/IntlayerProvider.d.ts +0 -2
  36. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  37. package/dist/types/editor/ContentSelector.d.ts +19 -0
  38. package/dist/types/editor/ContentSelector.d.ts.map +1 -0
  39. package/dist/types/editor/EditorProvider.d.ts +5 -18
  40. package/dist/types/editor/EditorProvider.d.ts.map +1 -1
  41. package/dist/types/editor/useEditor.d.ts +10 -0
  42. package/dist/types/editor/useEditor.d.ts.map +1 -0
  43. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  44. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  45. package/dist/types/plugins.d.ts.map +1 -1
  46. package/package.json +7 -7
  47. package/dist/cjs/editor/CommunicatorContext.cjs +0 -2
  48. package/dist/cjs/editor/CommunicatorContext.cjs.map +0 -1
  49. package/dist/cjs/editor/ConfigurationContext.cjs +0 -2
  50. package/dist/cjs/editor/ConfigurationContext.cjs.map +0 -1
  51. package/dist/cjs/editor/ContentSelectorWrapper.cjs +0 -2
  52. package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +0 -1
  53. package/dist/cjs/editor/DictionariesRecordContext.cjs +0 -2
  54. package/dist/cjs/editor/DictionariesRecordContext.cjs.map +0 -1
  55. package/dist/cjs/editor/EditedContentContext.cjs +0 -2
  56. package/dist/cjs/editor/EditedContentContext.cjs.map +0 -1
  57. package/dist/cjs/editor/EditorEnabledContext.cjs +0 -2
  58. package/dist/cjs/editor/EditorEnabledContext.cjs.map +0 -1
  59. package/dist/cjs/editor/EditorStateContext.cjs +0 -2
  60. package/dist/cjs/editor/EditorStateContext.cjs.map +0 -1
  61. package/dist/cjs/editor/FocusDictionaryContext.cjs +0 -2
  62. package/dist/cjs/editor/FocusDictionaryContext.cjs.map +0 -1
  63. package/dist/cjs/editor/IntlayerEditorProvider.cjs +0 -2
  64. package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +0 -1
  65. package/dist/cjs/editor/index.cjs +0 -1
  66. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +0 -2
  67. package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +0 -1
  68. package/dist/cjs/editor/useCrossFrameState.cjs +0 -2
  69. package/dist/cjs/editor/useCrossFrameState.cjs.map +0 -1
  70. package/dist/cjs/editor/useCrossURLPathState.cjs +0 -2
  71. package/dist/cjs/editor/useCrossURLPathState.cjs.map +0 -1
  72. package/dist/cjs/editor/useEditedContentRenderer.cjs +0 -2
  73. package/dist/cjs/editor/useEditedContentRenderer.cjs.map +0 -1
  74. package/dist/cjs/editor/useIframeClickInterceptor.cjs +0 -2
  75. package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +0 -1
  76. package/dist/esm/editor/CommunicatorContext.mjs +0 -2
  77. package/dist/esm/editor/CommunicatorContext.mjs.map +0 -1
  78. package/dist/esm/editor/ConfigurationContext.mjs +0 -2
  79. package/dist/esm/editor/ConfigurationContext.mjs.map +0 -1
  80. package/dist/esm/editor/ContentSelectorWrapper.mjs +0 -2
  81. package/dist/esm/editor/ContentSelectorWrapper.mjs.map +0 -1
  82. package/dist/esm/editor/DictionariesRecordContext.mjs +0 -2
  83. package/dist/esm/editor/DictionariesRecordContext.mjs.map +0 -1
  84. package/dist/esm/editor/EditedContentContext.mjs +0 -2
  85. package/dist/esm/editor/EditedContentContext.mjs.map +0 -1
  86. package/dist/esm/editor/EditorEnabledContext.mjs +0 -2
  87. package/dist/esm/editor/EditorEnabledContext.mjs.map +0 -1
  88. package/dist/esm/editor/EditorStateContext.mjs +0 -2
  89. package/dist/esm/editor/EditorStateContext.mjs.map +0 -1
  90. package/dist/esm/editor/FocusDictionaryContext.mjs +0 -2
  91. package/dist/esm/editor/FocusDictionaryContext.mjs.map +0 -1
  92. package/dist/esm/editor/IntlayerEditorProvider.mjs +0 -2
  93. package/dist/esm/editor/IntlayerEditorProvider.mjs.map +0 -1
  94. package/dist/esm/editor/index.mjs +0 -1
  95. package/dist/esm/editor/useCrossFrameMessageListener.mjs +0 -2
  96. package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +0 -1
  97. package/dist/esm/editor/useCrossFrameState.mjs +0 -2
  98. package/dist/esm/editor/useCrossFrameState.mjs.map +0 -1
  99. package/dist/esm/editor/useCrossURLPathState.mjs +0 -2
  100. package/dist/esm/editor/useCrossURLPathState.mjs.map +0 -1
  101. package/dist/esm/editor/useEditedContentRenderer.mjs +0 -2
  102. package/dist/esm/editor/useEditedContentRenderer.mjs.map +0 -1
  103. package/dist/esm/editor/useIframeClickInterceptor.mjs +0 -2
  104. package/dist/esm/editor/useIframeClickInterceptor.mjs.map +0 -1
  105. package/dist/types/editor/CommunicatorContext.d.ts +0 -12
  106. package/dist/types/editor/CommunicatorContext.d.ts.map +0 -1
  107. package/dist/types/editor/ConfigurationContext.d.ts +0 -10
  108. package/dist/types/editor/ConfigurationContext.d.ts.map +0 -1
  109. package/dist/types/editor/ContentSelectorWrapper.d.ts +0 -9
  110. package/dist/types/editor/ContentSelectorWrapper.d.ts.map +0 -1
  111. package/dist/types/editor/DictionariesRecordContext.d.ts +0 -16
  112. package/dist/types/editor/DictionariesRecordContext.d.ts.map +0 -1
  113. package/dist/types/editor/EditedContentContext.d.ts +0 -35
  114. package/dist/types/editor/EditedContentContext.d.ts.map +0 -1
  115. package/dist/types/editor/EditorEnabledContext.d.ts +0 -11
  116. package/dist/types/editor/EditorEnabledContext.d.ts.map +0 -1
  117. package/dist/types/editor/EditorStateContext.d.ts +0 -12
  118. package/dist/types/editor/EditorStateContext.d.ts.map +0 -1
  119. package/dist/types/editor/FocusDictionaryContext.d.ts +0 -16
  120. package/dist/types/editor/FocusDictionaryContext.d.ts.map +0 -1
  121. package/dist/types/editor/IntlayerEditorProvider.d.ts +0 -9
  122. package/dist/types/editor/IntlayerEditorProvider.d.ts.map +0 -1
  123. package/dist/types/editor/index.d.ts +0 -3
  124. package/dist/types/editor/useCrossFrameMessageListener.d.ts +0 -7
  125. package/dist/types/editor/useCrossFrameMessageListener.d.ts.map +0 -1
  126. package/dist/types/editor/useCrossFrameState.d.ts +0 -13
  127. package/dist/types/editor/useCrossFrameState.d.ts.map +0 -1
  128. package/dist/types/editor/useCrossURLPathState.d.ts +0 -6
  129. package/dist/types/editor/useCrossURLPathState.d.ts.map +0 -1
  130. package/dist/types/editor/useEditedContentRenderer.d.ts +0 -21
  131. package/dist/types/editor/useEditedContentRenderer.d.ts.map +0 -1
  132. package/dist/types/editor/useIframeClickInterceptor.d.ts +0 -6
  133. package/dist/types/editor/useIframeClickInterceptor.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { ContentSelectorRenderer } from './editor';\nimport { EditedContentRenderer } from './editor/useEditedContentRenderer';\nimport { HTMLRenderer } from './html/HTMLRenderer';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration?.editor.enabled ? (\n <ContentSelectorRenderer {...rest} key={rest.children}>\n <EditedContentRenderer {...rest}>\n {rest.children}\n </EditedContentRenderer>\n </ContentSelectorRenderer>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelectorRenderer {...rest}>\n {renderPreactElement(node)}\n </ContentSelectorRenderer>\n ) : (\n renderPreactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelectorRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelectorRenderer {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelectorRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n h(HTMLRenderer as any, { ...rest, html, userComponents } as any);\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\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AAqB,CAAE,GAAG,EAAM,OAAM,iBAAgB,CAAQ,CAE5D,EAAU,GAAQ,CAgBxB,OAdc,IAAI,MAAM,EAAS,CAC/B,IAAI,EAAQ,EAAM,CAShB,OARI,IAAS,QACJ,EAGL,IAAS,MACH,GAAoC,EAAO,EAAe,CAG7D,QAAQ,IAAI,EAAQ,EAAK,EAEnC,CAAC,EAIL,CAuCY,GACX,EACA,EAAoB,KACN,CACd,EACE,GAAU,EAAc,qBAAqB,cAC7C,EAAW,EAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACD,EACA,EACA,EAAa,GAAU,EAAc,qBAAqB,cAAc,CACxE,EACA,EACA,EACA,EACA,EACA,EACA,EACD"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { ContentSelector } from './editor/ContentSelector';\nimport { HTMLRenderer } from './html/HTMLRenderer';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { MarkdownMetadataRenderer, MarkdownRendererPlugin } from './markdown';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins = {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children: configuration?.editor.enabled ? (\n <ContentSelector {...rest}>{renderPreactElement(node)}</ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: (\n <ContentSelector {...rest}>\n <MarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataRenderer>\n </ContentSelector>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children: (\n <ContentSelector {...rest}>\n <MarkdownRendererPlugin {...rest} components={components}>\n {node}\n </MarkdownRendererPlugin>\n </ContentSelector>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'use') {\n return (components?: any) => render(components);\n }\n\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n};\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n h(HTMLRenderer as any, { ...rest, html, userComponents } as any);\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'use') {\n return (userComponents?: HTMLComponents) => render(userComponents);\n }\n\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n};\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n];\n"],"mappings":"qwBAyCA,MAAa,EAA+B,CAC1C,GAAI,uBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OA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AIL,CAuCY,GACX,EACA,EAAoB,KACN,CACd,EACE,GAAU,EAAc,qBAAqB,cAC7C,EAAW,EAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACD,EACA,EACA,EAAa,GAAU,EAAc,qBAAqB,cAAc,CACxE,EACA,EACA,EACA,EACA,EACA,EACA,EACD"}
@@ -6,7 +6,6 @@ import { ComponentChild, FunctionComponent } from "preact";
6
6
  type IntlayerValue = {
7
7
  locale: LocalesValues;
8
8
  setLocale: (newLocale: LocalesValues) => void;
9
- disableEditor?: boolean;
10
9
  isCookieEnabled?: boolean;
11
10
  };
12
11
  /**
@@ -22,7 +21,6 @@ type IntlayerProviderProps = {
22
21
  locale?: LocalesValues;
23
22
  defaultLocale?: LocalesValues;
24
23
  setLocale?: (locale: LocalesValues) => void;
25
- disableEditor?: boolean;
26
24
  isCookieEnabled?: boolean;
27
25
  };
28
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;;;KAcK,aAAA;EACH,MAAA,EAAQ,aAAA;EACR,SAAA,GAAY,SAAA,EAAW,aAAA;EACvB,aAAA;EACA,eAAA;AAAA;;;;cAMW,qBAAA,EAAqB,MAAA,CAAA,OAAA,CAAA,aAAA;;;;cASrB,kBAAA,QAAkB,aAAA;AAAA,KAEnB,qBAAA;EACV,QAAA,GAAW,cAAA;EACX,MAAA,GAAS,aAAA;EACT,aAAA,GAAgB,aAAA;EAChB,SAAA,IAAa,MAAA,EAAQ,aAAA;EACrB,aAAA;EACA,eAAA;AAAA;;;;cAMW,uBAAA,EAAyB,iBAAA,CACpC,qBAAA;AAbF;;;;;;;;;;;;;;;;;;;;AAAA,cA0Fa,gBAAA,EAAkB,iBAAA,CAAkB,qBAAA"}
1
+ {"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;;;KAYK,aAAA;EACH,MAAA,EAAQ,aAAA;EACR,SAAA,GAAY,SAAA,EAAW,aAAA;EACvB,eAAA;AAAA;;;;cAMW,qBAAA,EAAqB,MAAA,CAAA,OAAA,CAAA,aAAA;;;;cAQrB,kBAAA,QAAkB,aAAA;AAAA,KAEnB,qBAAA;EACV,QAAA,GAAW,cAAA;EACX,MAAA,GAAS,aAAA;EACT,aAAA,GAAgB,aAAA;EAChB,SAAA,IAAa,MAAA,EAAQ,aAAA;EACrB,eAAA;AAAA;AAPF;;;AAAA,cAaa,uBAAA,EAAyB,iBAAA,CACpC,qBAAA;;AAZF;;;;;;;;;;;;;;;;;;;cAsFa,gBAAA,EAAkB,iBAAA,CAAkB,qBAAA"}
@@ -0,0 +1,19 @@
1
+ import { NodeProps } from "@intlayer/core/interpreter";
2
+ import { FunctionalComponent, HTMLAttributes } from "preact";
3
+
4
+ //#region src/editor/ContentSelector.d.ts
5
+ declare module 'preact' {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {
9
+ 'key-path'?: string;
10
+ 'dictionary-key'?: string;
11
+ };
12
+ }
13
+ }
14
+ }
15
+ type ContentSelectorWrapperProps = NodeProps & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
16
+ declare const ContentSelector: FunctionalComponent<ContentSelectorWrapperProps>;
17
+ //#endregion
18
+ export { ContentSelector, ContentSelectorWrapperProps };
19
+ //# sourceMappingURL=ContentSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/editor/ContentSelector.tsx"],"mappings":";;;;;YAOY,GAAA;IAAA,UACE,iBAAA;MACR,mCAAA,EAAqC,cAAA,CAAe,WAAA;QAClD,UAAA;QACA,gBAAA;MAAA;IAAA;EAAA;AAAA;AAAA,KAMI,2BAAA,GAA8B,SAAA,GACxC,IAAA,CAAK,cAAA,CAAe,cAAA;AAAA,cAET,eAAA,EAAiB,mBAAA,CAC5B,2BAAA"}
@@ -1,22 +1,9 @@
1
- import { ComponentChildren, FunctionComponent } from "preact";
2
- import { IntlayerConfig } from "@intlayer/types/config";
1
+ import { ComponentChild, FunctionComponent } from "preact";
3
2
 
4
3
  //#region src/editor/EditorProvider.d.ts
5
- type EditorProviderProps = {
6
- mode?: 'editor' | 'client';
7
- configuration?: IntlayerConfig;
8
- postMessage?: (data: any) => void;
9
- allowedOrigins?: string[];
10
- children?: ComponentChildren;
11
- };
12
- declare const EditorProvider: FunctionComponent<EditorProviderProps>;
13
- type CommunicatorProviderProps = {
14
- postMessage?: (data: any) => void;
15
- allowedOrigins?: string[];
16
- };
17
- type ConfigurationProviderProps = {
18
- configuration?: IntlayerConfig;
19
- };
4
+ declare const EditorProvider: FunctionComponent<{
5
+ children?: ComponentChild;
6
+ }>;
20
7
  //#endregion
21
- export { CommunicatorProviderProps, ConfigurationProviderProps, EditorProvider, EditorProviderProps };
8
+ export { EditorProvider };
22
9
  //# sourceMappingURL=EditorProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditorProvider.d.ts","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"mappings":";;;;KAuDY,mBAAA;EACV,IAAA;EACA,aAAA,GAAgB,cAAA;EAChB,WAAA,IAAe,IAAA;EACf,cAAA;EACA,QAAA,GAAW,iBAAA;AAAA;AAAA,cAGA,cAAA,EAAgB,iBAAA,CAAkB,mBAAA;AAAA,KA+CnC,yBAAA;EACV,WAAA,IAAe,IAAA;EACf,cAAA;AAAA;AAAA,KAEU,0BAAA;EAA+B,aAAA,GAAgB,cAAA;AAAA"}
1
+ {"version":3,"file":"EditorProvider.d.ts","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"mappings":";;;cAGa,cAAA,EAAgB,iBAAA;EAC3B,QAAA,GAAW,cAAA;AAAA"}
@@ -0,0 +1,10 @@
1
+ //#region src/editor/useEditor.d.ts
2
+ /**
3
+ * Initialises the Intlayer editor client singleton when the editor is enabled.
4
+ * Syncs the current locale from the Intlayer context into the editor manager so
5
+ * the editor always knows which locale the app is displaying.
6
+ */
7
+ declare const useEditor: () => void;
8
+ //#endregion
9
+ export { useEditor };
10
+ //# sourceMappingURL=useEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEditor.d.ts","names":[],"sources":["../../../src/editor/useEditor.tsx"],"mappings":";;AAWA;;;;cAAa,SAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLRenderer.d.ts","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"mappings":";;;;;;;AAM8C;KAKzC,gBAAA,IAAoB,KAAA;EACvB,QAAA;EAAA,CACC,GAAA;AAAA,MACG,GAAA,CAAI,OAAA;AAAA,cAaG,qBAAA,EAAqB,MAAA,SAAA,gBAAA;AAAA,KAEtB,eAAA;EAfN;;;;EAoBJ,UAAA,GAAa,cAAA;AAAA;;;;AALf;;;cAca,UAAA,GACX,OAAA;EACA;AAAA,IAAgB,eAAA,KACf,GAAA,CAAI,OAAA;;AAHP;;;;;cA4Ba,eAAA;EAAmB;AAAA,IAAgB,eAAA,MAGtC,OAAA,aAAe,CAAA,CAAA,GAAA,CAAA,OAAA;AAAA,KAUb,iBAAA,GAAoB,eAAA;EArB/B;;;EAyBC,QAAA;EA3CgB;;;EA+ChB,IAAA;EA7BD;AAQD;;EAyBE,UAAA,GAAa,cAAA;EACb,aAAA;EACA,OAAA,GAAU,OAAA;AAAA;;;;cAMC,YAAA,EAAc,iBAAA,CAAkB,iBAAA"}
1
+ {"version":3,"file":"HTMLRenderer.d.ts","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"mappings":";;;;;;;AAK8C;KAKzC,gBAAA,IAAoB,KAAA;EACvB,QAAA;EAAA,CACC,GAAA;AAAA,MACG,GAAA,CAAI,OAAA;AAAA,cAaG,qBAAA,EAAqB,MAAA,SAAA,gBAAA;AAAA,KAEtB,eAAA;EAfN;;;;EAoBJ,UAAA,GAAa,cAAA;AAAA;;;;AALf;;;cAca,UAAA,GACX,OAAA;EACA;AAAA,IAAgB,eAAA,KACf,GAAA,CAAI,OAAA;;AAHP;;;;;cA4Ba,eAAA;EAAmB;AAAA,IAAgB,eAAA,MAGtC,OAAA,aAAe,CAAA,CAAA,GAAA,CAAA,OAAA;AAAA,KAUb,iBAAA,GAAoB,eAAA;EArB/B;;;EAyBC,QAAA;EA3CgB;;;EA+ChB,IAAA;EA7BD;AAQD;;EAyBE,UAAA,GAAa,cAAA;EACb,aAAA;EACA,OAAA,GAAU,OAAA;AAAA;;;;cAMC,YAAA,EAAc,iBAAA,CAAkB,iBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"mappings":";;;;;;;KAcK,2BAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA,GAAS,aAAA;EACT,QAAA;EACA,OAAA,GAAU,uBAAA;EACV,UAAA,GAAa,cAAA;AAAA;AAAA,cAGF,sBAAA,EAAwB,iBAAA,CACnC,2BAAA;AAAA,KAoBG,6BAAA,GAAgC,2BAAA;EACnC,eAAA,EAAiB,OAAA;AAAA;AAAA,cAGN,wBAAA,EAA0B,iBAAA,CACrC,6BAAA"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"mappings":";;;;;;;KAeK,2BAAA;EACH,aAAA;EACA,OAAA,EAAS,OAAA;EACT,MAAA,GAAS,aAAA;EACT,QAAA;EACA,OAAA,GAAU,uBAAA;EACV,UAAA,GAAa,cAAA;AAAA;AAAA,cAGF,sBAAA,EAAwB,iBAAA,CACnC,2BAAA;AAAA,KAYG,6BAAA,GAAgC,2BAAA;EACnC,eAAA,EAAiB,OAAA;AAAA;AAAA,cAGN,wBAAA,EAA0B,iBAAA,CACrC,6BAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.tsx"],"mappings":";;;;;;;;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AAA,CACT,QAAA,CAAS,QAAA;EACV,QAAA;EACA,IAAA;AAAA;EAGI,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,KAAA;EACvD,QAAA,EAAU,oBAAA,CAAqB,CAAA;AAAA;AAAA,cAIxB,cAAA,EAAgB,OAAA;;;;KA2BjB,cAAA,MAAoB,CAAA;EAC9B,QAAA,EAAU,QAAA;EAAA,CACT,QAAA,CAAS,IAAA;EACV,IAAA;AAAA;EAGI,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,YAAA,CAAa,CAAA;AAAA;;cAK7D,UAAA,EAAY,OAAA;;;;UAqCR,wBAAA,iBAAyC,aAAA;EACxD,UAAA,EAAY,cAAA,CAAe,CAAA;EAC3B,kBAAA,EAAoB,gBAAA,CAAiB,CAAA;EACrC,eAAA,EAAiB,aAAA,CAAc,CAAA,EAAG,CAAA,EAAG,CAAA;EACrC,cAAA,EAAgB,YAAA,CAAa,CAAA;EAC7B,UAAA,EAAY,cAAA,CAAe,CAAA;AAAA;;;;;;KAQjB,uBAAA,GAA0B,IAAA,CACpC,yBAAA;EAGA,UAAA;EACA,kBAAA;EACA,eAAA;EACA,cAAA;EACA,UAAA;AAAA;AAAA,KAGU,oBAAA,cAEA,aAAA,GAAgB,eAAA,IACxB,sBAAA,CAAyB,CAAA,EAAG,uBAAA,EAAyB,CAAA;;;;;cAM5C,UAAA,GACX,MAAA,GAAS,aAAA,EACT,QAAA,eACC,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-intlayer",
3
- "version": "8.3.4",
3
+ "version": "8.4.0",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Preact applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -92,12 +92,12 @@
92
92
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
93
93
  },
94
94
  "dependencies": {
95
- "@intlayer/api": "8.3.4",
96
- "@intlayer/chokidar": "8.3.4",
97
- "@intlayer/config": "8.3.4",
98
- "@intlayer/core": "8.3.4",
99
- "@intlayer/editor": "8.3.4",
100
- "@intlayer/types": "8.3.4"
95
+ "@intlayer/api": "8.4.0",
96
+ "@intlayer/chokidar": "8.4.0",
97
+ "@intlayer/config": "8.4.0",
98
+ "@intlayer/core": "8.4.0",
99
+ "@intlayer/editor": "8.4.0",
100
+ "@intlayer/types": "8.4.0"
101
101
  },
102
102
  "devDependencies": {
103
103
  "@types/node": "25.5.0",
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./EditorStateContext.cjs`),t=()=>{let t=e.useEditorStateManager();return{postMessage:e=>t.messenger.send(e.type,e.data),senderId:t.messenger.senderId}};exports.useCommunicator=t;
2
- //# sourceMappingURL=CommunicatorContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommunicatorContext.cjs","names":["useEditorStateManager"],"sources":["../../../src/editor/CommunicatorContext.tsx"],"sourcesContent":["import { useEditorStateManager } from './EditorStateContext';\n\nexport const useCommunicator = () => {\n const manager = useEditorStateManager();\n return {\n postMessage: (data: any) => manager.messenger.send(data.type, data.data),\n senderId: manager.messenger.senderId,\n };\n};\n\n// Backward-compat types\nexport type CommunicatorProviderProps = {\n postMessage?: (data: any) => void;\n allowedOrigins?: string[];\n};\n"],"mappings":"+GAEa,MAAwB,CACnC,IAAM,EAAUA,EAAAA,uBAAuB,CACvC,MAAO,CACL,YAAc,GAAc,EAAQ,UAAU,KAAK,EAAK,KAAM,EAAK,KAAK,CACxE,SAAU,EAAQ,UAAU,SAC7B"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`);let t=require(`preact/hooks`);const n=()=>{let n=e.useEditorStateManager(),[r,i]=(0,t.useState)(n.configuration.value);return(0,t.useEffect)(()=>{let e=e=>i(e.detail);return n.configuration.addEventListener(`change`,e),()=>n.configuration.removeEventListener(`change`,e)},[n]),r};exports.useConfiguration=n;
2
- //# sourceMappingURL=ConfigurationContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigurationContext.cjs","names":["useEditorStateManager"],"sources":["../../../src/editor/ConfigurationContext.tsx"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport const useConfiguration = (): IntlayerConfig | undefined => {\n const manager = useEditorStateManager();\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager.configuration.value\n );\n\n useEffect(() => {\n const handler = (e: Event) =>\n setConfig((e as CustomEvent<IntlayerConfig>).detail);\n manager.configuration.addEventListener('change', handler);\n return () => manager.configuration.removeEventListener('change', handler);\n }, [manager]);\n\n return config;\n};\n\nexport type ConfigurationProviderProps = { configuration?: IntlayerConfig };\n"],"mappings":"0LAIA,MAAa,MAAqD,CAChE,IAAM,EAAUA,EAAAA,uBAAuB,CACjC,CAAC,EAAQ,IAAA,EAAA,EAAA,UACb,EAAQ,cAAc,MACvB,CASD,OAPA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAW,GACf,EAAW,EAAkC,OAAO,CAEtD,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`),t=require(`./EditorEnabledContext.cjs`),n=require(`../client/IntlayerProvider.cjs`),r=require(`./FocusDictionaryContext.cjs`);let i=require(`@intlayer/types/nodeType`),a=require(`@intlayer/core/utils`),o=require(`@intlayer/editor`),s=require(`preact/hooks`),c=require(`preact/jsx-runtime`);const l=({children:t,dictionaryKey:n,keyPath:l})=>{let{focusedContent:u,setFocusedContent:d}=r.useFocusDictionary(),f=e.useEditorStateManager(),p=(0,s.useRef)(null),m=l.filter(e=>e.type!==i.NodeType.Translation),h=(u?.dictionaryKey===n&&(u?.keyPath?.length??0)>0&&(0,a.isSameKeyPath)(u?.keyPath??[],m))??!1;return(0,s.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{d({dictionaryKey:n,keyPath:m})},r=()=>{f.messenger.send(`${o.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,{dictionaryKey:n,keyPath:m})},i=()=>{f.messenger.send(`${o.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,null)};return e.addEventListener(`intlayer:press`,t),e.addEventListener(`intlayer:hover`,r),e.addEventListener(`intlayer:unhover`,i),()=>{e.removeEventListener(`intlayer:press`,t),e.removeEventListener(`intlayer:hover`,r),e.removeEventListener(`intlayer:unhover`,i)}}),(0,c.jsx)(`intlayer-content-selector`,{ref:p,"is-selecting":h||void 0,children:t})},u=({children:e,...r})=>{let{enabled:i}=t.useEditorEnabled(),{disableEditor:a}=n.useIntlayerContext();return(0,s.useEffect)(()=>{(0,o.defineIntlayerElements)()},[]),i&&!a?(0,c.jsx)(l,{...r,children:e}):e};exports.ContentSelectorRenderer=u;
2
- //# sourceMappingURL=ContentSelectorWrapper.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentSelectorWrapper.cjs","names":["useFocusDictionary","useEditorStateManager","NodeType","MessageKey","useEditorEnabled","useIntlayerContext"],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport { defineIntlayerElements, MessageKey } from '@intlayer/editor';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type { FunctionalComponent, JSX } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport { useIntlayerContext } from '../client';\nimport { useEditorEnabled } from './EditorEnabledContext';\nimport { useEditorStateManager } from './EditorStateContext';\nimport { useFocusDictionary } from './FocusDictionaryContext';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const manager = useEditorStateManager();\n const ref = useRef<HTMLElement>(null);\n\n const filteredKeyPath = keyPath.filter(\n (key) => key.type !== NodeType.Translation\n );\n\n const isSelected =\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false;\n\n // Preact (like React 18) requires addEventListener for web component custom events\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const handlePress = () => {\n setFocusedContent({ dictionaryKey, keyPath: filteredKeyPath });\n };\n\n const handleHover = () => {\n manager.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n { dictionaryKey, keyPath: filteredKeyPath }\n );\n };\n\n const handleUnhover = () => {\n manager.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n null\n );\n };\n\n el.addEventListener('intlayer:press', handlePress);\n el.addEventListener('intlayer:hover', handleHover);\n el.addEventListener('intlayer:unhover', handleUnhover);\n return () => {\n el.removeEventListener('intlayer:press', handlePress);\n el.removeEventListener('intlayer:hover', handleHover);\n el.removeEventListener('intlayer:unhover', handleUnhover);\n };\n });\n\n return (\n // @ts-ignore — custom element typing\n <intlayer-content-selector ref={ref} is-selecting={isSelected || undefined}>\n {children}\n </intlayer-content-selector>\n );\n};\n\nexport const ContentSelectorRenderer: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, ...props }) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n useEffect(() => {\n defineIntlayerElements();\n }, []);\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":"8bAcA,MAAM,GAED,CAAE,WAAU,gBAAe,aAAc,CAC5C,GAAM,CAAE,iBAAgB,qBAAsBA,EAAAA,oBAAoB,CAC5D,EAAUC,EAAAA,uBAAuB,CACjC,GAAA,EAAA,EAAA,QAA0B,KAAK,CAE/B,EAAkB,EAAQ,OAC7B,GAAQ,EAAI,OAASC,EAAAA,SAAS,YAChC,CAEK,GACH,GAAgB,gBAAkB,IAChC,GAAgB,SAAS,QAAU,GAAK,IAAA,EAAA,EAAA,eAC3B,GAAgB,SAAW,EAAE,CAAE,EAAgB,GAC/D,GAmCF,OAhCA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAK,EAAI,QACf,GAAI,CAAC,EAAI,OAET,IAAM,MAAoB,CACxB,EAAkB,CAAE,gBAAe,QAAS,EAAiB,CAAC,EAG1D,MAAoB,CACxB,EAAQ,UAAU,KAChB,GAAGC,EAAAA,WAAW,iCAAiC,OAC/C,CAAE,gBAAe,QAAS,EAAiB,CAC5C,EAGG,MAAsB,CAC1B,EAAQ,UAAU,KAChB,GAAGA,EAAAA,WAAW,iCAAiC,OAC/C,KACD,EAMH,OAHA,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,mBAAoB,EAAc,KACzC,CACX,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,mBAAoB,EAAc,GAE3D,EAIA,EAAA,EAAA,KAAC,4BAAD,CAAgC,MAAK,eAAc,GAAc,IAAA,GAC9D,WACyB,CAAA,EAInB,GAER,CAAE,WAAU,GAAG,KAAY,CAC9B,GAAM,CAAE,WAAYC,EAAAA,kBAAkB,CAChC,CAAE,iBAAkBC,EAAAA,oBAAoB,CAc9C,OAZA,EAAA,EAAA,eAAgB,EACd,EAAA,EAAA,yBAAwB,EACvB,EAAE,CAAC,CAEF,GAAW,CAAC,GAEZ,EAAA,EAAA,KAAC,EAAD,CAA+B,GAAI,EAChC,WAC6B,CAAA,CAI7B"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`);let t=require(`preact/hooks`);const n=()=>{let n=e.useEditorStateManager(),[r,i]=(0,t.useState)(n.localeDictionaries.value??{});return(0,t.useEffect)(()=>{let e=e=>i(e.detail??{});return n.localeDictionaries.addEventListener(`change`,e),()=>n.localeDictionaries.removeEventListener(`change`,e)},[n]),{localeDictionaries:r,setLocaleDictionaries:e=>n.localeDictionaries.set(e),setLocaleDictionary:e=>n.setLocaleDictionary(e)}},r=()=>{let{setLocaleDictionaries:e,setLocaleDictionary:t}=n();return{setLocaleDictionaries:e,setLocaleDictionary:t}};exports.useDictionariesRecord=n,exports.useDictionariesRecordActions=r;
2
- //# sourceMappingURL=DictionariesRecordContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DictionariesRecordContext.cjs","names":["useEditorStateManager"],"sources":["../../../src/editor/DictionariesRecordContext.tsx"],"sourcesContent":["import type { DictionaryContent } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent };\n\nexport const useDictionariesRecord = () => {\n const manager = useEditorStateManager();\n const [localeDictionaries, setLocaleDictionariesState] =\n useState<DictionaryContent>(manager.localeDictionaries.value ?? {});\n\n useEffect(() => {\n const handler = (e: Event) =>\n setLocaleDictionariesState(\n (e as CustomEvent<DictionaryContent>).detail ?? {}\n );\n manager.localeDictionaries.addEventListener('change', handler);\n return () =>\n manager.localeDictionaries.removeEventListener('change', handler);\n }, [manager]);\n\n return {\n localeDictionaries,\n setLocaleDictionaries: (value: DictionaryContent) =>\n manager.localeDictionaries.set(value),\n setLocaleDictionary: (dictionary: Dictionary) =>\n manager.setLocaleDictionary(dictionary),\n };\n};\n\nexport const useDictionariesRecordActions = () => {\n const { setLocaleDictionaries, setLocaleDictionary } =\n useDictionariesRecord();\n return { setLocaleDictionaries, setLocaleDictionary };\n};\n"],"mappings":"0LAOA,MAAa,MAA8B,CACzC,IAAM,EAAUA,EAAAA,uBAAuB,CACjC,CAAC,EAAoB,IAAA,EAAA,EAAA,UACG,EAAQ,mBAAmB,OAAS,EAAE,CAAC,CAYrE,OAVA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAW,GACf,EACG,EAAqC,QAAU,EAAE,CACnD,CAEH,OADA,EAAQ,mBAAmB,iBAAiB,SAAU,EAAQ,KAE5D,EAAQ,mBAAmB,oBAAoB,SAAU,EAAQ,EAClE,CAAC,EAAQ,CAAC,CAEN,CACL,qBACA,sBAAwB,GACtB,EAAQ,mBAAmB,IAAI,EAAM,CACvC,oBAAsB,GACpB,EAAQ,oBAAoB,EAAW,CAC1C,EAGU,MAAqC,CAChD,GAAM,CAAE,wBAAuB,uBAC7B,GAAuB,CACzB,MAAO,CAAE,wBAAuB,sBAAqB"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`);let t=require(`preact/hooks`);const n=()=>{let n=e.useEditorStateManager(),[r,i]=(0,t.useState)(n.editedContent.value);return(0,t.useEffect)(()=>{let e=e=>i(e.detail);return n.editedContent.addEventListener(`change`,e),()=>n.editedContent.removeEventListener(`change`,e)},[n]),{editedContent:r,setEditedContentState:e=>n.editedContent.set(e),setEditedDictionary:e=>n.setEditedDictionary(e),setEditedContent:(e,t)=>n.setEditedContent(e,t),addEditedContent:(e,t,r,i)=>n.addContent(e,t,r,i),renameEditedContent:(e,t,r)=>n.renameContent(e,t,r),removeEditedContent:(e,t)=>n.removeContent(e,t),restoreEditedContent:e=>n.restoreContent(e),clearEditedDictionaryContent:e=>n.clearContent(e),clearEditedContent:()=>n.clearAllContent(),getEditedContentValue:(e,t)=>n.getContentValue(e,t)}},r=()=>{let{editedContent:e,...t}=n();return t},i=()=>{let t=e.useEditorStateManager();return()=>t.messenger.send(`INTLAYER_EDITED_CONTENT_CHANGED/get`)},a=()=>{let t=e.useEditorStateManager();return()=>t.editedContent.postCurrentValue()};exports.useEditedContent=n,exports.useEditedContentActions=r,exports.useGetEditedContentState=i,exports.usePostEditedContentState=a;
2
- //# sourceMappingURL=EditedContentContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditedContentContext.cjs","names":["useEditorStateManager"],"sources":["../../../src/editor/EditedContentContext.tsx"],"sourcesContent":["import type { DictionaryContent } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport const useEditedContent = () => {\n const manager = useEditorStateManager();\n const [editedContent, setEditedContentState] = useState<\n DictionaryContent | undefined\n >(manager.editedContent.value);\n\n useEffect(() => {\n const handler = (e: Event) =>\n setEditedContentState((e as CustomEvent<DictionaryContent>).detail);\n manager.editedContent.addEventListener('change', handler);\n return () => manager.editedContent.removeEventListener('change', handler);\n }, [manager]);\n\n return {\n editedContent,\n setEditedContentState: (value: DictionaryContent) =>\n manager.editedContent.set(value),\n setEditedDictionary: (dict: Dictionary) =>\n manager.setEditedDictionary(dict),\n setEditedContent: (\n localId: LocalDictionaryId,\n value: Dictionary['content']\n ) => manager.setEditedContent(localId, value),\n addEditedContent: (\n localId: LocalDictionaryId,\n value: ContentNode,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => manager.addContent(localId, value, keyPath, overwrite),\n renameEditedContent: (\n localId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => manager.renameContent(localId, newKey, keyPath),\n removeEditedContent: (localId: LocalDictionaryId, keyPath: KeyPath[]) =>\n manager.removeContent(localId, keyPath),\n restoreEditedContent: (localId: LocalDictionaryId) =>\n manager.restoreContent(localId),\n clearEditedDictionaryContent: (localId: LocalDictionaryId) =>\n manager.clearContent(localId),\n clearEditedContent: () => manager.clearAllContent(),\n getEditedContentValue: (\n localIdOrKey: LocalDictionaryId | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined =>\n manager.getContentValue(localIdOrKey, keyPath),\n };\n};\n\nexport const useEditedContentActions = () => {\n const actions = useEditedContent();\n const { editedContent, ...rest } = actions;\n return rest;\n};\n\nexport const useGetEditedContentState = () => {\n const manager = useEditorStateManager();\n return () => manager.messenger.send('INTLAYER_EDITED_CONTENT_CHANGED/get');\n};\n\nexport const usePostEditedContentState = () => {\n const manager = useEditorStateManager();\n return () => manager.editedContent.postCurrentValue();\n};\n"],"mappings":"0LAUA,MAAa,MAAyB,CACpC,IAAM,EAAUA,EAAAA,uBAAuB,CACjC,CAAC,EAAe,IAAA,EAAA,EAAA,UAEpB,EAAQ,cAAc,MAAM,CAS9B,OAPA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAW,GACf,EAAuB,EAAqC,OAAO,CAErE,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN,CACL,gBACA,sBAAwB,GACtB,EAAQ,cAAc,IAAI,EAAM,CAClC,oBAAsB,GACpB,EAAQ,oBAAoB,EAAK,CACnC,kBACE,EACA,IACG,EAAQ,iBAAiB,EAAS,EAAM,CAC7C,kBACE,EACA,EACA,EACA,IACG,EAAQ,WAAW,EAAS,EAAO,EAAS,EAAU,CAC3D,qBACE,EACA,EACA,IACG,EAAQ,cAAc,EAAS,EAAQ,EAAQ,CACpD,qBAAsB,EAA4B,IAChD,EAAQ,cAAc,EAAS,EAAQ,CACzC,qBAAuB,GACrB,EAAQ,eAAe,EAAQ,CACjC,6BAA+B,GAC7B,EAAQ,aAAa,EAAQ,CAC/B,uBAA0B,EAAQ,iBAAiB,CACnD,uBACE,EACA,IAEA,EAAQ,gBAAgB,EAAc,EAAQ,CACjD,EAGU,MAAgC,CAE3C,GAAM,CAAE,gBAAe,GAAG,GADV,GAAkB,CAElC,OAAO,GAGI,MAAiC,CAC5C,IAAM,EAAUA,EAAAA,uBAAuB,CACvC,UAAa,EAAQ,UAAU,KAAK,sCAAsC,EAG/D,MAAkC,CAC7C,IAAM,EAAUA,EAAAA,uBAAuB,CACvC,UAAa,EAAQ,cAAc,kBAAkB"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`);let t=require(`@intlayer/editor`),n=require(`preact/hooks`);const r=()=>{let t=e.useEditorStateManager(),[r,i]=(0,n.useState)(t.editorEnabled.value??!1);return(0,n.useEffect)(()=>{let e=e=>i(e.detail);return t.editorEnabled.addEventListener(`change`,e),()=>t.editorEnabled.removeEventListener(`change`,e)},[t]),{enabled:r}},i=()=>{let{enabled:t}=r(),n=e.useEditorStateManager();return[t,e=>n.editorEnabled.set(e)]},a=()=>{let n=e.useEditorStateManager();return()=>{n.messenger.send(`${t.MessageKey.INTLAYER_EDITOR_ENABLED}/get`)}},o=()=>{let t=e.useEditorStateManager();return()=>t.editorEnabled.postCurrentValue()};exports.useEditorEnabled=r,exports.useEditorEnabledState=i,exports.useGetEditorEnabledState=a,exports.usePostEditorEnabledState=o;
2
- //# sourceMappingURL=EditorEnabledContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditorEnabledContext.cjs","names":["useEditorStateManager","MessageKey"],"sources":["../../../src/editor/EditorEnabledContext.tsx"],"sourcesContent":["import { MessageKey } from '@intlayer/editor';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type EditorEnabledStateProps = {\n enabled: boolean;\n};\n\nexport const useEditorEnabled = (): EditorEnabledStateProps => {\n const manager = useEditorStateManager();\n const [enabled, setEnabled] = useState<boolean>(\n manager.editorEnabled.value ?? false\n );\n\n useEffect(() => {\n const handler = (e: Event) =>\n setEnabled((e as CustomEvent<boolean>).detail);\n manager.editorEnabled.addEventListener('change', handler);\n return () => manager.editorEnabled.removeEventListener('change', handler);\n }, [manager]);\n\n return { enabled };\n};\n\nexport const useEditorEnabledState = () => {\n const { enabled } = useEditorEnabled();\n const manager = useEditorStateManager();\n return [\n enabled,\n (value: boolean) => manager.editorEnabled.set(value),\n ] as const;\n};\n\nexport const useGetEditorEnabledState = () => {\n const manager = useEditorStateManager();\n return () => {\n manager.messenger.send(`${MessageKey.INTLAYER_EDITOR_ENABLED}/get`);\n };\n};\n\nexport const usePostEditorEnabledState = () => {\n const manager = useEditorStateManager();\n return () => manager.editorEnabled.postCurrentValue();\n};\n"],"mappings":"wNAQA,MAAa,MAAkD,CAC7D,IAAM,EAAUA,EAAAA,uBAAuB,CACjC,CAAC,EAAS,IAAA,EAAA,EAAA,UACd,EAAQ,cAAc,OAAS,GAChC,CASD,OAPA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAW,GACf,EAAY,EAA2B,OAAO,CAEhD,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN,CAAE,UAAS,EAGP,MAA8B,CACzC,GAAM,CAAE,WAAY,GAAkB,CAChC,EAAUA,EAAAA,uBAAuB,CACvC,MAAO,CACL,EACC,GAAmB,EAAQ,cAAc,IAAI,EAAM,CACrD,EAGU,MAAiC,CAC5C,IAAM,EAAUA,EAAAA,uBAAuB,CACvC,UAAa,CACX,EAAQ,UAAU,KAAK,GAAGC,EAAAA,WAAW,wBAAwB,MAAM,GAI1D,MAAkC,CAC7C,IAAM,EAAUD,EAAAA,uBAAuB,CACvC,UAAa,EAAQ,cAAc,kBAAkB"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`preact`),t=require(`preact/hooks`),n=require(`preact/jsx-runtime`);const r=(0,e.createContext)(null),i=({manager:e,children:t})=>(0,n.jsx)(r.Provider,{value:e,children:t}),a=()=>{let e=(0,t.useContext)(r);if(!e)throw Error(`useEditorStateManager: no EditorStateProvider found`);return e};exports.EditorStateProvider=i,exports.useEditorStateManager=a;
2
- //# sourceMappingURL=EditorStateContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditorStateContext.cjs","names":[],"sources":["../../../src/editor/EditorStateContext.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport {\n type ComponentChildren,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\n\nconst EditorStateContext = createContext<EditorStateManager | null>(null);\n\nexport const EditorStateProvider: FunctionComponent<{\n manager: EditorStateManager;\n children?: ComponentChildren;\n}> = ({ manager, children }) => (\n <EditorStateContext.Provider value={manager}>\n {children}\n </EditorStateContext.Provider>\n);\n\nexport const useEditorStateManager = (): EditorStateManager => {\n const ctx = useContext(EditorStateContext);\n if (!ctx)\n throw new Error('useEditorStateManager: no EditorStateProvider found');\n return ctx;\n};\n"],"mappings":"kMAQA,MAAM,GAAA,EAAA,EAAA,eAA8D,KAAK,CAE5D,GAGP,CAAE,UAAS,eACf,EAAA,EAAA,KAAC,EAAmB,SAApB,CAA6B,MAAO,EACjC,WAC2B,CAAA,CAGnB,MAAkD,CAC7D,IAAM,GAAA,EAAA,EAAA,YAAiB,EAAmB,CAC1C,GAAI,CAAC,EACH,MAAU,MAAM,sDAAsD,CACxE,OAAO"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`);let t=require(`preact/hooks`);const n=()=>{let n=e.useEditorStateManager(),[r,i]=(0,t.useState)(n.focusedContent.value??null);return(0,t.useEffect)(()=>{let e=e=>i(e.detail);return n.focusedContent.addEventListener(`change`,e),()=>n.focusedContent.removeEventListener(`change`,e)},[n]),{focusedContent:r,setFocusedContent:e=>n.focusedContent.set(e),setFocusedContentKeyPath:e=>n.setFocusedContentKeyPath(e)}},r=()=>{let{setFocusedContent:e,setFocusedContentKeyPath:t}=n();return{setFocusedContent:e,setFocusedContentKeyPath:t}};exports.useFocusDictionary=n,exports.useFocusDictionaryActions=r;
2
- //# sourceMappingURL=FocusDictionaryContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FocusDictionaryContext.cjs","names":["useEditorStateManager"],"sources":["../../../src/editor/FocusDictionaryContext.tsx"],"sourcesContent":["import type { FileContent } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { FileContent };\n\nexport const useFocusDictionary = () => {\n const manager = useEditorStateManager();\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager.focusedContent.value ?? null\n );\n\n useEffect(() => {\n const handler = (e: Event) =>\n setFocusedContentState((e as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handler);\n return () => manager.focusedContent.removeEventListener('change', handler);\n }, [manager]);\n\n return {\n focusedContent,\n setFocusedContent: (value: FileContent | null) =>\n manager.focusedContent.set(value),\n setFocusedContentKeyPath: (keyPath: KeyPath[]) =>\n manager.setFocusedContentKeyPath(keyPath),\n };\n};\n\nexport const useFocusDictionaryActions = () => {\n const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n return { setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":"0LAOA,MAAa,MAA2B,CACtC,IAAM,EAAUA,EAAAA,uBAAuB,CACjC,CAAC,EAAgB,IAAA,EAAA,EAAA,UACrB,EAAQ,eAAe,OAAS,KACjC,CASD,OAPA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAW,GACf,EAAwB,EAAsC,OAAO,CAEvE,OADA,EAAQ,eAAe,iBAAiB,SAAU,EAAQ,KAC7C,EAAQ,eAAe,oBAAoB,SAAU,EAAQ,EACzE,CAAC,EAAQ,CAAC,CAEN,CACL,iBACA,kBAAoB,GAClB,EAAQ,eAAe,IAAI,EAAM,CACnC,yBAA2B,GACzB,EAAQ,yBAAyB,EAAQ,CAC5C,EAGU,MAAkC,CAC7C,GAAM,CAAE,oBAAmB,4BAA6B,GAAoB,CAC5E,MAAO,CAAE,oBAAmB,2BAA0B"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorProvider.cjs`);let t=require(`preact/jsx-runtime`);const n=({children:n})=>(0,t.jsx)(e.EditorProvider,{mode:`client`,children:n});exports.IntlayerEditorProvider=n;
2
- //# sourceMappingURL=IntlayerEditorProvider.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlayerEditorProvider.cjs","names":["EditorProvider"],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["import type { ComponentChildren, FunctionComponent } from 'preact';\nimport { EditorProvider } from './EditorProvider';\n\nexport const IntlayerEditorProvider: FunctionComponent<{\n children?: ComponentChildren;\n}> = ({ children }) => (\n <EditorProvider mode=\"client\">{children}</EditorProvider>\n);\n"],"mappings":"4LAGA,MAAa,GAEP,CAAE,eACN,EAAA,EAAA,KAACA,EAAAA,eAAD,CAAgB,KAAK,SAAU,WAA0B,CAAA"}
@@ -1 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./EditorStateContext.cjs`),t=require(`./ContentSelectorWrapper.cjs`);exports.ContentSelectorRenderer=t.ContentSelectorRenderer,exports.EditorStateProvider=e.EditorStateProvider,exports.useEditorStateManager=e.useEditorStateManager;
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`);let t=require(`preact/hooks`);const n=(n,r,i)=>{let a=e.useEditorStateManager();return(0,t.useEffect)(()=>{if(r)return a.messenger.subscribe(n,r)},[a,n,i]),e=>a.messenger.send(n,e)};exports.useCrossFrameMessageListener=n;
2
- //# sourceMappingURL=useCrossFrameMessageListener.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCrossFrameMessageListener.cjs","names":["useEditorStateManager"],"sources":["../../../src/editor/useCrossFrameMessageListener.tsx"],"sourcesContent":["import type { MessageKey } from '@intlayer/editor';\nimport { useEffect } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport const useCrossFrameMessageListener = <S,>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void,\n revalidator?: any\n) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!onEventTriggered) return;\n return manager.messenger.subscribe<S>(key, onEventTriggered);\n }, [manager, key, revalidator]);\n\n return (data?: S) => manager.messenger.send(key, data);\n};\n"],"mappings":"0LAIA,MAAa,GACX,EACA,EACA,IACG,CACH,IAAM,EAAUA,EAAAA,uBAAuB,CAOvC,OALA,EAAA,EAAA,eAAgB,CACT,KACL,OAAO,EAAQ,UAAU,UAAa,EAAK,EAAiB,EAC3D,CAAC,EAAS,EAAK,EAAY,CAAC,CAEvB,GAAa,EAAQ,UAAU,KAAK,EAAK,EAAK"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditorStateContext.cjs`);let t=require(`@intlayer/editor`),n=require(`preact/hooks`);const r=(r,i,a)=>{let o=e.useEditorStateManager(),s=typeof i==`function`?i():i,[c,l]=(0,n.useState)(s),u=(0,n.useRef)(null);return(0,n.useEffect)(()=>{let{emit:e=!0,receive:n=!0}=a??{},i=new t.CrossFrameStateManager(r,o.messenger,{emit:e,receive:n,initialValue:s});u.current=i;let c=e=>{l(e.detail)};return i.addEventListener(`change`,c),i.start(),()=>{i.removeEventListener(`change`,c),i.stop(),u.current=null}},[r,o.messenger,a?.emit,a?.receive]),[c,e=>{l(t=>{let n=typeof e==`function`?e(t):e;return u.current?.set(n),n})},()=>u.current?.postCurrentValue()]};exports.useCrossFrameState=r;
2
- //# sourceMappingURL=useCrossFrameState.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCrossFrameState.cjs","names":["useEditorStateManager","CrossFrameStateManager"],"sources":["../../../src/editor/useCrossFrameState.tsx"],"sourcesContent":["import { CrossFrameStateManager, type MessageKey } from '@intlayer/editor';\nimport {\n type Dispatch,\n type StateUpdater,\n useEffect,\n useRef,\n useState,\n} from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type CrossFrameStateOptions = {\n emit?: boolean;\n receive?: boolean;\n};\n\nexport type SetStateAction<S> = S | ((prevState: S) => S);\nexport type CrossFrameStateUpdater<S> = (value: SetStateAction<S>) => void;\n\nexport const useCrossFrameState = <S,>(\n key: `${MessageKey}`,\n initialState?: S | (() => S),\n options?: CrossFrameStateOptions\n): [S, CrossFrameStateUpdater<S>, () => void] => {\n const manager = useEditorStateManager();\n\n const resolvedInitial =\n typeof initialState === 'function'\n ? (initialState as () => S)()\n : initialState;\n\n const [value, setValueState] = useState<S>(resolvedInitial as S);\n const stateManagerRef = useRef<CrossFrameStateManager<S> | null>(null);\n\n useEffect(() => {\n const { emit = true, receive = true } = options ?? {};\n const stateManager = new CrossFrameStateManager<S>(key, manager.messenger, {\n emit,\n receive,\n initialValue: resolvedInitial,\n });\n stateManagerRef.current = stateManager;\n\n const handler = (e: Event) => {\n setValueState((e as CustomEvent<S>).detail);\n };\n stateManager.addEventListener('change', handler);\n stateManager.start();\n\n return () => {\n stateManager.removeEventListener('change', handler);\n stateManager.stop();\n stateManagerRef.current = null;\n };\n }, [key, manager.messenger, options?.emit, options?.receive]);\n\n const setValue: CrossFrameStateUpdater<S> = (valueOrUpdater) => {\n setValueState((prev) => {\n const newValue =\n typeof valueOrUpdater === 'function'\n ? (valueOrUpdater as (prev: S) => S)(prev)\n : valueOrUpdater;\n stateManagerRef.current?.set(newValue);\n return newValue;\n });\n };\n\n const postState = () => stateManagerRef.current?.postCurrentValue();\n\n return [value, setValue, postState];\n};\n"],"mappings":"wNAkBA,MAAa,GACX,EACA,EACA,IAC+C,CAC/C,IAAM,EAAUA,EAAAA,uBAAuB,CAEjC,EACJ,OAAO,GAAiB,WACnB,GAA0B,CAC3B,EAEA,CAAC,EAAO,IAAA,EAAA,EAAA,UAA6B,EAAqB,CAC1D,GAAA,EAAA,EAAA,QAA2D,KAAK,CAqCtE,OAnCA,EAAA,EAAA,eAAgB,CACd,GAAM,CAAE,OAAO,GAAM,UAAU,IAAS,GAAW,EAAE,CAC/C,EAAe,IAAIC,EAAAA,uBAA0B,EAAK,EAAQ,UAAW,CACzE,OACA,UACA,aAAc,EACf,CAAC,CACF,EAAgB,QAAU,EAE1B,IAAM,EAAW,GAAa,CAC5B,EAAe,EAAqB,OAAO,EAK7C,OAHA,EAAa,iBAAiB,SAAU,EAAQ,CAChD,EAAa,OAAO,KAEP,CACX,EAAa,oBAAoB,SAAU,EAAQ,CACnD,EAAa,MAAM,CACnB,EAAgB,QAAU,OAE3B,CAAC,EAAK,EAAQ,UAAW,GAAS,KAAM,GAAS,QAAQ,CAAC,CAetD,CAAC,EAbqC,GAAmB,CAC9D,EAAe,GAAS,CACtB,IAAM,EACJ,OAAO,GAAmB,WACrB,EAAkC,EAAK,CACxC,EAEN,OADA,EAAgB,SAAS,IAAI,EAAS,CAC/B,GACP,MAGoB,EAAgB,SAAS,kBAAkB,CAEhC"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=()=>{},t=()=>{};exports.useCrossURLPathSetter=e,exports.useCrossURLPathState=t;
2
- //# sourceMappingURL=useCrossURLPathState.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCrossURLPathState.cjs","names":[],"sources":["../../../src/editor/useCrossURLPathState.tsx"],"sourcesContent":["// UrlStateManager is started by EditorStateManager.start() in client mode.\n// Nothing extra needed here.\nexport const useCrossURLPathSetter = () => {\n // No-op: managed by EditorStateManager\n};\n\nexport const useCrossURLPathState = () => {\n // No-op: managed by EditorStateManager\n};\n"],"mappings":"mEAEA,MAAa,MAA8B,GAI9B,MAA6B"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./EditedContentContext.cjs`);let t=require(`@intlayer/core/interpreter`);const n=({dictionaryKey:t,keyPath:n,children:r})=>{let i=e.useEditedContentActions();return i?i.getEditedContentValue(t,n)??r:r},r=e=>{let r=n(e);if(typeof r==`object`){let n=(0,t.getContent)(r,{...e,locale:e.locale},(0,t.getBasePlugins)(e.locale));return typeof n==`string`?n:(console.error(`Incorrect edited content format. Content type: ${typeof n}. Expected string. Value ${JSON.stringify(n)}`),e.children)}return r};exports.EditedContentRenderer=r,exports.useEditedContentRenderer=n;
2
- //# sourceMappingURL=useEditedContentRenderer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useEditedContentRenderer.cjs","names":["useEditedContentActions"],"sources":["../../../src/editor/useEditedContentRenderer.tsx"],"sourcesContent":["import { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { FunctionalComponent } from 'preact';\nimport { useEditedContentActions } from './EditedContentContext';\n\ntype EditedContentRendererProps = {\n dictionaryKey: Dictionary['key'];\n keyPath: KeyPath[];\n children: string;\n locale?: Locale;\n};\n\nexport const useEditedContentRenderer = ({\n dictionaryKey,\n keyPath,\n children,\n}: EditedContentRendererProps) => {\n const editedContentContext = useEditedContentActions();\n\n if (editedContentContext) {\n const editedValue = editedContentContext.getEditedContentValue(\n dictionaryKey,\n keyPath\n ) as string;\n\n const value = editedValue ?? children;\n\n return value;\n }\n\n return children;\n};\n\nexport const EditedContentRenderer: FunctionalComponent<\n EditedContentRendererProps\n> = (props) => {\n const content = useEditedContentRenderer(props);\n\n if (typeof content === 'object') {\n const transformedEditedContent = getContent(\n content,\n { ...props, locale: props.locale },\n getBasePlugins(props.locale)\n );\n\n if (typeof transformedEditedContent !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformedEditedContent}. Expected string. Value ${JSON.stringify(transformedEditedContent)}`\n );\n\n return props.children;\n }\n\n return transformedEditedContent;\n }\n\n return content;\n};\n"],"mappings":"0MAcA,MAAa,GAA4B,CACvC,gBACA,UACA,cACgC,CAChC,IAAM,EAAuBA,EAAAA,yBAAyB,CAatD,OAXI,EACkB,EAAqB,sBACvC,EACA,EACD,EAE4B,EAKxB,GAGI,EAER,GAAU,CACb,IAAM,EAAU,EAAyB,EAAM,CAE/C,GAAI,OAAO,GAAY,SAAU,CAC/B,IAAM,GAAA,EAAA,EAAA,YACJ,EACA,CAAE,GAAG,EAAO,OAAQ,EAAM,OAAQ,EAAA,EAAA,EAAA,gBACnB,EAAM,OAAO,CAC7B,CAUD,OARI,OAAO,GAA6B,SAQjC,GAPL,QAAQ,MACN,kDAAkD,OAAO,EAAyB,2BAA2B,KAAK,UAAU,EAAyB,GACtJ,CAEM,EAAM,UAMjB,OAAO"}
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./useCrossFrameMessageListener.cjs`);let t=require(`@intlayer/editor`);const n=()=>{e.useCrossFrameMessageListener(t.MessageKey.INTLAYER_IFRAME_CLICKED)},r=()=>{e.useCrossFrameMessageListener(t.MessageKey.INTLAYER_IFRAME_CLICKED,t.mergeIframeClick)};exports.useIframeClickInterceptor=n,exports.useIframeClickMerger=r;
2
- //# sourceMappingURL=useIframeClickInterceptor.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIframeClickInterceptor.cjs","names":["MessageKey","mergeIframeClick"],"sources":["../../../src/editor/useIframeClickInterceptor.tsx"],"sourcesContent":["import { MessageKey, mergeIframeClick } from '@intlayer/editor';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\nexport const useIframeClickInterceptor = () => {\n useCrossFrameMessageListener<undefined>(MessageKey.INTLAYER_IFRAME_CLICKED);\n};\n\nexport const useIframeClickMerger = () => {\n useCrossFrameMessageListener<MessageEvent>(\n MessageKey.INTLAYER_IFRAME_CLICKED,\n mergeIframeClick\n );\n};\n"],"mappings":"wMAGA,MAAa,MAAkC,CAC7C,EAAA,6BAAwCA,EAAAA,WAAW,wBAAwB,EAGhE,MAA6B,CACxC,EAAA,6BACEA,EAAAA,WAAW,wBACXC,EAAAA,iBACD"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";const t=()=>{let t=e();return{postMessage:e=>t.messenger.send(e.type,e.data),senderId:t.messenger.senderId}};export{t as useCommunicator};
2
- //# sourceMappingURL=CommunicatorContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommunicatorContext.mjs","names":[],"sources":["../../../src/editor/CommunicatorContext.tsx"],"sourcesContent":["import { useEditorStateManager } from './EditorStateContext';\n\nexport const useCommunicator = () => {\n const manager = useEditorStateManager();\n return {\n postMessage: (data: any) => manager.messenger.send(data.type, data.data),\n senderId: manager.messenger.senderId,\n };\n};\n\n// Backward-compat types\nexport type CommunicatorProviderProps = {\n postMessage?: (data: any) => void;\n allowedOrigins?: string[];\n};\n"],"mappings":"iEAEA,MAAa,MAAwB,CACnC,IAAM,EAAU,GAAuB,CACvC,MAAO,CACL,YAAc,GAAc,EAAQ,UAAU,KAAK,EAAK,KAAM,EAAK,KAAK,CACxE,SAAU,EAAQ,UAAU,SAC7B"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"preact/hooks";const r=()=>{let r=e(),[i,a]=n(r.configuration.value);return t(()=>{let e=e=>a(e.detail);return r.configuration.addEventListener(`change`,e),()=>r.configuration.removeEventListener(`change`,e)},[r]),i};export{r as useConfiguration};
2
- //# sourceMappingURL=ConfigurationContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigurationContext.mjs","names":[],"sources":["../../../src/editor/ConfigurationContext.tsx"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport const useConfiguration = (): IntlayerConfig | undefined => {\n const manager = useEditorStateManager();\n const [config, setConfig] = useState<IntlayerConfig | undefined>(\n manager.configuration.value\n );\n\n useEffect(() => {\n const handler = (e: Event) =>\n setConfig((e as CustomEvent<IntlayerConfig>).detail);\n manager.configuration.addEventListener('change', handler);\n return () => manager.configuration.removeEventListener('change', handler);\n }, [manager]);\n\n return config;\n};\n\nexport type ConfigurationProviderProps = { configuration?: IntlayerConfig };\n"],"mappings":"wHAIA,MAAa,MAAqD,CAChE,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAQ,GAAa,EAC1B,EAAQ,cAAc,MACvB,CASD,OAPA,MAAgB,CACd,IAAM,EAAW,GACf,EAAW,EAAkC,OAAO,CAEtD,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEditorEnabled as t}from"./EditorEnabledContext.mjs";import{useIntlayerContext as n}from"../client/IntlayerProvider.mjs";import{useFocusDictionary as r}from"./FocusDictionaryContext.mjs";import{NodeType as i}from"@intlayer/types/nodeType";import{isSameKeyPath as a}from"@intlayer/core/utils";import{MessageKey as o,defineIntlayerElements as s}from"@intlayer/editor";import{useEffect as c,useRef as l}from"preact/hooks";import{jsx as u}from"preact/jsx-runtime";const d=({children:t,dictionaryKey:n,keyPath:s})=>{let{focusedContent:d,setFocusedContent:f}=r(),p=e(),m=l(null),h=s.filter(e=>e.type!==i.Translation),g=(d?.dictionaryKey===n&&(d?.keyPath?.length??0)>0&&a(d?.keyPath??[],h))??!1;return c(()=>{let e=m.current;if(!e)return;let t=()=>{f({dictionaryKey:n,keyPath:h})},r=()=>{p.messenger.send(`${o.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,{dictionaryKey:n,keyPath:h})},i=()=>{p.messenger.send(`${o.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,null)};return e.addEventListener(`intlayer:press`,t),e.addEventListener(`intlayer:hover`,r),e.addEventListener(`intlayer:unhover`,i),()=>{e.removeEventListener(`intlayer:press`,t),e.removeEventListener(`intlayer:hover`,r),e.removeEventListener(`intlayer:unhover`,i)}}),u(`intlayer-content-selector`,{ref:m,"is-selecting":g||void 0,children:t})},f=({children:e,...r})=>{let{enabled:i}=t(),{disableEditor:a}=n();return c(()=>{s()},[]),i&&!a?u(d,{...r,children:e}):e};export{f as ContentSelectorRenderer};
2
- //# sourceMappingURL=ContentSelectorWrapper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentSelectorWrapper.mjs","names":[],"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isSameKeyPath } from '@intlayer/core/utils';\nimport { defineIntlayerElements, MessageKey } from '@intlayer/editor';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type { FunctionalComponent, JSX } from 'preact';\nimport { useEffect, useRef } from 'preact/hooks';\nimport { useIntlayerContext } from '../client';\nimport { useEditorEnabled } from './EditorEnabledContext';\nimport { useEditorStateManager } from './EditorStateContext';\nimport { useFocusDictionary } from './FocusDictionaryContext';\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'>;\n\nconst ContentSelectorWrapperContent: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const manager = useEditorStateManager();\n const ref = useRef<HTMLElement>(null);\n\n const filteredKeyPath = keyPath.filter(\n (key) => key.type !== NodeType.Translation\n );\n\n const isSelected =\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], filteredKeyPath)) ??\n false;\n\n // Preact (like React 18) requires addEventListener for web component custom events\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const handlePress = () => {\n setFocusedContent({ dictionaryKey, keyPath: filteredKeyPath });\n };\n\n const handleHover = () => {\n manager.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n { dictionaryKey, keyPath: filteredKeyPath }\n );\n };\n\n const handleUnhover = () => {\n manager.messenger.send(\n `${MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,\n null\n );\n };\n\n el.addEventListener('intlayer:press', handlePress);\n el.addEventListener('intlayer:hover', handleHover);\n el.addEventListener('intlayer:unhover', handleUnhover);\n return () => {\n el.removeEventListener('intlayer:press', handlePress);\n el.removeEventListener('intlayer:hover', handleHover);\n el.removeEventListener('intlayer:unhover', handleUnhover);\n };\n });\n\n return (\n // @ts-ignore — custom element typing\n <intlayer-content-selector ref={ref} is-selecting={isSelected || undefined}>\n {children}\n </intlayer-content-selector>\n );\n};\n\nexport const ContentSelectorRenderer: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, ...props }) => {\n const { enabled } = useEditorEnabled();\n const { disableEditor } = useIntlayerContext();\n\n useEffect(() => {\n defineIntlayerElements();\n }, []);\n\n if (enabled && !disableEditor) {\n return (\n <ContentSelectorWrapperContent {...props}>\n {children}\n </ContentSelectorWrapperContent>\n );\n }\n\n return children;\n};\n"],"mappings":"shBAcA,MAAM,GAED,CAAE,WAAU,gBAAe,aAAc,CAC5C,GAAM,CAAE,iBAAgB,qBAAsB,GAAoB,CAC5D,EAAU,GAAuB,CACjC,EAAM,EAAoB,KAAK,CAE/B,EAAkB,EAAQ,OAC7B,GAAQ,EAAI,OAAS,EAAS,YAChC,CAEK,GACH,GAAgB,gBAAkB,IAChC,GAAgB,SAAS,QAAU,GAAK,GACzC,EAAc,GAAgB,SAAW,EAAE,CAAE,EAAgB,GAC/D,GAmCF,OAhCA,MAAgB,CACd,IAAM,EAAK,EAAI,QACf,GAAI,CAAC,EAAI,OAET,IAAM,MAAoB,CACxB,EAAkB,CAAE,gBAAe,QAAS,EAAiB,CAAC,EAG1D,MAAoB,CACxB,EAAQ,UAAU,KAChB,GAAG,EAAW,iCAAiC,OAC/C,CAAE,gBAAe,QAAS,EAAiB,CAC5C,EAGG,MAAsB,CAC1B,EAAQ,UAAU,KAChB,GAAG,EAAW,iCAAiC,OAC/C,KACD,EAMH,OAHA,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,iBAAkB,EAAY,CAClD,EAAG,iBAAiB,mBAAoB,EAAc,KACzC,CACX,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,iBAAkB,EAAY,CACrD,EAAG,oBAAoB,mBAAoB,EAAc,GAE3D,CAIA,EAAC,4BAAD,CAAgC,MAAK,eAAc,GAAc,IAAA,GAC9D,WACyB,CAAA,EAInB,GAER,CAAE,WAAU,GAAG,KAAY,CAC9B,GAAM,CAAE,WAAY,GAAkB,CAChC,CAAE,iBAAkB,GAAoB,CAc9C,OAZA,MAAgB,CACd,GAAwB,EACvB,EAAE,CAAC,CAEF,GAAW,CAAC,EAEZ,EAAC,EAAD,CAA+B,GAAI,EAChC,WAC6B,CAAA,CAI7B"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"preact/hooks";const r=()=>{let r=e(),[i,a]=n(r.localeDictionaries.value??{});return t(()=>{let e=e=>a(e.detail??{});return r.localeDictionaries.addEventListener(`change`,e),()=>r.localeDictionaries.removeEventListener(`change`,e)},[r]),{localeDictionaries:i,setLocaleDictionaries:e=>r.localeDictionaries.set(e),setLocaleDictionary:e=>r.setLocaleDictionary(e)}},i=()=>{let{setLocaleDictionaries:e,setLocaleDictionary:t}=r();return{setLocaleDictionaries:e,setLocaleDictionary:t}};export{r as useDictionariesRecord,i as useDictionariesRecordActions};
2
- //# sourceMappingURL=DictionariesRecordContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DictionariesRecordContext.mjs","names":[],"sources":["../../../src/editor/DictionariesRecordContext.tsx"],"sourcesContent":["import type { DictionaryContent } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { DictionaryContent };\n\nexport const useDictionariesRecord = () => {\n const manager = useEditorStateManager();\n const [localeDictionaries, setLocaleDictionariesState] =\n useState<DictionaryContent>(manager.localeDictionaries.value ?? {});\n\n useEffect(() => {\n const handler = (e: Event) =>\n setLocaleDictionariesState(\n (e as CustomEvent<DictionaryContent>).detail ?? {}\n );\n manager.localeDictionaries.addEventListener('change', handler);\n return () =>\n manager.localeDictionaries.removeEventListener('change', handler);\n }, [manager]);\n\n return {\n localeDictionaries,\n setLocaleDictionaries: (value: DictionaryContent) =>\n manager.localeDictionaries.set(value),\n setLocaleDictionary: (dictionary: Dictionary) =>\n manager.setLocaleDictionary(dictionary),\n };\n};\n\nexport const useDictionariesRecordActions = () => {\n const { setLocaleDictionaries, setLocaleDictionary } =\n useDictionariesRecord();\n return { setLocaleDictionaries, setLocaleDictionary };\n};\n"],"mappings":"wHAOA,MAAa,MAA8B,CACzC,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAoB,GACzB,EAA4B,EAAQ,mBAAmB,OAAS,EAAE,CAAC,CAYrE,OAVA,MAAgB,CACd,IAAM,EAAW,GACf,EACG,EAAqC,QAAU,EAAE,CACnD,CAEH,OADA,EAAQ,mBAAmB,iBAAiB,SAAU,EAAQ,KAE5D,EAAQ,mBAAmB,oBAAoB,SAAU,EAAQ,EAClE,CAAC,EAAQ,CAAC,CAEN,CACL,qBACA,sBAAwB,GACtB,EAAQ,mBAAmB,IAAI,EAAM,CACvC,oBAAsB,GACpB,EAAQ,oBAAoB,EAAW,CAC1C,EAGU,MAAqC,CAChD,GAAM,CAAE,wBAAuB,uBAC7B,GAAuB,CACzB,MAAO,CAAE,wBAAuB,sBAAqB"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"preact/hooks";const r=()=>{let r=e(),[i,a]=n(r.editedContent.value);return t(()=>{let e=e=>a(e.detail);return r.editedContent.addEventListener(`change`,e),()=>r.editedContent.removeEventListener(`change`,e)},[r]),{editedContent:i,setEditedContentState:e=>r.editedContent.set(e),setEditedDictionary:e=>r.setEditedDictionary(e),setEditedContent:(e,t)=>r.setEditedContent(e,t),addEditedContent:(e,t,n,i)=>r.addContent(e,t,n,i),renameEditedContent:(e,t,n)=>r.renameContent(e,t,n),removeEditedContent:(e,t)=>r.removeContent(e,t),restoreEditedContent:e=>r.restoreContent(e),clearEditedDictionaryContent:e=>r.clearContent(e),clearEditedContent:()=>r.clearAllContent(),getEditedContentValue:(e,t)=>r.getContentValue(e,t)}},i=()=>{let{editedContent:e,...t}=r();return t},a=()=>{let t=e();return()=>t.messenger.send(`INTLAYER_EDITED_CONTENT_CHANGED/get`)},o=()=>{let t=e();return()=>t.editedContent.postCurrentValue()};export{r as useEditedContent,i as useEditedContentActions,a as useGetEditedContentState,o as usePostEditedContentState};
2
- //# sourceMappingURL=EditedContentContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditedContentContext.mjs","names":[],"sources":["../../../src/editor/EditedContentContext.tsx"],"sourcesContent":["import type { DictionaryContent } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport const useEditedContent = () => {\n const manager = useEditorStateManager();\n const [editedContent, setEditedContentState] = useState<\n DictionaryContent | undefined\n >(manager.editedContent.value);\n\n useEffect(() => {\n const handler = (e: Event) =>\n setEditedContentState((e as CustomEvent<DictionaryContent>).detail);\n manager.editedContent.addEventListener('change', handler);\n return () => manager.editedContent.removeEventListener('change', handler);\n }, [manager]);\n\n return {\n editedContent,\n setEditedContentState: (value: DictionaryContent) =>\n manager.editedContent.set(value),\n setEditedDictionary: (dict: Dictionary) =>\n manager.setEditedDictionary(dict),\n setEditedContent: (\n localId: LocalDictionaryId,\n value: Dictionary['content']\n ) => manager.setEditedContent(localId, value),\n addEditedContent: (\n localId: LocalDictionaryId,\n value: ContentNode,\n keyPath?: KeyPath[],\n overwrite?: boolean\n ) => manager.addContent(localId, value, keyPath, overwrite),\n renameEditedContent: (\n localId: LocalDictionaryId,\n newKey: KeyPath['key'],\n keyPath?: KeyPath[]\n ) => manager.renameContent(localId, newKey, keyPath),\n removeEditedContent: (localId: LocalDictionaryId, keyPath: KeyPath[]) =>\n manager.removeContent(localId, keyPath),\n restoreEditedContent: (localId: LocalDictionaryId) =>\n manager.restoreContent(localId),\n clearEditedDictionaryContent: (localId: LocalDictionaryId) =>\n manager.clearContent(localId),\n clearEditedContent: () => manager.clearAllContent(),\n getEditedContentValue: (\n localIdOrKey: LocalDictionaryId | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined =>\n manager.getContentValue(localIdOrKey, keyPath),\n };\n};\n\nexport const useEditedContentActions = () => {\n const actions = useEditedContent();\n const { editedContent, ...rest } = actions;\n return rest;\n};\n\nexport const useGetEditedContentState = () => {\n const manager = useEditorStateManager();\n return () => manager.messenger.send('INTLAYER_EDITED_CONTENT_CHANGED/get');\n};\n\nexport const usePostEditedContentState = () => {\n const manager = useEditorStateManager();\n return () => manager.editedContent.postCurrentValue();\n};\n"],"mappings":"wHAUA,MAAa,MAAyB,CACpC,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAe,GAAyB,EAE7C,EAAQ,cAAc,MAAM,CAS9B,OAPA,MAAgB,CACd,IAAM,EAAW,GACf,EAAuB,EAAqC,OAAO,CAErE,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN,CACL,gBACA,sBAAwB,GACtB,EAAQ,cAAc,IAAI,EAAM,CAClC,oBAAsB,GACpB,EAAQ,oBAAoB,EAAK,CACnC,kBACE,EACA,IACG,EAAQ,iBAAiB,EAAS,EAAM,CAC7C,kBACE,EACA,EACA,EACA,IACG,EAAQ,WAAW,EAAS,EAAO,EAAS,EAAU,CAC3D,qBACE,EACA,EACA,IACG,EAAQ,cAAc,EAAS,EAAQ,EAAQ,CACpD,qBAAsB,EAA4B,IAChD,EAAQ,cAAc,EAAS,EAAQ,CACzC,qBAAuB,GACrB,EAAQ,eAAe,EAAQ,CACjC,6BAA+B,GAC7B,EAAQ,aAAa,EAAQ,CAC/B,uBAA0B,EAAQ,iBAAiB,CACnD,uBACE,EACA,IAEA,EAAQ,gBAAgB,EAAc,EAAQ,CACjD,EAGU,MAAgC,CAE3C,GAAM,CAAE,gBAAe,GAAG,GADV,GAAkB,CAElC,OAAO,GAGI,MAAiC,CAC5C,IAAM,EAAU,GAAuB,CACvC,UAAa,EAAQ,UAAU,KAAK,sCAAsC,EAG/D,MAAkC,CAC7C,IAAM,EAAU,GAAuB,CACvC,UAAa,EAAQ,cAAc,kBAAkB"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{MessageKey as t}from"@intlayer/editor";import{useEffect as n,useState as r}from"preact/hooks";const i=()=>{let t=e(),[i,a]=r(t.editorEnabled.value??!1);return n(()=>{let e=e=>a(e.detail);return t.editorEnabled.addEventListener(`change`,e),()=>t.editorEnabled.removeEventListener(`change`,e)},[t]),{enabled:i}},a=()=>{let{enabled:t}=i(),n=e();return[t,e=>n.editorEnabled.set(e)]},o=()=>{let n=e();return()=>{n.messenger.send(`${t.INTLAYER_EDITOR_ENABLED}/get`)}},s=()=>{let t=e();return()=>t.editorEnabled.postCurrentValue()};export{i as useEditorEnabled,a as useEditorEnabledState,o as useGetEditorEnabledState,s as usePostEditorEnabledState};
2
- //# sourceMappingURL=EditorEnabledContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditorEnabledContext.mjs","names":[],"sources":["../../../src/editor/EditorEnabledContext.tsx"],"sourcesContent":["import { MessageKey } from '@intlayer/editor';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type EditorEnabledStateProps = {\n enabled: boolean;\n};\n\nexport const useEditorEnabled = (): EditorEnabledStateProps => {\n const manager = useEditorStateManager();\n const [enabled, setEnabled] = useState<boolean>(\n manager.editorEnabled.value ?? false\n );\n\n useEffect(() => {\n const handler = (e: Event) =>\n setEnabled((e as CustomEvent<boolean>).detail);\n manager.editorEnabled.addEventListener('change', handler);\n return () => manager.editorEnabled.removeEventListener('change', handler);\n }, [manager]);\n\n return { enabled };\n};\n\nexport const useEditorEnabledState = () => {\n const { enabled } = useEditorEnabled();\n const manager = useEditorStateManager();\n return [\n enabled,\n (value: boolean) => manager.editorEnabled.set(value),\n ] as const;\n};\n\nexport const useGetEditorEnabledState = () => {\n const manager = useEditorStateManager();\n return () => {\n manager.messenger.send(`${MessageKey.INTLAYER_EDITOR_ENABLED}/get`);\n };\n};\n\nexport const usePostEditorEnabledState = () => {\n const manager = useEditorStateManager();\n return () => manager.editorEnabled.postCurrentValue();\n};\n"],"mappings":"sKAQA,MAAa,MAAkD,CAC7D,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAS,GAAc,EAC5B,EAAQ,cAAc,OAAS,GAChC,CASD,OAPA,MAAgB,CACd,IAAM,EAAW,GACf,EAAY,EAA2B,OAAO,CAEhD,OADA,EAAQ,cAAc,iBAAiB,SAAU,EAAQ,KAC5C,EAAQ,cAAc,oBAAoB,SAAU,EAAQ,EACxE,CAAC,EAAQ,CAAC,CAEN,CAAE,UAAS,EAGP,MAA8B,CACzC,GAAM,CAAE,WAAY,GAAkB,CAChC,EAAU,GAAuB,CACvC,MAAO,CACL,EACC,GAAmB,EAAQ,cAAc,IAAI,EAAM,CACrD,EAGU,MAAiC,CAC5C,IAAM,EAAU,GAAuB,CACvC,UAAa,CACX,EAAQ,UAAU,KAAK,GAAG,EAAW,wBAAwB,MAAM,GAI1D,MAAkC,CAC7C,IAAM,EAAU,GAAuB,CACvC,UAAa,EAAQ,cAAc,kBAAkB"}
@@ -1,2 +0,0 @@
1
- import{createContext as e}from"preact";import{useContext as t}from"preact/hooks";import{jsx as n}from"preact/jsx-runtime";const r=e(null),i=({manager:e,children:t})=>n(r.Provider,{value:e,children:t}),a=()=>{let e=t(r);if(!e)throw Error(`useEditorStateManager: no EditorStateProvider found`);return e};export{i as EditorStateProvider,a as useEditorStateManager};
2
- //# sourceMappingURL=EditorStateContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditorStateContext.mjs","names":[],"sources":["../../../src/editor/EditorStateContext.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport {\n type ComponentChildren,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\n\nconst EditorStateContext = createContext<EditorStateManager | null>(null);\n\nexport const EditorStateProvider: FunctionComponent<{\n manager: EditorStateManager;\n children?: ComponentChildren;\n}> = ({ manager, children }) => (\n <EditorStateContext.Provider value={manager}>\n {children}\n </EditorStateContext.Provider>\n);\n\nexport const useEditorStateManager = (): EditorStateManager => {\n const ctx = useContext(EditorStateContext);\n if (!ctx)\n throw new Error('useEditorStateManager: no EditorStateProvider found');\n return ctx;\n};\n"],"mappings":"0HAQA,MAAM,EAAqB,EAAyC,KAAK,CAE5D,GAGP,CAAE,UAAS,cACf,EAAC,EAAmB,SAApB,CAA6B,MAAO,EACjC,WAC2B,CAAA,CAGnB,MAAkD,CAC7D,IAAM,EAAM,EAAW,EAAmB,CAC1C,GAAI,CAAC,EACH,MAAU,MAAM,sDAAsD,CACxE,OAAO"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t,useState as n}from"preact/hooks";const r=()=>{let r=e(),[i,a]=n(r.focusedContent.value??null);return t(()=>{let e=e=>a(e.detail);return r.focusedContent.addEventListener(`change`,e),()=>r.focusedContent.removeEventListener(`change`,e)},[r]),{focusedContent:i,setFocusedContent:e=>r.focusedContent.set(e),setFocusedContentKeyPath:e=>r.setFocusedContentKeyPath(e)}},i=()=>{let{setFocusedContent:e,setFocusedContentKeyPath:t}=r();return{setFocusedContent:e,setFocusedContentKeyPath:t}};export{r as useFocusDictionary,i as useFocusDictionaryActions};
2
- //# sourceMappingURL=FocusDictionaryContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FocusDictionaryContext.mjs","names":[],"sources":["../../../src/editor/FocusDictionaryContext.tsx"],"sourcesContent":["import type { FileContent } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { useEffect, useState } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport type { FileContent };\n\nexport const useFocusDictionary = () => {\n const manager = useEditorStateManager();\n const [focusedContent, setFocusedContentState] = useState<FileContent | null>(\n manager.focusedContent.value ?? null\n );\n\n useEffect(() => {\n const handler = (e: Event) =>\n setFocusedContentState((e as CustomEvent<FileContent | null>).detail);\n manager.focusedContent.addEventListener('change', handler);\n return () => manager.focusedContent.removeEventListener('change', handler);\n }, [manager]);\n\n return {\n focusedContent,\n setFocusedContent: (value: FileContent | null) =>\n manager.focusedContent.set(value),\n setFocusedContentKeyPath: (keyPath: KeyPath[]) =>\n manager.setFocusedContentKeyPath(keyPath),\n };\n};\n\nexport const useFocusDictionaryActions = () => {\n const { setFocusedContent, setFocusedContentKeyPath } = useFocusDictionary();\n return { setFocusedContent, setFocusedContentKeyPath };\n};\n"],"mappings":"wHAOA,MAAa,MAA2B,CACtC,IAAM,EAAU,GAAuB,CACjC,CAAC,EAAgB,GAA0B,EAC/C,EAAQ,eAAe,OAAS,KACjC,CASD,OAPA,MAAgB,CACd,IAAM,EAAW,GACf,EAAwB,EAAsC,OAAO,CAEvE,OADA,EAAQ,eAAe,iBAAiB,SAAU,EAAQ,KAC7C,EAAQ,eAAe,oBAAoB,SAAU,EAAQ,EACzE,CAAC,EAAQ,CAAC,CAEN,CACL,iBACA,kBAAoB,GAClB,EAAQ,eAAe,IAAI,EAAM,CACnC,yBAA2B,GACzB,EAAQ,yBAAyB,EAAQ,CAC5C,EAGU,MAAkC,CAC7C,GAAM,CAAE,oBAAmB,4BAA6B,GAAoB,CAC5E,MAAO,CAAE,oBAAmB,2BAA0B"}
@@ -1,2 +0,0 @@
1
- import{EditorProvider as e}from"./EditorProvider.mjs";import{jsx as t}from"preact/jsx-runtime";const n=({children:n})=>t(e,{mode:`client`,children:n});export{n as IntlayerEditorProvider};
2
- //# sourceMappingURL=IntlayerEditorProvider.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlayerEditorProvider.mjs","names":[],"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["import type { ComponentChildren, FunctionComponent } from 'preact';\nimport { EditorProvider } from './EditorProvider';\n\nexport const IntlayerEditorProvider: FunctionComponent<{\n children?: ComponentChildren;\n}> = ({ children }) => (\n <EditorProvider mode=\"client\">{children}</EditorProvider>\n);\n"],"mappings":"+FAGA,MAAa,GAEP,CAAE,cACN,EAAC,EAAD,CAAgB,KAAK,SAAU,WAA0B,CAAA"}
@@ -1 +0,0 @@
1
- import{EditorStateProvider as e,useEditorStateManager as t}from"./EditorStateContext.mjs";import{ContentSelectorRenderer as n}from"./ContentSelectorWrapper.mjs";export{n as ContentSelectorRenderer,e as EditorStateProvider,t as useEditorStateManager};
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{useEffect as t}from"preact/hooks";const n=(n,r,i)=>{let a=e();return t(()=>{if(r)return a.messenger.subscribe(n,r)},[a,n,i]),e=>a.messenger.send(n,e)};export{n as useCrossFrameMessageListener};
2
- //# sourceMappingURL=useCrossFrameMessageListener.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCrossFrameMessageListener.mjs","names":[],"sources":["../../../src/editor/useCrossFrameMessageListener.tsx"],"sourcesContent":["import type { MessageKey } from '@intlayer/editor';\nimport { useEffect } from 'preact/hooks';\nimport { useEditorStateManager } from './EditorStateContext';\n\nexport const useCrossFrameMessageListener = <S,>(\n key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`,\n onEventTriggered?: (data: S) => void,\n revalidator?: any\n) => {\n const manager = useEditorStateManager();\n\n useEffect(() => {\n if (!onEventTriggered) return;\n return manager.messenger.subscribe<S>(key, onEventTriggered);\n }, [manager, key, revalidator]);\n\n return (data?: S) => manager.messenger.send(key, data);\n};\n"],"mappings":"0GAIA,MAAa,GACX,EACA,EACA,IACG,CACH,IAAM,EAAU,GAAuB,CAOvC,OALA,MAAgB,CACT,KACL,OAAO,EAAQ,UAAU,UAAa,EAAK,EAAiB,EAC3D,CAAC,EAAS,EAAK,EAAY,CAAC,CAEvB,GAAa,EAAQ,UAAU,KAAK,EAAK,EAAK"}
@@ -1,2 +0,0 @@
1
- import{useEditorStateManager as e}from"./EditorStateContext.mjs";import{CrossFrameStateManager as t}from"@intlayer/editor";import{useEffect as n,useRef as r,useState as i}from"preact/hooks";const a=(a,o,s)=>{let c=e(),l=typeof o==`function`?o():o,[u,d]=i(l),f=r(null);return n(()=>{let{emit:e=!0,receive:n=!0}=s??{},r=new t(a,c.messenger,{emit:e,receive:n,initialValue:l});f.current=r;let i=e=>{d(e.detail)};return r.addEventListener(`change`,i),r.start(),()=>{r.removeEventListener(`change`,i),r.stop(),f.current=null}},[a,c.messenger,s?.emit,s?.receive]),[u,e=>{d(t=>{let n=typeof e==`function`?e(t):e;return f.current?.set(n),n})},()=>f.current?.postCurrentValue()]};export{a as useCrossFrameState};
2
- //# sourceMappingURL=useCrossFrameState.mjs.map