@bettercms-ai/kit 4.1.1 → 4.2.0-next.0
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/context.d.ts +8 -0
- package/dist/context.js.map +1 -1
- package/dist/controls/rich-text/block-tool.d.ts +1 -1
- package/dist/controls/rich-text/block-tool.js +1 -1
- package/dist/controls/rich-text/block-tool.js.map +1 -1
- package/dist/controls/rich-text/blocks.js +3 -1
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +26 -3
- package/dist/controls/rich-text/catalog.js +239 -58
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/codec.d.ts +1 -1
- package/dist/controls/rich-text/codec.js +2 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/dom.js +8 -3
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.js +32 -6
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/rewriteSelection.d.ts +25 -0
- package/dist/controls/rich-text/rewriteSelection.js +28 -0
- package/dist/controls/rich-text/rewriteSelection.js.map +1 -0
- package/dist/controls/rich-text/slash-preview.js +18 -5
- package/dist/controls/rich-text/slash-preview.js.map +1 -1
- package/dist/controls/rich-text/table-grid.js +26 -21
- package/dist/controls/rich-text/table-grid.js.map +1 -1
- package/dist/controls/rich-text/toolbar.js +1 -0
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/text.js +1 -1
- package/dist/controls/text.js.map +1 -1
- package/dist/engine/field-shell.js +8 -4
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +3 -2
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.js +4 -3
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/item-list.js +2 -2
- package/dist/engine/item-list.js.map +1 -1
- package/dist/engine/schema-form.d.ts +2 -0
- package/dist/engine/schema-form.js +2 -0
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/kit.css +6 -32
- package/dist/lib/reduced-motion.d.ts +1 -0
- package/dist/lib/reduced-motion.js +19 -0
- package/dist/lib/reduced-motion.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/theme.css +100 -0
- package/dist/tokens.css +6 -0
- package/dist/ui/content-fields.js +3 -2
- package/dist/ui/content-fields.js.map +1 -1
- package/dist/ui/controls.js +3 -2
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/floating-panel.js +3 -2
- package/dist/ui/floating-panel.js.map +1 -1
- package/dist/ui/foundations.js +3 -2
- package/dist/ui/foundations.js.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/inspector.d.ts +22 -4
- package/dist/ui/inspector.js +72 -27
- package/dist/ui/inspector.js.map +1 -1
- package/dist/ui/tab.js +3 -2
- package/dist/ui/tab.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { cn } from "../../lib/cn.js";
|
|
|
2
2
|
import { AI_REWRITE_COMMANDS, useKitEnv, useKitLook, useKitServices } from "../../context.js";
|
|
3
3
|
import { Button } from "../../ui/button.js";
|
|
4
4
|
import { platformKeys, shortcutHintsOn } from "../../ui/shortcut-hint.js";
|
|
5
|
+
import { useKitReducedMotion } from "../../lib/reduced-motion.js";
|
|
5
6
|
import { Menu, MenuContent, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Tooltip } from "../../ui/overlay.js";
|
|
6
7
|
import { Input, Textarea } from "../../ui/input.js";
|
|
7
8
|
import { LinkPopoverBody } from "../link.js";
|
|
@@ -11,6 +12,7 @@ import { COMPONENT_INSERT_TOAST } from "../component-services.js";
|
|
|
11
12
|
import { eventKey } from "../../lib/key-event.js";
|
|
12
13
|
import { aiCommandsOffered, mapRewriteOntoRuns, textRuns } from "./ai-runs.js";
|
|
13
14
|
import { ALL_FEATURES } from "./codec.js";
|
|
15
|
+
import { FORMATTING_REMOVED, LINK_SENTINEL, linkAttrs, selectionShape, unwrapLinkSentinels } from "./rewriteSelection.js";
|
|
14
16
|
import { createOutlineStore, outlineOf } from "./toc.js";
|
|
15
17
|
import { CatalogComponentsProvider, InsertMenuContent, SlashMenuPanel, blockAllowed, catalogKey, noteRecent, useCatalog } from "./catalog.js";
|
|
16
18
|
import { openComponentPanel } from "./component-panel.js";
|
|
@@ -27,7 +29,7 @@ import { ButtonLinkPanel, applyButton, buttonAt, buttonInitial, insertButton, re
|
|
|
27
29
|
import * as React from "react";
|
|
28
30
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
29
31
|
import { IconArrowBarToDown, IconArrowBarToUp, IconCode, IconCopy, IconGripVertical, IconPlus, IconTransform, IconTrash } from "@tabler/icons-react";
|
|
30
|
-
import { AnimatePresence, motion
|
|
32
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
31
33
|
import { createPortal, flushSync } from "react-dom";
|
|
32
34
|
//#region src/controls/rich-text/editor.tsx
|
|
33
35
|
/**
|
|
@@ -314,7 +316,8 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
314
316
|
const setModalOpen = (o) => onExpandedOpenChange ? onExpandedOpenChange(o) : setModalOwn(o);
|
|
315
317
|
const [md, setMd] = React.useState(null);
|
|
316
318
|
const [mdConfirm, setMdConfirm] = React.useState(false);
|
|
317
|
-
const reduceMotion =
|
|
319
|
+
const reduceMotion = useKitReducedMotion();
|
|
320
|
+
const slashReduce = !!useKitReducedMotion();
|
|
318
321
|
const [bubble, setBubble] = React.useState(null);
|
|
319
322
|
/** Comment was picked: the toolbar stays away until the next click or key inside this editor */
|
|
320
323
|
const [quiet, setQuiet] = React.useState(false);
|
|
@@ -1259,12 +1262,32 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1259
1262
|
return;
|
|
1260
1263
|
}
|
|
1261
1264
|
el.focus({ preventScroll: true });
|
|
1265
|
+
const shape = selectionShape(range, el);
|
|
1266
|
+
const attrs = shape.link ? linkAttrs(shape.link) : null;
|
|
1262
1267
|
const s = window.getSelection();
|
|
1263
1268
|
s?.removeAllRanges();
|
|
1264
1269
|
s?.addRange(range);
|
|
1265
1270
|
insertTextAtCaret(out);
|
|
1271
|
+
if (shape.link && attrs && (!el.contains(shape.link) || !shape.link.textContent?.includes(out))) {
|
|
1272
|
+
const node = s?.focusNode;
|
|
1273
|
+
const off = s?.focusOffset ?? 0;
|
|
1274
|
+
if (s && node && node.nodeType === Node.TEXT_NODE && off >= out.length) {
|
|
1275
|
+
const r = document.createRange();
|
|
1276
|
+
r.setStart(node, off - out.length);
|
|
1277
|
+
r.setEnd(node, off);
|
|
1278
|
+
s.removeAllRanges();
|
|
1279
|
+
s.addRange(r);
|
|
1280
|
+
const sentinel = `${LINK_SENTINEL}${rid()}`;
|
|
1281
|
+
if (exec("createLink", sentinel)) el.querySelectorAll("a[href]").forEach((a) => {
|
|
1282
|
+
if (a.getAttribute("href") !== sentinel) return;
|
|
1283
|
+
for (const [k, v] of attrs) a.setAttribute(k, v);
|
|
1284
|
+
});
|
|
1285
|
+
s.collapseToEnd();
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
unwrapLinkSentinels(el);
|
|
1266
1289
|
emit();
|
|
1267
|
-
notify("Rewritten with AI", { description: hints ? platformKeys("Press ⌘Z to undo") : void 0 });
|
|
1290
|
+
notify(shape.loses ? FORMATTING_REMOVED : "Rewritten with AI", { description: hints ? platformKeys("Press ⌘Z to undo") : void 0 });
|
|
1268
1291
|
}, (err) => notify("Could not rewrite the selection", { description: err instanceof Error ? err.message : String(err) }));
|
|
1269
1292
|
};
|
|
1270
1293
|
const onGripDown = (e) => {
|
|
@@ -1872,7 +1895,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1872
1895
|
}, i)) : null,
|
|
1873
1896
|
gutter && showGutter ? /* @__PURE__ */ jsxs("div", {
|
|
1874
1897
|
"data-rt-gutter": "",
|
|
1875
|
-
className: cn("absolute z-[3] flex", gutterMode === "outside" ? "-left-12 pr-1" : "left-0", v16 && gutterMode === "outside" ? (gBlock?.getAttribute("data-rt-island") === "table" ? "-left-[78px] " : "-left-[54px] ") + "group/bh items-center gap-px rounded-[7px] p-px pr-px transition-[background-color,box-shadow] duration-100 hover:bg-kit-insp-tip-bg hover:shadow-[0_0_0_1px_var(--kit-insp-tip-line),0_1px_2px_rgb(0_0_0/0.06),0_2px_8px_-2px_rgb(0_0_0/0.06)]" : "items-start"),
|
|
1898
|
+
className: cn("absolute z-[3] flex", gutterMode === "outside" ? "-left-12 pr-1" : "left-0", v16 && gutterMode === "outside" ? (gBlock?.getAttribute("data-rt-island") === "table" ? "-left-[78px] " : "-left-[54px] ") + "group/bh items-center gap-px rounded-[7px] p-px pr-px transition-[background-color,box-shadow] duration-100 hover:bg-kit-insp-tip-bg hover:shadow-[0_0_0_1px_var(--kit-insp-tip-line),0_1px_2px_rgb(0_0_0/0.06),0_2px_8px_-2px_rgb(0_0_0/0.06)] [@media(hover:hover)]:motion-safe:animate-[kit-fade-in_120ms_ease-out]" : "items-start"),
|
|
1876
1899
|
style: { top: gutter.top + Math.max(-2, Math.min(4, gutter.height / 2 - 12)) },
|
|
1877
1900
|
children: [gutterMode === "outside" ? /* @__PURE__ */ jsxs(Popover, {
|
|
1878
1901
|
open: gutterInsert,
|
|
@@ -2156,13 +2179,16 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
2156
2179
|
}), /* @__PURE__ */ jsx(motion.div, {
|
|
2157
2180
|
initial: {
|
|
2158
2181
|
opacity: 0,
|
|
2159
|
-
y: flipUp ? -4 : 4
|
|
2182
|
+
y: slashReduce ? 0 : flipUp ? -4 : 4
|
|
2160
2183
|
},
|
|
2161
2184
|
animate: {
|
|
2162
2185
|
opacity: 1,
|
|
2163
2186
|
y: 0
|
|
2164
2187
|
},
|
|
2165
|
-
transition: {
|
|
2188
|
+
transition: {
|
|
2189
|
+
duration: .14,
|
|
2190
|
+
ease: "easeOut"
|
|
2191
|
+
},
|
|
2166
2192
|
style: {
|
|
2167
2193
|
left: Math.min(window.innerWidth - 330, Math.max(8, slash.rect.left)),
|
|
2168
2194
|
...flipUp ? { bottom: window.innerHeight - slash.rect.top + 6 } : { top: slash.rect.bottom + 6 }
|