solid-intlayer 9.8.3 → 9.8.5
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/editor/createEditedContentSource.cjs +1 -0
- package/dist/cjs/markdown/MarkdownRenderer.cjs +1 -1
- package/dist/esm/editor/createEditedContentSource.mjs +20 -0
- package/dist/esm/markdown/MarkdownRenderer.mjs +28 -27
- package/dist/solid/editor/createEditedContentSource.js +31 -0
- package/dist/solid/markdown/MarkdownRenderer.jsx +3 -1
- package/dist/types/editor/createEditedContentSource.d.ts +8 -0
- package/package.json +10 -10
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 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../solidCompat.cjs");let t=require("solid-js"),n=require("@intlayer/editor/isEnabled");var r=(r,i)=>{let[a,o]=(0,t.createSignal)();return process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.isEnabled||e.createWatchEffect(()=>({currentDictionaryKey:r(),keyPathJson:JSON.stringify(i()??[])}),({currentDictionaryKey:e,keyPathJson:t})=>{if(!e)return;let n=!1,r=null;return import(`@intlayer/editor`).then(({subscribeToEditedContentSource:i})=>{n||(r=i(e,JSON.parse(t),e=>o(()=>e)))}).catch(()=>{}),()=>{n=!0,r?.()}}),a};exports.createEditedContentSource=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../editor/createEditedContentSource.cjs"),t=require("../LoadingBoundary.cjs"),n=require("../solidCompat.cjs"),r=require("./compiler.cjs"),i=require("./MarkdownProvider.cjs");let a=require("solid-js/web"),o=require("@intlayer/core/markdown"),s=require("solid-js"),c=require("@intlayer/core/dictionaryManipulator");var l=(e,t={})=>r.compileMarkdown(e,t),u=(e={})=>{let t=(0,s.useContext)(i.MarkdownContext);return n=>t?t.renderMarkdown(n,{forceBlock:e.forceBlock,preserveFrontmatter:e.preserveFrontmatter,tagfilter:e.tagfilter},e.components,e.wrapper):l(n,e)},d=r=>{let o=(0,s.useContext)(i.MarkdownContext),{renderMarkdown:c}=i.useMarkdown(),l=e.createEditedContentSource(()=>r.dictionaryKey,()=>r.keyPath),u=n.createAsyncValue(()=>[l()??r.children,r.forceBlock,r.preserveFrontmatter,r.tagfilter,r.components,r.wrapper],([e,t,n,r,i,a])=>c(e,{forceBlock:t,preserveFrontmatter:n,tagfilter:r},{...o?.components??{},...i??{}},a));return(0,a.createComponent)(t.LoadingBoundary,{get children(){return u()}})},f=e=>{let t=(0,s.createMemo)(()=>(0,o.getMarkdownMetadata)(e.children));return(0,s.createMemo)(()=>(0,c.getContentNodeByKeyPath)(t(),e.metadataKeyPath))()};exports.MarkdownMetadataRenderer=f,exports.MarkdownRenderer=d,exports.renderMarkdown=l,exports.useMarkdownRenderer=u;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createWatchEffect as e } from "../solidCompat.mjs";
|
|
2
|
+
import { createSignal as t } from "solid-js";
|
|
3
|
+
import { isEnabled as n } from "@intlayer/editor/isEnabled";
|
|
4
|
+
// src/editor/createEditedContentSource.ts
|
|
5
|
+
var r = (r, i) => {
|
|
6
|
+
let [a, o] = t();
|
|
7
|
+
return process.env.INTLAYER_EDITOR_ENABLED === "false" || !n || e(() => ({
|
|
8
|
+
currentDictionaryKey: r(),
|
|
9
|
+
keyPathJson: JSON.stringify(i() ?? [])
|
|
10
|
+
}), ({ currentDictionaryKey: e, keyPathJson: t }) => {
|
|
11
|
+
if (!e) return;
|
|
12
|
+
let n = !1, r = null;
|
|
13
|
+
return import("@intlayer/editor").then(({ subscribeToEditedContentSource: i }) => {
|
|
14
|
+
n || (r = i(e, JSON.parse(t), (e) => o(() => e)));
|
|
15
|
+
}).catch(() => {}), () => {
|
|
16
|
+
n = !0, r?.();
|
|
17
|
+
};
|
|
18
|
+
}), a;
|
|
19
|
+
};
|
|
20
|
+
export { r as createEditedContentSource };
|
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { createEditedContentSource as e } from "../editor/createEditedContentSource.mjs";
|
|
2
|
+
import { LoadingBoundary as t } from "../LoadingBoundary.mjs";
|
|
3
|
+
import { createAsyncValue as n } from "../solidCompat.mjs";
|
|
4
|
+
import { compileMarkdown as r } from "./compiler.mjs";
|
|
5
|
+
import { MarkdownContext as i, useMarkdown as a } from "./MarkdownProvider.mjs";
|
|
6
|
+
import { createComponent as o } from "solid-js/web";
|
|
7
|
+
import { getMarkdownMetadata as s } from "@intlayer/core/markdown";
|
|
8
|
+
import { createMemo as c, useContext as l } from "solid-js";
|
|
9
|
+
import { getContentNodeByKeyPath as u } from "@intlayer/core/dictionaryManipulator";
|
|
9
10
|
// src/markdown/MarkdownRenderer.tsx
|
|
10
|
-
var
|
|
11
|
-
let t =
|
|
11
|
+
var d = (e, t = {}) => r(e, t), f = (e = {}) => {
|
|
12
|
+
let t = l(i);
|
|
12
13
|
return (n) => t ? t.renderMarkdown(n, {
|
|
13
14
|
forceBlock: e.forceBlock,
|
|
14
15
|
preserveFrontmatter: e.preserveFrontmatter,
|
|
15
16
|
tagfilter: e.tagfilter
|
|
16
|
-
}, e.components, e.wrapper) :
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
], ([e, t, n, r, i, a]) =>
|
|
17
|
+
}, e.components, e.wrapper) : d(n, e);
|
|
18
|
+
}, p = (r) => {
|
|
19
|
+
let s = l(i), { renderMarkdown: c } = a(), u = e(() => r.dictionaryKey, () => r.keyPath), d = n(() => [
|
|
20
|
+
u() ?? r.children,
|
|
21
|
+
r.forceBlock,
|
|
22
|
+
r.preserveFrontmatter,
|
|
23
|
+
r.tagfilter,
|
|
24
|
+
r.components,
|
|
25
|
+
r.wrapper
|
|
26
|
+
], ([e, t, n, r, i, a]) => c(e, {
|
|
26
27
|
forceBlock: t,
|
|
27
28
|
preserveFrontmatter: n,
|
|
28
29
|
tagfilter: r
|
|
29
30
|
}, {
|
|
30
|
-
...
|
|
31
|
+
...s?.components ?? {},
|
|
31
32
|
...i ?? {}
|
|
32
33
|
}, a));
|
|
33
|
-
return
|
|
34
|
-
return
|
|
34
|
+
return o(t, { get children() {
|
|
35
|
+
return d();
|
|
35
36
|
} });
|
|
36
|
-
},
|
|
37
|
-
let t =
|
|
38
|
-
return
|
|
37
|
+
}, m = (e) => {
|
|
38
|
+
let t = c(() => s(e.children));
|
|
39
|
+
return c(() => u(t(), e.metadataKeyPath))();
|
|
39
40
|
};
|
|
40
|
-
export {
|
|
41
|
+
export { m as MarkdownMetadataRenderer, p as MarkdownRenderer, d as renderMarkdown, f as useMarkdownRenderer };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createWatchEffect } from "../solidCompat.js";
|
|
2
|
+
import { createSignal } from "solid-js";
|
|
3
|
+
import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
4
|
+
// src/editor/createEditedContentSource.ts
|
|
5
|
+
/**
|
|
6
|
+
* Tracks the source string edited in the visual editor for a markdown / html
|
|
7
|
+
* node. The accessor returns `undefined` when the node is not edited (or the
|
|
8
|
+
* editor is off).
|
|
9
|
+
*/
|
|
10
|
+
var createEditedContentSource = (dictionaryKey, keyPath) => {
|
|
11
|
+
const [editedSource, setEditedSource] = createSignal();
|
|
12
|
+
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !isEnabled) return editedSource;
|
|
13
|
+
createWatchEffect(() => ({
|
|
14
|
+
currentDictionaryKey: dictionaryKey(),
|
|
15
|
+
keyPathJson: JSON.stringify(keyPath() ?? [])
|
|
16
|
+
}), ({ currentDictionaryKey, keyPathJson }) => {
|
|
17
|
+
if (!currentDictionaryKey) return;
|
|
18
|
+
let isStopped = false;
|
|
19
|
+
let unsubscribe = null;
|
|
20
|
+
import("@intlayer/editor").then(({ subscribeToEditedContentSource }) => {
|
|
21
|
+
if (isStopped) return;
|
|
22
|
+
unsubscribe = subscribeToEditedContentSource(currentDictionaryKey, JSON.parse(keyPathJson), (source) => setEditedSource(() => source));
|
|
23
|
+
}).catch(() => {});
|
|
24
|
+
return () => {
|
|
25
|
+
isStopped = true;
|
|
26
|
+
unsubscribe?.();
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
return editedSource;
|
|
30
|
+
};
|
|
31
|
+
export { createEditedContentSource };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createEditedContentSource } from "../editor/createEditedContentSource.js";
|
|
1
2
|
import { LoadingBoundary } from "../LoadingBoundary.jsx";
|
|
2
3
|
import { createAsyncValue } from "../solidCompat.js";
|
|
3
4
|
import { compileMarkdown } from "./compiler.jsx";
|
|
@@ -23,8 +24,9 @@ var useMarkdownRenderer = (options = {}) => {
|
|
|
23
24
|
var MarkdownRenderer = (props) => {
|
|
24
25
|
const context = useContext(MarkdownContext);
|
|
25
26
|
const { renderMarkdown } = useMarkdown();
|
|
27
|
+
const editedSource = createEditedContentSource(() => props.dictionaryKey, () => props.keyPath);
|
|
26
28
|
const rendered = createAsyncValue(() => [
|
|
27
|
-
props.children,
|
|
29
|
+
editedSource() ?? props.children,
|
|
28
30
|
props.forceBlock,
|
|
29
31
|
props.preserveFrontmatter,
|
|
30
32
|
props.tagfilter,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KeyPath } from '@intlayer/types/keyPath';
|
|
2
|
+
import { Accessor } from 'solid-js';
|
|
3
|
+
/**
|
|
4
|
+
* Tracks the source string edited in the visual editor for a markdown / html
|
|
5
|
+
* node. The accessor returns `undefined` when the node is not edited (or the
|
|
6
|
+
* editor is off).
|
|
7
|
+
*/
|
|
8
|
+
export declare const createEditedContentSource: (dictionaryKey: Accessor<string | undefined>, keyPath: Accessor<KeyPath[] | undefined>) => Accessor<string | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-intlayer",
|
|
3
|
-
"version": "9.8.
|
|
3
|
+
"version": "9.8.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -114,24 +114,24 @@
|
|
|
114
114
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
115
115
|
},
|
|
116
116
|
"dependencies": {
|
|
117
|
-
"@intlayer/api": "9.8.
|
|
118
|
-
"@intlayer/config": "9.8.
|
|
119
|
-
"@intlayer/core": "9.8.
|
|
120
|
-
"@intlayer/editor": "9.8.
|
|
121
|
-
"@intlayer/types": "9.8.
|
|
117
|
+
"@intlayer/api": "9.8.5",
|
|
118
|
+
"@intlayer/config": "9.8.5",
|
|
119
|
+
"@intlayer/core": "9.8.5",
|
|
120
|
+
"@intlayer/editor": "9.8.5",
|
|
121
|
+
"@intlayer/types": "9.8.5"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@solidjs/testing-library": "0.8.10",
|
|
125
|
-
"@testing-library/jest-dom": "
|
|
125
|
+
"@testing-library/jest-dom": "8.0.0",
|
|
126
126
|
"@testing-library/user-event": "14.6.13",
|
|
127
127
|
"@types/node": "^26",
|
|
128
128
|
"@typescript/typescript6": "^6.0.2",
|
|
129
129
|
"@utils/ts-config": "1.0.4",
|
|
130
130
|
"@utils/ts-config-types": "1.0.4",
|
|
131
131
|
"@utils/tsdown-config": "1.0.4",
|
|
132
|
-
"jsdom": "
|
|
132
|
+
"jsdom": "31.0.1",
|
|
133
133
|
"rimraf": "6.1.4",
|
|
134
|
-
"solid-js": "2.0.
|
|
134
|
+
"solid-js": "2.0.3",
|
|
135
135
|
"tsdown": "0.23.7",
|
|
136
136
|
"typescript": "7.0.2",
|
|
137
137
|
"vite": "8.3.8",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
}
|
|
150
150
|
},
|
|
151
151
|
"optionalDependencies": {
|
|
152
|
-
"@intlayer/analytics": "9.8.
|
|
152
|
+
"@intlayer/analytics": "9.8.5"
|
|
153
153
|
},
|
|
154
154
|
"engines": {
|
|
155
155
|
"node": ">=14.18"
|