@bettercms-ai/kit 3.1.25 → 3.1.27

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.
@@ -59,4 +59,4 @@ export interface RichTextEditorProps {
59
59
  /** the components this field may embed (the insert menus' More components); absent → none offered */
60
60
  components?: CatalogComponents;
61
61
  }
62
- export declare function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, features, references, single, allowNewTab, id, invalid, variant, expandCrumbs, expandedOpen, onExpandedOpenChange, inModal, hideFullscreen, maxHeight, autoFocus, onComment, commentInPlace, components, }: RichTextEditorProps): import("react/jsx-runtime").JSX.Element;
62
+ export declare function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder, docKey, features, references, single, allowNewTab, id, invalid, variant, expandCrumbs, expandedOpen, onExpandedOpenChange, inModal, hideFullscreen, maxHeight, autoFocus, onComment, commentInPlace, components, }: RichTextEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -255,12 +255,35 @@ var CODE_LANGUAGES = [
255
255
  var LANG_NONE = "_none";
256
256
  var LANG_OTHER = "_other";
257
257
  var CODE_LANGUAGE_REASON = "Use letters, numbers and hyphens, like cpp or csharp.";
258
- function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, features = ALL_FEATURES, references, single, allowNewTab = true, id, invalid, variant = "document", expandCrumbs, expandedOpen, onExpandedOpenChange, inModal, hideFullscreen, maxHeight, autoFocus, onComment, commentInPlace, components }) {
258
+ /**
259
+ * True while a `<fieldset>` around `el` is disabled. A host holds a form that way (a locked section's dock form, a save
260
+ * in flight): the fieldset disables every form control in it, but a contenteditable is no form control, so the editor
261
+ * reads the fence itself (NEW-Q40-LOCKRTE).
262
+ */
263
+ function useDisabledFieldset(el) {
264
+ const [fenced, setFenced] = React.useState(false);
265
+ React.useLayoutEffect(() => {
266
+ const node = el.current;
267
+ if (!node) return;
268
+ const read = () => setFenced(!!node.closest("fieldset:disabled"));
269
+ read();
270
+ const watch = new MutationObserver(read);
271
+ for (let f = node.closest("fieldset"); f; f = f.parentElement?.closest("fieldset") ?? null) watch.observe(f, {
272
+ attributes: true,
273
+ attributeFilter: ["disabled"]
274
+ });
275
+ return () => watch.disconnect();
276
+ }, [el]);
277
+ return fenced;
278
+ }
279
+ function RichTextEditor({ value, onChange, readOnly: readOnlyProp, placeholder, docKey, features = ALL_FEATURES, references, single, allowNewTab = true, id, invalid, variant = "document", expandCrumbs, expandedOpen, onExpandedOpenChange, inModal, hideFullscreen, maxHeight, autoFocus, onComment, commentInPlace, components }) {
259
280
  const hints = shortcutHintsOn();
260
281
  const ph = placeholder ?? (hints ? "Type '/' for commands" : "Write something…");
261
282
  const dense = variant === "panel";
262
283
  const ref = React.useRef(null);
263
284
  const wrap = React.useRef(null);
285
+ const fenced = useDisabledFieldset(wrap);
286
+ const readOnly = !!readOnlyProp || fenced;
264
287
  const scroller = React.useRef(null);
265
288
  const saved = React.useRef(null);
266
289
  const known = React.useRef(null);
@@ -1438,7 +1461,7 @@ function RichTextEditor({ value, onChange, readOnly, placeholder, docKey, featur
1438
1461
  children: /* @__PURE__ */ jsxs("div", {
1439
1462
  ref: wrap,
1440
1463
  "data-rt-editor": "",
1441
- 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"),
1464
+ className: cn("relative [--rt-toolbar-h:2rem] pointer-coarse:[--rt-toolbar-h:2.75rem]", "rounded-kit-lg border transition-colors duration-150", fenced ? "cursor-not-allowed bg-kit-subtle opacity-60" : 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"),
1442
1465
  style: { "--rt-sticky-top": toolbarOpen && !dense ? `calc(${stickyTop}px + var(--rt-toolbar-h))` : "var(--kit-sticky-top, 0px)" },
1443
1466
  onMouseLeave: () => !blockMenu && !gutterInsert && !drag && setGutter(null),
1444
1467
  onKeyDown: onWrapKeyDown,