svelte-intlayer 8.5.2 → 8.6.1
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/dist/IntlayerNodeWrapper.svelte +2 -3
- package/dist/client/useLocaleStorage.js +3 -3
- package/dist/format/useNumber.d.ts +1 -1
- package/dist/format/usePercentage.d.ts +1 -1
- package/dist/html/index.d.ts +1 -1
- package/dist/html/index.js +39 -1
- package/dist/plugins.d.ts +3 -0
- package/dist/plugins.js +181 -233
- package/package.json +9 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { localeStorageOptions } from '@intlayer/core/localization';
|
|
2
|
-
import {
|
|
2
|
+
import { getLocaleFromStorageClient, LocaleStorageClient, setLocaleInStorageClient as setLocaleInStorageCore, } from '@intlayer/core/utils';
|
|
3
3
|
import { readable } from 'svelte/store';
|
|
4
4
|
/**
|
|
5
5
|
* Get the locale cookie
|
|
6
6
|
*/
|
|
7
|
-
export const localeInStorage =
|
|
7
|
+
export const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);
|
|
8
8
|
/**
|
|
9
9
|
* @deprecated Use localeInStorage instead
|
|
10
10
|
*
|
|
@@ -28,7 +28,7 @@ export const setLocaleCookie = setLocaleInStorage;
|
|
|
28
28
|
* Composable that provides the locale storage and a function to set it
|
|
29
29
|
*/
|
|
30
30
|
export const useLocaleStorage = (isCookieEnabled) => {
|
|
31
|
-
const storage =
|
|
31
|
+
const storage = LocaleStorageClient({
|
|
32
32
|
...localeStorageOptions,
|
|
33
33
|
isCookieEnabled,
|
|
34
34
|
});
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* @returns {import('svelte/store').Readable<(...args: Parameters<typeof number>) => string>}
|
|
5
5
|
* A store containing a number formatting function bound to the active locale.
|
|
6
6
|
*/
|
|
7
|
-
export declare const useNumber: () => import("svelte/store").Readable<(value: string | number,
|
|
7
|
+
export declare const useNumber: () => import("svelte/store").Readable<(value: string | number, args_1?: (Intl.NumberFormatOptions & {
|
|
8
8
|
locale?: import("@intlayer/types/module_augmentation").LocalesValues;
|
|
9
9
|
}) | undefined) => string>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const usePercentage: () => import("svelte/store").Readable<(value: string | number,
|
|
1
|
+
export declare const usePercentage: () => import("svelte/store").Readable<(value: string | number, args_1?: (Intl.NumberFormatOptions & {
|
|
2
2
|
locale?: import("@intlayer/types/module_augmentation").LocalesValues;
|
|
3
3
|
}) | undefined) => string>;
|
package/dist/html/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RenderHTMLOptions } from './context';
|
|
2
|
-
export { getHTMLContext, type
|
|
2
|
+
export { getHTMLContext, type RenderHTMLOptions, setHTMLContext, setHTMLContext as setIntlayerHTML, } from './context';
|
|
3
3
|
export { default as HTMLProvider } from './HTMLProvider.svelte';
|
|
4
4
|
export { default as HTMLRenderer } from './HTMLRenderer.svelte';
|
|
5
5
|
export type RenderHTMLProps = RenderHTMLOptions;
|
package/dist/html/index.js
CHANGED
|
@@ -4,7 +4,45 @@ export { getHTMLContext, setHTMLContext, setHTMLContext as setIntlayerHTML, } fr
|
|
|
4
4
|
export { default as HTMLProvider } from './HTMLProvider.svelte';
|
|
5
5
|
export { default as HTMLRenderer } from './HTMLRenderer.svelte';
|
|
6
6
|
export const renderHTML = (html, options = {}) => {
|
|
7
|
-
|
|
7
|
+
const components = options.components || {};
|
|
8
|
+
// Proxy handles standard HTML tags lazily without a hardcoded list
|
|
9
|
+
const wrappedComponents = new Proxy(components, {
|
|
10
|
+
get(target, prop) {
|
|
11
|
+
if (typeof prop === 'string' && prop in target) {
|
|
12
|
+
return target[prop];
|
|
13
|
+
}
|
|
14
|
+
// Fallback: Lazily generate a wrapper for standard lowercase HTML tags
|
|
15
|
+
if (typeof prop === 'string' &&
|
|
16
|
+
/^[a-z][a-z0-9]*$/.test(prop) &&
|
|
17
|
+
typeof document !== 'undefined') {
|
|
18
|
+
return ({ children = [], ...props }) => {
|
|
19
|
+
const element = document.createElement(prop);
|
|
20
|
+
// Apply props as attributes
|
|
21
|
+
for (const [key, value] of Object.entries(props)) {
|
|
22
|
+
if (key.startsWith('on') && typeof value === 'function') {
|
|
23
|
+
const eventName = key.slice(2).toLowerCase();
|
|
24
|
+
element.addEventListener(eventName, value);
|
|
25
|
+
}
|
|
26
|
+
else if (value !== undefined && value !== null) {
|
|
27
|
+
element.setAttribute(key, String(value));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Append children
|
|
31
|
+
for (const child of children) {
|
|
32
|
+
if (typeof child === 'string') {
|
|
33
|
+
element.appendChild(document.createTextNode(child));
|
|
34
|
+
}
|
|
35
|
+
else if (child instanceof Node) {
|
|
36
|
+
element.appendChild(child);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return element;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return getHTML(html, wrappedComponents);
|
|
8
46
|
};
|
|
9
47
|
export const useHTMLRenderer = (options = {}) => {
|
|
10
48
|
const context = getHTMLContext();
|
package/dist/plugins.d.ts
CHANGED
|
@@ -60,6 +60,9 @@ export type MarkdownCond<T, _S, L extends LocalesValues> = T extends {
|
|
|
60
60
|
metadata: DeepTransformContent<U, L>;
|
|
61
61
|
} & any : never;
|
|
62
62
|
export declare const markdownPlugin: Plugins;
|
|
63
|
+
/** ---------------------------------------------
|
|
64
|
+
* HTML PLUGIN
|
|
65
|
+
* --------------------------------------------- */
|
|
63
66
|
export type HTMLPluginCond<T> = T extends {
|
|
64
67
|
nodeType: NodeType | string;
|
|
65
68
|
[NodeTypes.HTML]: infer I;
|
package/dist/plugins.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import configuration from '@intlayer/config/built';
|
|
2
|
-
import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin,
|
|
3
|
-
import { HTML_TAGS, } from '@intlayer/core/transpiler';
|
|
4
|
-
import { isEnabled } from '@intlayer/editor/isEnabled';
|
|
2
|
+
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, translationPlugin, } from '@intlayer/core/interpreter';
|
|
5
3
|
import * as NodeTypes from '@intlayer/types/nodeType';
|
|
6
4
|
import { default as ContentSelector } from './editor/ContentSelector.svelte';
|
|
5
|
+
import { HTMLRenderer } from './html/index';
|
|
7
6
|
import { renderIntlayerNode } from './renderIntlayerNode';
|
|
8
7
|
// Lazy pre-load heavy modules — creates separate code-split chunks
|
|
9
8
|
let _getMarkdownMetadata = null;
|
|
@@ -28,17 +27,21 @@ void Promise.all([
|
|
|
28
27
|
* Basic Intlayer node plugins for content handling
|
|
29
28
|
* These handle the core content transformation logic
|
|
30
29
|
*/
|
|
31
|
-
export const intlayerNodePlugins =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
typeof node === '
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
export const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === 'false'
|
|
31
|
+
? fallbackPlugin
|
|
32
|
+
: {
|
|
33
|
+
id: 'intlayer-node-plugin',
|
|
34
|
+
canHandle: (node) => typeof node === 'bigint' ||
|
|
35
|
+
typeof node === 'string' ||
|
|
36
|
+
typeof node === 'number',
|
|
37
|
+
transform: (node, { children, ...rest }) => renderIntlayerNode({
|
|
38
|
+
value: children ?? node,
|
|
39
|
+
component: configuration.editor.enabled
|
|
40
|
+
? ContentSelector
|
|
41
|
+
: undefined,
|
|
42
|
+
props: rest,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
42
45
|
/**
|
|
43
46
|
* Svelte-specific node plugins for handling basic content types
|
|
44
47
|
* These plugins handle strings, numbers, and bigints in Svelte applications
|
|
@@ -94,234 +97,179 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
94
97
|
return parts;
|
|
95
98
|
};
|
|
96
99
|
/** Insertion plugin for Svelte. Handles component insertion. */
|
|
97
|
-
export const insertionPlugin =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
plugins: [
|
|
117
|
-
...(props.plugins ?? []).filter((plugin) => plugin.id !== 'intlayer-node-plugin'),
|
|
118
|
-
],
|
|
119
|
-
});
|
|
120
|
-
return (values) => {
|
|
121
|
-
const result = splitAndJoinInsertion(transformedResult, values);
|
|
122
|
-
return deepTransformNode(result, {
|
|
100
|
+
export const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'
|
|
101
|
+
? fallbackPlugin
|
|
102
|
+
: {
|
|
103
|
+
id: 'insertion-plugin',
|
|
104
|
+
canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,
|
|
105
|
+
transform: (node, props, deepTransformNode) => {
|
|
106
|
+
const newKeyPath = [
|
|
107
|
+
...props.keyPath,
|
|
108
|
+
{
|
|
109
|
+
type: NodeTypes.INSERTION,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
const children = node[NodeTypes.INSERTION];
|
|
113
|
+
/** Insertion string plugin. Replaces string node with a component that render the insertion. */
|
|
114
|
+
const insertionStringPlugin = {
|
|
115
|
+
id: 'insertion-string-plugin',
|
|
116
|
+
canHandle: (node) => typeof node === 'string',
|
|
117
|
+
transform: (node, subProps, deepTransformNode) => {
|
|
118
|
+
const transformedResult = deepTransformNode(node, {
|
|
123
119
|
...subProps,
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
children: node,
|
|
121
|
+
plugins: [
|
|
122
|
+
...(props.plugins ?? []).filter((plugin) => plugin.id !== 'intlayer-node-plugin'),
|
|
123
|
+
],
|
|
126
124
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
});
|
|
136
|
-
if (typeof children === 'object' &&
|
|
137
|
-
children !== null &&
|
|
138
|
-
'nodeType' in children &&
|
|
139
|
-
[NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(children.nodeType)) {
|
|
140
|
-
return (values) => (arg) => {
|
|
141
|
-
const func = result;
|
|
142
|
-
const inner = func(arg);
|
|
143
|
-
if (typeof inner === 'function') {
|
|
144
|
-
return inner(values);
|
|
145
|
-
}
|
|
146
|
-
return inner;
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
return result;
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
153
|
-
export const markdownStringPlugin = {
|
|
154
|
-
id: 'markdown-string-plugin',
|
|
155
|
-
canHandle: (node) => typeof node === 'string',
|
|
156
|
-
transform: (node, props, deepTransformNode) => {
|
|
157
|
-
const { ...rest } = props;
|
|
158
|
-
const metadata = _getMarkdownMetadata?.(node) ?? {};
|
|
159
|
-
const metadataPlugins = {
|
|
160
|
-
id: 'markdown-metadata-plugin',
|
|
161
|
-
canHandle: (metadataNode) => typeof metadataNode === 'string' ||
|
|
162
|
-
typeof metadataNode === 'number' ||
|
|
163
|
-
typeof metadataNode === 'boolean' ||
|
|
164
|
-
!metadataNode,
|
|
165
|
-
transform: (metadataNode, props) => renderIntlayerNode({
|
|
166
|
-
value: metadataNode,
|
|
167
|
-
component: isEnabled
|
|
168
|
-
? (_MarkdownMetadataWithSelector ?? _MarkdownMetadataRenderer)
|
|
169
|
-
: _MarkdownMetadataRenderer,
|
|
170
|
-
props: {
|
|
171
|
-
...rest,
|
|
172
|
-
value: node, // The full markdown string
|
|
173
|
-
metadataKeyPath: props.keyPath,
|
|
174
|
-
},
|
|
175
|
-
}),
|
|
176
|
-
};
|
|
177
|
-
// Transform metadata while keeping the same structure
|
|
178
|
-
const metadataNodes = deepTransformNode(metadata, {
|
|
179
|
-
plugins: [metadataPlugins],
|
|
180
|
-
dictionaryKey: rest.dictionaryKey,
|
|
181
|
-
keyPath: [],
|
|
182
|
-
}) ?? {};
|
|
183
|
-
const render = (components) => {
|
|
184
|
-
const nodeResult = renderIntlayerNode({
|
|
185
|
-
value: node,
|
|
186
|
-
component: isEnabled
|
|
187
|
-
? (_MarkdownWithSelector ?? _MarkdownRenderer)
|
|
188
|
-
: _MarkdownRenderer,
|
|
189
|
-
props: {
|
|
190
|
-
...rest,
|
|
191
|
-
value: node,
|
|
192
|
-
...components,
|
|
193
|
-
},
|
|
194
|
-
additionalProps: {
|
|
195
|
-
metadata: metadataNodes,
|
|
125
|
+
return (values) => {
|
|
126
|
+
const result = splitAndJoinInsertion(transformedResult, values);
|
|
127
|
+
return deepTransformNode(result, {
|
|
128
|
+
...subProps,
|
|
129
|
+
plugins: props.plugins,
|
|
130
|
+
children: result,
|
|
131
|
+
});
|
|
132
|
+
};
|
|
196
133
|
},
|
|
134
|
+
};
|
|
135
|
+
const result = deepTransformNode(children, {
|
|
136
|
+
...props,
|
|
137
|
+
children,
|
|
138
|
+
keyPath: newKeyPath,
|
|
139
|
+
plugins: [insertionStringPlugin, ...(props.plugins ?? [])],
|
|
197
140
|
});
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return (newComponents) => render(newComponents);
|
|
141
|
+
if (typeof children === 'object' &&
|
|
142
|
+
children !== null &&
|
|
143
|
+
'nodeType' in children &&
|
|
144
|
+
[NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(children.nodeType)) {
|
|
145
|
+
return (values) => (arg) => {
|
|
146
|
+
const func = result;
|
|
147
|
+
const inner = func(arg);
|
|
148
|
+
if (typeof inner === 'function') {
|
|
149
|
+
return inner(values);
|
|
208
150
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
return Reflect.get(target, prop, receiver);
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
return render();
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
export const markdownPlugin = {
|
|
220
|
-
id: 'markdown-plugin',
|
|
221
|
-
canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,
|
|
222
|
-
transform: (node, props, deepTransformNode) => {
|
|
223
|
-
const newKeyPath = [
|
|
224
|
-
...props.keyPath,
|
|
225
|
-
{
|
|
226
|
-
type: NodeTypes.MARKDOWN,
|
|
227
|
-
},
|
|
228
|
-
];
|
|
229
|
-
const children = node[NodeTypes.MARKDOWN];
|
|
230
|
-
return deepTransformNode(children, {
|
|
231
|
-
...props,
|
|
232
|
-
children,
|
|
233
|
-
keyPath: newKeyPath,
|
|
234
|
-
plugins: [markdownStringPlugin, ...(props.plugins ?? [])],
|
|
235
|
-
});
|
|
236
|
-
},
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* Create default HTML tag components using DOM API.
|
|
240
|
-
* Each component creates the corresponding HTML element with its props and children.
|
|
241
|
-
* Note: This approach works in browser environments.
|
|
242
|
-
*/
|
|
243
|
-
const createDefaultHTMLComponents = () => {
|
|
244
|
-
const components = {};
|
|
245
|
-
for (const tag of HTML_TAGS) {
|
|
246
|
-
components[tag] = ({ children = [], ...props }) => {
|
|
247
|
-
const element = document.createElement(tag);
|
|
248
|
-
// Apply props as attributes
|
|
249
|
-
for (const [key, value] of Object.entries(props)) {
|
|
250
|
-
if (key.startsWith('on') && typeof value === 'function') {
|
|
251
|
-
// Handle event listeners
|
|
252
|
-
const eventName = key.slice(2).toLowerCase();
|
|
253
|
-
element.addEventListener(eventName, value);
|
|
254
|
-
}
|
|
255
|
-
else if (value !== undefined && value !== null) {
|
|
256
|
-
element.setAttribute(key, String(value));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
// Append children
|
|
260
|
-
for (const child of children) {
|
|
261
|
-
if (typeof child === 'string') {
|
|
262
|
-
element.appendChild(document.createTextNode(child));
|
|
263
|
-
}
|
|
264
|
-
else if (child instanceof Node) {
|
|
265
|
-
element.appendChild(child);
|
|
266
|
-
}
|
|
151
|
+
return inner;
|
|
152
|
+
};
|
|
267
153
|
}
|
|
268
|
-
return
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
154
|
+
return result;
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
158
|
+
export const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'
|
|
159
|
+
? fallbackPlugin
|
|
160
|
+
: {
|
|
161
|
+
id: 'markdown-string-plugin',
|
|
162
|
+
canHandle: (node) => typeof node === 'string',
|
|
163
|
+
transform: (node, props, deepTransformNode) => {
|
|
164
|
+
const { ...rest } = props;
|
|
165
|
+
const metadata = _getMarkdownMetadata?.(node) ?? {};
|
|
166
|
+
const metadataPlugins = {
|
|
167
|
+
id: 'markdown-metadata-plugin',
|
|
168
|
+
canHandle: (metadataNode) => typeof metadataNode === 'string' ||
|
|
169
|
+
typeof metadataNode === 'number' ||
|
|
170
|
+
typeof metadataNode === 'boolean' ||
|
|
171
|
+
!metadataNode,
|
|
172
|
+
transform: (metadataNode, props) => renderIntlayerNode({
|
|
173
|
+
value: metadataNode,
|
|
174
|
+
component: configuration.editor.enabled
|
|
175
|
+
? (_MarkdownMetadataWithSelector ?? _MarkdownMetadataRenderer)
|
|
176
|
+
: _MarkdownMetadataRenderer,
|
|
177
|
+
props: {
|
|
178
|
+
...rest,
|
|
179
|
+
value: node, // The full markdown string
|
|
180
|
+
metadataKeyPath: props.keyPath,
|
|
181
|
+
},
|
|
182
|
+
}),
|
|
295
183
|
};
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
184
|
+
// Transform metadata while keeping the same structure
|
|
185
|
+
const metadataNodes = deepTransformNode(metadata, {
|
|
186
|
+
plugins: [metadataPlugins],
|
|
187
|
+
dictionaryKey: rest.dictionaryKey,
|
|
188
|
+
keyPath: [],
|
|
189
|
+
}) ?? {};
|
|
190
|
+
const render = (components) => {
|
|
191
|
+
const nodeResult = renderIntlayerNode({
|
|
192
|
+
value: node,
|
|
193
|
+
component: configuration.editor.enabled
|
|
194
|
+
? (_MarkdownWithSelector ?? _MarkdownRenderer)
|
|
195
|
+
: _MarkdownRenderer,
|
|
196
|
+
props: {
|
|
197
|
+
...rest,
|
|
198
|
+
value: node,
|
|
199
|
+
...components,
|
|
200
|
+
},
|
|
201
|
+
additionalProps: {
|
|
202
|
+
metadata: metadataNodes,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
return new Proxy(nodeResult, {
|
|
206
|
+
get(target, prop, receiver) {
|
|
207
|
+
if (prop === 'value') {
|
|
208
|
+
return node;
|
|
209
|
+
}
|
|
210
|
+
if (prop === 'metadata') {
|
|
211
|
+
return metadataNodes;
|
|
212
|
+
}
|
|
213
|
+
if (prop === 'use') {
|
|
214
|
+
return (newComponents) => render(newComponents);
|
|
215
|
+
}
|
|
216
|
+
if (prop === 'toString') {
|
|
217
|
+
return () => _compile?.(node, { runtime: _svelteHtmlRuntime, components: components }, {}) ?? node;
|
|
218
|
+
}
|
|
219
|
+
return Reflect.get(target, prop, receiver);
|
|
220
|
+
},
|
|
221
|
+
});
|
|
308
222
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
223
|
+
return render();
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
export const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'
|
|
227
|
+
? fallbackPlugin
|
|
228
|
+
: {
|
|
229
|
+
id: 'markdown-plugin',
|
|
230
|
+
canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,
|
|
231
|
+
transform: (node, props, deepTransformNode) => {
|
|
232
|
+
const newKeyPath = [
|
|
233
|
+
...props.keyPath,
|
|
234
|
+
{
|
|
235
|
+
type: NodeTypes.MARKDOWN,
|
|
319
236
|
},
|
|
237
|
+
];
|
|
238
|
+
const children = node[NodeTypes.MARKDOWN];
|
|
239
|
+
return deepTransformNode(children, {
|
|
240
|
+
...props,
|
|
241
|
+
children,
|
|
242
|
+
keyPath: newKeyPath,
|
|
243
|
+
plugins: [markdownStringPlugin, ...(props.plugins ?? [])],
|
|
320
244
|
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
/** HTML plugin. Replaces node with a function that takes components => HTMLElement[]. */
|
|
248
|
+
export const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === 'false'
|
|
249
|
+
? fallbackPlugin
|
|
250
|
+
: {
|
|
251
|
+
id: 'html-plugin',
|
|
252
|
+
canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.HTML,
|
|
253
|
+
transform: (node, props) => {
|
|
254
|
+
const htmlString = node[NodeTypes.HTML];
|
|
255
|
+
const _tags = node.tags ?? [];
|
|
256
|
+
// Type-safe render function that accepts properly typed components
|
|
257
|
+
const render = (userComponents = {}) => renderIntlayerNode({
|
|
258
|
+
...props,
|
|
259
|
+
value: htmlString,
|
|
260
|
+
component: HTMLRenderer,
|
|
261
|
+
props: {
|
|
262
|
+
...props,
|
|
263
|
+
value: htmlString,
|
|
264
|
+
components: userComponents,
|
|
265
|
+
},
|
|
266
|
+
additionalProps: {
|
|
267
|
+
use: (components) => render(components),
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
return render();
|
|
271
|
+
},
|
|
272
|
+
};
|
|
325
273
|
/**
|
|
326
274
|
* Get the plugins array for Svelte content transformation.
|
|
327
275
|
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
@@ -338,4 +286,4 @@ export const getPlugins = (locale, fallback = true) => [
|
|
|
338
286
|
insertionPlugin,
|
|
339
287
|
markdownPlugin,
|
|
340
288
|
htmlPlugin,
|
|
341
|
-
];
|
|
289
|
+
].filter(Boolean);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-intlayer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.1",
|
|
4
4
|
"description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intlayer",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@intlayer/api": "8.
|
|
86
|
-
"@intlayer/config": "8.
|
|
87
|
-
"@intlayer/core": "8.
|
|
88
|
-
"@intlayer/editor": "8.
|
|
89
|
-
"@intlayer/types": "8.
|
|
85
|
+
"@intlayer/api": "8.6.1",
|
|
86
|
+
"@intlayer/config": "8.6.1",
|
|
87
|
+
"@intlayer/core": "8.6.1",
|
|
88
|
+
"@intlayer/editor": "8.6.1",
|
|
89
|
+
"@intlayer/types": "8.6.1"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@sveltejs/adapter-auto": "7.0.1",
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"rimraf": "6.1.3",
|
|
100
100
|
"svelte": "5.55.0",
|
|
101
101
|
"svelte-check": "4.4.5",
|
|
102
|
-
"tsdown": "0.21.
|
|
102
|
+
"tsdown": "0.21.7",
|
|
103
103
|
"typescript": "6.0.2",
|
|
104
|
-
"vite": "8.0.
|
|
105
|
-
"vitest": "4.1.
|
|
104
|
+
"vite": "8.0.3",
|
|
105
|
+
"vitest": "4.1.2"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"svelte": ">=5.0.0"
|