@bettercms-ai/kit 3.2.0 → 4.1.1
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/adapters/lossy.d.ts +4 -0
- package/dist/adapters/lossy.js +4 -0
- package/dist/adapters/lossy.js.map +1 -1
- package/dist/adapters/prod-types.d.ts +4 -0
- package/dist/adapters/prod-types.js +4 -1
- package/dist/adapters/prod-types.js.map +1 -1
- package/dist/adapters/schema.js +7 -0
- package/dist/adapters/schema.js.map +1 -1
- package/dist/context.d.ts +81 -4
- package/dist/context.js +58 -1
- package/dist/context.js.map +1 -1
- package/dist/controls/choice.d.ts +1 -1
- package/dist/controls/choice.js +21 -2
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/index.d.ts +1 -0
- package/dist/controls/index.js +3 -2
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/link.d.ts +23 -2
- package/dist/controls/link.js +456 -4
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/media-v16.d.ts +27 -0
- package/dist/controls/media-v16.js +261 -0
- package/dist/controls/media-v16.js.map +1 -0
- package/dist/controls/media.js +63 -1
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/reference-services.d.ts +8 -0
- package/dist/controls/reference.js +78 -2
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/ai-runs.d.ts +13 -0
- package/dist/controls/rich-text/ai-runs.js +71 -0
- package/dist/controls/rich-text/ai-runs.js.map +1 -0
- package/dist/controls/rich-text/block-tool.d.ts +31 -0
- package/dist/controls/rich-text/block-tool.js +62 -0
- package/dist/controls/rich-text/block-tool.js.map +1 -0
- package/dist/controls/rich-text/blocks.d.ts +6 -1
- package/dist/controls/rich-text/blocks.js +404 -24
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +21 -6
- package/dist/controls/rich-text/catalog.js +312 -23
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/code-head.d.ts +30 -0
- package/dist/controls/rich-text/code-head.js +230 -0
- package/dist/controls/rich-text/code-head.js.map +1 -0
- package/dist/controls/rich-text/codec.d.ts +3 -3
- package/dist/controls/rich-text/codec.js +3 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/control.d.ts +1 -1
- package/dist/controls/rich-text/control.js +11 -29
- package/dist/controls/rich-text/control.js.map +1 -1
- package/dist/controls/rich-text/dom.d.ts +27 -0
- package/dist/controls/rich-text/dom.js +69 -4
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.js +212 -50
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/ops.js +1 -0
- package/dist/controls/rich-text/ops.js.map +1 -1
- package/dist/controls/rich-text/slash-preview.d.ts +8 -0
- package/dist/controls/rich-text/slash-preview.js +287 -0
- package/dist/controls/rich-text/slash-preview.js.map +1 -0
- package/dist/controls/rich-text/table-grid.d.ts +22 -0
- package/dist/controls/rich-text/table-grid.js +1052 -0
- package/dist/controls/rich-text/table-grid.js.map +1 -0
- package/dist/controls/rich-text/toolbar.js +60 -18
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/text.d.ts +6 -0
- package/dist/controls/text.js +95 -5
- package/dist/controls/text.js.map +1 -1
- package/dist/core/facets.d.ts +1 -0
- package/dist/core/facets.js +1 -0
- package/dist/core/facets.js.map +1 -1
- package/dist/engine/array.d.ts +7 -0
- package/dist/engine/array.js +164 -45
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/expand.d.ts +1 -1
- package/dist/engine/expand.js +1 -1
- package/dist/engine/expand.js.map +1 -1
- package/dist/engine/field-shell.d.ts +12 -0
- package/dist/engine/field-shell.js +217 -63
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +39 -2
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.d.ts +71 -10
- package/dist/engine/grouping.js +223 -26
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/held.d.ts +2 -2
- package/dist/engine/held.js +2 -2
- package/dist/engine/held.js.map +1 -1
- package/dist/engine/kit-field.d.ts +0 -10
- package/dist/engine/kit-field.js +40 -72
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.js +7 -2
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/dist/kit.css +85 -0
- package/dist/schema/table.d.ts +2 -1
- package/dist/schema/table.js +5 -0
- package/dist/schema/table.js.map +1 -1
- package/dist/schema/types.d.ts +6 -0
- package/dist/schema/types.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +115 -0
- package/dist/tokens.css +268 -0
- package/dist/ui/block-icon-picker.d.ts +38 -0
- package/dist/ui/block-icon-picker.js +141 -0
- package/dist/ui/block-icon-picker.js.map +1 -0
- package/dist/ui/button.js +1 -0
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/code-language-menu.d.ts +24 -0
- package/dist/ui/code-language-menu.js +123 -0
- package/dist/ui/code-language-menu.js.map +1 -0
- package/dist/ui/content-fields.d.ts +47 -0
- package/dist/ui/content-fields.js +278 -0
- package/dist/ui/content-fields.js.map +1 -0
- package/dist/ui/foundations.d.ts +118 -0
- package/dist/ui/foundations.js +564 -0
- package/dist/ui/foundations.js.map +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +7 -1
- package/dist/ui/inspector.d.ts +394 -0
- package/dist/ui/inspector.js +1173 -0
- package/dist/ui/inspector.js.map +1 -0
- package/dist/ui/overlay.d.ts +7 -2
- package/dist/ui/overlay.js +55 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/shortcut-hint.js +1 -1
- package/dist/ui/shortcut-hint.js.map +1 -1
- package/dist/ui/toast.d.ts +5 -3
- package/dist/ui/toast.js +83 -11
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/tooltip-card.d.ts +45 -0
- package/dist/ui/tooltip-card.js +135 -0
- package/dist/ui/tooltip-card.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { cn } from "../../lib/cn.js";
|
|
2
|
-
import { useKitEnv, useKitServices } from "../../context.js";
|
|
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
5
|
import { Menu, MenuContent, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Tooltip } from "../../ui/overlay.js";
|
|
6
6
|
import { Input, Textarea } from "../../ui/input.js";
|
|
7
7
|
import { LinkPopoverBody } from "../link.js";
|
|
8
8
|
import { ExpandedEditorModal } from "../../ui/expanded-editor-modal.js";
|
|
9
|
-
import { closestBlock, createIsland, defaultModel, editingHost, esc, hydrate, isEmptyHtml, ownsMenu, placeCaret, rangeRect, rid, sanitize, serialize, textBeforeCaret, topBlock } from "./dom.js";
|
|
9
|
+
import { closestBlock, createIsland, defaultModel, editingHost, esc, hydrate, isEmptyHtml, ownsMenu, placeCaret, rangeRect, rid, sanitize, serialize, textBeforeCaret, textToParas, topBlock } from "./dom.js";
|
|
10
10
|
import { COMPONENT_INSERT_TOAST } from "../component-services.js";
|
|
11
11
|
import { eventKey } from "../../lib/key-event.js";
|
|
12
|
+
import { aiCommandsOffered, mapRewriteOntoRuns, textRuns } from "./ai-runs.js";
|
|
12
13
|
import { ALL_FEATURES } from "./codec.js";
|
|
13
14
|
import { createOutlineStore, outlineOf } from "./toc.js";
|
|
14
15
|
import { CatalogComponentsProvider, InsertMenuContent, SlashMenuPanel, blockAllowed, catalogKey, noteRecent, useCatalog } from "./catalog.js";
|
|
@@ -20,6 +21,7 @@ import { EMPTY_FMT, FormatToolbar, MARK_FEATURE, stylesFor } from "./toolbar.js"
|
|
|
20
21
|
import { SelectionBubble } from "./floating.js";
|
|
21
22
|
import { applyTextLink, fromLinkValue, textLinkOf, toLinkValue } from "./link-form.js";
|
|
22
23
|
import { checklistShortcut, insertChecklist, syncTaskA11y, toggleTaskAtPointer, toggleTaskFromKey } from "./checklist.js";
|
|
24
|
+
import { CodeHead, measureCodes, recolourCodes, sameCodes } from "./code-head.js";
|
|
23
25
|
import { FN_MARK, FOOTNOTE_POPOVER_CLASS, FOOTNOTE_REFUSED, FootnoteEditor, FootnotesList, backToMarker, caretAfterMarker, insertFootnote, renumberFootnotes } from "./footnote.js";
|
|
24
26
|
import { ButtonLinkPanel, applyButton, buttonAt, buttonInitial, insertButton, removeButton } from "./button.js";
|
|
25
27
|
import * as React from "react";
|
|
@@ -46,6 +48,7 @@ import { createPortal, flushSync } from "react-dom";
|
|
|
46
48
|
* Everything the editor offers is limited to what the field accepts (`features`): a toolbar button, a slash command, a
|
|
47
49
|
* Markdown shortcut or pasted markup the field cannot hold is not offered, or is turned into what it can hold and said so.
|
|
48
50
|
*/
|
|
51
|
+
var V16_QUOTE_CLASS = "[&_blockquote:not([data-rt-isolate]_*)]:border-kit-insp-accent [&_blockquote:not([data-rt-isolate]_*)]:py-0.5 [&_blockquote:not([data-rt-isolate]_*)]:text-[17px] [&_blockquote:not([data-rt-isolate]_*)]:leading-7 [&_blockquote:not([data-rt-isolate]_*)]:text-kit-insp-tip-body";
|
|
49
52
|
var RT_PROSE = "text-kit-base leading-[1.6] text-kit-fg [&>*+*]:mt-3 [&_span[class]:not([data-rt-isolate]_*)]:!text-inherit [&_span[class]:not([data-rt-isolate]_*)]:![-webkit-text-fill-color:currentColor] [&_span[class]:not([data-rt-isolate]_*)]:!bg-none [&_span[class]:not([data-rt-isolate]_*)]:!opacity-100 [&_span[class]:not([data-rt-isolate]_*)]:!visible [&_h1:not([data-rt-isolate]_*)]:text-[28px] [&_h1:not([data-rt-isolate]_*)]:font-semibold [&_h1:not([data-rt-isolate]_*)]:leading-9 [&_h1:not([data-rt-isolate]_*)]:tracking-[-0.01em] [&_h2:not([data-rt-isolate]_*)]:text-[22px] [&_h2:not([data-rt-isolate]_*)]:font-semibold [&_h2:not([data-rt-isolate]_*)]:leading-8 [&_h2:not([data-rt-isolate]_*)]:tracking-[-0.01em] [&_h3:not([data-rt-isolate]_*)]:text-kit-lg [&_h3:not([data-rt-isolate]_*)]:font-semibold [&_h4:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:font-semibold [&_h5:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:font-semibold [&_h6:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:font-semibold [&_h6:not([data-rt-isolate]_*)]:uppercase [&_h6:not([data-rt-isolate]_*)]:tracking-wide [&_h6:not([data-rt-isolate]_*)]:text-kit-fg-2 [&>h1]:mt-6 [&>h2]:mt-6 [&>h3]:mt-5 [&>*:first-child]:mt-0 [&_ul:not([data-rt-isolate]_*)]:list-disc [&_ul:not([data-rt-isolate]_*)]:pl-5 [&_ol:not([data-rt-isolate]_*)]:list-decimal [&_ol:not([data-rt-isolate]_*)]:pl-5 [&_li:not([data-rt-isolate]_*)]:pl-1 [&_li+li:not([data-rt-isolate]_*)]:mt-1 [&_li:not([data-rt-isolate]_*)]:marker:text-kit-fg-3 [&_ul[data-task]:not([data-rt-isolate]_*)]:list-none [&_ul[data-task]:not([data-rt-isolate]_*)]:pl-0 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:relative [&_ul[data-task]>li:not([data-rt-isolate]_*)]:pl-7 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:absolute [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:left-0 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:top-[0.2em] [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:flex [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:size-4 [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:items-center [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:justify-center [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:rounded-kit-md [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:border [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:border-kit-line-strong [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:bg-kit-surface [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:text-[11px] [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:font-semibold [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:leading-none [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:content-[''] [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:text-kit-fg-3 [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:line-through [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:border-kit-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:bg-kit-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:text-kit-fg-inverse [&_ul[data-task]>li[data-checked=true]:not([data-rt-isolate]_*)]:before:content-['✓'] [&_blockquote:not([data-rt-isolate]_*)]:border-l-2 [&_blockquote:not([data-rt-isolate]_*)]:border-kit-line-strong [&_blockquote:not([data-rt-isolate]_*)]:pl-4 [&_blockquote:not([data-rt-isolate]_*)]:text-kit-fg-2 [&_blockquote:not([data-rt-isolate]_*)]:italic [&_a:not([data-rt-isolate]_*)]:text-kit-accent-fg [&_a:not([data-rt-isolate]_*)]:underline [&_a:not([data-rt-isolate]_*)]:decoration-kit-accent-line [&_a:not([data-rt-isolate]_*)]:underline-offset-2 [&_a[data-button]:not([data-rt-isolate]_*)]:inline-flex [&_a[data-button]:not([data-rt-isolate]_*)]:h-9 [&_a[data-button]:not([data-rt-isolate]_*)]:items-center [&_a[data-button]:not([data-rt-isolate]_*)]:rounded-kit-md [&_a[data-button]:not([data-rt-isolate]_*)]:bg-kit-inverse [&_a[data-button]:not([data-rt-isolate]_*)]:px-3.5 [&_a[data-button]:not([data-rt-isolate]_*)]:text-kit-sm [&_a[data-button]:not([data-rt-isolate]_*)]:font-medium [&_a[data-button]:not([data-rt-isolate]_*)]:text-kit-fg-inverse [&_a[data-button]:not([data-rt-isolate]_*)]:no-underline [&_abbr:not([data-rt-isolate]_*)]:cursor-help [&_abbr:not([data-rt-isolate]_*)]:underline [&_abbr:not([data-rt-isolate]_*)]:decoration-dotted [&_abbr:not([data-rt-isolate]_*)]:underline-offset-2 [&_sup:not([data-rt-isolate]_*)]:text-[0.7em] [&_sup:not([data-rt-isolate]_*)]:leading-none [&_code:not([data-rt-isolate]_*)]:rounded-kit-md [&_code:not([data-rt-isolate]_*)]:bg-kit-muted [&_code:not([data-rt-isolate]_*)]:px-1 [&_code:not([data-rt-isolate]_*)]:py-px [&_code:not([data-rt-isolate]_*)]:font-kit-mono [&_code:not([data-rt-isolate]_*)]:text-[0.9em] [&_pre:not([data-rt-isolate]_*)]:overflow-x-auto [&_pre:not([data-rt-isolate]_*)]:whitespace-pre [&_pre:not([data-rt-isolate]_*)]:rounded-kit-lg [&_pre:not([data-rt-isolate]_*)]:bg-kit-code [&_pre:not([data-rt-isolate]_*)]:text-kit-code-fg [&_pre:not([data-rt-isolate]_*)]:p-3 [&_pre:not([data-rt-isolate]_*)]:font-kit-mono [&_pre:not([data-rt-isolate]_*)]:text-kit-sm [&_pre:not([data-rt-isolate]_*)]:border [&_pre:not([data-rt-isolate]_*)]:border-kit-line [&_pre_code:not([data-rt-isolate]_*)]:rounded-none [&_pre_code:not([data-rt-isolate]_*)]:bg-transparent [&_pre_code:not([data-rt-isolate]_*)]:p-0 [&_pre_code:not([data-rt-isolate]_*)]:text-[1em] [&_hr:not([data-rt-isolate]_*)]:my-6 [&_hr:not([data-rt-isolate]_*)]:border-kit-line [&_figure:not([data-rt-isolate]_*)]:my-4 [&_img:not([data-rt-isolate]_*)]:rounded-kit-lg [&_img:not([data-rt-isolate]_*)]:border [&_img:not([data-rt-isolate]_*)]:border-kit-line [&_figcaption:not([data-rt-isolate]_*)]:mt-1.5 [&_figcaption:not([data-rt-isolate]_*)]:text-center [&_figcaption:not([data-rt-isolate]_*)]:text-kit-sm [&_figcaption:not([data-rt-isolate]_*)]:text-kit-fg-3 [&_figure_img:not([data-rt-isolate]_*)]:block [&_figure[data-size=s]_img:not([data-rt-isolate]_*)]:w-1/3 [&_figure[data-size=m]_img:not([data-rt-isolate]_*)]:w-1/2 [&_figure[data-size=l]_img:not([data-rt-isolate]_*)]:w-3/4 [&_figure[data-align=center]_img:not([data-rt-isolate]_*)]:mx-auto [&_figure[data-align=right]_img:not([data-rt-isolate]_*)]:ml-auto [&_figure[data-align=full]_img:not([data-rt-isolate]_*)]:w-full [&_div[data-callout]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-callout]:not([data-rt-isolate]_*)]:border [&_div[data-callout]:not([data-rt-isolate]_*)]:border-kit-info-line [&_div[data-callout]:not([data-rt-isolate]_*)]:bg-kit-info-soft [&_div[data-callout]:not([data-rt-isolate]_*)]:px-4 [&_div[data-callout]:not([data-rt-isolate]_*)]:py-3 [&_div[data-callout]:not([data-rt-isolate]_*)]:text-kit-fg [&_div[data-callout=tip]:not([data-rt-isolate]_*)]:border-kit-success-line [&_div[data-callout=tip]:not([data-rt-isolate]_*)]:bg-kit-success-soft [&_div[data-callout=warning]:not([data-rt-isolate]_*)]:border-kit-warning-line [&_div[data-callout=warning]:not([data-rt-isolate]_*)]:bg-kit-warning-soft [&_div[data-callout]>p[data-title]:not([data-rt-isolate]_*)]:font-medium [&_details:not([data-rt-isolate]_*)]:rounded-kit-md [&_summary:not([data-rt-isolate]_*)]:cursor-pointer [&_summary:not([data-rt-isolate]_*)]:font-medium [&_details>div:not([data-rt-isolate]_*)]:mt-1 [&_details>div:not([data-rt-isolate]_*)]:border-l [&_details>div:not([data-rt-isolate]_*)]:border-kit-line [&_details>div:not([data-rt-isolate]_*)]:pl-4 [&_details>div:not([data-rt-isolate]_*)]:ml-1 [&_div[data-rt=columns]:not([data-rt-isolate]_*)]:grid [&_div[data-rt=columns]:not([data-rt-isolate]_*)]:gap-4 [&_div[data-cols='2']:not([data-rt-isolate]_*)]:grid-cols-2 [&_div[data-cols='3']:not([data-rt-isolate]_*)]:grid-cols-3 [&_div[data-cols='4']:not([data-rt-isolate]_*)]:grid-cols-4 [&_div[data-gap=s]:not([data-rt-isolate]_*)]:gap-2 [&_div[data-gap=l]:not([data-rt-isolate]_*)]:gap-7 [&_div[data-rt=file]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-rt=file]:not([data-rt-isolate]_*)]:border [&_div[data-rt=file]:not([data-rt-isolate]_*)]:border-kit-line [&_div[data-rt=file]:not([data-rt-isolate]_*)]:px-3 [&_div[data-rt=file]:not([data-rt-isolate]_*)]:py-2.5 [&_div[data-rt=file]:not([data-rt-isolate]_*)]:text-kit-sm [&_div[data-embed]:not([data-rt-isolate]_*)]:flex [&_div[data-embed]:not([data-rt-isolate]_*)]:aspect-video [&_div[data-embed]:not([data-rt-isolate]_*)]:items-center [&_div[data-embed]:not([data-rt-isolate]_*)]:justify-center [&_div[data-embed]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-embed]:not([data-rt-isolate]_*)]:border [&_div[data-embed]:not([data-rt-isolate]_*)]:border-kit-line [&_div[data-embed]:not([data-rt-isolate]_*)]:bg-kit-subtle [&_div[data-embed]:not([data-rt-isolate]_*)]:text-kit-sm [&_div[data-embed]:not([data-rt-isolate]_*)]:text-kit-fg-3 [&_div[data-block]:not([data-rt-isolate]_*)]:flex [&_div[data-block]:not([data-rt-isolate]_*)]:items-center [&_div[data-block]:not([data-rt-isolate]_*)]:gap-2 [&_div[data-block]:not([data-rt-isolate]_*)]:rounded-kit-lg [&_div[data-block]:not([data-rt-isolate]_*)]:border [&_div[data-block]:not([data-rt-isolate]_*)]:border-dashed [&_div[data-block]:not([data-rt-isolate]_*)]:border-kit-accent-line [&_div[data-block]:not([data-rt-isolate]_*)]:bg-kit-accent-softer [&_div[data-block]:not([data-rt-isolate]_*)]:px-3 [&_div[data-block]:not([data-rt-isolate]_*)]:py-3 [&_div[data-block]:not([data-rt-isolate]_*)]:text-kit-sm [&_div[data-block]:not([data-rt-isolate]_*)]:text-kit-accent-fg [&_table:not([data-rt-isolate]_*)]:w-full [&_table:not([data-rt-isolate]_*)]:border-collapse [&_table:not([data-rt-isolate]_*)]:text-kit-sm [&_td:not([data-rt-isolate]_*)]:border [&_td:not([data-rt-isolate]_*)]:border-kit-line [&_td:not([data-rt-isolate]_*)]:px-2.5 [&_td:not([data-rt-isolate]_*)]:py-1.5 [&_td:not([data-rt-isolate]_*)]:align-top [&_th:not([data-rt-isolate]_*)]:border [&_th:not([data-rt-isolate]_*)]:border-kit-line [&_th:not([data-rt-isolate]_*)]:bg-kit-subtle [&_th:not([data-rt-isolate]_*)]:px-2.5 [&_th:not([data-rt-isolate]_*)]:py-1.5 [&_th:not([data-rt-isolate]_*)]:text-left [&_th:not([data-rt-isolate]_*)]:align-top [&_th:not([data-rt-isolate]_*)]:font-medium";
|
|
50
53
|
/** Panel density (≈340px inspector): 13px text, smaller headings. */
|
|
51
54
|
var RT_PANEL = "text-kit-sm leading-[1.6] [&_h1:not([data-rt-isolate]_*)]:text-kit-xl [&_h1:not([data-rt-isolate]_*)]:leading-7 [&_h2:not([data-rt-isolate]_*)]:text-kit-lg [&_h2:not([data-rt-isolate]_*)]:leading-7 [&_h3:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:text-kit-xs";
|
|
@@ -252,6 +255,8 @@ var CODE_LANGUAGES = [
|
|
|
252
255
|
label: "YAML"
|
|
253
256
|
}
|
|
254
257
|
];
|
|
258
|
+
/** Look "v16": one half of the block handle pill (prototype content.css:488-491): 22×24, radius 5, a quiet grey that darkens with the pill. */
|
|
259
|
+
var V16_HANDLE_BTN = "flex h-6 w-[22px] items-center justify-center rounded-[5px] text-kit-insp-faint outline-none transition-colors duration-100 group-hover/bh:text-kit-insp-quiet hover:!bg-kit-insp-card-hover hover:!text-kit-insp-tip-title focus-visible:bg-kit-insp-card-hover focus-visible:text-kit-insp-tip-title data-[popup-open]:bg-kit-insp-card-hover data-[popup-open]:text-kit-insp-tip-title [&_svg]:size-3.5";
|
|
255
260
|
var LANG_NONE = "_none";
|
|
256
261
|
var LANG_OTHER = "_other";
|
|
257
262
|
var CODE_LANGUAGE_REASON = "Use letters, numbers and hyphens, like cpp or csharp.";
|
|
@@ -297,6 +302,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
297
302
|
valueRef.current = value;
|
|
298
303
|
const services = useKitServices();
|
|
299
304
|
const env = useKitEnv();
|
|
305
|
+
const v16 = useKitLook() === "v16";
|
|
300
306
|
const featureKey = features.join(",");
|
|
301
307
|
const allows = React.useCallback((f) => features.includes(f), [featureKey]);
|
|
302
308
|
const [empty, setEmpty] = React.useState(isEmptyHtml(value));
|
|
@@ -332,6 +338,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
332
338
|
const [langOther, setLangOther] = React.useState(null);
|
|
333
339
|
const langId = React.useId();
|
|
334
340
|
const canAI = env.can("ai.use") && !!services.aiRewrite;
|
|
341
|
+
const canAiCommand = aiCommandsOffered(v16, env.can("ai.use"), services.aiCommand);
|
|
335
342
|
const aiAttempt = React.useRef(0);
|
|
336
343
|
const [link, setLink] = React.useState(null);
|
|
337
344
|
const [drag, setDrag] = React.useState(null);
|
|
@@ -353,6 +360,13 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
353
360
|
const [gutterRoom, setGutterRoom] = React.useState(false);
|
|
354
361
|
const blurTimer = React.useRef(void 0);
|
|
355
362
|
const [notice, setNotice] = React.useState(null);
|
|
363
|
+
const [codes, setCodes] = React.useState([]);
|
|
364
|
+
const v16Ref = React.useRef(v16);
|
|
365
|
+
v16Ref.current = v16;
|
|
366
|
+
const placeCodes = React.useCallback((force) => {
|
|
367
|
+
const next = v16Ref.current ? measureCodes(ref.current, scroller.current) : [];
|
|
368
|
+
setCodes((p) => !force && sameCodes(p, next) ? p : next);
|
|
369
|
+
}, []);
|
|
356
370
|
const expanded = !!inModal;
|
|
357
371
|
const toolbarOpen = !readOnly && (focused || menus.style || menus.more || insertOpen || expanded || !!md || !!link);
|
|
358
372
|
const scrollable = !!maxHeight && !expanded;
|
|
@@ -400,6 +414,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
400
414
|
el.querySelectorAll(":scope > ol[data-rt=\"footnotes\"]").forEach((n) => n.remove());
|
|
401
415
|
el.querySelectorAll(FN_MARK).forEach((m) => m.setAttribute("contenteditable", "false"));
|
|
402
416
|
hydrate(el);
|
|
417
|
+
if (v16Ref.current) recolourCodes(el);
|
|
403
418
|
syncTaskA11y(el);
|
|
404
419
|
setFootnotes(renumberFootnotes(el));
|
|
405
420
|
outline.current.set(outlineOf(el));
|
|
@@ -482,6 +497,14 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
482
497
|
ro.observe(w);
|
|
483
498
|
return () => ro.disconnect();
|
|
484
499
|
}, []);
|
|
500
|
+
React.useLayoutEffect(() => placeCodes());
|
|
501
|
+
React.useEffect(() => {
|
|
502
|
+
const el = ref.current;
|
|
503
|
+
if (!v16 || !el || typeof ResizeObserver === "undefined") return;
|
|
504
|
+
const ro = new ResizeObserver(() => placeCodes());
|
|
505
|
+
ro.observe(el);
|
|
506
|
+
return () => ro.disconnect();
|
|
507
|
+
}, [v16, placeCodes]);
|
|
485
508
|
const [stickyTop, setStickyTop] = React.useState(0);
|
|
486
509
|
React.useEffect(() => {
|
|
487
510
|
const w = wrap.current;
|
|
@@ -638,7 +661,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
638
661
|
const s = window.getSelection();
|
|
639
662
|
return topBlock(el, s && s.rangeCount && el.contains(s.anchorNode) ? s.anchorNode : document.activeElement);
|
|
640
663
|
};
|
|
641
|
-
const deleteBlock = (b) => {
|
|
664
|
+
const deleteBlock = (b, label = "Block deleted") => {
|
|
642
665
|
const el = ref.current;
|
|
643
666
|
if (!el || !el.contains(b)) return;
|
|
644
667
|
const next = b.nextSibling;
|
|
@@ -652,7 +675,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
652
675
|
setGutter(null);
|
|
653
676
|
setBlockMenu(false);
|
|
654
677
|
emit();
|
|
655
|
-
notify(
|
|
678
|
+
notify(label, { action: {
|
|
656
679
|
label: "Undo",
|
|
657
680
|
onClick: () => {
|
|
658
681
|
const root = ref.current;
|
|
@@ -664,15 +687,34 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
664
687
|
}
|
|
665
688
|
} });
|
|
666
689
|
};
|
|
690
|
+
/** look v16 "Turn into" on a block island: the block becomes `nodes`, the caret goes to the first, Undo puts it back */
|
|
691
|
+
const replaceBlock = (b, nodes, label) => {
|
|
692
|
+
const el = ref.current;
|
|
693
|
+
if (!el || !el.contains(b) || !nodes.length) return;
|
|
694
|
+
b.replaceWith(...nodes);
|
|
695
|
+
setGutter(null);
|
|
696
|
+
emit();
|
|
697
|
+
placeCaret(nodes[0]);
|
|
698
|
+
notify(label, { action: {
|
|
699
|
+
label: "Undo",
|
|
700
|
+
onClick: () => {
|
|
701
|
+
if (!nodes[0].isConnected) return;
|
|
702
|
+
nodes[0].before(b);
|
|
703
|
+
nodes.forEach((n) => n.remove());
|
|
704
|
+
emit();
|
|
705
|
+
}
|
|
706
|
+
} });
|
|
707
|
+
};
|
|
667
708
|
const duplicateBlock$1 = (b) => {
|
|
668
709
|
const c = duplicateBlock(b);
|
|
669
710
|
emit();
|
|
670
711
|
if (gutter) placeGutter(c);
|
|
671
712
|
};
|
|
672
713
|
const moveBlock$1 = (b, dir) => {
|
|
673
|
-
if (!moveBlock(b, dir)) return;
|
|
714
|
+
if (!moveBlock(b, dir)) return false;
|
|
674
715
|
emit();
|
|
675
716
|
if (gutter) requestAnimationFrame(() => placeGutter(b));
|
|
717
|
+
return true;
|
|
676
718
|
};
|
|
677
719
|
const turnInto$1 = (b, tag) => {
|
|
678
720
|
const el = ref.current;
|
|
@@ -747,7 +789,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
747
789
|
emit();
|
|
748
790
|
refresh();
|
|
749
791
|
};
|
|
750
|
-
const slashCat = useCatalog(slash?.query ?? "", allows, slash?.folder ?? false, components ?? null);
|
|
792
|
+
const slashCat = useCatalog(slash?.query ?? "", allows, slash?.folder ?? false, components ?? null, canAiCommand, !!slash?.ai);
|
|
751
793
|
const caretRect = () => {
|
|
752
794
|
const s = window.getSelection();
|
|
753
795
|
if (!s || !s.rangeCount) return null;
|
|
@@ -759,9 +801,16 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
759
801
|
folder: true,
|
|
760
802
|
active: 1
|
|
761
803
|
});
|
|
804
|
+
if (it.kind === "ai") return setSlash((s) => s && {
|
|
805
|
+
...s,
|
|
806
|
+
ai: true,
|
|
807
|
+
folder: false,
|
|
808
|
+
active: 1
|
|
809
|
+
});
|
|
762
810
|
if (it.kind === "back") return setSlash((s) => s && {
|
|
763
811
|
...s,
|
|
764
812
|
folder: false,
|
|
813
|
+
ai: false,
|
|
765
814
|
active: 0
|
|
766
815
|
});
|
|
767
816
|
const sl = slash;
|
|
@@ -781,8 +830,96 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
781
830
|
} catch {}
|
|
782
831
|
if (it.kind === "component") flushSync(() => emit());
|
|
783
832
|
}
|
|
833
|
+
if (it.ai) {
|
|
834
|
+
emit();
|
|
835
|
+
return runAiCommand(it.ai, it.label, sl ? topBlock(ref.current, sl.node) : null);
|
|
836
|
+
}
|
|
784
837
|
insertBlock(it);
|
|
785
838
|
};
|
|
839
|
+
/**
|
|
840
|
+
* Look v16, a "BetterCMS AI" command picked in the slash menu (prototype content.jsx:1210, F2115-F2121). The host's
|
|
841
|
+
* `aiCommand` service writes; a rewrite command replaces the text block right above the caret's line, the others
|
|
842
|
+
* write new paragraphs at that line. Every write carries an Undo; a refusal and a failure are named.
|
|
843
|
+
*/
|
|
844
|
+
const runAiCommand = (kind, label, at) => {
|
|
845
|
+
const run = services.aiCommand;
|
|
846
|
+
const root = ref.current;
|
|
847
|
+
if (!run || !root) return;
|
|
848
|
+
const words = (n) => (n.textContent ?? "").replace(/\u200b/g, "");
|
|
849
|
+
const above = [];
|
|
850
|
+
for (const k of Array.from(root.children)) {
|
|
851
|
+
if (k === at) break;
|
|
852
|
+
above.push(k);
|
|
853
|
+
}
|
|
854
|
+
const rewrite = AI_REWRITE_COMMANDS.includes(kind);
|
|
855
|
+
const near = [...above].reverse().find((n) => words(n).trim());
|
|
856
|
+
const target = rewrite && near instanceof HTMLElement && /^(P|H[1-6]|BLOCKQUOTE)$/.test(near.tagName) ? near : null;
|
|
857
|
+
if (rewrite && !target) {
|
|
858
|
+
notify(`Nothing above to ${kind === "translate" ? "translate" : kind === "spelling" ? "check" : "rewrite"}`, { description: "Put the caret on the line under a paragraph, heading or quote, then pick the command again." });
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
const before = target ? target.innerHTML : "";
|
|
862
|
+
target?.normalize();
|
|
863
|
+
const runs = target ? textRuns(target) : [];
|
|
864
|
+
const context = {
|
|
865
|
+
text: Array.from(root.children).map(words).filter((t) => t.trim()).join("\n\n"),
|
|
866
|
+
before: above.map(words).filter((t) => t.trim()).join("\n\n"),
|
|
867
|
+
target: target ? words(target) : "",
|
|
868
|
+
line: at ? words(at).trim() : "",
|
|
869
|
+
runs: runs.length > 1 ? runs.map((r) => r.run.text) : []
|
|
870
|
+
};
|
|
871
|
+
notify(`BetterCMS AI · ${label}`);
|
|
872
|
+
Promise.resolve().then(() => run(kind, context)).then((out) => {
|
|
873
|
+
const el = ref.current;
|
|
874
|
+
const text = typeof out === "string" ? out.trim() : "";
|
|
875
|
+
if (!el || !text) return;
|
|
876
|
+
if (target) {
|
|
877
|
+
if (!el.contains(target) || words(target) !== context.target) {
|
|
878
|
+
notify("The text changed before BetterCMS AI came back", { description: "Nothing was replaced. Pick the command again to retry." });
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
const flat = (s) => s.replace(/\s*\n+\s*/g, " ");
|
|
882
|
+
const pieces = mapRewriteOntoRuns(runs.map((r) => r.run), text);
|
|
883
|
+
const marked = runs.some((r) => r.run.marked);
|
|
884
|
+
if (pieces && runs.every((r) => r.node.isConnected && target.contains(r.node))) runs.forEach((r, i) => r.node.data = flat(pieces[i]));
|
|
885
|
+
else target.textContent = flat(text.split("␞").join(""));
|
|
886
|
+
const kept = !!pieces;
|
|
887
|
+
emit();
|
|
888
|
+
notify(`${label}: done`, {
|
|
889
|
+
...marked && !kept ? { description: "Its formatting was removed: the new text did not line up with the old." } : {},
|
|
890
|
+
action: {
|
|
891
|
+
label: "Undo",
|
|
892
|
+
onClick: () => {
|
|
893
|
+
if (!target.isConnected) return;
|
|
894
|
+
target.innerHTML = before;
|
|
895
|
+
emit();
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
const tpl = document.createElement("template");
|
|
902
|
+
tpl.innerHTML = textToParas(text.replace(/\n{3,}/g, "\n\n"));
|
|
903
|
+
const nodes = Array.from(tpl.content.children);
|
|
904
|
+
if (!nodes.length) return;
|
|
905
|
+
const line = at && el.contains(at) ? at : null;
|
|
906
|
+
const emptyLine = line && line.tagName === "P" && !words(line).trim() ? line : null;
|
|
907
|
+
if (emptyLine) emptyLine.replaceWith(...nodes);
|
|
908
|
+
else if (line) line.after(...nodes);
|
|
909
|
+
else el.append(...nodes);
|
|
910
|
+
placeCaret(nodes[nodes.length - 1]);
|
|
911
|
+
emit();
|
|
912
|
+
notify(`${label}: done`, { action: {
|
|
913
|
+
label: "Undo",
|
|
914
|
+
onClick: () => {
|
|
915
|
+
if (!nodes[0].isConnected) return;
|
|
916
|
+
if (emptyLine) nodes[0].before(emptyLine);
|
|
917
|
+
nodes.forEach((n) => n.remove());
|
|
918
|
+
emit();
|
|
919
|
+
}
|
|
920
|
+
} });
|
|
921
|
+
}, (err) => notify("BetterCMS AI could not finish", { description: err instanceof Error ? err.message : String(err) }));
|
|
922
|
+
};
|
|
786
923
|
const toggleInlineCode = () => {
|
|
787
924
|
const el = ref.current;
|
|
788
925
|
const s = window.getSelection();
|
|
@@ -810,9 +947,10 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
810
947
|
if (e.key === "Escape") {
|
|
811
948
|
e.preventDefault();
|
|
812
949
|
e.stopPropagation();
|
|
813
|
-
setSlash(slash.folder ? {
|
|
950
|
+
setSlash(slash.folder || slash.ai ? {
|
|
814
951
|
...slash,
|
|
815
952
|
folder: false,
|
|
953
|
+
ai: false,
|
|
816
954
|
active: 0
|
|
817
955
|
} : null);
|
|
818
956
|
return;
|
|
@@ -929,7 +1067,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
929
1067
|
const onWrapKeyDown = (e) => {
|
|
930
1068
|
if (e.defaultPrevented) return;
|
|
931
1069
|
const mod = e.metaKey || e.ctrlKey;
|
|
932
|
-
if (mod && e.key === "Enter" &&
|
|
1070
|
+
if (mod && !hideFullscreen && (e.key === "Enter" || v16 && e.shiftKey && e.key.toLowerCase() === "f")) {
|
|
933
1071
|
e.preventDefault();
|
|
934
1072
|
setModalOpen(true);
|
|
935
1073
|
return;
|
|
@@ -1000,7 +1138,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1000
1138
|
setSlash({
|
|
1001
1139
|
...slash,
|
|
1002
1140
|
query: q,
|
|
1003
|
-
active: slash.folder ? 1 : 0
|
|
1141
|
+
active: slash.folder || slash.ai ? 1 : 0
|
|
1004
1142
|
});
|
|
1005
1143
|
};
|
|
1006
1144
|
const openLink = () => {
|
|
@@ -1171,9 +1309,13 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1171
1309
|
}
|
|
1172
1310
|
setDrag((d) => {
|
|
1173
1311
|
if (d && d.target !== d.from) {
|
|
1312
|
+
const same = d.target ? d.target === d.from.nextElementSibling : d.from === ref.current?.lastElementChild;
|
|
1174
1313
|
if (d.target) d.target.before(d.from);
|
|
1175
1314
|
else ref.current?.append(d.from);
|
|
1176
|
-
setTimeout(
|
|
1315
|
+
setTimeout(() => {
|
|
1316
|
+
emit();
|
|
1317
|
+
if (v16 && !same) services.toast?.("Block moved");
|
|
1318
|
+
}, 0);
|
|
1177
1319
|
}
|
|
1178
1320
|
return null;
|
|
1179
1321
|
});
|
|
@@ -1356,6 +1498,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1356
1498
|
const api = React.useRef({
|
|
1357
1499
|
emit,
|
|
1358
1500
|
deleteBlock,
|
|
1501
|
+
replaceBlock,
|
|
1359
1502
|
exitIsland,
|
|
1360
1503
|
record,
|
|
1361
1504
|
oneStep,
|
|
@@ -1370,6 +1513,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1370
1513
|
api.current = {
|
|
1371
1514
|
emit,
|
|
1372
1515
|
deleteBlock,
|
|
1516
|
+
replaceBlock,
|
|
1373
1517
|
exitIsland,
|
|
1374
1518
|
record,
|
|
1375
1519
|
oneStep,
|
|
@@ -1385,7 +1529,8 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1385
1529
|
readOnly,
|
|
1386
1530
|
dense,
|
|
1387
1531
|
emit: () => api.current.emit(),
|
|
1388
|
-
remove: (x) => api.current.deleteBlock(x),
|
|
1532
|
+
remove: (x, label) => api.current.deleteBlock(x, label),
|
|
1533
|
+
replace: (x, nodes, label) => api.current.replaceBlock(x, nodes, label),
|
|
1389
1534
|
exit: (x) => api.current.exitIsland(x),
|
|
1390
1535
|
record: (x, before, label, coalesce) => api.current.record(x, before, label, coalesce),
|
|
1391
1536
|
step: (label, write, before) => api.current.oneStep(label, write, before),
|
|
@@ -1479,6 +1624,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1479
1624
|
setFocused(false);
|
|
1480
1625
|
setBubble(null);
|
|
1481
1626
|
ref.current?.querySelectorAll("[data-hint]").forEach((n) => n.removeAttribute("data-hint"));
|
|
1627
|
+
if (v16) recolourCodes(ref.current);
|
|
1482
1628
|
if (valueRef.current !== known.current && !md) load(valueRef.current);
|
|
1483
1629
|
}, 400);
|
|
1484
1630
|
},
|
|
@@ -1710,16 +1856,23 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1710
1856
|
notify("That drop is not an image from the media library");
|
|
1711
1857
|
}
|
|
1712
1858
|
},
|
|
1713
|
-
className: cn(RT_PROSE, dense && "text-kit-sm leading-[1.6] [&_h1:not([data-rt-isolate]_*)]:text-kit-xl [&_h1:not([data-rt-isolate]_*)]:leading-7 [&_h2:not([data-rt-isolate]_*)]:text-kit-lg [&_h2:not([data-rt-isolate]_*)]:leading-7 [&_h3:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:text-kit-xs", "peer relative outline-none focus-visible:shadow-none [&_*:not([data-rt-isolate]_*)]:outline-none", "[&>p[data-hint]]:before:pointer-events-none [&>p[data-hint]]:before:float-left [&>p[data-hint]]:before:h-0 [&>p[data-hint]]:before:text-kit-fg-4 [&>p[data-hint]]:before:content-[attr(data-hint)]", "[&_a[data-button]:not([data-rt-isolate]_*)]:cursor-pointer [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:cursor-pointer", "[&_sup[data-rt=fn]]:mx-px [&_sup[data-rt=fn]]:cursor-pointer [&_sup[data-rt=fn]]:rounded-kit-sm [&_sup[data-rt=fn]]:px-0.5 [&_sup[data-rt=fn]]:text-[0.72em] [&_sup[data-rt=fn]]:leading-[0] [&_sup[data-rt=fn]]:font-semibold [&_sup[data-rt=fn]]:text-kit-accent-fg [&_sup[data-rt=fn]:hover]:bg-kit-accent-soft", dense ? "px-2.5 py-2" : "px-4 py-3.5", minH)
|
|
1859
|
+
className: cn(RT_PROSE, dense && "text-kit-sm leading-[1.6] [&_h1:not([data-rt-isolate]_*)]:text-kit-xl [&_h1:not([data-rt-isolate]_*)]:leading-7 [&_h2:not([data-rt-isolate]_*)]:text-kit-lg [&_h2:not([data-rt-isolate]_*)]:leading-7 [&_h3:not([data-rt-isolate]_*)]:text-kit-md [&_h4:not([data-rt-isolate]_*)]:text-kit-base [&_h5:not([data-rt-isolate]_*)]:text-kit-sm [&_h6:not([data-rt-isolate]_*)]:text-kit-xs", v16 && "[&>pre]:!relative [&>pre]:!my-5 [&>pre]:!rounded-[10px] [&>pre]:!border-0 [&>pre]:!bg-kit-insp-code-bg [&>pre]:!pb-[14px] [&>pre]:!pl-[60px] [&>pre]:!pr-4 [&>pre]:!pt-[50px] [&>pre]:![font:12.5px/22px_'JetBrains_Mono',ui-monospace,SFMono-Regular,Menlo,monospace] [&>pre]:!text-kit-insp-code-fg [&>pre]:caret-white [&>pre]:!whitespace-pre [&>pre]:overflow-x-auto [&>pre]:[scrollbar-width:thin] [&>pre[data-rt-wrap]]:!whitespace-pre-wrap [&>pre[data-rt-wrap]]:!pl-4 [&>pre[data-rt-wrap]]:overflow-x-visible [&_span[data-rt-hl=c]]:text-kit-insp-code-cmt [&_span[data-rt-hl=k]]:text-kit-insp-code-kw [&_span[data-rt-hl=s]]:text-kit-insp-code-str [&_span[data-rt-hl=n]]:text-kit-insp-code-num [&_span[data-rt-hl=f]]:text-kit-insp-code-fn", v16 && V16_QUOTE_CLASS, "peer relative outline-none focus-visible:shadow-none [&_*:not([data-rt-isolate]_*)]:outline-none", "[&>p[data-hint]]:before:pointer-events-none [&>p[data-hint]]:before:float-left [&>p[data-hint]]:before:h-0 [&>p[data-hint]]:before:text-kit-fg-4 [&>p[data-hint]]:before:content-[attr(data-hint)]", "[&_a[data-button]:not([data-rt-isolate]_*)]:cursor-pointer [&_ul[data-task]>li:not([data-rt-isolate]_*)]:before:cursor-pointer", "[&_sup[data-rt=fn]]:mx-px [&_sup[data-rt=fn]]:cursor-pointer [&_sup[data-rt=fn]]:rounded-kit-sm [&_sup[data-rt=fn]]:px-0.5 [&_sup[data-rt=fn]]:text-[0.72em] [&_sup[data-rt=fn]]:leading-[0] [&_sup[data-rt=fn]]:font-semibold [&_sup[data-rt=fn]]:text-kit-accent-fg [&_sup[data-rt=fn]:hover]:bg-kit-accent-soft", dense ? "px-2.5 py-2" : "px-4 py-3.5", minH)
|
|
1714
1860
|
}),
|
|
1715
1861
|
empty ? /* @__PURE__ */ jsx("div", {
|
|
1716
1862
|
"aria-hidden": true,
|
|
1717
1863
|
className: cn("pointer-events-none absolute text-kit-fg-4 peer-focus:hidden", dense ? "text-kit-sm" : "text-kit-base", dense ? "left-2.5 top-2" : "left-4 top-3.5"),
|
|
1718
1864
|
children: ph
|
|
1719
1865
|
}) : null,
|
|
1866
|
+
v16 ? codes.map((s, i) => /* @__PURE__ */ jsx(CodeHead, {
|
|
1867
|
+
s,
|
|
1868
|
+
readOnly,
|
|
1869
|
+
onLanguage: setCodeLanguage,
|
|
1870
|
+
onLayout: () => requestAnimationFrame(() => placeCodes(true)),
|
|
1871
|
+
notify: (m) => notify(m)
|
|
1872
|
+
}, i)) : null,
|
|
1720
1873
|
gutter && showGutter ? /* @__PURE__ */ jsxs("div", {
|
|
1721
1874
|
"data-rt-gutter": "",
|
|
1722
|
-
className: cn("absolute z-[3] flex
|
|
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"),
|
|
1723
1876
|
style: { top: gutter.top + Math.max(-2, Math.min(4, gutter.height / 2 - 12)) },
|
|
1724
1877
|
children: [gutterMode === "outside" ? /* @__PURE__ */ jsxs(Popover, {
|
|
1725
1878
|
open: gutterInsert,
|
|
@@ -1730,41 +1883,48 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1730
1883
|
}
|
|
1731
1884
|
setGutterInsert(o);
|
|
1732
1885
|
},
|
|
1733
|
-
children: [
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1886
|
+
children: [
|
|
1887
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
1888
|
+
content: "Add a block below",
|
|
1889
|
+
disabled: gutterInsert,
|
|
1890
|
+
children: /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
1891
|
+
"aria-label": "Add a block below",
|
|
1892
|
+
className: v16 ? V16_HANDLE_BTN : cn("flex items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[popup-open]:bg-kit-hover data-[popup-open]:text-kit-fg", btn),
|
|
1893
|
+
children: /* @__PURE__ */ jsx(IconPlus, {
|
|
1894
|
+
stroke: 1.5,
|
|
1895
|
+
"aria-hidden": true
|
|
1896
|
+
})
|
|
1742
1897
|
})
|
|
1743
|
-
})
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
inserted.current
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1898
|
+
}),
|
|
1899
|
+
v16 ? /* @__PURE__ */ jsx("i", {
|
|
1900
|
+
"aria-hidden": true,
|
|
1901
|
+
className: "h-3.5 w-px bg-transparent transition-colors duration-100 group-hover/bh:bg-kit-insp-tip-line"
|
|
1902
|
+
}) : null,
|
|
1903
|
+
gutterInsert ? /* @__PURE__ */ jsx(InsertMenuContent, {
|
|
1904
|
+
side: "bottom",
|
|
1905
|
+
align: "start",
|
|
1906
|
+
allows,
|
|
1907
|
+
keepFocusOnClose: () => inserted.current,
|
|
1908
|
+
onInsert: (it) => {
|
|
1909
|
+
const b = gutterTarget.current;
|
|
1910
|
+
const el = ref.current;
|
|
1911
|
+
inserted.current = true;
|
|
1912
|
+
setGutterInsert(false);
|
|
1913
|
+
if (!b || !el || !el.contains(b)) return;
|
|
1914
|
+
const p = document.createElement("p");
|
|
1915
|
+
p.innerHTML = "<br>";
|
|
1916
|
+
b.after(p);
|
|
1917
|
+
el.focus({ preventScroll: true });
|
|
1918
|
+
placeCaret(p);
|
|
1919
|
+
insertBlock(it);
|
|
1920
|
+
}
|
|
1921
|
+
}) : null
|
|
1922
|
+
]
|
|
1763
1923
|
}) : null, /* @__PURE__ */ jsxs(Menu, {
|
|
1764
1924
|
open: blockMenu,
|
|
1765
1925
|
onOpenChange: setBlockMenu,
|
|
1766
1926
|
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
1767
|
-
content: "Drag to move, click for options",
|
|
1927
|
+
content: v16 ? "Drag to move · click for menu" : "Drag to move, click for options",
|
|
1768
1928
|
disabled: blockMenu || !!drag,
|
|
1769
1929
|
children: /* @__PURE__ */ jsx(MenuTrigger, {
|
|
1770
1930
|
"aria-label": "Block options",
|
|
@@ -1775,18 +1935,18 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1775
1935
|
setBlockMenu(true);
|
|
1776
1936
|
}
|
|
1777
1937
|
},
|
|
1778
|
-
className: cn("flex cursor-grab items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg active:cursor-grabbing", gutterMode === "inset" ? "h-[22px] w-4 rounded-kit-sm [&_svg:not([data-rt-isolate]_*)]:size-3.5" : btn, (blockMenu || drag) && "bg-kit-hover text-kit-fg"),
|
|
1938
|
+
className: v16 && gutterMode !== "inset" ? cn(V16_HANDLE_BTN, "cursor-grab active:cursor-grabbing", (blockMenu || drag) && "bg-kit-insp-tip-line text-kit-insp-tip-title") : cn("flex cursor-grab items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg active:cursor-grabbing", gutterMode === "inset" ? "h-[22px] w-4 rounded-kit-sm [&_svg:not([data-rt-isolate]_*)]:size-3.5" : btn, (blockMenu || drag) && "bg-kit-hover text-kit-fg"),
|
|
1779
1939
|
children: /* @__PURE__ */ jsx(IconGripVertical, {
|
|
1780
1940
|
stroke: 1.5,
|
|
1781
1941
|
"aria-hidden": true
|
|
1782
1942
|
})
|
|
1783
1943
|
})
|
|
1784
1944
|
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
1785
|
-
className: "w-56",
|
|
1945
|
+
className: v16 ? "w-[200px] min-w-[200px] rounded-[10px]" : "w-56",
|
|
1786
1946
|
align: "start",
|
|
1787
1947
|
finalFocus: false,
|
|
1788
1948
|
children: [
|
|
1789
|
-
turnStyles.length > 1 ? /* @__PURE__ */ jsxs(MenuSub, { children: [/* @__PURE__ */ jsx(MenuSubTrigger, {
|
|
1949
|
+
turnStyles.length > 1 && !v16 ? /* @__PURE__ */ jsxs(MenuSub, { children: [/* @__PURE__ */ jsx(MenuSubTrigger, {
|
|
1790
1950
|
icon: /* @__PURE__ */ jsx(IconTransform, { stroke: 1.5 }),
|
|
1791
1951
|
disabled: !gIsText,
|
|
1792
1952
|
children: "Turn into"
|
|
@@ -1798,7 +1958,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1798
1958
|
children: t.label
|
|
1799
1959
|
}, t.tag))
|
|
1800
1960
|
})] }) : null,
|
|
1801
|
-
gBlock?.tagName === "PRE" && allows("pre") ? /* @__PURE__ */ jsxs(MenuSub, { children: [/* @__PURE__ */ jsx(MenuSubTrigger, {
|
|
1961
|
+
gBlock?.tagName === "PRE" && allows("pre") && !v16 ? /* @__PURE__ */ jsxs(MenuSub, { children: [/* @__PURE__ */ jsx(MenuSubTrigger, {
|
|
1802
1962
|
icon: /* @__PURE__ */ jsx(IconCode, { stroke: 1.5 }),
|
|
1803
1963
|
children: "Language"
|
|
1804
1964
|
}), /* @__PURE__ */ jsx(MenuSubContent, {
|
|
@@ -1841,14 +2001,14 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1841
2001
|
icon: /* @__PURE__ */ jsx(IconArrowBarToUp, { stroke: 1.5 }),
|
|
1842
2002
|
shortcut: "⌘⇧↑",
|
|
1843
2003
|
disabled: !gBlock?.previousElementSibling,
|
|
1844
|
-
onClick: () => gBlock && moveBlock$1(gBlock, -1),
|
|
2004
|
+
onClick: () => gBlock && moveBlock$1(gBlock, -1) && v16 && services.toast?.("Block moved"),
|
|
1845
2005
|
children: "Move up"
|
|
1846
2006
|
}),
|
|
1847
2007
|
/* @__PURE__ */ jsx(MenuItem, {
|
|
1848
2008
|
icon: /* @__PURE__ */ jsx(IconArrowBarToDown, { stroke: 1.5 }),
|
|
1849
2009
|
shortcut: "⌘⇧↓",
|
|
1850
2010
|
disabled: !gBlock?.nextElementSibling,
|
|
1851
|
-
onClick: () => gBlock && moveBlock$1(gBlock, 1),
|
|
2011
|
+
onClick: () => gBlock && moveBlock$1(gBlock, 1) && v16 && services.toast?.("Block moved"),
|
|
1852
2012
|
children: "Move down"
|
|
1853
2013
|
}),
|
|
1854
2014
|
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
@@ -1856,7 +2016,7 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
1856
2016
|
danger: true,
|
|
1857
2017
|
icon: /* @__PURE__ */ jsx(IconTrash, { stroke: 1.5 }),
|
|
1858
2018
|
onClick: () => gBlock && deleteBlock(gBlock),
|
|
1859
|
-
children: "Delete"
|
|
2019
|
+
children: v16 ? "Delete block" : "Delete"
|
|
1860
2020
|
})
|
|
1861
2021
|
]
|
|
1862
2022
|
})]
|
|
@@ -2012,6 +2172,8 @@ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder,
|
|
|
2012
2172
|
children: /* @__PURE__ */ jsx(SlashMenuPanel, {
|
|
2013
2173
|
query: slash.query,
|
|
2014
2174
|
folder: slash.folder,
|
|
2175
|
+
aiOffered: canAiCommand,
|
|
2176
|
+
aiView: !!slash.ai,
|
|
2015
2177
|
active: slash.active,
|
|
2016
2178
|
allows,
|
|
2017
2179
|
setActive: (a) => setSlash((s) => s && {
|