@skillre/dsh-plugin-sticky-wall 0.9.4 → 0.9.6
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/lib/client.js +85 -26
- package/lib/frontmatter.js +99 -5
- package/lib/index.js +10 -3
- package/lib/migrate.js +97 -16
- package/lib/store.js +60 -5
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -202,7 +202,7 @@ window.__ModuleLoader__.load({
|
|
|
202
202
|
"search": "\u641C\u7D22\u4FBF\u7B7E\u2026",
|
|
203
203
|
"bodyPlaceholder": "\u5199\u70B9\u4EC0\u4E48\u2026",
|
|
204
204
|
"titlePlaceholder": "\u6807\u9898\uFF08\u53EF\u9009\uFF09",
|
|
205
|
-
"tagsPlaceholder": "\u6807\u7B7E\uFF0C\u7528\
|
|
205
|
+
"tagsPlaceholder": "\u6807\u7B7E\uFF0C\u7528\u9017\u53F7\u5206\u9694",
|
|
206
206
|
"colorLabel": "\u989C\u8272",
|
|
207
207
|
"saveHint": "\u2318/Ctrl + Enter \u4FDD\u5B58 \xB7 Esc \u53D6\u6D88",
|
|
208
208
|
"count": "{count} \u5F20\u4FBF\u7B7E",
|
|
@@ -314,7 +314,7 @@ window.__ModuleLoader__.load({
|
|
|
314
314
|
"search": "Search notes\u2026",
|
|
315
315
|
"bodyPlaceholder": "Write something\u2026",
|
|
316
316
|
"titlePlaceholder": "Title (optional)",
|
|
317
|
-
"tagsPlaceholder": "Tags,
|
|
317
|
+
"tagsPlaceholder": "Tags, comma separated",
|
|
318
318
|
"colorLabel": "Color",
|
|
319
319
|
"saveHint": "\u2318/Ctrl + Enter to save \xB7 Esc to cancel",
|
|
320
320
|
"count": "{count} notes",
|
|
@@ -957,6 +957,8 @@ window.__ModuleLoader__.load({
|
|
|
957
957
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
958
958
|
var TASK = /^\[([ xX])\][ \t]+([\s\S]*)$/;
|
|
959
959
|
var ESCAPABLE = /* @__PURE__ */ new Set(["\\", "`", "*", "_", "{", "}", "[", "]", "(", ")", "#", "+", "-", ".", "!", ">", "~", "|"]);
|
|
960
|
+
var LINK = /\[([^\]]*)\]\(((?:[^()\s]|\([^()\s]*\))*)\)/y;
|
|
961
|
+
var AUTOLINK = /(?:https?:\/\/|www\.)[^\s<>()]+/y;
|
|
960
962
|
function runLength(text, from, char) {
|
|
961
963
|
let length = 0;
|
|
962
964
|
while (text.charAt(from + length) === char) length += 1;
|
|
@@ -967,13 +969,17 @@ window.__ModuleLoader__.load({
|
|
|
967
969
|
if (char === "") return false;
|
|
968
970
|
return /[A-Za-z0-9]/.test(char);
|
|
969
971
|
}
|
|
970
|
-
function findClosing(text, from, delimiter) {
|
|
972
|
+
function findClosing(text, from, delimiter, failed) {
|
|
973
|
+
if (failed !== void 0 && failed.has(from)) return -1;
|
|
971
974
|
const char = delimiter.charAt(0);
|
|
972
975
|
const underscore = char === "_";
|
|
973
976
|
let index = from;
|
|
974
977
|
while (index < text.length) {
|
|
975
978
|
const found = text.indexOf(delimiter, index);
|
|
976
|
-
if (found === -1)
|
|
979
|
+
if (found === -1) {
|
|
980
|
+
failed?.add(from);
|
|
981
|
+
return -1;
|
|
982
|
+
}
|
|
977
983
|
let backslashes = 0;
|
|
978
984
|
for (let probe = found - 1; probe >= 0 && text.charAt(probe) === "\\"; probe -= 1) backslashes += 1;
|
|
979
985
|
if (backslashes % 2 === 1) {
|
|
@@ -990,13 +996,23 @@ window.__ModuleLoader__.load({
|
|
|
990
996
|
}
|
|
991
997
|
return found;
|
|
992
998
|
}
|
|
999
|
+
failed?.add(from);
|
|
993
1000
|
return -1;
|
|
994
1001
|
}
|
|
995
|
-
function renderInline(text, keyPrefix = "i") {
|
|
1002
|
+
function renderInline(text, keyPrefix = "i", inLink = false) {
|
|
996
1003
|
const nodes = [];
|
|
997
1004
|
let buffer = "";
|
|
998
1005
|
let counter = 0;
|
|
999
1006
|
let index = 0;
|
|
1007
|
+
const failedClosers = /* @__PURE__ */ new Map();
|
|
1008
|
+
const failedFor = (delimiter) => {
|
|
1009
|
+
let set = failedClosers.get(delimiter);
|
|
1010
|
+
if (set === void 0) {
|
|
1011
|
+
set = /* @__PURE__ */ new Set();
|
|
1012
|
+
failedClosers.set(delimiter, set);
|
|
1013
|
+
}
|
|
1014
|
+
return set;
|
|
1015
|
+
};
|
|
1000
1016
|
const nextKey = () => `${keyPrefix}-${counter++}`;
|
|
1001
1017
|
const flush = () => {
|
|
1002
1018
|
if (buffer === "") return;
|
|
@@ -1019,7 +1035,7 @@ window.__ModuleLoader__.load({
|
|
|
1019
1035
|
}
|
|
1020
1036
|
if (char === "`") {
|
|
1021
1037
|
const open = runLength(text, index, "`");
|
|
1022
|
-
const closing = findClosing(text, index + open, "`".repeat(open));
|
|
1038
|
+
const closing = findClosing(text, index + open, "`".repeat(open), failedFor("`".repeat(open)));
|
|
1023
1039
|
if (closing !== -1) {
|
|
1024
1040
|
flush();
|
|
1025
1041
|
const inner = text.slice(index + open, closing);
|
|
@@ -1037,7 +1053,7 @@ window.__ModuleLoader__.load({
|
|
|
1037
1053
|
const opens = char !== "_" || !isWordChar(text, index - 1);
|
|
1038
1054
|
if (opens && run >= 3) {
|
|
1039
1055
|
const delimiter = char.repeat(3);
|
|
1040
|
-
const closing = findClosing(text, index + 3, delimiter);
|
|
1056
|
+
const closing = findClosing(text, index + 3, delimiter, failedFor(delimiter));
|
|
1041
1057
|
if (closing > index + 3) {
|
|
1042
1058
|
flush();
|
|
1043
1059
|
nodes.push(
|
|
@@ -1049,7 +1065,7 @@ window.__ModuleLoader__.load({
|
|
|
1049
1065
|
}
|
|
1050
1066
|
if (opens && run >= 2) {
|
|
1051
1067
|
const delimiter = char + char;
|
|
1052
|
-
const closing = findClosing(text, index + 2, delimiter);
|
|
1068
|
+
const closing = findClosing(text, index + 2, delimiter, failedFor(delimiter));
|
|
1053
1069
|
if (closing > index + 2) {
|
|
1054
1070
|
flush();
|
|
1055
1071
|
nodes.push(
|
|
@@ -1060,7 +1076,7 @@ window.__ModuleLoader__.load({
|
|
|
1060
1076
|
}
|
|
1061
1077
|
}
|
|
1062
1078
|
if (opens && run === 1) {
|
|
1063
|
-
const closing = findClosing(text, index + 1, char);
|
|
1079
|
+
const closing = findClosing(text, index + 1, char, failedFor(char));
|
|
1064
1080
|
if (closing > index + 1) {
|
|
1065
1081
|
flush();
|
|
1066
1082
|
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: renderInline(text.slice(index + 1, closing), `${keyPrefix}-e`) }, nextKey()));
|
|
@@ -1073,7 +1089,7 @@ window.__ModuleLoader__.load({
|
|
|
1073
1089
|
continue;
|
|
1074
1090
|
}
|
|
1075
1091
|
if (char === "~" && text.startsWith("~~", index)) {
|
|
1076
|
-
const closing = findClosing(text, index + 2, "~~");
|
|
1092
|
+
const closing = findClosing(text, index + 2, "~~", failedFor("~~"));
|
|
1077
1093
|
if (closing > index + 2) {
|
|
1078
1094
|
flush();
|
|
1079
1095
|
nodes.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("s", { children: renderInline(text.slice(index + 2, closing), `${keyPrefix}-d`) }, nextKey()));
|
|
@@ -1081,21 +1097,23 @@ window.__ModuleLoader__.load({
|
|
|
1081
1097
|
continue;
|
|
1082
1098
|
}
|
|
1083
1099
|
}
|
|
1084
|
-
if (char === "[") {
|
|
1085
|
-
const
|
|
1100
|
+
if (char === "[" && !inLink) {
|
|
1101
|
+
const close = text.indexOf("]", index + 1);
|
|
1102
|
+
const match = close === -1 || text.charAt(close + 1) !== "(" ? null : (LINK.lastIndex = index, LINK.exec(text));
|
|
1086
1103
|
if (match !== null) {
|
|
1087
1104
|
flush();
|
|
1088
1105
|
const label = match[1] ?? "";
|
|
1089
1106
|
const href = safeHref(match[2] ?? "");
|
|
1090
1107
|
nodes.push(
|
|
1091
|
-
href === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }, nextKey()) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "skw-md-link", href, target: "_blank", rel: "noreferrer noopener", children: renderInline(label, `${keyPrefix}-l
|
|
1108
|
+
href === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }, nextKey()) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "skw-md-link", href, target: "_blank", rel: "noreferrer noopener", children: renderInline(label, `${keyPrefix}-l`, true) }, nextKey())
|
|
1092
1109
|
);
|
|
1093
1110
|
index += match[0].length;
|
|
1094
1111
|
continue;
|
|
1095
1112
|
}
|
|
1096
1113
|
}
|
|
1097
|
-
if (char === "h" || char === "w") {
|
|
1098
|
-
|
|
1114
|
+
if (!inLink && (char === "h" || char === "w")) {
|
|
1115
|
+
AUTOLINK.lastIndex = index;
|
|
1116
|
+
const match = AUTOLINK.exec(text);
|
|
1099
1117
|
if (match !== null) {
|
|
1100
1118
|
const raw = match[0];
|
|
1101
1119
|
const trimmed = raw.replace(/[.,;:!?]+$/, "");
|
|
@@ -1236,16 +1254,19 @@ window.__ModuleLoader__.load({
|
|
|
1236
1254
|
function leadingSpace(line) {
|
|
1237
1255
|
return /^[ \t]*/.exec(line)?.[0] ?? "";
|
|
1238
1256
|
}
|
|
1239
|
-
var HEADING_MARKER = /^([ \t]*)(#{1,
|
|
1257
|
+
var HEADING_MARKER = /^([ \t]*)(#{1,6})[ \t]+/;
|
|
1240
1258
|
var TODO_MARKER = /^([ \t]*)([-*+])[ \t]+\[[ xX]\][ \t]+/;
|
|
1241
|
-
var ORDERED_MARKER = /^([ \t]*)(\d{1,
|
|
1259
|
+
var ORDERED_MARKER = /^([ \t]*)(\d{1,9})([.)])[ \t]+/;
|
|
1242
1260
|
var BULLET_MARKER = /^([ \t]*)([-*+])[ \t]+/;
|
|
1243
1261
|
var QUOTE_MARKER = /^([ \t]*)>[ \t]?/;
|
|
1262
|
+
var RULE_MARKER = /^([ \t]*)(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
1244
1263
|
function stripBlockMarker(line) {
|
|
1245
1264
|
for (const marker of [HEADING_MARKER, TODO_MARKER, ORDERED_MARKER, BULLET_MARKER, QUOTE_MARKER]) {
|
|
1246
1265
|
const match = marker.exec(line);
|
|
1247
1266
|
if (match !== null) return line.slice(match[0].length);
|
|
1248
1267
|
}
|
|
1268
|
+
const rule = RULE_MARKER.exec(line);
|
|
1269
|
+
if (rule !== null) return "";
|
|
1249
1270
|
return line.slice(leadingSpace(line).length);
|
|
1250
1271
|
}
|
|
1251
1272
|
function wrapSelection(ctx, open, close) {
|
|
@@ -1399,7 +1420,12 @@ window.__ModuleLoader__.load({
|
|
|
1399
1420
|
en: "Inline",
|
|
1400
1421
|
actions: [
|
|
1401
1422
|
{ id: "bold", key: "mdBold", zh: "\u7C97\u4F53", en: "Bold", glyph: "B", style: "bold", run: (ctx) => wrapSelection(ctx, "**", "**") },
|
|
1402
|
-
|
|
1423
|
+
// `*` rather than `_`: the parser refuses an underscore pair that touches a
|
|
1424
|
+
// word character (`snake_case_name` is an identifier), so italicising a
|
|
1425
|
+
// word inside a sentence produced `ab_cd_` — literal text, no <em>. An
|
|
1426
|
+
// empty selection produced `__`, which is a STRONG run and rendered bold.
|
|
1427
|
+
// The asterisk has no such word-boundary rule, so it always works.
|
|
1428
|
+
{ id: "italic", key: "mdItalic", zh: "\u659C\u4F53", en: "Italic", glyph: "I", style: "italic", run: (ctx) => wrapSelection(ctx, "*", "*") },
|
|
1403
1429
|
{ id: "strike", key: "mdStrike", zh: "\u5220\u9664\u7EBF", en: "Strikethrough", glyph: "S", style: "strike", run: (ctx) => wrapSelection(ctx, "~~", "~~") },
|
|
1404
1430
|
{ id: "code", key: "mdCode", zh: "\u884C\u5185\u4EE3\u7801", en: "Inline code", glyph: "<>", run: (ctx) => wrapSelection(ctx, "`", "`") },
|
|
1405
1431
|
{ id: "link", key: "mdLink", zh: "\u94FE\u63A5", en: "Link", glyph: "\u26D3", run: (ctx) => wrapSelection(ctx, "[", "](https://)") }
|
|
@@ -1422,14 +1448,19 @@ window.__ModuleLoader__.load({
|
|
|
1422
1448
|
for (const char of prefix) width += char === " " ? INDENT_WIDTH2 : 1;
|
|
1423
1449
|
return width;
|
|
1424
1450
|
}
|
|
1451
|
+
var INDENT_STEP = INDENT_WIDTH2;
|
|
1425
1452
|
function indentSelection(value, start, end, direction) {
|
|
1426
1453
|
return rewriteLines(value, start, end, (line) => {
|
|
1427
1454
|
if (line.trim() === "") return line;
|
|
1428
1455
|
const prefix = leadingSpace(line);
|
|
1429
1456
|
const body = line.slice(prefix.length);
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1457
|
+
const columns2 = columnsOf(prefix);
|
|
1458
|
+
if (direction === 1) {
|
|
1459
|
+
const level2 = Math.floor(columns2 / INDENT_STEP);
|
|
1460
|
+
return `${" ".repeat((level2 + 1) * INDENT_STEP)}${body}`;
|
|
1461
|
+
}
|
|
1462
|
+
const level = Math.ceil(columns2 / INDENT_STEP);
|
|
1463
|
+
return `${" ".repeat(Math.max(0, level - 1) * INDENT_STEP)}${body}`;
|
|
1433
1464
|
});
|
|
1434
1465
|
}
|
|
1435
1466
|
function fenceLines(lines) {
|
|
@@ -1578,33 +1609,54 @@ window.__ModuleLoader__.load({
|
|
|
1578
1609
|
const pending = (0, import_react.useRef)(null);
|
|
1579
1610
|
const guarded = (0, import_react.useCallback)((event) => {
|
|
1580
1611
|
const native = event.nativeEvent;
|
|
1581
|
-
|
|
1612
|
+
if (composing.current || native.isComposing || native.keyCode === 229) return true;
|
|
1613
|
+
if (justEnded.current) {
|
|
1614
|
+
justEnded.current = false;
|
|
1615
|
+
return true;
|
|
1616
|
+
}
|
|
1617
|
+
return false;
|
|
1582
1618
|
}, []);
|
|
1583
1619
|
(0, import_react.useEffect)(() => {
|
|
1584
1620
|
const node = areaRef.current;
|
|
1585
1621
|
if (node === null) return;
|
|
1622
|
+
let expiry = null;
|
|
1623
|
+
const clearExpiry = () => {
|
|
1624
|
+
if (expiry !== null) {
|
|
1625
|
+
clearTimeout(expiry);
|
|
1626
|
+
expiry = null;
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1586
1629
|
const open = () => {
|
|
1587
1630
|
composing.current = true;
|
|
1588
1631
|
justEnded.current = false;
|
|
1632
|
+
clearExpiry();
|
|
1589
1633
|
};
|
|
1590
1634
|
const close = () => {
|
|
1591
1635
|
composing.current = false;
|
|
1592
1636
|
justEnded.current = true;
|
|
1593
1637
|
tabEscape.current = false;
|
|
1638
|
+
clearExpiry();
|
|
1639
|
+
expiry = setTimeout(() => {
|
|
1640
|
+
justEnded.current = false;
|
|
1641
|
+
expiry = null;
|
|
1642
|
+
}, 0);
|
|
1594
1643
|
};
|
|
1595
1644
|
const settle = () => {
|
|
1596
1645
|
justEnded.current = false;
|
|
1646
|
+
clearExpiry();
|
|
1597
1647
|
};
|
|
1598
1648
|
const reset = () => {
|
|
1599
1649
|
composing.current = false;
|
|
1600
1650
|
justEnded.current = false;
|
|
1601
1651
|
tabEscape.current = false;
|
|
1652
|
+
clearExpiry();
|
|
1602
1653
|
};
|
|
1603
1654
|
node.addEventListener("compositionstart", open);
|
|
1604
1655
|
node.addEventListener("compositionend", close);
|
|
1605
1656
|
node.addEventListener("keyup", settle);
|
|
1606
1657
|
window.addEventListener("blur", reset);
|
|
1607
1658
|
return () => {
|
|
1659
|
+
clearExpiry();
|
|
1608
1660
|
node.removeEventListener("compositionstart", open);
|
|
1609
1661
|
node.removeEventListener("compositionend", close);
|
|
1610
1662
|
node.removeEventListener("keyup", settle);
|
|
@@ -2735,7 +2787,10 @@ window.__ModuleLoader__.load({
|
|
|
2735
2787
|
return stamp2.toLocaleDateString(zh2 ? "zh-CN" : "en-US", { month: "short", day: "numeric" });
|
|
2736
2788
|
}
|
|
2737
2789
|
function parseTags(raw) {
|
|
2738
|
-
return raw.split(/[
|
|
2790
|
+
return raw.split(/[,,]/).map((tag) => tag.trim()).filter((tag) => tag !== "");
|
|
2791
|
+
}
|
|
2792
|
+
function formatTags(tags) {
|
|
2793
|
+
return tags.join(", ");
|
|
2739
2794
|
}
|
|
2740
2795
|
function clampZoom(value) {
|
|
2741
2796
|
return Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, value));
|
|
@@ -3318,12 +3373,12 @@ window.__ModuleLoader__.load({
|
|
|
3318
3373
|
function openComposer(note) {
|
|
3319
3374
|
setDraftError("");
|
|
3320
3375
|
setDraftStatus("idle");
|
|
3321
|
-
setDraft(note ? { id: note.id, title: note.title, body: note.body, tags: note.tags
|
|
3376
|
+
setDraft(note ? { id: note.id, title: note.title, body: note.body, tags: formatTags(note.tags), color: note.color, width: layoutOf(note, 0).width } : { id: null, title: "", body: "", tags: "", color: "yellow", width: "md" });
|
|
3322
3377
|
}
|
|
3323
3378
|
async function saveDraft() {
|
|
3324
3379
|
if (!draft || inFlight.current) return;
|
|
3325
|
-
const body = draft.body
|
|
3326
|
-
if (body === "") {
|
|
3380
|
+
const body = draft.body;
|
|
3381
|
+
if (draft.id === null && body.trim() === "") {
|
|
3327
3382
|
setDraftError(t("emptyBody"));
|
|
3328
3383
|
setDraftStatus("failed");
|
|
3329
3384
|
return;
|
|
@@ -3338,6 +3393,10 @@ window.__ModuleLoader__.load({
|
|
|
3338
3393
|
life.current.signal,
|
|
3339
3394
|
{ centreReserve: centreReserve() }
|
|
3340
3395
|
);
|
|
3396
|
+
const placed = note.layout ?? layoutOf(note, notes.length);
|
|
3397
|
+
if (placed.width !== draft.width) {
|
|
3398
|
+
await api.move(note.id, { ...placed, width: draft.width }, life.current.signal);
|
|
3399
|
+
}
|
|
3341
3400
|
arrival.current = { id: note.id, token: Date.now() };
|
|
3342
3401
|
setArrivedId(note.id);
|
|
3343
3402
|
} else {
|
package/lib/frontmatter.js
CHANGED
|
@@ -183,16 +183,92 @@ export function findFrontmatter(text) {
|
|
|
183
183
|
for (let index = 0; index < lines.length; index += 1) {
|
|
184
184
|
const line = (lines[index] ?? '').replace(/\r$/, '');
|
|
185
185
|
const trimmed = line.trim();
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
/**
|
|
187
|
+
* An opening delimiter with no closing one is not frontmatter: the user is
|
|
188
|
+
* writing a document that starts with a rule. Fall back to plain body.
|
|
189
|
+
*
|
|
190
|
+
* The content BETWEEN the delimiters must also look like frontmatter. A note
|
|
191
|
+
* that merely starts with a horizontal rule and has another one further down
|
|
192
|
+
* is ordinary Markdown:
|
|
193
|
+
*
|
|
194
|
+
* ---
|
|
195
|
+
* # My notes
|
|
196
|
+
* Shopping list
|
|
197
|
+
* ---
|
|
198
|
+
*
|
|
199
|
+
* Treating that as a frontmatter block discarded everything up to the second
|
|
200
|
+
* rule, and the next write made the loss permanent on disk. So the block is
|
|
201
|
+
* only accepted when every line inside it is something the frontmatter
|
|
202
|
+
* grammar can represent: a `key: value` pair, a `- item` continuation, a
|
|
203
|
+
* comment, or a blank line.
|
|
204
|
+
*/
|
|
188
205
|
if (trimmed === DELIMITER || trimmed === '...') {
|
|
206
|
+
const raw = rest.slice(0, offset);
|
|
207
|
+
if (!looksLikeFrontmatter(raw))
|
|
208
|
+
return null;
|
|
189
209
|
const bodyStart = offset + line.length + 1;
|
|
190
|
-
return { raw
|
|
210
|
+
return { raw, body: rest.slice(bodyStart) };
|
|
191
211
|
}
|
|
192
212
|
offset += line.length + 1;
|
|
193
213
|
}
|
|
194
214
|
return null;
|
|
195
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Whether a block between two rules is really frontmatter.
|
|
218
|
+
*
|
|
219
|
+
* Two things are being told apart:
|
|
220
|
+
*
|
|
221
|
+
* - a DAMAGED frontmatter, which must still be honoured (its readable keys win)
|
|
222
|
+
* and flagged, per the fail-soft contract — `bad line` next to `color: pink`;
|
|
223
|
+
* - PROSE that merely sits between two horizontal rules, which must not be
|
|
224
|
+
* swallowed at all:
|
|
225
|
+
*
|
|
226
|
+
* ---
|
|
227
|
+
* # My notes
|
|
228
|
+
* Shopping list
|
|
229
|
+
* ---
|
|
230
|
+
*
|
|
231
|
+
* A `key:` anywhere settles it as frontmatter. With no key at all the block is
|
|
232
|
+
* frontmatter only if it still LOOKS like one: a short run of single-token
|
|
233
|
+
* attribute lines. Prose is what fails that test — a sentence carries spaces, and
|
|
234
|
+
* a Markdown heading starts with `#` — so the whole file is kept as the body.
|
|
235
|
+
*/
|
|
236
|
+
function looksLikeFrontmatter(raw) {
|
|
237
|
+
const lines = raw.split('\n').map((line) => line.trim()).filter((line) => line !== '');
|
|
238
|
+
if (lines.length === 0)
|
|
239
|
+
return true;
|
|
240
|
+
if (lines.some((line) => /^[A-Za-z0-9_.-]+\s*:/.test(line)))
|
|
241
|
+
return true;
|
|
242
|
+
// No key at all: accept only a short block of attribute-shaped tokens.
|
|
243
|
+
if (lines.length > MAX_DAMAGED_LINES)
|
|
244
|
+
return false;
|
|
245
|
+
// A single line is the ambiguous case a real damaged file produces
|
|
246
|
+
// (`---\nbad line\n---`). Prose between two rules is a MULTI-line document by
|
|
247
|
+
// nature, so one line is read as damaged frontmatter and flagged.
|
|
248
|
+
if (lines.length === 1)
|
|
249
|
+
return true;
|
|
250
|
+
return lines.every((line) => isAttributeToken(line));
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Whether one keyless line looks like a frontmatter attribute rather than prose.
|
|
254
|
+
*
|
|
255
|
+
* An attribute is a single token (`bad`, `broken_line`). A sentence has spaces,
|
|
256
|
+
* a Markdown heading starts with `#`, and a list item starts with a marker — none
|
|
257
|
+
* of those belong inside a frontmatter block.
|
|
258
|
+
*/
|
|
259
|
+
function isAttributeToken(line) {
|
|
260
|
+
if (line.length > MAX_DAMAGED_LINE_LENGTH)
|
|
261
|
+
return false;
|
|
262
|
+
if (line.startsWith('#'))
|
|
263
|
+
return false;
|
|
264
|
+
if (line.startsWith('- '))
|
|
265
|
+
return false;
|
|
266
|
+
return !/\s/.test(line);
|
|
267
|
+
}
|
|
268
|
+
/** How many keyless lines a damaged frontmatter block may still have. */
|
|
269
|
+
const MAX_DAMAGED_LINES = 8;
|
|
270
|
+
/** How long a keyless "attribute-looking" line may be. */
|
|
271
|
+
const MAX_DAMAGED_LINE_LENGTH = 40;
|
|
196
272
|
/**
|
|
197
273
|
* Parse a frontmatter block into its key/value pairs, last writer winning.
|
|
198
274
|
*
|
|
@@ -316,8 +392,18 @@ export function parseNoteFile(text, options) {
|
|
|
316
392
|
const title = unquote(entries.get('title') ?? '').slice(0, LIMITS.title);
|
|
317
393
|
const extra = {};
|
|
318
394
|
for (const [key, value] of entries) {
|
|
395
|
+
/**
|
|
396
|
+
* `extra` values are stored UNQUOTED, exactly like every known key.
|
|
397
|
+
*
|
|
398
|
+
* They used to keep the raw source text, so a quoted value (`due: "2026-05-01"`)
|
|
399
|
+
* went back through {@link scalar} as if it were a bare string and came out
|
|
400
|
+
* double-quoted. The next read then kept THOSE quotes, and the cycle compounded:
|
|
401
|
+
* measured 39 bytes -> 110 -> 358 over six saves, on its way past the 4 MB file
|
|
402
|
+
* cap where the note silently disappears from the wall. Unquoting here is what
|
|
403
|
+
* makes property 3 ("unknown keys survive") true rather than a loop.
|
|
404
|
+
*/
|
|
319
405
|
if (!KNOWN_KEYS.has(key))
|
|
320
|
-
extra[key] = value;
|
|
406
|
+
extra[key] = unquote(value);
|
|
321
407
|
}
|
|
322
408
|
const note = {
|
|
323
409
|
// An explicit id wins; the filename is the fallback so a hand-created file
|
|
@@ -362,7 +448,15 @@ function quote(value) {
|
|
|
362
448
|
}
|
|
363
449
|
/** Serialize a scalar plain when it is unambiguous, quoted otherwise. */
|
|
364
450
|
function scalar(value) {
|
|
365
|
-
|
|
451
|
+
// A value containing a newline MUST be quoted: written bare it becomes several
|
|
452
|
+
// physical lines, and the next read sees only the first as this key's value
|
|
453
|
+
// while the rest parses as a malformed top-level line.
|
|
454
|
+
if (value !== '' &&
|
|
455
|
+
!/[\r\n]/.test(value) &&
|
|
456
|
+
!/^[\s"'[\]{#&*!|>%@`,:?\-]/.test(value) &&
|
|
457
|
+
!/\s$/.test(value) &&
|
|
458
|
+
!/^(true|false|null|yes|no|on|off|~)$/i.test(value) &&
|
|
459
|
+
!/^[+-]?\d/.test(value)) {
|
|
366
460
|
return value;
|
|
367
461
|
}
|
|
368
462
|
return quote(value);
|
package/lib/index.js
CHANGED
|
@@ -131,11 +131,18 @@ async function readLegacyNotes(facility) {
|
|
|
131
131
|
* The directory a 0.7.x install's storage domain wrote its records into.
|
|
132
132
|
*
|
|
133
133
|
* It sits beside the notes directory, under the same DSH home, so it is derived
|
|
134
|
-
* rather than configured:
|
|
135
|
-
* it to find the `<id>.json.bak.<stamp>` files a broken 0.8.0 run left
|
|
134
|
+
* rather than configured: `<DSH_HOME>/storages/<domain name>/notes`. The recovery
|
|
135
|
+
* path uses it to find the `<id>.json.bak.<stamp>` files a broken 0.8.0 run left
|
|
136
|
+
* behind.
|
|
137
|
+
*
|
|
138
|
+
* The home is ONE `dirname` up, not two. `notesDir` is `<DSH_HOME>/sticky-notes`,
|
|
139
|
+
* so a second `dirname` stripped `.dsh` as well and produced
|
|
140
|
+
* `<parent-of-home>/storages/...` — a path that never exists. The recovery then
|
|
141
|
+
* hit ENOENT, reported `already-present`, and left every user's quarantined notes
|
|
142
|
+
* stranded: the whole recovery path was dead code in the shipped configuration.
|
|
136
143
|
*/
|
|
137
144
|
function legacyNotesDirOf(notesDir) {
|
|
138
|
-
const home = dirname(
|
|
145
|
+
const home = dirname(notesDir);
|
|
139
146
|
return join(home, 'storages', LEGACY_DOMAIN_NAME, 'notes');
|
|
140
147
|
}
|
|
141
148
|
/** Model-facing text for one tool result; short, deterministic and readable. */
|
package/lib/migrate.js
CHANGED
|
@@ -57,6 +57,22 @@ async function isAlreadyPresent(notesDir) {
|
|
|
57
57
|
* they wrote themselves must never have it confused with the seed.
|
|
58
58
|
*/
|
|
59
59
|
const SEEDED_WELCOME_BODY = '随手记下一闪而过的灵感,或一件临时的工作。';
|
|
60
|
+
/**
|
|
61
|
+
* Whether one path holds 0.8.0's auto-seeded welcome note.
|
|
62
|
+
*
|
|
63
|
+
* The test is the seeded BODY, not the file name: the name `welcome` is a legal
|
|
64
|
+
* id a 0.7.x wall could genuinely own, and the whole point of the recovery is to
|
|
65
|
+
* bring that note back. Only a file whose text carries the seed's own copy is
|
|
66
|
+
* safe to replace or delete.
|
|
67
|
+
*/
|
|
68
|
+
async function isSeededWelcome(path) {
|
|
69
|
+
try {
|
|
70
|
+
return (await readFile(path, 'utf8')).includes(SEEDED_WELCOME_BODY);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
60
76
|
/** True when the directory holds nothing but 0.8.0's auto-seeded welcome note. */
|
|
61
77
|
async function isBuggyEmptyWall(notesDir) {
|
|
62
78
|
let entries;
|
|
@@ -75,13 +91,7 @@ async function isBuggyEmptyWall(notesDir) {
|
|
|
75
91
|
const only = files[0] ?? '';
|
|
76
92
|
if (idOfFile(only) !== 'welcome')
|
|
77
93
|
return false;
|
|
78
|
-
|
|
79
|
-
const text = await readFile(join(notesDir, only), 'utf8');
|
|
80
|
-
return text.includes(SEEDED_WELCOME_BODY);
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
94
|
+
return isSeededWelcome(join(notesDir, only));
|
|
85
95
|
}
|
|
86
96
|
/**
|
|
87
97
|
* Recover a wall that 0.8.0 left looking empty.
|
|
@@ -126,12 +136,20 @@ async function recoverFromBuggyWall(notesDir, options) {
|
|
|
126
136
|
if (newest.size === 0)
|
|
127
137
|
return { migrated: false, reason: 'already-present' };
|
|
128
138
|
let written = 0;
|
|
139
|
+
/** Ids whose quarantined record was written back as a real note. */
|
|
140
|
+
const restored = new Set();
|
|
129
141
|
for (const [id, { file }] of newest) {
|
|
130
142
|
const target = join(notesDir, fileNameOf(id));
|
|
131
|
-
// Never overwrite a note the user already has on the wall
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
143
|
+
// Never overwrite a note the user already has on the wall — with ONE
|
|
144
|
+
// exception: 0.8.0's own auto-seeded welcome note. It is not user data, and
|
|
145
|
+
// `isBuggyEmptyWall` only lets this function run when the directory holds
|
|
146
|
+
// nothing else. Skipping it is what destroyed the user's real `welcome`
|
|
147
|
+
// note: the record was never written, and the cleanup below then deleted the
|
|
148
|
+
// seed, so the note vanished from both sides.
|
|
149
|
+
if (await stat(target).then(() => true, () => false)) {
|
|
150
|
+
if (!(await isSeededWelcome(target)))
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
135
153
|
try {
|
|
136
154
|
const envelope = JSON.parse(await readFile(join(legacyDir, file), 'utf8'));
|
|
137
155
|
const record = envelope.record;
|
|
@@ -139,6 +157,7 @@ async function recoverFromBuggyWall(notesDir, options) {
|
|
|
139
157
|
continue;
|
|
140
158
|
const note = normalizeLegacyRecord(record, id);
|
|
141
159
|
await writeFile(target, serializeNoteFile(note), 'utf8');
|
|
160
|
+
restored.add(id);
|
|
142
161
|
written += 1;
|
|
143
162
|
}
|
|
144
163
|
catch {
|
|
@@ -146,10 +165,13 @@ async function recoverFromBuggyWall(notesDir, options) {
|
|
|
146
165
|
// must not stop the rest from coming back.
|
|
147
166
|
}
|
|
148
167
|
}
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
if (written > 0)
|
|
152
|
-
|
|
168
|
+
// Remove the seed only when the user's own `welcome` note did NOT come back.
|
|
169
|
+
// When it did, the file at that path is now the user's note and must survive.
|
|
170
|
+
if (written > 0 && !restored.has('welcome')) {
|
|
171
|
+
const seeded = join(notesDir, fileNameOf('welcome'));
|
|
172
|
+
if (await isSeededWelcome(seeded))
|
|
173
|
+
await rm(seeded, { force: true });
|
|
174
|
+
}
|
|
153
175
|
return written === 0
|
|
154
176
|
? { migrated: false, reason: 'already-present' }
|
|
155
177
|
: { migrated: true, reason: 'recovered-from-broken-migration', count: written };
|
|
@@ -215,6 +237,55 @@ function sameNote(expected, actual) {
|
|
|
215
237
|
sameInstant(expected.createdAt, actual.createdAt) &&
|
|
216
238
|
sameInstant(expected.updatedAt, actual.updatedAt));
|
|
217
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* The read-back comparison, allowing for the format's DOCUMENTED normalizations.
|
|
242
|
+
*
|
|
243
|
+
* Four fields are normalized by the writer and passed through unchanged by the
|
|
244
|
+
* legacy reader, so comparing them raw made the migration fail for ordinary
|
|
245
|
+
* walls — an uppercase tag, a ninth tag, an over-long title, a `\r\n` body — and
|
|
246
|
+
* because the failure is deterministic the retry never converged:
|
|
247
|
+
*
|
|
248
|
+
* - `tags` are lowercased, inner whitespace collapsed, each truncated to
|
|
249
|
+
* `LIMITS.tag` and capped at `LIMITS.tags`;
|
|
250
|
+
* - `title` is whitespace-collapsed and truncated to `LIMITS.title`;
|
|
251
|
+
* - `body` has its line endings folded to `\n`;
|
|
252
|
+
* - `createdAt` / `updatedAt` are re-serialized through a date.
|
|
253
|
+
*
|
|
254
|
+
* Everything else — the id, the colour, the flags, the placement, the body's
|
|
255
|
+
* TEXT — must survive exactly. A `NaN` coordinate, for instance, serializes as
|
|
256
|
+
* `x: NaN` and parses back as `0`, which is real corruption and still fails.
|
|
257
|
+
*/
|
|
258
|
+
function sameNoteIgnoringNormalization(expected, actual) {
|
|
259
|
+
return (expected.id === actual.id &&
|
|
260
|
+
normalizeTitleForCompare(expected.title) === actual.title &&
|
|
261
|
+
expected.body.replace(/\r\n?/g, '\n') === actual.body &&
|
|
262
|
+
expected.color === actual.color &&
|
|
263
|
+
expected.pinned === actual.pinned &&
|
|
264
|
+
expected.archived === actual.archived &&
|
|
265
|
+
sameTagsForCompare(expected.tags, actual.tags) &&
|
|
266
|
+
sameLayout(expected.layout, actual.layout) &&
|
|
267
|
+
sameInstant(expected.createdAt, actual.createdAt) &&
|
|
268
|
+
sameInstant(expected.updatedAt, actual.updatedAt));
|
|
269
|
+
}
|
|
270
|
+
/** The title as the writer will store it. */
|
|
271
|
+
function normalizeTitleForCompare(raw) {
|
|
272
|
+
return raw.replace(/\s+/g, ' ').trim().slice(0, LIMITS.title);
|
|
273
|
+
}
|
|
274
|
+
/** Whether the legacy tag list and the stored one are the same list, normalized. */
|
|
275
|
+
function sameTagsForCompare(expected, actual) {
|
|
276
|
+
const normalized = [];
|
|
277
|
+
const seen = new Set();
|
|
278
|
+
for (const entry of expected) {
|
|
279
|
+
const tag = entry.trim().toLowerCase().replace(/\s+/g, ' ').slice(0, LIMITS.tag);
|
|
280
|
+
if (tag === '' || seen.has(tag))
|
|
281
|
+
continue;
|
|
282
|
+
seen.add(tag);
|
|
283
|
+
normalized.push(tag);
|
|
284
|
+
if (normalized.length >= LIMITS.tags)
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
return normalized.length === actual.length && normalized.every((tag, index) => tag === actual[index]);
|
|
288
|
+
}
|
|
218
289
|
/** Compare two placements, treating two `null`s as equal. */
|
|
219
290
|
function sameLayout(left, right) {
|
|
220
291
|
if (left === null || right === null)
|
|
@@ -278,6 +349,15 @@ export async function migrateNotes(options) {
|
|
|
278
349
|
// the one just written, but only a parse proves the bytes survived the
|
|
279
350
|
// round-trip, and a silently mangled note is the one failure a user would
|
|
280
351
|
// never notice until the text was already wrong.
|
|
352
|
+
//
|
|
353
|
+
// The comparison tolerates the format's DOCUMENTED normalizations and
|
|
354
|
+
// nothing else. Comparing the raw legacy note against the parsed file failed
|
|
355
|
+
// for any note with an uppercase tag, a ninth tag, a 200-character title or a
|
|
356
|
+
// `\r\n` body — the writer normalizes all four while the legacy reader passes
|
|
357
|
+
// them through — so such a wall aborted DETERMINISTICALLY, could never
|
|
358
|
+
// converge, and (with the retry cancelled) left the notes stranded. A
|
|
359
|
+
// normalization delta is not corruption; a lost id, body, colour, placement
|
|
360
|
+
// or timestamp is, and still fails here.
|
|
281
361
|
const files = (await readdir(notesDir)).filter((name) => idOfFile(name) !== null);
|
|
282
362
|
if (files.length !== legacy.length) {
|
|
283
363
|
throw new Error(`migrated ${String(files.length)} files from ${String(legacy.length)} legacy notes`);
|
|
@@ -291,8 +371,9 @@ export async function migrateNotes(options) {
|
|
|
291
371
|
fallbackId: note.id,
|
|
292
372
|
fallbackTime: info.mtime.toISOString(),
|
|
293
373
|
});
|
|
294
|
-
if (!
|
|
374
|
+
if (!sameNoteIgnoringNormalization(note, parsed.note)) {
|
|
295
375
|
throw new Error(`migrated file for ${note.id} does not round-trip`);
|
|
376
|
+
}
|
|
296
377
|
}
|
|
297
378
|
const at = (options.now ?? (() => new Date()))().toISOString();
|
|
298
379
|
// Best-effort: the marker is documentation of what happened, and the notes
|
package/lib/store.js
CHANGED
|
@@ -97,10 +97,19 @@ function normalizeBody(raw) {
|
|
|
97
97
|
* a legitimate edit — the user is clearing the card to retype it, or keeping a
|
|
98
98
|
* card as a title only — and refusing it left the editor unable to save at all,
|
|
99
99
|
* with the old text still on disk. Length is still capped.
|
|
100
|
+
*
|
|
101
|
+
* `previousLength` lets a note that is ALREADY over the cap be shortened. Such a
|
|
102
|
+
* note can exist: `load()` reads a hand-written file by its byte size, and a body
|
|
103
|
+
* under that limit can still exceed {@link LIMITS.body}. Rejecting every edit to
|
|
104
|
+
* it left the note permanently stuck, since the only way back under the cap is to
|
|
105
|
+
* delete characters — which is an update carrying an over-limit body until the
|
|
106
|
+
* writer gets there. Growth is still refused.
|
|
100
107
|
*/
|
|
101
|
-
function normalizeBodyForUpdate(raw) {
|
|
108
|
+
function normalizeBodyForUpdate(raw, previousLength = 0) {
|
|
102
109
|
const value = readBody(raw);
|
|
103
|
-
|
|
110
|
+
if (value.length > LIMITS.body && value.length >= previousLength) {
|
|
111
|
+
assertBodyLength(value);
|
|
112
|
+
}
|
|
104
113
|
return value;
|
|
105
114
|
}
|
|
106
115
|
/** Validate and trim a title; an absent title is the empty string. */
|
|
@@ -201,6 +210,17 @@ export class StickyWallStore {
|
|
|
201
210
|
*/
|
|
202
211
|
static async open(options) {
|
|
203
212
|
const store = new StickyWallStore(options);
|
|
213
|
+
/**
|
|
214
|
+
* Whether the one-time migration failed and must be retried.
|
|
215
|
+
*
|
|
216
|
+
* A failed migration leaves the legacy wall untouched, and the contract is
|
|
217
|
+
* that the NEXT start tries again. That retry only works if this start leaves
|
|
218
|
+
* no note file behind: `isAlreadyPresent` treats any `.md` in the directory as
|
|
219
|
+
* "already migrated", so seeding the welcome note after a failure would make
|
|
220
|
+
* the legacy wall permanently invisible — one transient read error would cost
|
|
221
|
+
* the user their whole 0.7.x wall, silently, forever.
|
|
222
|
+
*/
|
|
223
|
+
let migrationFailed = false;
|
|
204
224
|
if (options.readLegacy !== undefined) {
|
|
205
225
|
const result = await migrateNotes({
|
|
206
226
|
notesDir: store.notesDir,
|
|
@@ -209,6 +229,7 @@ export class StickyWallStore {
|
|
|
209
229
|
...(options.now === undefined ? {} : { now: options.now }),
|
|
210
230
|
});
|
|
211
231
|
if (!result.migrated && result.reason === 'failed') {
|
|
232
|
+
migrationFailed = true;
|
|
212
233
|
// The legacy wall is untouched and the next start retries, so the plugin
|
|
213
234
|
// still opens — empty rather than broken. Say so loudly enough that the
|
|
214
235
|
// Host log explains why the user's notes are missing.
|
|
@@ -217,7 +238,8 @@ export class StickyWallStore {
|
|
|
217
238
|
}
|
|
218
239
|
await mkdir(store.notesDir, { recursive: true });
|
|
219
240
|
await store.load();
|
|
220
|
-
|
|
241
|
+
// Never seed after a failure: the seed is what would cancel the retry.
|
|
242
|
+
if (options.seedWelcomeNote && !migrationFailed)
|
|
221
243
|
await store.seedWelcomeNote();
|
|
222
244
|
return store;
|
|
223
245
|
}
|
|
@@ -302,11 +324,32 @@ export class StickyWallStore {
|
|
|
302
324
|
// note has; a note WITH frontmatter keeps its authored `created`.
|
|
303
325
|
fallbackTime: info.mtime.toISOString(),
|
|
304
326
|
});
|
|
327
|
+
/**
|
|
328
|
+
* Enforce the body limit on the way IN as well as on the way out.
|
|
329
|
+
*
|
|
330
|
+
* `LIMITS.fileBytes` (4 MB) is a different guard: a file can be well
|
|
331
|
+
* under it and still carry a body twenty times the documented maximum.
|
|
332
|
+
* That body used to load happily and then be impossible to save — every
|
|
333
|
+
* `update` carrying it back was rejected with `body-too-long`, so the
|
|
334
|
+
* note was trapped in the editor. It is also what the renderer would have
|
|
335
|
+
* to lay out, and the client-side cost is linear in its length.
|
|
336
|
+
*
|
|
337
|
+
* The note is kept, not dropped: a hand-written file is the user's text,
|
|
338
|
+
* so it loads with a `metaError` the card can flag, and the editor can
|
|
339
|
+
* still shorten it.
|
|
340
|
+
*/
|
|
341
|
+
const tooLong = parsed.note.body.length > LIMITS.body
|
|
342
|
+
? `body-too-long:${String(parsed.note.body.length)}`
|
|
343
|
+
: undefined;
|
|
305
344
|
// The file name is the identity on disk. A frontmatter `id` that
|
|
306
345
|
// disagrees (a hand-copied file, a rename) must not become a second
|
|
307
346
|
// address for the same note: the next write would then land in a
|
|
308
347
|
// different file and leave the loaded one behind.
|
|
309
|
-
this.notes.set(id, {
|
|
348
|
+
this.notes.set(id, {
|
|
349
|
+
...parsed.note,
|
|
350
|
+
id,
|
|
351
|
+
...(tooLong === undefined ? {} : { metaError: parsed.note.metaError ?? tooLong }),
|
|
352
|
+
});
|
|
310
353
|
}
|
|
311
354
|
catch (error) {
|
|
312
355
|
this.log(`sticky-wall: skipping unreadable note file ${entry.name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -523,7 +566,19 @@ export class StickyWallStore {
|
|
|
523
566
|
// file's frontmatter is suspect) ride through untouched.
|
|
524
567
|
const next = { ...current };
|
|
525
568
|
if (patch?.body !== undefined)
|
|
526
|
-
next.body = normalizeBodyForUpdate(patch.body);
|
|
569
|
+
next.body = normalizeBodyForUpdate(patch.body, current.body.length);
|
|
570
|
+
/**
|
|
571
|
+
* Clear the over-limit flag once the body fits again.
|
|
572
|
+
*
|
|
573
|
+
* `load()` marks a hand-written note whose body exceeded the cap so the card
|
|
574
|
+
* can say why it is unsaveable. Shortening the body is the fix, so the mark
|
|
575
|
+
* has to come off — otherwise the card keeps warning about a problem that no
|
|
576
|
+
* longer exists. Any OTHER `metaError` (a malformed or newer frontmatter) is
|
|
577
|
+
* left alone: it describes the file, not the length.
|
|
578
|
+
*/
|
|
579
|
+
if (current.metaError?.startsWith('body-too-long') === true && next.body.length <= LIMITS.body) {
|
|
580
|
+
next.metaError = undefined;
|
|
581
|
+
}
|
|
527
582
|
if (patch?.title !== undefined)
|
|
528
583
|
next.title = normalizeTitle(patch.title);
|
|
529
584
|
if (patch?.tags !== undefined)
|