@quillmark/svelte 0.7.2 → 0.7.3
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/visual/ext.d.ts +8 -0
- package/dist/visual/ext.js +14 -2
- package/package.json +1 -1
package/dist/visual/ext.d.ts
CHANGED
|
@@ -15,5 +15,13 @@ import type { Document, CardAddr } from '@quillmark/wasm';
|
|
|
15
15
|
* The drop is an explicit `delete`, not a stored `undefined`: whether a JS
|
|
16
16
|
* `undefined` survives the wasm-bindgen crossing is not a property worth depending
|
|
17
17
|
* on.
|
|
18
|
+
*
|
|
19
|
+
* **A namespace emptied of keys is removed, not stored empty.** That is
|
|
20
|
+
* `removeExtNamespace`'s one correct use: it takes the whole namespace, and there is
|
|
21
|
+
* nothing left in this one to lose. `$ext` goes with it when `editor` was the last
|
|
22
|
+
* namespace. A stored `{}` survives the model but not the emit, where an empty
|
|
23
|
+
* mapping omits its own key and leaves a bare `$ext:` that reads back as null and
|
|
24
|
+
* fails the next parse. A patch dropping keys the namespace does not have writes
|
|
25
|
+
* nothing, so dismissing tips on a document that carries none is not a mutation.
|
|
18
26
|
*/
|
|
19
27
|
export declare function patchEditorExt(doc: Document, addr: CardAddr, patch: Record<string, unknown>): void;
|
package/dist/visual/ext.js
CHANGED
|
@@ -14,16 +14,28 @@
|
|
|
14
14
|
* The drop is an explicit `delete`, not a stored `undefined`: whether a JS
|
|
15
15
|
* `undefined` survives the wasm-bindgen crossing is not a property worth depending
|
|
16
16
|
* on.
|
|
17
|
+
*
|
|
18
|
+
* **A namespace emptied of keys is removed, not stored empty.** That is
|
|
19
|
+
* `removeExtNamespace`'s one correct use: it takes the whole namespace, and there is
|
|
20
|
+
* nothing left in this one to lose. `$ext` goes with it when `editor` was the last
|
|
21
|
+
* namespace. A stored `{}` survives the model but not the emit, where an empty
|
|
22
|
+
* mapping omits its own key and leaves a bare `$ext:` that reads back as null and
|
|
23
|
+
* fails the next parse. A patch dropping keys the namespace does not have writes
|
|
24
|
+
* nothing, so dismissing tips on a document that carries none is not a mutation.
|
|
17
25
|
*/
|
|
18
26
|
export function patchEditorExt(doc, addr, patch) {
|
|
19
27
|
// `getExtNamespace` reads just this namespace rather than serializing the whole
|
|
20
28
|
// card to fish out one `$ext` slot.
|
|
21
|
-
const
|
|
29
|
+
const current = doc.getExtNamespace(addr, 'editor');
|
|
30
|
+
const next = { ...(current ?? {}) };
|
|
22
31
|
for (const [key, value] of Object.entries(patch)) {
|
|
23
32
|
if (value === undefined)
|
|
24
33
|
delete next[key];
|
|
25
34
|
else
|
|
26
35
|
next[key] = value;
|
|
27
36
|
}
|
|
28
|
-
|
|
37
|
+
if (Object.keys(next).length > 0)
|
|
38
|
+
doc.storeExtNamespace(addr, 'editor', next);
|
|
39
|
+
else if (current)
|
|
40
|
+
doc.removeExtNamespace(addr, 'editor');
|
|
29
41
|
}
|