@sveltia/ui 0.79.0 → 0.79.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.
@@ -88,7 +88,9 @@
88
88
  // The content has been converted, if it has changed at all
89
89
  editorStore.pending = false;
90
90
 
91
- if (hasConverterError || !useRichText) {
91
+ // Ignore the content while a value is being imported, like the empty code block the editor
92
+ // starts with: it would overwrite the value, which then replaces the content once imported
93
+ if (hasConverterError || !useRichText || editorStore.importing) {
92
94
  return;
93
95
  }
94
96
 
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
3
3
  */
4
- export const UI_VERSION: "0.79.0";
4
+ export const UI_VERSION: "0.79.1";
@@ -3,4 +3,4 @@
3
3
  /**
4
4
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
5
5
  */
6
- export const UI_VERSION = '0.79.0';
6
+ export const UI_VERSION = '0.79.1';
@@ -50,6 +50,16 @@ export const createEditorStore = () => {
50
50
  * @type {{ source: string, exported: string } | undefined}
51
51
  */
52
52
  let lastImport = undefined;
53
+ /**
54
+ * Number of imports started, to tell the latest one.
55
+ * @type {number}
56
+ */
57
+ let importCount = 0;
58
+ /**
59
+ * Whether the latest import is still in progress.
60
+ * @type {boolean}
61
+ */
62
+ let importing = false;
53
63
 
54
64
  /**
55
65
  * Flag a conversion error, which takes the editor out of the rich text mode, and shows the error
@@ -76,6 +86,12 @@ export const createEditorStore = () => {
76
86
 
77
87
  const originalValue = inputValue;
78
88
 
89
+ importCount += 1;
90
+
91
+ const importId = importCount;
92
+
93
+ importing = true;
94
+
79
95
  try {
80
96
  // We should avoid an empty editor; there should be at least one `<p>`, so give it an empty
81
97
  // string if the `value` is `undefined`
@@ -96,6 +112,11 @@ export const createEditorStore = () => {
96
112
  inputValue = originalValue;
97
113
  // eslint-disable-next-line no-console
98
114
  console.error(ex);
115
+ } finally {
116
+ // An earlier import finishing last doesn’t end the latest one
117
+ if (importId === importCount) {
118
+ importing = false;
119
+ }
99
120
  }
100
121
  };
101
122
 
@@ -179,6 +200,9 @@ export const createEditorStore = () => {
179
200
  set pending(newValue) {
180
201
  pending = newValue;
181
202
  },
203
+ get importing() {
204
+ return importing;
205
+ },
182
206
  editorId,
183
207
  convertMarkdown,
184
208
  /**
@@ -1048,6 +1048,11 @@ export type TextEditorStore = {
1048
1048
  * has yet to convert it to Markdown and update {@link TextEditorStore.inputValue}.
1049
1049
  */
1050
1050
  pending: boolean;
1051
+ /**
1052
+ * Whether the latest {@link TextEditorStore.inputValue} is still
1053
+ * being imported to the Lexical editor.
1054
+ */
1055
+ importing: boolean;
1051
1056
  /**
1052
1057
  * Function to trigger the Lexical converter.
1053
1058
  */
package/dist/typedefs.js CHANGED
@@ -448,6 +448,8 @@
448
448
  * @property {boolean} showConverterError Whether to show a converter error in the UI.
449
449
  * @property {boolean} pending Whether the user has changed the rich text content, and the editor
450
450
  * has yet to convert it to Markdown and update {@link TextEditorStore.inputValue}.
451
+ * @property {boolean} importing Whether the latest {@link TextEditorStore.inputValue} is still
452
+ * being imported to the Lexical editor.
451
453
  * @property {() => Promise<void>} convertMarkdown Function to trigger the Lexical converter.
452
454
  * @property {(value: string) => string | undefined} getImportedValue Function to get the
453
455
  * {@link TextEditorStore.inputValue} last imported if the given value, exported by the editor, is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.79.0",
3
+ "version": "0.79.1",
4
4
  "description": "A collection of Svelte components and utilities for building user interfaces.",
5
5
  "repository": {
6
6
  "type": "git",