@intlayer/editor 9.8.4 → 9.9.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.
- package/README.md +1 -0
- package/dist/cjs/core/editedContentSource.cjs +67 -0
- package/dist/cjs/core/editedContentSource.cjs.map +1 -0
- package/dist/cjs/core/index.cjs +4 -1
- package/dist/cjs/index.cjs +4 -1
- package/dist/esm/core/editedContentSource.mjs +63 -0
- package/dist/esm/core/editedContentSource.mjs.map +1 -0
- package/dist/esm/core/index.mjs +2 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/types/core/editedContentSource.d.ts +17 -0
- package/dist/types/core/editedContentSource.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -190,6 +190,7 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
|
|
|
190
190
|
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React using Compiler</a></li>
|
|
191
191
|
<li><a href="https://intlayer.org/doc/environment/vite-and-react/react-router-v7" rel=''>React-router-v7</a></li>
|
|
192
192
|
<li><a href="https://intlayer.org/doc/environment/remix-3" rel=''>Remix 3</a></li>
|
|
193
|
+
<li><a href="https://intlayer.org/doc/environment/vinext" rel=''>vinext (Next.js on Vite)</a></li>
|
|
193
194
|
<li><a href="https://intlayer.org/doc/environment/tanstack-start" rel=''>Tanstack start</a>
|
|
194
195
|
<ul>
|
|
195
196
|
<li><a href="https://intlayer.org/doc/environment/tanstack-start/solid" rel=''>Solid</a></li>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_core_globalManager = require("./globalManager.cjs");
|
|
4
|
+
let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
|
|
5
|
+
_intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType);
|
|
6
|
+
|
|
7
|
+
// src/core/editedContentSource.ts
|
|
8
|
+
/**
|
|
9
|
+
* Unwraps an edited node down to its raw source string: translation → locale
|
|
10
|
+
* entry, markdown / html → inner node, file → loaded content.
|
|
11
|
+
*/
|
|
12
|
+
const resolveEditedSource = (node, locale) => {
|
|
13
|
+
let currentNode = node;
|
|
14
|
+
while (currentNode && typeof currentNode === "object") {
|
|
15
|
+
const sourceNode = currentNode;
|
|
16
|
+
if (sourceNode.nodeType === _intlayer_types_nodeType.TRANSLATION) {
|
|
17
|
+
const translations = sourceNode[_intlayer_types_nodeType.TRANSLATION];
|
|
18
|
+
currentNode = locale ? translations?.[locale] : void 0;
|
|
19
|
+
} else if (sourceNode.nodeType === _intlayer_types_nodeType.MARKDOWN || sourceNode.nodeType === _intlayer_types_nodeType.HTML) currentNode = sourceNode[sourceNode.nodeType];
|
|
20
|
+
else if (sourceNode.nodeType === _intlayer_types_nodeType.FILE) currentNode = sourceNode.content;
|
|
21
|
+
else return;
|
|
22
|
+
}
|
|
23
|
+
return typeof currentNode === "string" ? currentNode : void 0;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Subscribes to the source string edited in the visual editor for a markdown /
|
|
27
|
+
* html node. `onChange` receives `undefined` when the node is not edited.
|
|
28
|
+
*
|
|
29
|
+
* The selector wrapper only substitutes plain strings: nodes that need
|
|
30
|
+
* framework rendering (markdown, html) re-render from this source instead.
|
|
31
|
+
* Follows editor manager restarts. Returns an unsubscribe function.
|
|
32
|
+
*/
|
|
33
|
+
const subscribeToEditedContentSource = (dictionaryKey, keyPath, onChange) => {
|
|
34
|
+
let lastSource;
|
|
35
|
+
let unsubscribeManagerState = null;
|
|
36
|
+
const emit = (editedSource) => {
|
|
37
|
+
if (editedSource === lastSource) return;
|
|
38
|
+
lastSource = editedSource;
|
|
39
|
+
onChange(editedSource);
|
|
40
|
+
};
|
|
41
|
+
const subscribeToManager = (manager) => {
|
|
42
|
+
unsubscribeManagerState?.();
|
|
43
|
+
unsubscribeManagerState = null;
|
|
44
|
+
if (!manager) {
|
|
45
|
+
emit(void 0);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const updateEditedSource = () => emit(resolveEditedSource(manager.getContentValue(dictionaryKey, keyPath), manager.currentLocale.value));
|
|
49
|
+
updateEditedSource();
|
|
50
|
+
manager.editedContent.addEventListener("change", updateEditedSource);
|
|
51
|
+
manager.currentLocale.addEventListener("change", updateEditedSource);
|
|
52
|
+
unsubscribeManagerState = () => {
|
|
53
|
+
manager.editedContent.removeEventListener("change", updateEditedSource);
|
|
54
|
+
manager.currentLocale.removeEventListener("change", updateEditedSource);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
subscribeToManager(require_core_globalManager.getGlobalEditorManager());
|
|
58
|
+
const unsubscribeManagerChange = require_core_globalManager.onGlobalEditorManagerChange(subscribeToManager);
|
|
59
|
+
return () => {
|
|
60
|
+
unsubscribeManagerChange();
|
|
61
|
+
unsubscribeManagerState?.();
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.resolveEditedSource = resolveEditedSource;
|
|
66
|
+
exports.subscribeToEditedContentSource = subscribeToEditedContentSource;
|
|
67
|
+
//# sourceMappingURL=editedContentSource.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editedContentSource.cjs","names":["NodeTypes","getGlobalEditorManager","onGlobalEditorManagerChange"],"sources":["../../../src/core/editedContentSource.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type { EditorStateManager } from './EditorStateManager';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from './globalManager';\n\ntype SourceNode = {\n nodeType?: unknown;\n content?: unknown;\n [key: string]: unknown;\n};\n\n/**\n * Unwraps an edited node down to its raw source string: translation → locale\n * entry, markdown / html → inner node, file → loaded content.\n */\nexport const resolveEditedSource = (\n node: ContentNode | undefined,\n locale: string | undefined\n): string | undefined => {\n let currentNode: unknown = node;\n\n while (currentNode && typeof currentNode === 'object') {\n const sourceNode = currentNode as SourceNode;\n\n if (sourceNode.nodeType === NodeTypes.TRANSLATION) {\n const translations = sourceNode[NodeTypes.TRANSLATION] as\n | Record<string, unknown>\n | undefined;\n currentNode = locale ? translations?.[locale] : undefined;\n } else if (\n sourceNode.nodeType === NodeTypes.MARKDOWN ||\n sourceNode.nodeType === NodeTypes.HTML\n ) {\n currentNode = sourceNode[sourceNode.nodeType];\n } else if (sourceNode.nodeType === NodeTypes.FILE) {\n currentNode = sourceNode.content;\n } else {\n return undefined;\n }\n }\n\n return typeof currentNode === 'string' ? currentNode : undefined;\n};\n\n/**\n * Subscribes to the source string edited in the visual editor for a markdown /\n * html node. `onChange` receives `undefined` when the node is not edited.\n *\n * The selector wrapper only substitutes plain strings: nodes that need\n * framework rendering (markdown, html) re-render from this source instead.\n * Follows editor manager restarts. Returns an unsubscribe function.\n */\nexport const subscribeToEditedContentSource = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n onChange: (editedSource: string | undefined) => void\n): (() => void) => {\n let lastSource: string | undefined;\n let unsubscribeManagerState: (() => void) | null = null;\n\n const emit = (editedSource: string | undefined) => {\n if (editedSource === lastSource) return;\n lastSource = editedSource;\n onChange(editedSource);\n };\n\n const subscribeToManager = (manager: EditorStateManager | null) => {\n unsubscribeManagerState?.();\n unsubscribeManagerState = null;\n\n if (!manager) {\n emit(undefined);\n return;\n }\n\n const updateEditedSource = () =>\n emit(\n resolveEditedSource(\n manager.getContentValue(dictionaryKey, keyPath),\n manager.currentLocale.value as string | undefined\n )\n );\n\n updateEditedSource();\n manager.editedContent.addEventListener('change', updateEditedSource);\n manager.currentLocale.addEventListener('change', updateEditedSource);\n\n unsubscribeManagerState = () => {\n manager.editedContent.removeEventListener('change', updateEditedSource);\n manager.currentLocale.removeEventListener('change', updateEditedSource);\n };\n };\n\n subscribeToManager(getGlobalEditorManager());\n const unsubscribeManagerChange =\n onGlobalEditorManagerChange(subscribeToManager);\n\n return () => {\n unsubscribeManagerChange();\n unsubscribeManagerState?.();\n };\n};\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,uBACX,MACA,WACuB;CACvB,IAAI,cAAuB;CAE3B,OAAO,eAAe,OAAO,gBAAgB,UAAU;EACrD,MAAM,aAAa;EAEnB,IAAI,WAAW,aAAaA,yBAAU,aAAa;GACjD,MAAM,eAAe,WAAWA,yBAAU;GAG1C,cAAc,SAAS,eAAe,UAAU;EAClD,OAAO,IACL,WAAW,aAAaA,yBAAU,YAClC,WAAW,aAAaA,yBAAU,MAElC,cAAc,WAAW,WAAW;OAC/B,IAAI,WAAW,aAAaA,yBAAU,MAC3C,cAAc,WAAW;OAEzB;CAEJ;CAEA,OAAO,OAAO,gBAAgB,WAAW,cAAc;AACzD;;;;;;;;;AAUA,MAAa,kCACX,eACA,SACA,aACiB;CACjB,IAAI;CACJ,IAAI,0BAA+C;CAEnD,MAAM,QAAQ,iBAAqC;EACjD,IAAI,iBAAiB,YAAY;EACjC,aAAa;EACb,SAAS,YAAY;CACvB;CAEA,MAAM,sBAAsB,YAAuC;EACjE,0BAA0B;EAC1B,0BAA0B;EAE1B,IAAI,CAAC,SAAS;GACZ,KAAK,MAAS;GACd;EACF;EAEA,MAAM,2BACJ,KACE,oBACE,QAAQ,gBAAgB,eAAe,OAAO,GAC9C,QAAQ,cAAc,KACxB,CACF;EAEF,mBAAmB;EACnB,QAAQ,cAAc,iBAAiB,UAAU,kBAAkB;EACnE,QAAQ,cAAc,iBAAiB,UAAU,kBAAkB;EAEnE,gCAAgC;GAC9B,QAAQ,cAAc,oBAAoB,UAAU,kBAAkB;GACtE,QAAQ,cAAc,oBAAoB,UAAU,kBAAkB;EACxE;CACF;CAEA,mBAAmBC,kDAAuB,CAAC;CAC3C,MAAM,2BACJC,uDAA4B,kBAAkB;CAEhD,aAAa;EACX,yBAAyB;EACzB,0BAA0B;CAC5B;AACF"}
|
package/dist/cjs/core/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_core_CrossFrameMessenger = require("./CrossFrameMessenger.cjs");
|
|
3
3
|
const require_core_CrossFrameStateManager = require("./CrossFrameStateManager.cjs");
|
|
4
4
|
const require_core_EditorStateManager = require("./EditorStateManager.cjs");
|
|
5
|
+
const require_core_editedContentSource = require("./editedContentSource.cjs");
|
|
5
6
|
const require_core_globalManager = require("./globalManager.cjs");
|
|
6
7
|
const require_core_IframeClickInterceptor = require("./IframeClickInterceptor.cjs");
|
|
7
8
|
const require_core_initEditorClient = require("./initEditorClient.cjs");
|
|
@@ -19,5 +20,7 @@ exports.createSharedWindowState = require_core_sharedWindowState.createSharedWin
|
|
|
19
20
|
exports.getGlobalEditorManager = require_core_globalManager.getGlobalEditorManager;
|
|
20
21
|
exports.initEditorClient = require_core_initEditorClient.initEditorClient;
|
|
21
22
|
exports.onGlobalEditorManagerChange = require_core_globalManager.onGlobalEditorManagerChange;
|
|
23
|
+
exports.resolveEditedSource = require_core_editedContentSource.resolveEditedSource;
|
|
22
24
|
exports.setGlobalEditorManager = require_core_globalManager.setGlobalEditorManager;
|
|
23
|
-
exports.stopEditorClient = require_core_initEditorClient.stopEditorClient;
|
|
25
|
+
exports.stopEditorClient = require_core_initEditorClient.stopEditorClient;
|
|
26
|
+
exports.subscribeToEditedContentSource = require_core_editedContentSource.subscribeToEditedContentSource;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const require_core_IframeClickInterceptor = require("./core/IframeClickIntercept
|
|
|
9
9
|
const require_core_sharedWindowState = require("./core/sharedWindowState.cjs");
|
|
10
10
|
const require_core_UrlStateManager = require("./core/UrlStateManager.cjs");
|
|
11
11
|
const require_core_EditorStateManager = require("./core/EditorStateManager.cjs");
|
|
12
|
+
const require_core_editedContentSource = require("./core/editedContentSource.cjs");
|
|
12
13
|
const require_core_initEditorClient = require("./core/initEditorClient.cjs");
|
|
13
14
|
|
|
14
15
|
exports.CLIENT_HEARTBEAT_INTERVAL_MS = require_core_EditorStateManager.CLIENT_HEARTBEAT_INTERVAL_MS;
|
|
@@ -27,5 +28,7 @@ exports.defineIntlayerElements = require_components_ContentSelector.defineIntlay
|
|
|
27
28
|
exports.getGlobalEditorManager = require_core_globalManager.getGlobalEditorManager;
|
|
28
29
|
exports.initEditorClient = require_core_initEditorClient.initEditorClient;
|
|
29
30
|
exports.onGlobalEditorManagerChange = require_core_globalManager.onGlobalEditorManagerChange;
|
|
31
|
+
exports.resolveEditedSource = require_core_editedContentSource.resolveEditedSource;
|
|
30
32
|
exports.setGlobalEditorManager = require_core_globalManager.setGlobalEditorManager;
|
|
31
|
-
exports.stopEditorClient = require_core_initEditorClient.stopEditorClient;
|
|
33
|
+
exports.stopEditorClient = require_core_initEditorClient.stopEditorClient;
|
|
34
|
+
exports.subscribeToEditedContentSource = require_core_editedContentSource.subscribeToEditedContentSource;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getGlobalEditorManager, onGlobalEditorManagerChange } from "./globalManager.mjs";
|
|
2
|
+
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
3
|
+
|
|
4
|
+
// src/core/editedContentSource.ts
|
|
5
|
+
/**
|
|
6
|
+
* Unwraps an edited node down to its raw source string: translation → locale
|
|
7
|
+
* entry, markdown / html → inner node, file → loaded content.
|
|
8
|
+
*/
|
|
9
|
+
const resolveEditedSource = (node, locale) => {
|
|
10
|
+
let currentNode = node;
|
|
11
|
+
while (currentNode && typeof currentNode === "object") {
|
|
12
|
+
const sourceNode = currentNode;
|
|
13
|
+
if (sourceNode.nodeType === NodeTypes.TRANSLATION) {
|
|
14
|
+
const translations = sourceNode[NodeTypes.TRANSLATION];
|
|
15
|
+
currentNode = locale ? translations?.[locale] : void 0;
|
|
16
|
+
} else if (sourceNode.nodeType === NodeTypes.MARKDOWN || sourceNode.nodeType === NodeTypes.HTML) currentNode = sourceNode[sourceNode.nodeType];
|
|
17
|
+
else if (sourceNode.nodeType === NodeTypes.FILE) currentNode = sourceNode.content;
|
|
18
|
+
else return;
|
|
19
|
+
}
|
|
20
|
+
return typeof currentNode === "string" ? currentNode : void 0;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Subscribes to the source string edited in the visual editor for a markdown /
|
|
24
|
+
* html node. `onChange` receives `undefined` when the node is not edited.
|
|
25
|
+
*
|
|
26
|
+
* The selector wrapper only substitutes plain strings: nodes that need
|
|
27
|
+
* framework rendering (markdown, html) re-render from this source instead.
|
|
28
|
+
* Follows editor manager restarts. Returns an unsubscribe function.
|
|
29
|
+
*/
|
|
30
|
+
const subscribeToEditedContentSource = (dictionaryKey, keyPath, onChange) => {
|
|
31
|
+
let lastSource;
|
|
32
|
+
let unsubscribeManagerState = null;
|
|
33
|
+
const emit = (editedSource) => {
|
|
34
|
+
if (editedSource === lastSource) return;
|
|
35
|
+
lastSource = editedSource;
|
|
36
|
+
onChange(editedSource);
|
|
37
|
+
};
|
|
38
|
+
const subscribeToManager = (manager) => {
|
|
39
|
+
unsubscribeManagerState?.();
|
|
40
|
+
unsubscribeManagerState = null;
|
|
41
|
+
if (!manager) {
|
|
42
|
+
emit(void 0);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const updateEditedSource = () => emit(resolveEditedSource(manager.getContentValue(dictionaryKey, keyPath), manager.currentLocale.value));
|
|
46
|
+
updateEditedSource();
|
|
47
|
+
manager.editedContent.addEventListener("change", updateEditedSource);
|
|
48
|
+
manager.currentLocale.addEventListener("change", updateEditedSource);
|
|
49
|
+
unsubscribeManagerState = () => {
|
|
50
|
+
manager.editedContent.removeEventListener("change", updateEditedSource);
|
|
51
|
+
manager.currentLocale.removeEventListener("change", updateEditedSource);
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
subscribeToManager(getGlobalEditorManager());
|
|
55
|
+
const unsubscribeManagerChange = onGlobalEditorManagerChange(subscribeToManager);
|
|
56
|
+
return () => {
|
|
57
|
+
unsubscribeManagerChange();
|
|
58
|
+
unsubscribeManagerState?.();
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { resolveEditedSource, subscribeToEditedContentSource };
|
|
63
|
+
//# sourceMappingURL=editedContentSource.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editedContentSource.mjs","names":[],"sources":["../../../src/core/editedContentSource.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type { EditorStateManager } from './EditorStateManager';\nimport {\n getGlobalEditorManager,\n onGlobalEditorManagerChange,\n} from './globalManager';\n\ntype SourceNode = {\n nodeType?: unknown;\n content?: unknown;\n [key: string]: unknown;\n};\n\n/**\n * Unwraps an edited node down to its raw source string: translation → locale\n * entry, markdown / html → inner node, file → loaded content.\n */\nexport const resolveEditedSource = (\n node: ContentNode | undefined,\n locale: string | undefined\n): string | undefined => {\n let currentNode: unknown = node;\n\n while (currentNode && typeof currentNode === 'object') {\n const sourceNode = currentNode as SourceNode;\n\n if (sourceNode.nodeType === NodeTypes.TRANSLATION) {\n const translations = sourceNode[NodeTypes.TRANSLATION] as\n | Record<string, unknown>\n | undefined;\n currentNode = locale ? translations?.[locale] : undefined;\n } else if (\n sourceNode.nodeType === NodeTypes.MARKDOWN ||\n sourceNode.nodeType === NodeTypes.HTML\n ) {\n currentNode = sourceNode[sourceNode.nodeType];\n } else if (sourceNode.nodeType === NodeTypes.FILE) {\n currentNode = sourceNode.content;\n } else {\n return undefined;\n }\n }\n\n return typeof currentNode === 'string' ? currentNode : undefined;\n};\n\n/**\n * Subscribes to the source string edited in the visual editor for a markdown /\n * html node. `onChange` receives `undefined` when the node is not edited.\n *\n * The selector wrapper only substitutes plain strings: nodes that need\n * framework rendering (markdown, html) re-render from this source instead.\n * Follows editor manager restarts. Returns an unsubscribe function.\n */\nexport const subscribeToEditedContentSource = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n onChange: (editedSource: string | undefined) => void\n): (() => void) => {\n let lastSource: string | undefined;\n let unsubscribeManagerState: (() => void) | null = null;\n\n const emit = (editedSource: string | undefined) => {\n if (editedSource === lastSource) return;\n lastSource = editedSource;\n onChange(editedSource);\n };\n\n const subscribeToManager = (manager: EditorStateManager | null) => {\n unsubscribeManagerState?.();\n unsubscribeManagerState = null;\n\n if (!manager) {\n emit(undefined);\n return;\n }\n\n const updateEditedSource = () =>\n emit(\n resolveEditedSource(\n manager.getContentValue(dictionaryKey, keyPath),\n manager.currentLocale.value as string | undefined\n )\n );\n\n updateEditedSource();\n manager.editedContent.addEventListener('change', updateEditedSource);\n manager.currentLocale.addEventListener('change', updateEditedSource);\n\n unsubscribeManagerState = () => {\n manager.editedContent.removeEventListener('change', updateEditedSource);\n manager.currentLocale.removeEventListener('change', updateEditedSource);\n };\n };\n\n subscribeToManager(getGlobalEditorManager());\n const unsubscribeManagerChange =\n onGlobalEditorManagerChange(subscribeToManager);\n\n return () => {\n unsubscribeManagerChange();\n unsubscribeManagerState?.();\n };\n};\n"],"mappings":";;;;;;;;AAmBA,MAAa,uBACX,MACA,WACuB;CACvB,IAAI,cAAuB;CAE3B,OAAO,eAAe,OAAO,gBAAgB,UAAU;EACrD,MAAM,aAAa;EAEnB,IAAI,WAAW,aAAa,UAAU,aAAa;GACjD,MAAM,eAAe,WAAW,UAAU;GAG1C,cAAc,SAAS,eAAe,UAAU;EAClD,OAAO,IACL,WAAW,aAAa,UAAU,YAClC,WAAW,aAAa,UAAU,MAElC,cAAc,WAAW,WAAW;OAC/B,IAAI,WAAW,aAAa,UAAU,MAC3C,cAAc,WAAW;OAEzB;CAEJ;CAEA,OAAO,OAAO,gBAAgB,WAAW,cAAc;AACzD;;;;;;;;;AAUA,MAAa,kCACX,eACA,SACA,aACiB;CACjB,IAAI;CACJ,IAAI,0BAA+C;CAEnD,MAAM,QAAQ,iBAAqC;EACjD,IAAI,iBAAiB,YAAY;EACjC,aAAa;EACb,SAAS,YAAY;CACvB;CAEA,MAAM,sBAAsB,YAAuC;EACjE,0BAA0B;EAC1B,0BAA0B;EAE1B,IAAI,CAAC,SAAS;GACZ,KAAK,MAAS;GACd;EACF;EAEA,MAAM,2BACJ,KACE,oBACE,QAAQ,gBAAgB,eAAe,OAAO,GAC9C,QAAQ,cAAc,KACxB,CACF;EAEF,mBAAmB;EACnB,QAAQ,cAAc,iBAAiB,UAAU,kBAAkB;EACnE,QAAQ,cAAc,iBAAiB,UAAU,kBAAkB;EAEnE,gCAAgC;GAC9B,QAAQ,cAAc,oBAAoB,UAAU,kBAAkB;GACtE,QAAQ,cAAc,oBAAoB,UAAU,kBAAkB;EACxE;CACF;CAEA,mBAAmB,uBAAuB,CAAC;CAC3C,MAAM,2BACJ,4BAA4B,kBAAkB;CAEhD,aAAa;EACX,yBAAyB;EACzB,0BAA0B;CAC5B;AACF"}
|
package/dist/esm/core/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CrossFrameMessenger } from "./CrossFrameMessenger.mjs";
|
|
2
2
|
import { CrossFrameStateManager } from "./CrossFrameStateManager.mjs";
|
|
3
3
|
import { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, EditorStateManager } from "./EditorStateManager.mjs";
|
|
4
|
+
import { resolveEditedSource, subscribeToEditedContentSource } from "./editedContentSource.mjs";
|
|
4
5
|
import { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager } from "./globalManager.mjs";
|
|
5
6
|
import { IframeClickInterceptor } from "./IframeClickInterceptor.mjs";
|
|
6
7
|
import { initEditorClient, stopEditorClient } from "./initEditorClient.mjs";
|
|
7
8
|
import { createSharedWindowState } from "./sharedWindowState.mjs";
|
|
8
9
|
import { UrlStateManager } from "./UrlStateManager.mjs";
|
|
9
10
|
|
|
10
|
-
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, CrossFrameMessenger, CrossFrameStateManager, EditorStateManager, IframeClickInterceptor, UrlStateManager, createSharedWindowState, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, setGlobalEditorManager, stopEditorClient };
|
|
11
|
+
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, CrossFrameMessenger, CrossFrameStateManager, EditorStateManager, IframeClickInterceptor, UrlStateManager, createSharedWindowState, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, resolveEditedSource, setGlobalEditorManager, stopEditorClient, subscribeToEditedContentSource };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { IframeClickInterceptor } from "./core/IframeClickInterceptor.mjs";
|
|
|
8
8
|
import { createSharedWindowState } from "./core/sharedWindowState.mjs";
|
|
9
9
|
import { UrlStateManager } from "./core/UrlStateManager.mjs";
|
|
10
10
|
import { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, EditorStateManager } from "./core/EditorStateManager.mjs";
|
|
11
|
+
import { resolveEditedSource, subscribeToEditedContentSource } from "./core/editedContentSource.mjs";
|
|
11
12
|
import { initEditorClient, stopEditorClient } from "./core/initEditorClient.mjs";
|
|
12
13
|
|
|
13
|
-
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, CrossFrameMessenger, CrossFrameStateManager, EditorStateManager, IframeClickInterceptor, IntlayerContentSelectorElement, IntlayerContentSelectorWrapperElement, MessageKey, UrlStateManager, createSharedWindowState, defineIntlayerContentSelectorWrapper, defineIntlayerElements, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, setGlobalEditorManager, stopEditorClient };
|
|
14
|
+
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, CrossFrameMessenger, CrossFrameStateManager, EditorStateManager, IframeClickInterceptor, IntlayerContentSelectorElement, IntlayerContentSelectorWrapperElement, MessageKey, UrlStateManager, createSharedWindowState, defineIntlayerContentSelectorWrapper, defineIntlayerElements, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, resolveEditedSource, setGlobalEditorManager, stopEditorClient, subscribeToEditedContentSource };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { KeyPath } from "@intlayer/types/keyPath";
|
|
2
|
+
import { ContentNode } from "@intlayer/types/dictionary";
|
|
3
|
+
/**
|
|
4
|
+
* Unwraps an edited node down to its raw source string: translation → locale
|
|
5
|
+
* entry, markdown / html → inner node, file → loaded content.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolveEditedSource: (node: ContentNode | undefined, locale: string | undefined) => string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Subscribes to the source string edited in the visual editor for a markdown /
|
|
10
|
+
* html node. `onChange` receives `undefined` when the node is not edited.
|
|
11
|
+
*
|
|
12
|
+
* The selector wrapper only substitutes plain strings: nodes that need
|
|
13
|
+
* framework rendering (markdown, html) re-render from this source instead.
|
|
14
|
+
* Follows editor manager restarts. Returns an unsubscribe function.
|
|
15
|
+
*/
|
|
16
|
+
export declare const subscribeToEditedContentSource: (dictionaryKey: string, keyPath: KeyPath[], onChange: (editedSource: string | undefined) => void) => (() => void);
|
|
17
|
+
//# sourceMappingURL=editedContentSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editedContentSource.d.ts","names":[],"sources":["../../../src/core/editedContentSource.ts"],"mappings":";;;;;;qBAmBa,sBAAmB,MACxB,yBAAuB;;;;;;;;;qBAoClB,iCAA8B,uBACpB,SACZ,WAAS,WACP"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CrossFrameMessenger, MessagePayload, MessengerConfig } from "./CrossFrameMessenger.js";
|
|
2
2
|
import { CrossFrameStateAction, CrossFrameStateManager, CrossFrameStateOptions } from "./CrossFrameStateManager.js";
|
|
3
3
|
import { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, ClientReadyPayload, DictionaryContent, EditorStateManager, EditorStateManagerConfig, FileContent } from "./EditorStateManager.js";
|
|
4
|
+
import { resolveEditedSource, subscribeToEditedContentSource } from "./editedContentSource.js";
|
|
4
5
|
import { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager } from "./globalManager.js";
|
|
5
6
|
import { IframeClickInterceptor } from "./IframeClickInterceptor.js";
|
|
6
7
|
import { initEditorClient, stopEditorClient } from "./initEditorClient.js";
|
|
7
8
|
import { SharedWindowState, createSharedWindowState } from "./sharedWindowState.js";
|
|
8
9
|
import { UrlStateManager } from "./UrlStateManager.js";
|
|
9
|
-
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, ClientReadyPayload, CrossFrameMessenger, CrossFrameStateAction, CrossFrameStateManager, CrossFrameStateOptions, DictionaryContent, EditorStateManager, EditorStateManagerConfig, FileContent, IframeClickInterceptor, MessagePayload, MessengerConfig, SharedWindowState, UrlStateManager, createSharedWindowState, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, setGlobalEditorManager, stopEditorClient };
|
|
10
|
+
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, ClientReadyPayload, CrossFrameMessenger, CrossFrameStateAction, CrossFrameStateManager, CrossFrameStateOptions, DictionaryContent, EditorStateManager, EditorStateManagerConfig, FileContent, IframeClickInterceptor, MessagePayload, MessengerConfig, SharedWindowState, UrlStateManager, createSharedWindowState, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, resolveEditedSource, setGlobalEditorManager, stopEditorClient, subscribeToEditedContentSource };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import "./components/index.js";
|
|
|
4
4
|
import { CrossFrameMessenger, MessagePayload, MessengerConfig } from "./core/CrossFrameMessenger.js";
|
|
5
5
|
import { CrossFrameStateAction, CrossFrameStateManager, CrossFrameStateOptions } from "./core/CrossFrameStateManager.js";
|
|
6
6
|
import { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, ClientReadyPayload, DictionaryContent, EditorStateManager, EditorStateManagerConfig, FileContent } from "./core/EditorStateManager.js";
|
|
7
|
+
import { resolveEditedSource, subscribeToEditedContentSource } from "./core/editedContentSource.js";
|
|
7
8
|
import { getGlobalEditorManager, onGlobalEditorManagerChange, setGlobalEditorManager } from "./core/globalManager.js";
|
|
8
9
|
import { IframeClickInterceptor } from "./core/IframeClickInterceptor.js";
|
|
9
10
|
import { initEditorClient, stopEditorClient } from "./core/initEditorClient.js";
|
|
@@ -11,4 +12,4 @@ import { SharedWindowState, createSharedWindowState } from "./core/sharedWindowS
|
|
|
11
12
|
import { UrlStateManager } from "./core/UrlStateManager.js";
|
|
12
13
|
import "./core/index.js";
|
|
13
14
|
import { MessageKey } from "./messageKey.js";
|
|
14
|
-
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, ClientReadyPayload, CrossFrameMessenger, CrossFrameStateAction, CrossFrameStateManager, CrossFrameStateOptions, DictionaryContent, EditorStateManager, EditorStateManagerConfig, FileContent, IframeClickInterceptor, IntlayerContentSelectorElement, IntlayerContentSelectorWrapperElement, MessageKey, MessagePayload, MessengerConfig, SharedWindowState, UrlStateManager, createSharedWindowState, defineIntlayerContentSelectorWrapper, defineIntlayerElements, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, setGlobalEditorManager, stopEditorClient };
|
|
15
|
+
export { CLIENT_HEARTBEAT_INTERVAL_MS, CLIENT_HEARTBEAT_TIMEOUT_MS, ClientReadyPayload, CrossFrameMessenger, CrossFrameStateAction, CrossFrameStateManager, CrossFrameStateOptions, DictionaryContent, EditorStateManager, EditorStateManagerConfig, FileContent, IframeClickInterceptor, IntlayerContentSelectorElement, IntlayerContentSelectorWrapperElement, MessageKey, MessagePayload, MessengerConfig, SharedWindowState, UrlStateManager, createSharedWindowState, defineIntlayerContentSelectorWrapper, defineIntlayerElements, getGlobalEditorManager, initEditorClient, onGlobalEditorManagerChange, resolveEditedSource, setGlobalEditorManager, stopEditorClient, subscribeToEditedContentSource };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/editor",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides the utilities to interface the application with the Intlayer editor and manipulate dictionaries",
|
|
6
6
|
"keywords": [
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@intlayer/config": "9.
|
|
80
|
-
"@intlayer/core": "9.
|
|
81
|
-
"@intlayer/dictionaries-entry": "9.
|
|
82
|
-
"@intlayer/types": "9.
|
|
79
|
+
"@intlayer/config": "9.9.0",
|
|
80
|
+
"@intlayer/core": "9.9.0",
|
|
81
|
+
"@intlayer/dictionaries-entry": "9.9.0",
|
|
82
|
+
"@intlayer/types": "9.9.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/node": "^26",
|