@bettercms-ai/kit 3.1.12 → 3.1.14
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/controls/code.js +2 -2
- package/dist/controls/code.js.map +1 -1
- package/dist/controls/color.js +1 -1
- package/dist/controls/color.js.map +1 -1
- package/dist/controls/link.js +2 -1
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/location.d.ts +1 -1
- package/dist/controls/location.js +24 -7
- package/dist/controls/location.js.map +1 -1
- package/dist/controls/media.js +1 -1
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/number.js +18 -5
- package/dist/controls/number.js.map +1 -1
- package/dist/controls/reference.js +1 -1
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +2 -1
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/control.js +1 -1
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/editor.js +63 -4
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/ops.d.ts +3 -0
- package/dist/controls/rich-text/ops.js +47 -2
- package/dist/controls/rich-text/ops.js.map +1 -1
- package/dist/engine/array.js +2 -2
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/field-shell.js +2 -2
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/kit-field.js +1 -1
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/lib/validate.js +30 -0
- package/dist/lib/validate.js.map +1 -1
- package/dist/library/entries/advanced.entries.js +1 -1
- package/dist/library/entries/advanced.entries.js.map +1 -1
- package/dist/library/entries/media.entries.js +1 -1
- package/dist/library/entries/media.entries.js.map +1 -1
- package/dist/library/kit-catalog.json +2 -2
- package/dist/styles.css +1 -1
- package/dist/theme.css +2 -2
- package/dist/tokens.css +7 -7
- package/dist/ui/button.js +2 -2
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/controls.js +6 -6
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/input.js +12 -0
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/select.js +1 -1
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/toast.js +1 -1
- package/dist/ui/toast.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ import { CatalogComponentsProvider, InsertMenuContent, SlashMenuPanel, blockAllo
|
|
|
15
15
|
import { openComponentPanel } from "./component-panel.js";
|
|
16
16
|
import { Island } from "./blocks.js";
|
|
17
17
|
import { htmlToMarkdown, looksLikeMarkdown, markdownToHtml } from "./markdown.js";
|
|
18
|
-
import { duplicateBlock, ensureLineAfter, indentListItem, insertBasic, insertIsland, liveInlineCode, liveInlineEmphasis, liveMarkdown, moveBlock, outdentListItem, pastedHtml, restrictHtml, turnInto } from "./ops.js";
|
|
18
|
+
import { duplicateBlock, ensureLineAfter, forgetLiveMarkdown, indentListItem, insertBasic, insertIsland, liveInlineCode, liveInlineEmphasis, liveMarkdown, moveBlock, outdentListItem, pastedHtml, restrictHtml, turnInto, undoLiveMarkdown } from "./ops.js";
|
|
19
19
|
import { EMPTY_FMT, FormatToolbar, MARK_FEATURE, stylesFor } from "./toolbar.js";
|
|
20
20
|
import { SelectionBubble } from "./floating.js";
|
|
21
21
|
import { applyTextLink, fromLinkValue, textLinkOf, toLinkValue } from "./link-form.js";
|
|
@@ -87,6 +87,43 @@ function toggleScript(root, tag) {
|
|
|
87
87
|
if (other) unwrap(other);
|
|
88
88
|
exec(tag === "sup" ? "superscript" : "subscript");
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* RP-012: underline inside a link. The browser reads a link's own decoration as the mark, so its underline command
|
|
92
|
+
* there turns nothing on and the mark was dropped in silence. Inside one link the mark is ours: an explicit `<u>` around
|
|
93
|
+
* the selection, taken off again when the selection sits in one. False when the selection is not inside one link (the
|
|
94
|
+
* browser's own command runs).
|
|
95
|
+
*/
|
|
96
|
+
function toggleLinkUnderline(root) {
|
|
97
|
+
const s = window.getSelection();
|
|
98
|
+
if (!s || !s.rangeCount || s.isCollapsed) return false;
|
|
99
|
+
const r = s.getRangeAt(0);
|
|
100
|
+
const at = (n) => n?.nodeType === 1 ? n : n?.parentElement ?? null;
|
|
101
|
+
const link = at(r.startContainer)?.closest("a");
|
|
102
|
+
if (!link || !root.contains(link) || at(r.endContainer)?.closest("a") !== link) return false;
|
|
103
|
+
const select = (first, last) => {
|
|
104
|
+
const nr = document.createRange();
|
|
105
|
+
nr.setStartBefore(first);
|
|
106
|
+
nr.setEndAfter(last);
|
|
107
|
+
s.removeAllRanges();
|
|
108
|
+
s.addRange(nr);
|
|
109
|
+
};
|
|
110
|
+
const inside = at(r.startContainer)?.closest("u");
|
|
111
|
+
const around = r.startContainer === r.endContainer && r.endOffset - r.startOffset === 1 ? r.startContainer.childNodes[r.startOffset] : null;
|
|
112
|
+
const on = inside && link.contains(inside) ? inside : around instanceof HTMLElement && around.tagName === "U" ? around : null;
|
|
113
|
+
if (on) {
|
|
114
|
+
const kids = Array.from(on.childNodes);
|
|
115
|
+
on.replaceWith(...kids);
|
|
116
|
+
if (kids.length) select(kids[0], kids[kids.length - 1]);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const u = document.createElement("u");
|
|
120
|
+
u.append(r.extractContents());
|
|
121
|
+
r.insertNode(u);
|
|
122
|
+
s.selectAllChildren(u);
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
/** The underline mark at `el`: inside a link only an explicit `<u>` counts (the link's own decoration is not the mark). */
|
|
126
|
+
var underlineAt = (el) => el?.closest("a") ? !!el.closest("u") : queryState("underline");
|
|
90
127
|
/** Focus is in another text field (the comment composer, a link input) while the page's selection stays in this editor. */
|
|
91
128
|
var typingElsewhere = (el) => {
|
|
92
129
|
const ae = document.activeElement;
|
|
@@ -478,7 +515,7 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
|
|
|
478
515
|
const next = {
|
|
479
516
|
bold: queryState("bold") && !/^H[1-6]$/.test(tb?.tagName ?? ""),
|
|
480
517
|
italic: queryState("italic"),
|
|
481
|
-
underline:
|
|
518
|
+
underline: underlineAt(anchorEl),
|
|
482
519
|
strike: queryState("strikeThrough"),
|
|
483
520
|
sup: !!anchorEl?.closest(`sup:not(${FOOTNOTE_SUP})`),
|
|
484
521
|
sub: !!anchorEl?.closest("sub"),
|
|
@@ -671,6 +708,13 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
|
|
|
671
708
|
const text = s.toString();
|
|
672
709
|
if (!text) return void notify("Select some text first", { description: "Or wrap words in backticks to format them as code." });
|
|
673
710
|
insertHtmlAtCaret(`<code>${esc(text)}</code>`);
|
|
711
|
+
(s.anchorNode && topBlock(el, s.anchorNode))?.querySelectorAll("code").forEach((c) => {
|
|
712
|
+
if (c.textContent !== text) return;
|
|
713
|
+
const prev = c.previousSibling;
|
|
714
|
+
const next = c.nextSibling;
|
|
715
|
+
if (prev instanceof Text && /[^\s ] $/.test(prev.data)) prev.data = `${prev.data.slice(0, -1)} `;
|
|
716
|
+
if (next instanceof Text && /^ [^\s ]/.test(next.data)) next.data = ` ${next.data.slice(1)}`;
|
|
717
|
+
});
|
|
674
718
|
emit();
|
|
675
719
|
};
|
|
676
720
|
const onKeyDown = (e) => {
|
|
@@ -720,6 +764,12 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
|
|
|
720
764
|
toggleInlineCode();
|
|
721
765
|
return;
|
|
722
766
|
}
|
|
767
|
+
if (mod && !e.altKey && !e.shiftKey && k === "u" && allows("underline") && ref.current && toggleLinkUnderline(ref.current)) {
|
|
768
|
+
e.preventDefault();
|
|
769
|
+
emit();
|
|
770
|
+
refresh();
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
723
773
|
if (mod && !e.altKey && !e.shiftKey && (k === "b" && !allows("bold") || k === "i" && !allows("italic") || k === "u" && !allows("underline"))) {
|
|
724
774
|
e.preventDefault();
|
|
725
775
|
return;
|
|
@@ -814,6 +864,7 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
|
|
|
814
864
|
hist.current.textAt = Date.now();
|
|
815
865
|
hist.current.future = [];
|
|
816
866
|
}
|
|
867
|
+
forgetLiveMarkdown(ref.current);
|
|
817
868
|
if (!single && ne.inputType === "insertText" && allows("checklist") && checklistShortcut(ref.current, ne.data)) {
|
|
818
869
|
setSlash(null);
|
|
819
870
|
emit();
|
|
@@ -1189,6 +1240,11 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
|
|
|
1189
1240
|
if (!islandRedo()) exec("redo");
|
|
1190
1241
|
return true;
|
|
1191
1242
|
}
|
|
1243
|
+
if (ref.current && undoLiveMarkdown(ref.current)) {
|
|
1244
|
+
e.preventDefault();
|
|
1245
|
+
emit();
|
|
1246
|
+
return true;
|
|
1247
|
+
}
|
|
1192
1248
|
if (islandUndo()) {
|
|
1193
1249
|
e.preventDefault();
|
|
1194
1250
|
return true;
|
|
@@ -1260,7 +1316,10 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
|
|
|
1260
1316
|
setQuiet(true);
|
|
1261
1317
|
if (q) onComment(q);
|
|
1262
1318
|
} : void 0;
|
|
1263
|
-
const onMark = (cmd) => allows(MARK_FEATURE[cmd]) && run(() =>
|
|
1319
|
+
const onMark = (cmd) => allows(MARK_FEATURE[cmd]) && run(() => {
|
|
1320
|
+
if (cmd === "superscript" || cmd === "subscript") ref.current && toggleScript(ref.current, cmd === "superscript" ? "sup" : "sub");
|
|
1321
|
+
else if (!(cmd === "underline" && ref.current && toggleLinkUnderline(ref.current))) exec(cmd);
|
|
1322
|
+
});
|
|
1264
1323
|
const onStyle = (tag) => {
|
|
1265
1324
|
restoreSel();
|
|
1266
1325
|
turnInto$1(currentBlock(), tag);
|
|
@@ -1290,7 +1349,7 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
|
|
|
1290
1349
|
children: /* @__PURE__ */ jsxs("div", {
|
|
1291
1350
|
ref: wrap,
|
|
1292
1351
|
"data-rt-editor": "",
|
|
1293
|
-
className: cn("relative [--rt-toolbar-h:2rem] pointer-coarse:[--rt-toolbar-h:2.75rem]", "rounded-kit-lg border transition-colors duration-150", expanded ? "bg-[var(--kit-surface-raised)]" : "bg-kit-surface", invalid ? "border-[var(--kit-field-invalid)]" : toolbarOpen ? "border-kit-
|
|
1352
|
+
className: cn("relative [--rt-toolbar-h:2rem] pointer-coarse:[--rt-toolbar-h:2.75rem]", "rounded-kit-lg border transition-colors duration-150", expanded ? "bg-[var(--kit-surface-raised)]" : "bg-kit-surface", invalid ? "border-[var(--kit-field-invalid)]" : toolbarOpen ? "border-[var(--kit-field-border-focus)]" : "border-kit-line-strong"),
|
|
1294
1353
|
style: { "--rt-sticky-top": toolbarOpen && !dense ? `calc(${stickyTop}px + var(--rt-toolbar-h))` : "var(--kit-sticky-top, 0px)" },
|
|
1295
1354
|
onMouseLeave: () => !blockMenu && !gutterInsert && !drag && setGutter(null),
|
|
1296
1355
|
onKeyDown: onWrapKeyDown,
|