@inkandswitch/patchwork-pkg-base 0.0.76 → 0.0.77
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/module-settings-url +1 -1
- package/package.json +1 -1
- package/packages/raw/raw-editor.js +17 -5
- package/plugin-registry-url +1 -1
package/module-settings-url
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
automerge:
|
|
1
|
+
automerge:rLkAjbaRPW3NECRfSP5kdrfeRUa
|
package/package.json
CHANGED
|
@@ -393,6 +393,7 @@ function downloadBlob(blob, name) {
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
function prepareForJson(v) {
|
|
396
|
+
if (isImmutableString(v)) return String(v)
|
|
396
397
|
if (v instanceof Uint8Array) return Array.from(v)
|
|
397
398
|
if (Array.isArray(v)) return v.map(prepareForJson)
|
|
398
399
|
if (v !== null && typeof v === "object") {
|
|
@@ -403,8 +404,9 @@ function prepareForJson(v) {
|
|
|
403
404
|
return v
|
|
404
405
|
}
|
|
405
406
|
|
|
407
|
+
// An ImmutableString is an object too, but it's a string with no history.
|
|
406
408
|
function isCollection(v) {
|
|
407
|
-
return v !== null && typeof v === "object" && !(v instanceof Uint8Array)
|
|
409
|
+
return v !== null && typeof v === "object" && !(v instanceof Uint8Array) && !isImmutableString(v)
|
|
408
410
|
}
|
|
409
411
|
|
|
410
412
|
// ── tree flattening ──────────────────────────────────────────────────────────
|
|
@@ -520,6 +522,7 @@ let ICONS = {
|
|
|
520
522
|
|
|
521
523
|
function valueColor(v) {
|
|
522
524
|
if (v === null) return "var(--re-null)"
|
|
525
|
+
if (isImmutableString(v)) return "var(--re-string)"
|
|
523
526
|
switch (typeof v) {
|
|
524
527
|
case "string": return "var(--re-string)"
|
|
525
528
|
case "number": return "var(--re-number)"
|
|
@@ -535,7 +538,7 @@ function autoSize(el) {
|
|
|
535
538
|
|
|
536
539
|
function valueText(v) {
|
|
537
540
|
if (v === null) return "null"
|
|
538
|
-
if (typeof v === "string") return JSON.stringify(v)
|
|
541
|
+
if (typeof v === "string" || isImmutableString(v)) return JSON.stringify(String(v))
|
|
539
542
|
return String(v)
|
|
540
543
|
}
|
|
541
544
|
|
|
@@ -888,6 +891,11 @@ function RawEditorApp(props) {
|
|
|
888
891
|
let wrapRect = wrapperEl.getBoundingClientRect()
|
|
889
892
|
setEditing({pk: row.id, path: row.path, value: row.value, mode: "text",
|
|
890
893
|
anchorRect: {top: valRect.top - wrapRect.top, left: valRect.left - wrapRect.left}})
|
|
894
|
+
} else if (isImmutableString(row.value)) {
|
|
895
|
+
// Edited as the string it is, and written back as an ImmutableString:
|
|
896
|
+
// it has no text to splice into.
|
|
897
|
+
setEditing({pk: row.id, path: row.path, value: String(row.value), mode: "value",
|
|
898
|
+
original: cloneValue(row.value)})
|
|
891
899
|
} else {
|
|
892
900
|
setEditing({pk: row.id, path: row.path, value: row.value, mode: "value"})
|
|
893
901
|
}
|
|
@@ -896,7 +904,10 @@ function RawEditorApp(props) {
|
|
|
896
904
|
function confirmEdit(newValue) {
|
|
897
905
|
let ed = editing()
|
|
898
906
|
if (!ed || ed.mode !== "value") return
|
|
899
|
-
|
|
907
|
+
if (ed.original && typeof newValue === "string") {
|
|
908
|
+
newValue = new Automerge.ImmutableString(newValue)
|
|
909
|
+
}
|
|
910
|
+
pushUndo({type: "edit", path: ed.path, oldValue: ed.original ?? ed.value, newValue})
|
|
900
911
|
handle.change(d => applyAtPath(d, ed.path, newValue))
|
|
901
912
|
setEditing(null)
|
|
902
913
|
}
|
|
@@ -1046,7 +1057,8 @@ function RawEditorApp(props) {
|
|
|
1046
1057
|
let kind = createMemo(() => {
|
|
1047
1058
|
let v = row().value
|
|
1048
1059
|
if (v instanceof Uint8Array) return "u8"
|
|
1049
|
-
|
|
1060
|
+
let s = isImmutableString(v) ? String(v) : v
|
|
1061
|
+
if (typeof s === "string" && isValidAutomergeUrl(s)) return "url"
|
|
1050
1062
|
return "plain"
|
|
1051
1063
|
})
|
|
1052
1064
|
let canEdit = createMemo(() => !coll() && kind() !== "u8")
|
|
@@ -1100,7 +1112,7 @@ function RawEditorApp(props) {
|
|
|
1100
1112
|
return html`<${Uint8Inspector} bytes=${() => row().value} />`
|
|
1101
1113
|
}
|
|
1102
1114
|
if (kind() === "url") {
|
|
1103
|
-
return html`<span class="re-automerge-url" onClick=${() => openAmUrl(row().value)}>${() => row().value}</span>`
|
|
1115
|
+
return html`<span class="re-automerge-url" onClick=${() => openAmUrl(String(row().value))}>${() => String(row().value)}</span>`
|
|
1104
1116
|
}
|
|
1105
1117
|
return html`<span class="re-value" style=${() => `color:${valueColor(row().value)}`}
|
|
1106
1118
|
on:dblclick=${(e) => startEdit(row(), e.currentTarget)}>${() => valueText(row().value)}</span>`
|
package/plugin-registry-url
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
automerge:
|
|
1
|
+
automerge:2TeZFFdZxDRtJpNyQQKLQiMX18qs
|