@skillre/dsh-plugin-sticky-wall 0.9.5 → 0.9.7
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 +24 -26
- package/lib/markdown-parse.js +11 -3
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -411,7 +411,7 @@ window.__ModuleLoader__.load({
|
|
|
411
411
|
while (index < raw.length) {
|
|
412
412
|
const char = raw[index];
|
|
413
413
|
if (char === " ") width += 1;
|
|
414
|
-
else if (char === " ") width += INDENT_WIDTH;
|
|
414
|
+
else if (char === " ") width += INDENT_WIDTH - width % INDENT_WIDTH;
|
|
415
415
|
else break;
|
|
416
416
|
index += 1;
|
|
417
417
|
}
|
|
@@ -426,7 +426,7 @@ window.__ModuleLoader__.load({
|
|
|
426
426
|
consumed += 1;
|
|
427
427
|
index += 1;
|
|
428
428
|
} else if (char === " ") {
|
|
429
|
-
consumed += INDENT_WIDTH;
|
|
429
|
+
consumed += INDENT_WIDTH - consumed % INDENT_WIDTH;
|
|
430
430
|
index += 1;
|
|
431
431
|
} else break;
|
|
432
432
|
}
|
|
@@ -1283,7 +1283,7 @@ window.__ModuleLoader__.load({
|
|
|
1283
1283
|
}
|
|
1284
1284
|
function applyHeading(level) {
|
|
1285
1285
|
return (ctx) => rewriteLines(ctx.value, ctx.start, ctx.end, (line) => {
|
|
1286
|
-
const indent =
|
|
1286
|
+
const indent = indentSpaces(line);
|
|
1287
1287
|
return `${indent}${"#".repeat(level)} ${stripBlockMarker(line)}`;
|
|
1288
1288
|
});
|
|
1289
1289
|
}
|
|
@@ -1291,7 +1291,7 @@ window.__ModuleLoader__.load({
|
|
|
1291
1291
|
return (ctx) => {
|
|
1292
1292
|
let nextNumber = null;
|
|
1293
1293
|
return rewriteLines(ctx.value, ctx.start, ctx.end, (line) => {
|
|
1294
|
-
const indent =
|
|
1294
|
+
const indent = indentSpaces(line);
|
|
1295
1295
|
const body = stripBlockMarker(line);
|
|
1296
1296
|
if (kind === "bullet") return `${indent}- ${body}`;
|
|
1297
1297
|
if (kind === "todo") return `${indent}- [ ] ${body}`;
|
|
@@ -1445,30 +1445,27 @@ window.__ModuleLoader__.load({
|
|
|
1445
1445
|
];
|
|
1446
1446
|
function columnsOf(prefix) {
|
|
1447
1447
|
let width = 0;
|
|
1448
|
-
for (const char of prefix)
|
|
1448
|
+
for (const char of prefix) {
|
|
1449
|
+
width += char === " " ? INDENT_WIDTH2 - width % INDENT_WIDTH2 : 1;
|
|
1450
|
+
}
|
|
1449
1451
|
return width;
|
|
1450
1452
|
}
|
|
1451
|
-
function
|
|
1452
|
-
|
|
1453
|
-
for (const line of value.split("\n")) {
|
|
1454
|
-
if (line.trim() === "") continue;
|
|
1455
|
-
const columns2 = columnsOf(leadingSpace(line));
|
|
1456
|
-
if (columns2 === 0) continue;
|
|
1457
|
-
sawIndent = true;
|
|
1458
|
-
if (columns2 % WIDE_INDENT_UNIT !== 0) return INDENT_WIDTH2;
|
|
1459
|
-
}
|
|
1460
|
-
return sawIndent ? WIDE_INDENT_UNIT : INDENT_WIDTH2;
|
|
1453
|
+
function indentSpaces(line) {
|
|
1454
|
+
return " ".repeat(columnsOf(leadingSpace(line)));
|
|
1461
1455
|
}
|
|
1462
|
-
var
|
|
1456
|
+
var INDENT_STEP = INDENT_WIDTH2;
|
|
1463
1457
|
function indentSelection(value, start, end, direction) {
|
|
1464
|
-
const unit2 = indentUnitOf(value);
|
|
1465
1458
|
return rewriteLines(value, start, end, (line) => {
|
|
1466
1459
|
if (line.trim() === "") return line;
|
|
1467
1460
|
const prefix = leadingSpace(line);
|
|
1468
1461
|
const body = line.slice(prefix.length);
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1462
|
+
const columns2 = columnsOf(prefix);
|
|
1463
|
+
if (direction === 1) {
|
|
1464
|
+
const level2 = Math.floor(columns2 / INDENT_STEP);
|
|
1465
|
+
return `${" ".repeat((level2 + 1) * INDENT_STEP)}${body}`;
|
|
1466
|
+
}
|
|
1467
|
+
const level = Math.ceil(columns2 / INDENT_STEP);
|
|
1468
|
+
return `${" ".repeat(Math.max(0, level - 1) * INDENT_STEP)}${body}`;
|
|
1472
1469
|
});
|
|
1473
1470
|
}
|
|
1474
1471
|
function fenceLines(lines) {
|
|
@@ -1536,8 +1533,8 @@ window.__ModuleLoader__.load({
|
|
|
1536
1533
|
const body = text.slice(leadingSpace(text).length);
|
|
1537
1534
|
const quote = QUOTE_PREFIX.exec(body);
|
|
1538
1535
|
if (quote !== null) {
|
|
1539
|
-
const prefix2 =
|
|
1540
|
-
if (start - line.from <
|
|
1536
|
+
const prefix2 = indentSpaces(text);
|
|
1537
|
+
if (start - line.from < leadingSpace(text).length + quote[0].length) return null;
|
|
1541
1538
|
if (body.slice(quote[0].length).trim() === "") return dropMarkerLine(value, line.from, line.to);
|
|
1542
1539
|
const marker2 = quote[0].endsWith(" ") || quote[0].endsWith(" ") ? quote[0] : `${quote[0]} `;
|
|
1543
1540
|
const insert = `
|
|
@@ -1555,7 +1552,8 @@ window.__ModuleLoader__.load({
|
|
|
1555
1552
|
if (itemBody.trim() === "") {
|
|
1556
1553
|
return dropMarkerLine(value, line.from, line.to);
|
|
1557
1554
|
}
|
|
1558
|
-
const
|
|
1555
|
+
const indent = indentSpaces(text);
|
|
1556
|
+
const nextMarker = todo !== null ? `${indent}${todo[2] ?? "-"} [ ] ` : bullet !== null ? `${indent}${bullet[2] ?? "-"} ` : `${indent}${Number(ordered?.[2] ?? "1") + 1}${ordered?.[3] ?? "."} `;
|
|
1559
1557
|
const insert = `
|
|
1560
1558
|
${nextMarker}`;
|
|
1561
1559
|
const caret = start + insert.length;
|
|
@@ -1579,7 +1577,7 @@ window.__ModuleLoader__.load({
|
|
|
1579
1577
|
const prefix = leadingSpace(text);
|
|
1580
1578
|
if (prefix !== "" && text.trim() !== "" && start - line.from >= prefix.length) {
|
|
1581
1579
|
const insert = `
|
|
1582
|
-
${
|
|
1580
|
+
${indentSpaces(text)}`;
|
|
1583
1581
|
const caret = start + insert.length;
|
|
1584
1582
|
return { value: value.slice(0, start) + insert + value.slice(end), start: caret, end: caret };
|
|
1585
1583
|
}
|
|
@@ -1888,7 +1886,7 @@ window.__ModuleLoader__.load({
|
|
|
1888
1886
|
.skw-ed-btn[data-style="italic"] { font-style: italic; }
|
|
1889
1887
|
.skw-ed-btn[data-style="strike"] { text-decoration: line-through; }
|
|
1890
1888
|
.skw-ed-btn[disabled] { opacity: .45; cursor: default; }
|
|
1891
|
-
.skw-ed-input { width: 100%; min-height: ${MIN_HEIGHT_PX}px; padding: 8px 10px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; resize: none; overflow-y: auto; overflow-x: hidden; }
|
|
1889
|
+
.skw-ed-input { width: 100%; min-height: ${MIN_HEIGHT_PX}px; padding: 8px 10px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 20px; resize: none; overflow-y: auto; overflow-x: hidden; tab-size: ${INDENT_WIDTH2}; }
|
|
1892
1890
|
.skw-ed-input::placeholder { color: var(--dsw-alias-label-tertiary); }
|
|
1893
1891
|
.skw-ed-input:focus-visible { outline: none; border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); }
|
|
1894
1892
|
.skw-ed-input:disabled { opacity: .7; }
|
|
@@ -2582,7 +2580,7 @@ window.__ModuleLoader__.load({
|
|
|
2582
2580
|
border: 1px solid color-mix(in srgb, var(--skw-md-ink, currentColor) 14%, transparent);
|
|
2583
2581
|
font-size: .92em; line-height: 1.45; max-height: 180px;
|
|
2584
2582
|
}
|
|
2585
|
-
.skw-md .skw-md-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
|
|
2583
|
+
.skw-md .skw-md-pre code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; tab-size: 2; }
|
|
2586
2584
|
.skw-md .skw-md-code {
|
|
2587
2585
|
padding: .08em .34em; border-radius: 4px; font-size: .94em;
|
|
2588
2586
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
package/lib/markdown-parse.js
CHANGED
|
@@ -61,7 +61,15 @@ const QUOTE = /^>[ \t]?(.*)$/;
|
|
|
61
61
|
const TASK = /^\[([ xX])\][ \t]+([\s\S]*)$/;
|
|
62
62
|
/** A table divider cell: `---`, `:---`, `---:`, `:---:`. */
|
|
63
63
|
const TABLE_DIVIDER = /^\|?[ \t]*:?-{2,}:?[ \t]*(?:\|[ \t]*:?-{2,}:?[ \t]*)*\|?[ \t]*$/;
|
|
64
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Measure leading whitespace in columns and split the line.
|
|
66
|
+
*
|
|
67
|
+
* A tab advances to the next multiple of {@link INDENT_WIDTH}, which is the CSS
|
|
68
|
+
* `tab-size` the editor paints with (see `EDITOR_CSS` in
|
|
69
|
+
* `src/client/editor.tsx`). The nesting LEVEL is unchanged either way — a tab is
|
|
70
|
+
* still worth "about one level" — but this keeps `indent` an honest column count
|
|
71
|
+
* instead of drifting one column on a mixed `" \t"` prefix.
|
|
72
|
+
*/
|
|
65
73
|
function toLine(raw) {
|
|
66
74
|
let width = 0;
|
|
67
75
|
let index = 0;
|
|
@@ -70,7 +78,7 @@ function toLine(raw) {
|
|
|
70
78
|
if (char === ' ')
|
|
71
79
|
width += 1;
|
|
72
80
|
else if (char === '\t')
|
|
73
|
-
width += INDENT_WIDTH;
|
|
81
|
+
width += INDENT_WIDTH - (width % INDENT_WIDTH);
|
|
74
82
|
else
|
|
75
83
|
break;
|
|
76
84
|
index += 1;
|
|
@@ -88,7 +96,7 @@ function stripColumns(raw, width) {
|
|
|
88
96
|
index += 1;
|
|
89
97
|
}
|
|
90
98
|
else if (char === '\t') {
|
|
91
|
-
consumed += INDENT_WIDTH;
|
|
99
|
+
consumed += INDENT_WIDTH - (consumed % INDENT_WIDTH);
|
|
92
100
|
index += 1;
|
|
93
101
|
}
|
|
94
102
|
else
|