svelte-intlayer 9.8.4 → 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 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,7 @@
1
+ import type { KeyPath } from '@intlayer/types/keyPath';
2
+ import { type Readable } from 'svelte/store';
3
+ /**
4
+ * Store of the source string edited in the visual editor for a markdown / html
5
+ * node. Holds `undefined` when the node is not edited (or the editor is off).
6
+ */
7
+ export declare const getEditedContentSource: (dictionaryKey: string | undefined, keyPath: KeyPath[] | undefined) => Readable<string | undefined>;
@@ -0,0 +1,25 @@
1
+ import { isEnabled } from '@intlayer/editor/isEnabled';
2
+ import { readable } from 'svelte/store';
3
+ /**
4
+ * Store of the source string edited in the visual editor for a markdown / html
5
+ * node. Holds `undefined` when the node is not edited (or the editor is off).
6
+ */
7
+ export const getEditedContentSource = (dictionaryKey, keyPath) => readable(undefined, (set) => {
8
+ if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled)
9
+ return;
10
+ if (!dictionaryKey)
11
+ return;
12
+ let isStopped = false;
13
+ let unsubscribe = null;
14
+ import('@intlayer/editor')
15
+ .then(({ subscribeToEditedContentSource }) => {
16
+ if (isStopped)
17
+ return;
18
+ unsubscribe = subscribeToEditedContentSource(dictionaryKey, keyPath ?? [], set);
19
+ })
20
+ .catch(() => { });
21
+ return () => {
22
+ isStopped = true;
23
+ unsubscribe?.();
24
+ };
25
+ });
@@ -1,14 +1,18 @@
1
1
  <script lang="ts">
2
2
  import type { KeyPath } from '@intlayer/types/keyPath';
3
3
  import ContentSelector from '../editor/ContentSelector.svelte';
4
+ import { getEditedContentSource } from '../editor/editedContentSource';
4
5
  import HTMLRenderer from './HTMLRenderer.svelte';
5
6
 
6
7
  export let dictionaryKey: string;
7
8
  export let keyPath: KeyPath[];
8
9
  export let value: string;
9
10
  export let components: any = {};
11
+
12
+ // Live preview of the source edited in the visual editor
13
+ $: editedSource = getEditedContentSource(dictionaryKey, keyPath);
10
14
  </script>
11
15
 
12
16
  <ContentSelector {dictionaryKey} {keyPath}>
13
- <HTMLRenderer {value} {components} />
17
+ <HTMLRenderer value={$editedSource ?? value} {components} />
14
18
  </ContentSelector>
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { KeyPath } from '@intlayer/types/keyPath';
3
3
  import ContentSelector from '../editor/ContentSelector.svelte';
4
+ import { getEditedContentSource } from '../editor/editedContentSource';
4
5
  import type { ParsedMarkdown } from './compiler';
5
6
  import MarkdownRenderer from './MarkdownRenderer.svelte';
6
7
 
@@ -9,10 +10,10 @@ export let keyPath: KeyPath[];
9
10
  export let value: string | ParsedMarkdown;
10
11
 
11
12
  $: overrides = { ...$$restProps };
13
+ // Live preview of the source edited in the visual editor
14
+ $: editedSource = getEditedContentSource(dictionaryKey, keyPath);
12
15
  </script>
13
16
 
14
17
  <ContentSelector {dictionaryKey} {keyPath}>
15
- <MarkdownRenderer {value} {overrides} />
18
+ <MarkdownRenderer value={$editedSource ?? value} {overrides} />
16
19
  </ContentSelector>
17
-
18
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-intlayer",
3
- "version": "9.8.4",
3
+ "version": "9.8.5",
4
4
  "description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
5
5
  "keywords": [
6
6
  "data",
@@ -83,11 +83,11 @@
83
83
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
84
84
  },
85
85
  "dependencies": {
86
- "@intlayer/api": "9.8.4",
87
- "@intlayer/config": "9.8.4",
88
- "@intlayer/core": "9.8.4",
89
- "@intlayer/editor": "9.8.4",
90
- "@intlayer/types": "9.8.4"
86
+ "@intlayer/api": "9.8.5",
87
+ "@intlayer/config": "9.8.5",
88
+ "@intlayer/core": "9.8.5",
89
+ "@intlayer/editor": "9.8.5",
90
+ "@intlayer/types": "9.8.5"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@sveltejs/adapter-auto": "9.0.0",
@@ -109,7 +109,7 @@
109
109
  "svelte": ">=5.0.0"
110
110
  },
111
111
  "optionalDependencies": {
112
- "@intlayer/analytics": "9.8.4"
112
+ "@intlayer/analytics": "9.8.5"
113
113
  },
114
114
  "engines": {
115
115
  "node": ">=14.18"