@rebasepro/cms 0.25.0-canary.ge06257e → 0.25.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.
@@ -24,7 +24,7 @@ function EntityTableCellActions({ showError, disabled, showExpandIcon, selected,
24
24
  size: "small",
25
25
  onClick: doOpenPopup,
26
26
  children: /* @__PURE__ */ jsxs("svg", {
27
- fill: "#888",
27
+ fill: "#838991",
28
28
  width: "20",
29
29
  height: "20",
30
30
  viewBox: "0 0 24 24",
@@ -1 +1 @@
1
- {"version":3,"file":"EntityTableCellActions.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/EntityTableCellActions.tsx"],"sourcesContent":["import { AlertCircleIcon, IconButton } from \"@rebasepro/ui\";\nimport { ErrorTooltip, useTranslation } from \"@rebasepro/app\";\nimport { useCallback, useEffect, useRef } from \"react\";\n\nexport interface EntityTableCellActionsProps {\n showError: false | Error | undefined;\n disabled: boolean;\n showExpandIcon: boolean | undefined;\n selected: boolean | undefined;\n openPopup?: (cellRect: DOMRect | undefined) => void;\n children?: React.ReactNode;\n}\n\nexport function EntityTableCellActions({\n showError,\n disabled,\n showExpandIcon,\n selected,\n openPopup,\n children\n}: EntityTableCellActionsProps) {\n const { t } = useTranslation();\n\n const ref = useRef<HTMLDivElement>(null);\n const doOpenPopup = useCallback(() => {\n if (openPopup) {\n const cellRect = ref && ref?.current?.getBoundingClientRect();\n openPopup(cellRect);\n }\n }, []);\n\n const iconRef = useRef<HTMLButtonElement>(null);\n useEffect(() => {\n if (iconRef.current && selected) {\n iconRef.current.focus({ preventScroll: true });\n }\n }, [selected]);\n\n return <>\n {(showError || (!disabled && showExpandIcon)) &&\n <div ref={ref} className=\"absolute top-0.5 right-0.5 flex items-center\">\n {selected && children}\n\n {selected && !disabled && showExpandIcon &&\n <IconButton aria-label={t(\"expand\")}\n ref={iconRef}\n size={\"small\"}\n onClick={doOpenPopup}>\n <svg\n fill={\"#888\"}\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\">\n <path className=\"cls-2\"\n d=\"M20,5a1,1,0,0,0-1-1L14,4h0a1,1,0,0,0,0,2h2.57L13.29,9.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L18,7.42V10a1,1,0,0,0,1,1h0a1,1,0,0,0,1-1Z\"/>\n <path className=\"cls-2\"\n d=\"M10.71,13.29a1,1,0,0,0-1.42,0L6,16.57V14a1,1,0,0,0-1-1H5a1,1,0,0,0-1,1l0,5a1,1,0,0,0,1,1h5a1,1,0,0,0,0-2H7.42l3.29-3.29A1,1,0,0,0,10.71,13.29Z\"/>\n </svg>\n </IconButton>\n }\n\n {showError && <ErrorTooltip\n side={\"left\"}\n title={showError.message}>\n <div\n className={\"flex items-center justify-center\"}\n style={{\n width: 32,\n height: 32\n }}>\n <AlertCircleIcon\n />\n </div>\n </ErrorTooltip>\n }\n\n </div>\n }\n </>;\n}\n"],"mappings":";;;;;AAaA,SAAgB,uBAAuB,EACnC,WACA,UACA,gBACA,UACA,WACA,YAC4B;CAC5B,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,cAAc,kBAAkB;EAClC,IAAI,WAEA,UADiB,OAAO,KAAK,SAAS,sBAAsB,CAC1C;CAE1B,GAAG,CAAC,CAAC;CAEL,MAAM,UAAU,OAA0B,IAAI;CAC9C,gBAAgB;EACZ,IAAI,QAAQ,WAAW,UACnB,QAAQ,QAAQ,MAAM,EAAE,eAAe,KAAK,CAAC;CAErD,GAAG,CAAC,QAAQ,CAAC;CAEb,OAAO,oBAAA,UAAA,EAAA,WACD,aAAc,CAAC,YAAY,mBACzB,qBAAC,OAAD;EAAU;EAAK,WAAU;YAAzB;GACK,YAAY;GAEZ,YAAY,CAAC,YAAY,kBACtB,oBAAC,YAAD;IAAY,cAAY,EAAE,QAAQ;IAC9B,KAAK;IACL,MAAM;IACN,SAAS;cACT,qBAAC,OAAD;KACI,MAAM;KACN,OAAM;KACN,QAAO;KACP,SAAQ;eAJZ,CAKI,oBAAC,QAAD;MAAM,WAAU;MACZ,GAAE;KAAuI,CAAA,GAC7I,oBAAC,QAAD;MAAM,WAAU;MACZ,GAAE;KAAiJ,CAAA,CACtJ;;GACG,CAAA;GAGf,aAAa,oBAAC,cAAD;IACV,MAAM;IACN,OAAO,UAAU;cACjB,oBAAC,OAAD;KACI,WAAW;KACX,OAAO;MACH,OAAO;MACP,QAAQ;KACZ;eACA,oBAAC,iBAAD,CACC,CAAA;IACA,CAAA;GACK,CAAA;EAGb;IAEX,CAAA;AACN"}
1
+ {"version":3,"file":"EntityTableCellActions.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/internal/EntityTableCellActions.tsx"],"sourcesContent":["import { AlertCircleIcon, IconButton } from \"@rebasepro/ui\";\nimport { ErrorTooltip, useTranslation } from \"@rebasepro/app\";\nimport { useCallback, useEffect, useRef } from \"react\";\n\nexport interface EntityTableCellActionsProps {\n showError: false | Error | undefined;\n disabled: boolean;\n showExpandIcon: boolean | undefined;\n selected: boolean | undefined;\n openPopup?: (cellRect: DOMRect | undefined) => void;\n children?: React.ReactNode;\n}\n\nexport function EntityTableCellActions({\n showError,\n disabled,\n showExpandIcon,\n selected,\n openPopup,\n children\n}: EntityTableCellActionsProps) {\n const { t } = useTranslation();\n\n const ref = useRef<HTMLDivElement>(null);\n const doOpenPopup = useCallback(() => {\n if (openPopup) {\n const cellRect = ref && ref?.current?.getBoundingClientRect();\n openPopup(cellRect);\n }\n }, []);\n\n const iconRef = useRef<HTMLButtonElement>(null);\n useEffect(() => {\n if (iconRef.current && selected) {\n iconRef.current.focus({ preventScroll: true });\n }\n }, [selected]);\n\n return <>\n {(showError || (!disabled && showExpandIcon)) &&\n <div ref={ref} className=\"absolute top-0.5 right-0.5 flex items-center\">\n {selected && children}\n\n {selected && !disabled && showExpandIcon &&\n <IconButton aria-label={t(\"expand\")}\n ref={iconRef}\n size={\"small\"}\n onClick={doOpenPopup}>\n <svg\n fill={\"#838991\"}\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\">\n <path className=\"cls-2\"\n d=\"M20,5a1,1,0,0,0-1-1L14,4h0a1,1,0,0,0,0,2h2.57L13.29,9.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L18,7.42V10a1,1,0,0,0,1,1h0a1,1,0,0,0,1-1Z\"/>\n <path className=\"cls-2\"\n d=\"M10.71,13.29a1,1,0,0,0-1.42,0L6,16.57V14a1,1,0,0,0-1-1H5a1,1,0,0,0-1,1l0,5a1,1,0,0,0,1,1h5a1,1,0,0,0,0-2H7.42l3.29-3.29A1,1,0,0,0,10.71,13.29Z\"/>\n </svg>\n </IconButton>\n }\n\n {showError && <ErrorTooltip\n side={\"left\"}\n title={showError.message}>\n <div\n className={\"flex items-center justify-center\"}\n style={{\n width: 32,\n height: 32\n }}>\n <AlertCircleIcon\n />\n </div>\n </ErrorTooltip>\n }\n\n </div>\n }\n </>;\n}\n"],"mappings":";;;;;AAaA,SAAgB,uBAAuB,EACnC,WACA,UACA,gBACA,UACA,WACA,YAC4B;CAC5B,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,MAAM,OAAuB,IAAI;CACvC,MAAM,cAAc,kBAAkB;EAClC,IAAI,WAEA,UADiB,OAAO,KAAK,SAAS,sBAAsB,CAC1C;CAE1B,GAAG,CAAC,CAAC;CAEL,MAAM,UAAU,OAA0B,IAAI;CAC9C,gBAAgB;EACZ,IAAI,QAAQ,WAAW,UACnB,QAAQ,QAAQ,MAAM,EAAE,eAAe,KAAK,CAAC;CAErD,GAAG,CAAC,QAAQ,CAAC;CAEb,OAAO,oBAAA,UAAA,EAAA,WACD,aAAc,CAAC,YAAY,mBACzB,qBAAC,OAAD;EAAU;EAAK,WAAU;YAAzB;GACK,YAAY;GAEZ,YAAY,CAAC,YAAY,kBACtB,oBAAC,YAAD;IAAY,cAAY,EAAE,QAAQ;IAC9B,KAAK;IACL,MAAM;IACN,SAAS;cACT,qBAAC,OAAD;KACI,MAAM;KACN,OAAM;KACN,QAAO;KACP,SAAQ;eAJZ,CAKI,oBAAC,QAAD;MAAM,WAAU;MACZ,GAAE;KAAuI,CAAA,GAC7I,oBAAC,QAAD;MAAM,WAAU;MACZ,GAAE;KAAiJ,CAAA,CACtJ;;GACG,CAAA;GAGf,aAAa,oBAAC,cAAD;IACV,MAAM;IACN,OAAO,UAAU;cACjB,oBAAC,OAAD;KACI,WAAW;KACX,OAAO;MACH,OAAO;MACP,QAAQ;KACZ;eACA,oBAAC,iBAAD,CACC,CAAA;IACA,CAAA;GACK,CAAA;EAGb;IAEX,CAAA;AACN"}
@@ -9,7 +9,7 @@ function PropertyConfigBadge({ propertyConfig, disabled, size = "medium" }) {
9
9
  const defaultPropertyConfig = typeof propertyConfig?.property === "object" ? getDefaultFieldConfig(propertyConfig.property) : void 0;
10
10
  return /* @__PURE__ */ jsx("div", {
11
11
  className: classes,
12
- style: { background: !disabled ? propertyConfig?.color ?? defaultPropertyConfig?.color ?? "#888" : void 0 },
12
+ style: { background: !disabled ? propertyConfig?.color ?? defaultPropertyConfig?.color ?? "#838991" : void 0 },
13
13
  children: propertyConfig?.Icon ? getIconForWidget(propertyConfig, iconSize) : getIconForWidget(defaultPropertyConfig, iconSize)
14
14
  });
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyConfigBadge.js","names":[],"sources":["../../src/components/PropertyConfigBadge.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertyConfig } from \"@rebasepro/cms-types\";\nimport { getDefaultFieldConfig } from \"./field_configs\";\nimport { getIconForWidget } from \"../util/property_utils\";\n\nexport function PropertyConfigBadge({\n propertyConfig,\n disabled,\n size = \"medium\"\n}: {\n propertyConfig: PropertyConfig | undefined,\n disabled?: boolean,\n size?: \"extraSmall\" | \"small\" | \"medium\"\n}): React.ReactNode {\n const sizeClasses = size === \"extraSmall\" ? \"h-5 w-5\" : size === \"small\" ? \"h-6 w-6\" : \"h-8 w-8\";\n const iconSize = size === \"extraSmall\" ? 14 : size === \"small\" ? \"smallest\" : \"small\";\n const classes = `${sizeClasses} flex-shrink-0 flex items-center justify-center rounded-full shadow-2xs text-white ` + (disabled ? \"bg-surface-400 dark:bg-surface-600\" : \"\");\n\n const defaultPropertyConfig = typeof propertyConfig?.property === \"object\" ? getDefaultFieldConfig(propertyConfig.property as Property) : undefined;\n\n return <div\n className={classes}\n style={{\n background: !disabled ? (propertyConfig?.color ?? defaultPropertyConfig?.color ?? \"#888\") : undefined\n }}>\n {propertyConfig?.Icon ? getIconForWidget(propertyConfig, iconSize) : getIconForWidget(defaultPropertyConfig, iconSize)}\n </div>\n}\n"],"mappings":";;;;AAKA,SAAgB,oBAAoB,EAChC,gBACA,UACA,OAAO,YAKS;CAChB,MAAM,cAAc,SAAS,eAAe,YAAY,SAAS,UAAU,YAAY;CACvF,MAAM,WAAW,SAAS,eAAe,KAAK,SAAS,UAAU,aAAa;CAC9E,MAAM,UAAU,GAAG,YAAY,wFAAwF,WAAW,uCAAuC;CAEzK,MAAM,wBAAwB,OAAO,gBAAgB,aAAa,WAAW,sBAAsB,eAAe,QAAoB,IAAI,KAAA;CAE1I,OAAO,oBAAC,OAAD;EACH,WAAW;EACX,OAAO,EACH,YAAY,CAAC,WAAY,gBAAgB,SAAS,uBAAuB,SAAS,SAAU,KAAA,EAChG;YACC,gBAAgB,OAAO,iBAAiB,gBAAgB,QAAQ,IAAI,iBAAiB,uBAAuB,QAAQ;CACpH,CAAA;AACT"}
1
+ {"version":3,"file":"PropertyConfigBadge.js","names":[],"sources":["../../src/components/PropertyConfigBadge.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { PropertyConfig } from \"@rebasepro/cms-types\";\nimport { getDefaultFieldConfig } from \"./field_configs\";\nimport { getIconForWidget } from \"../util/property_utils\";\n\nexport function PropertyConfigBadge({\n propertyConfig,\n disabled,\n size = \"medium\"\n}: {\n propertyConfig: PropertyConfig | undefined,\n disabled?: boolean,\n size?: \"extraSmall\" | \"small\" | \"medium\"\n}): React.ReactNode {\n const sizeClasses = size === \"extraSmall\" ? \"h-5 w-5\" : size === \"small\" ? \"h-6 w-6\" : \"h-8 w-8\";\n const iconSize = size === \"extraSmall\" ? 14 : size === \"small\" ? \"smallest\" : \"small\";\n const classes = `${sizeClasses} flex-shrink-0 flex items-center justify-center rounded-full shadow-2xs text-white ` + (disabled ? \"bg-surface-400 dark:bg-surface-600\" : \"\");\n\n const defaultPropertyConfig = typeof propertyConfig?.property === \"object\" ? getDefaultFieldConfig(propertyConfig.property as Property) : undefined;\n\n return <div\n className={classes}\n style={{\n background: !disabled ? (propertyConfig?.color ?? defaultPropertyConfig?.color ?? \"#838991\") : undefined\n }}>\n {propertyConfig?.Icon ? getIconForWidget(propertyConfig, iconSize) : getIconForWidget(defaultPropertyConfig, iconSize)}\n </div>\n}\n"],"mappings":";;;;AAKA,SAAgB,oBAAoB,EAChC,gBACA,UACA,OAAO,YAKS;CAChB,MAAM,cAAc,SAAS,eAAe,YAAY,SAAS,UAAU,YAAY;CACvF,MAAM,WAAW,SAAS,eAAe,KAAK,SAAS,UAAU,aAAa;CAC9E,MAAM,UAAU,GAAG,YAAY,wFAAwF,WAAW,uCAAuC;CAEzK,MAAM,wBAAwB,OAAO,gBAAgB,aAAa,WAAW,sBAAsB,eAAe,QAAoB,IAAI,KAAA;CAE1I,OAAO,oBAAC,OAAD;EACH,WAAW;EACX,OAAO,EACH,YAAY,CAAC,WAAY,gBAAgB,SAAS,uBAAuB,SAAS,YAAa,KAAA,EACnG;YACC,gBAAgB,OAAO,iBAAiB,gBAAgB,QAAQ,IAAI,iBAAiB,uBAAuB,QAAQ;CACpH,CAAA;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"Scaffold.js","names":[],"sources":["../../../src/components/app/Scaffold.tsx"],"sourcesContent":["import React, { PropsWithChildren, useCallback, useMemo } from \"react\";\nimport { cls, defaultBorderMixin, IconButton, Sheet, Tooltip } from \"@rebasepro/ui\";\nimport { ChevronLeftIcon, ErrorBoundary, MenuIcon } from \"@rebasepro/ui\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ConnectionLostBanner, useLargeLayout, useTranslation } from \"@rebasepro/app\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { AppContext } from \"./useApp\";\n\nexport const DRAWER_WIDTH = 280;\n\n/**\n * Namespaced by base path: two admins served from one origin are two different\n * navigations, and a single key would have them overwrite each other's drawer.\n */\nexport function drawerOpenStorageKey(basePath: string | undefined) {\n return `rebase-drawer-open:${basePath || \"/\"}`;\n}\n\n/** `null` when the user has never toggled the drawer, or storage is unavailable. */\nfunction readStoredDrawerOpen(key: string): boolean | null {\n if (typeof window === \"undefined\") return null;\n try {\n const stored = window.localStorage.getItem(key);\n return stored === null ? null : stored === \"true\";\n } catch (e) {\n // Storage can be blocked: private mode, sandboxed iframe, cookie policy.\n return null;\n }\n}\n\nfunction writeStoredDrawerOpen(key: string, open: boolean) {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(key, String(open));\n } catch (e) {\n // Same as above: a drawer that forgets is better than a crash.\n }\n}\n\n/**\n * @group Core\n */\nexport interface ScaffoldProps {\n\n /**\n * Expand the collapsed drawer while the pointer is over it. On by default —\n * pass `false` to keep the rail a rail until the user clicks the toggle.\n */\n autoOpenDrawer?: boolean;\n\n /**\n * Start with the drawer expanded rather than collapsed to icons.\n *\n * Distinct from {@link autoOpenDrawer}, which is a hover behaviour: this one\n * only seeds the very first visit. Once the user toggles the drawer, that\n * choice is stored in `localStorage` and wins over this prop on every load.\n *\n * Ignored on small layouts, where an expanded drawer covers the content it is\n * meant to navigate.\n */\n defaultDrawerOpen?: boolean;\n\n /**\n * Logo to be displayed in the top bar and drawer.\n * Note that this has no effect if you are using a custom AppBar or Drawer.\n */\n logo?: string;\n\n /**\n * If true, the main content will be padded in large layouts. Defaults to true.\n */\n padding?: boolean;\n\n className?: string;\n\n style?: React.CSSProperties;\n}\n\n/**\n * This view acts as a scaffold for Rebase.\n *\n * It is in charge of displaying the navigation drawer, top bar and main\n * collection views.\n * This component needs a parent {@link Rebase}\n *\n * @param props\n\n * @group Core\n */\nexport const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(\n function Scaffold(props: PropsWithChildren<ScaffoldProps>) {\n\n const {\n children,\n autoOpenDrawer = true,\n defaultDrawerOpen = false,\n logo,\n className,\n style,\n padding = true\n } = props;\n\n // `toArray` keeps strings and numbers, and those have no `.type` at all.\n // Reading `child.type.componentType` off one threw a TypeError from\n // inside the layout, which is a bewildering way to be told that a stray\n // text node — a conditional that rendered `\"\"`, a template string —\n // reached the Scaffold. Anything that is not an element is just \"other\".\n const slotOf = (child: React.ReactNode): string | undefined =>\n React.isValidElement(child)\n ? (child.type as { componentType?: string })?.componentType\n : undefined;\n\n const childArray = React.Children.toArray(children);\n const drawerChildren = childArray.filter((child) => slotOf(child) === \"Drawer\");\n if (drawerChildren.length > 1) {\n throw Error(\"Only one Drawer component is allowed in Scaffold\");\n }\n const appBarChildren = childArray.filter((child) => slotOf(child) === \"AppBar\");\n if (appBarChildren.length > 1) {\n throw Error(\"Only one AppBar component is allowed in Scaffold\");\n }\n const otherChildren = childArray\n .filter((child) => slotOf(child) !== \"Drawer\" && slotOf(child) !== \"AppBar\");\n const includeDrawer = drawerChildren.length > 0;\n const largeLayout = useLargeLayout();\n\n const storageKey = drawerOpenStorageKey(useUrlController().basePath);\n\n // Seeded once, deliberately: a `useEffect` syncing this to the prop would\n // re-expand the drawer under a user who had just collapsed it.\n const [drawerOpen, setDrawerOpenState] = React.useState(defaultDrawerOpen && largeLayout);\n const [onHover, setOnHover] = React.useState(false);\n\n // The stored choice is a client-only fact, so it is applied after the first\n // render rather than seeded into it: reading storage while rendering would\n // make the client disagree with server-rendered HTML. A layout effect runs\n // before paint, so the drawer still arrives in its remembered state.\n // `defaultDrawerOpen` seeds the very first visit and is ignored after that.\n React.useLayoutEffect(() => {\n const stored = readStoredDrawerOpen(storageKey);\n if (stored === null) return;\n setDrawerOpenState(stored && largeLayout);\n // Deliberately not re-run on `largeLayout`: crossing the breakpoint is\n // the effect below, and re-running here would undo a user's toggle.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [storageKey]);\n\n // One piece of state drives two different things: the expanded rail on\n // large layouts, and the modal sheet on small ones. Carrying an expanded\n // rail across the breakpoint would drop that sheet, overlay and all, over\n // the content — so the crossing resets it, and widening again restores\n // whatever the user last chose.\n const wasLargeLayout = React.useRef(largeLayout);\n React.useEffect(() => {\n if (wasLargeLayout.current === largeLayout) return;\n wasLargeLayout.current = largeLayout;\n setDrawerOpenState(largeLayout ? (readStoredDrawerOpen(storageKey) ?? defaultDrawerOpen) : false);\n }, [largeLayout, defaultDrawerOpen, storageKey]);\n\n const setDrawerOpen = useCallback((open: boolean) => {\n setDrawerOpenState(open);\n // Small layouts render the drawer as a modal sheet. Remembering that\n // one would greet the next load with an overlay over the content.\n if (!largeLayout) return;\n writeStoredDrawerOpen(storageKey, open);\n }, [largeLayout, storageKey]);\n\n // The pointer has left, but a popover the drawer opened is still up, so the\n // collapse is owed rather than cancelled. See `setOnHoverFalse`.\n const collapseWhenPopoverCloses = React.useRef(false);\n\n const setOnHoverTrue = useCallback(() => {\n // Hover expansion is the default; `autoOpenDrawer={false}` opts out for\n // admins that want the rail to stay a rail until the toggle is clicked.\n if (!autoOpenDrawer) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(true);\n }, [autoOpenDrawer]);\n const setOnHoverFalse = useCallback(() => {\n // Don't collapse the drawer out from under an open popover/dropdown —\n // its content is portalled outside the drawer, so reaching for it reads\n // as a mouseleave. The collapse is owed until that popover closes.\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) {\n collapseWhenPopoverCloses.current = true;\n return;\n }\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n }, []);\n\n // Nothing fires a second mouseleave when the popover finally closes, so the\n // owed collapse has to be noticed rather than waited for. Only mounted\n // while the drawer is actually floating open.\n React.useEffect(() => {\n if (!onHover) return;\n const collapseIfOwed = () => {\n if (!collapseWhenPopoverCloses.current) return;\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n };\n const observer = new MutationObserver(collapseIfOwed);\n observer.observe(document.body, {\n childList: true,\n subtree: true\n });\n return () => observer.disconnect();\n }, [onHover]);\n\n const handleDrawerOpen = useCallback(() => {\n setDrawerOpen(true);\n }, [setDrawerOpen]);\n\n const handleDrawerClose = useCallback(() => {\n setDrawerOpen(false);\n }, [setDrawerOpen]);\n\n const computedDrawerOpen: boolean = drawerOpen;\n const computedDrawerHovered = Boolean(largeLayout && onHover);\n\n const hasAppBar = Boolean(appBarChildren.length > 0);\n const appContextValue = useMemo(() => ({\n hasDrawer: Boolean(includeDrawer),\n drawerOpen: computedDrawerOpen,\n drawerHovered: computedDrawerHovered,\n openDrawer: handleDrawerOpen,\n closeDrawer: handleDrawerClose,\n closeHover: setOnHoverFalse,\n logo\n }), [includeDrawer, computedDrawerOpen, computedDrawerHovered, handleDrawerOpen, handleDrawerClose, setOnHoverFalse, logo]);\n\n return (\n <AppContext.Provider value={appContextValue}>\n <div\n className={cls(\"flex h-screen w-screen overflow-hidden\",\n \"bg-surface-frame\",\n \"text-surface-900 dark:text-white\", className)}\n style={{\n paddingTop: \"env(safe-area-inset-top)\",\n paddingLeft: \"env(safe-area-inset-left)\",\n paddingRight: \"env(safe-area-inset-right)\",\n paddingBottom: \"env(safe-area-inset-bottom)\",\n height: \"100dvh\",\n ...style\n }}>\n {appBarChildren}\n\n <DrawerWrapper\n displayed={includeDrawer}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n open={drawerOpen}\n hovered={onHover}\n setDrawerOpen={setDrawerOpen}>\n {includeDrawer && drawerChildren}\n </DrawerWrapper>\n\n <main\n className=\"flex flex-col grow overflow-auto\">\n\n {hasAppBar && <DrawerHeader/>}\n\n {/* Above the sheet, so it is there on every screen: while\n the realtime connection is down, every live view is\n showing what it last received. */}\n <ConnectionLostBanner className={cls(\"px-2 pt-1\", {\n \"lg:pt-0 lg:pb-2\": padding,\n \"lg:pt-2\": !hasAppBar && padding\n })}/>\n\n <div\n // The sheet is one lightness step above the frame AND carries a\n // plain hairline on its edge. The step alone (#0a0a0a to #131313,\n // #f0f0f2 to #f9f9fa) is about 3 L* on both themes, under what a\n // dimmed screen renders, and the first pass of this system removed\n // the line on the theory that the step would do its work; the\n // frame and the sheet then read as one black. The reference's own\n // content sheet carries this line. Only in the inset `lg` layout:\n // edge-to-edge on small screens, a border draws at the viewport.\n className={cls(\"bg-surface-sheet\", \"grow overflow-auto m-0\", \"lg:border lg:border-hairline\", {\n \"mt-1 lg:m-0 lg:mx-2 lg:mb-2 lg:rounded-xl\": padding,\n // No app bar means no DrawerHeader spacer above, so inset the\n // panel by the same amount as its sides and bottom.\n // Must come after the padding classes, which reset lg margins.\n \"lg:mt-2\": !hasAppBar && padding,\n \"lg:mt-4\": !hasAppBar && !padding\n })}>\n\n <ErrorBoundary>\n {otherChildren}\n </ErrorBoundary>\n\n </div>\n </main>\n </div>\n </AppContext.Provider>\n );\n },\n equal\n)\n\nconst DrawerHeader = () => {\n return (\n <div className=\"flex flex-col min-h-14\"></div>\n );\n};\n\nfunction DrawerWrapper(props: {\n children: React.ReactNode,\n displayed: boolean,\n open: boolean,\n logo?: string,\n hovered: boolean,\n setDrawerOpen: (open: boolean) => void,\n onMouseEnter: () => void,\n onMouseMove: () => void,\n onMouseLeave: () => void\n}) {\n\n const layoutWidth = !props.displayed ? 0 : (props.open ? DRAWER_WIDTH : 72);\n const visualWidth = !props.displayed ? 0 : ((props.open || props.hovered) ? DRAWER_WIDTH : 72);\n\n const isFloating = props.hovered && !props.open;\n const { t } = useTranslation();\n\n // The drawer is part of the frame, on both themes. When it floats over the\n // sheet it needs an edge, because a frame-coloured panel over the sheet is\n // an object at that moment; docked, it is a region and gets none.\n const innerDrawer = <div\n className={cls(\"h-full overflow-hidden bg-surface-frame\", defaultBorderMixin,\n isFloating ? \"absolute top-0 left-0 bottom-0 z-50 shadow-lg border-r\" : \"relative\")}\n style={{\n width: visualWidth,\n transition: \"left 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms\"\n }}\n >\n\n <div className={\"flex flex-col h-full\"}>\n {props.children}\n </div>\n\n </div>;\n\n const largeLayout = useLargeLayout();\n if (!largeLayout) {\n if (!props.displayed)\n return null;\n return <>\n <IconButton\n aria-label={t(\"open_menu\")}\n onClick={() => props.setDrawerOpen(true)}\n className=\"absolute sm:top-2 sm:left-4 top-1 left-2\"\n >\n <MenuIcon/>\n </IconButton>\n <Sheet side={\"left\"}\n transparent={true}\n open={props.open}\n onOpenChange={props.setDrawerOpen}\n title={t(\"navigation_drawer\")}\n overlayClassName={\"bg-surface-scrim\"}\n >\n {innerDrawer}\n </Sheet>\n </>;\n }\n\n return (\n <div\n className=\"z-20 relative flex-shrink-0 overflow-visible\"\n onMouseEnter={props.onMouseEnter}\n onMouseMove={props.onMouseMove}\n onMouseLeave={props.onMouseLeave}\n style={{\n width: layoutWidth,\n minWidth: layoutWidth,\n transition: \"left 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms\"\n }}>\n\n {innerDrawer}\n\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,qBAAqB,UAA8B;CAC/D,OAAO,sBAAsB,YAAY;AAC7C;;AAGA,SAAS,qBAAqB,KAA6B;CACvD,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,IAAI;EACA,MAAM,SAAS,OAAO,aAAa,QAAQ,GAAG;EAC9C,OAAO,WAAW,OAAO,OAAO,WAAW;CAC/C,SA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I,2CAA2C,oBACtD,aAAa,2DAA2D,UAAU;EACtF,OAAO;GACH,OAAO;GACP,YAAY;EAChB;YAGA,oBAAC,OAAD;GAAK,WAAW;aACX,MAAM;EACN,CAAA;CAEJ,CAAA;CAGL,IAAI,CADgB,eACf,GAAa;EACd,IAAI,CAAC,MAAM,WACP,OAAO;EACX,OAAO,qBAAA,UAAA,EAAA,UAAA,CACH,oBAAC,YAAD;GACI,cAAY,EAAE,WAAW;GACzB,eAAe,MAAM,cAAc,IAAI;GACvC,WAAU;aAEV,oBAAC,UAAD,CAAU,CAAA;EACF,CAAA,GACZ,oBAAC,OAAD;GAAO,MAAM;GACT,aAAa;GACb,MAAM,MAAM;GACZ,cAAc,MAAM;GACpB,OAAO,EAAE,mBAAmB;GAC5B,kBAAkB;aAEjB;EACE,CAAA,CACT,EAAA,CAAA;CACN;CAEA,OACI,oBAAC,OAAD;EACI,WAAU;EACV,cAAc,MAAM;EACpB,aAAa,MAAM;EACnB,cAAc,MAAM;EACpB,OAAO;GACH,OAAO;GACP,UAAU;GACV,YAAY;EAChB;YAEC;CAEA,CAAA;AAEb"}
1
+ {"version":3,"file":"Scaffold.js","names":[],"sources":["../../../src/components/app/Scaffold.tsx"],"sourcesContent":["import React, { PropsWithChildren, useCallback, useMemo } from \"react\";\nimport { cls, defaultBorderMixin, IconButton, Sheet, Tooltip } from \"@rebasepro/ui\";\nimport { ChevronLeftIcon, ErrorBoundary, MenuIcon } from \"@rebasepro/ui\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ConnectionLostBanner, useLargeLayout, useTranslation } from \"@rebasepro/app\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { AppContext } from \"./useApp\";\n\nexport const DRAWER_WIDTH = 280;\n\n/**\n * Namespaced by base path: two admins served from one origin are two different\n * navigations, and a single key would have them overwrite each other's drawer.\n */\nexport function drawerOpenStorageKey(basePath: string | undefined) {\n return `rebase-drawer-open:${basePath || \"/\"}`;\n}\n\n/** `null` when the user has never toggled the drawer, or storage is unavailable. */\nfunction readStoredDrawerOpen(key: string): boolean | null {\n if (typeof window === \"undefined\") return null;\n try {\n const stored = window.localStorage.getItem(key);\n return stored === null ? null : stored === \"true\";\n } catch (e) {\n // Storage can be blocked: private mode, sandboxed iframe, cookie policy.\n return null;\n }\n}\n\nfunction writeStoredDrawerOpen(key: string, open: boolean) {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(key, String(open));\n } catch (e) {\n // Same as above: a drawer that forgets is better than a crash.\n }\n}\n\n/**\n * @group Core\n */\nexport interface ScaffoldProps {\n\n /**\n * Expand the collapsed drawer while the pointer is over it. On by default —\n * pass `false` to keep the rail a rail until the user clicks the toggle.\n */\n autoOpenDrawer?: boolean;\n\n /**\n * Start with the drawer expanded rather than collapsed to icons.\n *\n * Distinct from {@link autoOpenDrawer}, which is a hover behaviour: this one\n * only seeds the very first visit. Once the user toggles the drawer, that\n * choice is stored in `localStorage` and wins over this prop on every load.\n *\n * Ignored on small layouts, where an expanded drawer covers the content it is\n * meant to navigate.\n */\n defaultDrawerOpen?: boolean;\n\n /**\n * Logo to be displayed in the top bar and drawer.\n * Note that this has no effect if you are using a custom AppBar or Drawer.\n */\n logo?: string;\n\n /**\n * If true, the main content will be padded in large layouts. Defaults to true.\n */\n padding?: boolean;\n\n className?: string;\n\n style?: React.CSSProperties;\n}\n\n/**\n * This view acts as a scaffold for Rebase.\n *\n * It is in charge of displaying the navigation drawer, top bar and main\n * collection views.\n * This component needs a parent {@link Rebase}\n *\n * @param props\n\n * @group Core\n */\nexport const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(\n function Scaffold(props: PropsWithChildren<ScaffoldProps>) {\n\n const {\n children,\n autoOpenDrawer = true,\n defaultDrawerOpen = false,\n logo,\n className,\n style,\n padding = true\n } = props;\n\n // `toArray` keeps strings and numbers, and those have no `.type` at all.\n // Reading `child.type.componentType` off one threw a TypeError from\n // inside the layout, which is a bewildering way to be told that a stray\n // text node — a conditional that rendered `\"\"`, a template string —\n // reached the Scaffold. Anything that is not an element is just \"other\".\n const slotOf = (child: React.ReactNode): string | undefined =>\n React.isValidElement(child)\n ? (child.type as { componentType?: string })?.componentType\n : undefined;\n\n const childArray = React.Children.toArray(children);\n const drawerChildren = childArray.filter((child) => slotOf(child) === \"Drawer\");\n if (drawerChildren.length > 1) {\n throw Error(\"Only one Drawer component is allowed in Scaffold\");\n }\n const appBarChildren = childArray.filter((child) => slotOf(child) === \"AppBar\");\n if (appBarChildren.length > 1) {\n throw Error(\"Only one AppBar component is allowed in Scaffold\");\n }\n const otherChildren = childArray\n .filter((child) => slotOf(child) !== \"Drawer\" && slotOf(child) !== \"AppBar\");\n const includeDrawer = drawerChildren.length > 0;\n const largeLayout = useLargeLayout();\n\n const storageKey = drawerOpenStorageKey(useUrlController().basePath);\n\n // Seeded once, deliberately: a `useEffect` syncing this to the prop would\n // re-expand the drawer under a user who had just collapsed it.\n const [drawerOpen, setDrawerOpenState] = React.useState(defaultDrawerOpen && largeLayout);\n const [onHover, setOnHover] = React.useState(false);\n\n // The stored choice is a client-only fact, so it is applied after the first\n // render rather than seeded into it: reading storage while rendering would\n // make the client disagree with server-rendered HTML. A layout effect runs\n // before paint, so the drawer still arrives in its remembered state.\n // `defaultDrawerOpen` seeds the very first visit and is ignored after that.\n React.useLayoutEffect(() => {\n const stored = readStoredDrawerOpen(storageKey);\n if (stored === null) return;\n setDrawerOpenState(stored && largeLayout);\n // Deliberately not re-run on `largeLayout`: crossing the breakpoint is\n // the effect below, and re-running here would undo a user's toggle.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [storageKey]);\n\n // One piece of state drives two different things: the expanded rail on\n // large layouts, and the modal sheet on small ones. Carrying an expanded\n // rail across the breakpoint would drop that sheet, overlay and all, over\n // the content — so the crossing resets it, and widening again restores\n // whatever the user last chose.\n const wasLargeLayout = React.useRef(largeLayout);\n React.useEffect(() => {\n if (wasLargeLayout.current === largeLayout) return;\n wasLargeLayout.current = largeLayout;\n setDrawerOpenState(largeLayout ? (readStoredDrawerOpen(storageKey) ?? defaultDrawerOpen) : false);\n }, [largeLayout, defaultDrawerOpen, storageKey]);\n\n const setDrawerOpen = useCallback((open: boolean) => {\n setDrawerOpenState(open);\n // Small layouts render the drawer as a modal sheet. Remembering that\n // one would greet the next load with an overlay over the content.\n if (!largeLayout) return;\n writeStoredDrawerOpen(storageKey, open);\n }, [largeLayout, storageKey]);\n\n // The pointer has left, but a popover the drawer opened is still up, so the\n // collapse is owed rather than cancelled. See `setOnHoverFalse`.\n const collapseWhenPopoverCloses = React.useRef(false);\n\n const setOnHoverTrue = useCallback(() => {\n // Hover expansion is the default; `autoOpenDrawer={false}` opts out for\n // admins that want the rail to stay a rail until the toggle is clicked.\n if (!autoOpenDrawer) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(true);\n }, [autoOpenDrawer]);\n const setOnHoverFalse = useCallback(() => {\n // Don't collapse the drawer out from under an open popover/dropdown —\n // its content is portalled outside the drawer, so reaching for it reads\n // as a mouseleave. The collapse is owed until that popover closes.\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) {\n collapseWhenPopoverCloses.current = true;\n return;\n }\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n }, []);\n\n // Nothing fires a second mouseleave when the popover finally closes, so the\n // owed collapse has to be noticed rather than waited for. Only mounted\n // while the drawer is actually floating open.\n React.useEffect(() => {\n if (!onHover) return;\n const collapseIfOwed = () => {\n if (!collapseWhenPopoverCloses.current) return;\n if (document.querySelector(\"[data-radix-popper-content-wrapper]\")) return;\n collapseWhenPopoverCloses.current = false;\n setOnHover(false);\n };\n const observer = new MutationObserver(collapseIfOwed);\n observer.observe(document.body, {\n childList: true,\n subtree: true\n });\n return () => observer.disconnect();\n }, [onHover]);\n\n const handleDrawerOpen = useCallback(() => {\n setDrawerOpen(true);\n }, [setDrawerOpen]);\n\n const handleDrawerClose = useCallback(() => {\n setDrawerOpen(false);\n }, [setDrawerOpen]);\n\n const computedDrawerOpen: boolean = drawerOpen;\n const computedDrawerHovered = Boolean(largeLayout && onHover);\n\n const hasAppBar = Boolean(appBarChildren.length > 0);\n const appContextValue = useMemo(() => ({\n hasDrawer: Boolean(includeDrawer),\n drawerOpen: computedDrawerOpen,\n drawerHovered: computedDrawerHovered,\n openDrawer: handleDrawerOpen,\n closeDrawer: handleDrawerClose,\n closeHover: setOnHoverFalse,\n logo\n }), [includeDrawer, computedDrawerOpen, computedDrawerHovered, handleDrawerOpen, handleDrawerClose, setOnHoverFalse, logo]);\n\n return (\n <AppContext.Provider value={appContextValue}>\n <div\n className={cls(\"flex h-screen w-screen overflow-hidden\",\n \"bg-surface-frame\",\n \"text-surface-900 dark:text-white\", className)}\n style={{\n paddingTop: \"env(safe-area-inset-top)\",\n paddingLeft: \"env(safe-area-inset-left)\",\n paddingRight: \"env(safe-area-inset-right)\",\n paddingBottom: \"env(safe-area-inset-bottom)\",\n height: \"100dvh\",\n ...style\n }}>\n {appBarChildren}\n\n <DrawerWrapper\n displayed={includeDrawer}\n onMouseEnter={setOnHoverTrue}\n onMouseMove={setOnHoverTrue}\n onMouseLeave={setOnHoverFalse}\n open={drawerOpen}\n hovered={onHover}\n setDrawerOpen={setDrawerOpen}>\n {includeDrawer && drawerChildren}\n </DrawerWrapper>\n\n <main\n className=\"flex flex-col grow overflow-auto\">\n\n {hasAppBar && <DrawerHeader/>}\n\n {/* Above the sheet, so it is there on every screen: while\n the realtime connection is down, every live view is\n showing what it last received. */}\n <ConnectionLostBanner className={cls(\"px-2 pt-1\", {\n \"lg:pt-0 lg:pb-2\": padding,\n \"lg:pt-2\": !hasAppBar && padding\n })}/>\n\n <div\n // The sheet is one lightness step above the frame AND carries a\n // plain hairline on its edge. The step alone (#090a0c to #111316,\n // #eff0f3 to #f8f9fa) is about 3 L* on both themes, under what a\n // dimmed screen renders, and the first pass of this system removed\n // the line on the theory that the step would do its work; the\n // frame and the sheet then read as one black. The reference's own\n // content sheet carries this line. Only in the inset `lg` layout:\n // edge-to-edge on small screens, a border draws at the viewport.\n className={cls(\"bg-surface-sheet\", \"grow overflow-auto m-0\", \"lg:border lg:border-hairline\", {\n \"mt-1 lg:m-0 lg:mx-2 lg:mb-2 lg:rounded-xl\": padding,\n // No app bar means no DrawerHeader spacer above, so inset the\n // panel by the same amount as its sides and bottom.\n // Must come after the padding classes, which reset lg margins.\n \"lg:mt-2\": !hasAppBar && padding,\n \"lg:mt-4\": !hasAppBar && !padding\n })}>\n\n <ErrorBoundary>\n {otherChildren}\n </ErrorBoundary>\n\n </div>\n </main>\n </div>\n </AppContext.Provider>\n );\n },\n equal\n)\n\nconst DrawerHeader = () => {\n return (\n <div className=\"flex flex-col min-h-14\"></div>\n );\n};\n\nfunction DrawerWrapper(props: {\n children: React.ReactNode,\n displayed: boolean,\n open: boolean,\n logo?: string,\n hovered: boolean,\n setDrawerOpen: (open: boolean) => void,\n onMouseEnter: () => void,\n onMouseMove: () => void,\n onMouseLeave: () => void\n}) {\n\n const layoutWidth = !props.displayed ? 0 : (props.open ? DRAWER_WIDTH : 72);\n const visualWidth = !props.displayed ? 0 : ((props.open || props.hovered) ? DRAWER_WIDTH : 72);\n\n const isFloating = props.hovered && !props.open;\n const { t } = useTranslation();\n\n // The drawer is part of the frame, on both themes. When it floats over the\n // sheet it needs an edge, because a frame-coloured panel over the sheet is\n // an object at that moment; docked, it is a region and gets none.\n const innerDrawer = <div\n className={cls(\"h-full overflow-hidden bg-surface-frame\", defaultBorderMixin,\n isFloating ? \"absolute top-0 left-0 bottom-0 z-50 shadow-lg border-r\" : \"relative\")}\n style={{\n width: visualWidth,\n transition: \"left 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms\"\n }}\n >\n\n <div className={\"flex flex-col h-full\"}>\n {props.children}\n </div>\n\n </div>;\n\n const largeLayout = useLargeLayout();\n if (!largeLayout) {\n if (!props.displayed)\n return null;\n return <>\n <IconButton\n aria-label={t(\"open_menu\")}\n onClick={() => props.setDrawerOpen(true)}\n className=\"absolute sm:top-2 sm:left-4 top-1 left-2\"\n >\n <MenuIcon/>\n </IconButton>\n <Sheet side={\"left\"}\n transparent={true}\n open={props.open}\n onOpenChange={props.setDrawerOpen}\n title={t(\"navigation_drawer\")}\n overlayClassName={\"bg-surface-scrim\"}\n >\n {innerDrawer}\n </Sheet>\n </>;\n }\n\n return (\n <div\n className=\"z-20 relative flex-shrink-0 overflow-visible\"\n onMouseEnter={props.onMouseEnter}\n onMouseMove={props.onMouseMove}\n onMouseLeave={props.onMouseLeave}\n style={{\n width: layoutWidth,\n minWidth: layoutWidth,\n transition: \"left 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 75ms cubic-bezier(0.4, 0, 0.6, 1) 0ms\"\n }}>\n\n {innerDrawer}\n\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,qBAAqB,UAA8B;CAC/D,OAAO,sBAAsB,YAAY;AAC7C;;AAGA,SAAS,qBAAqB,KAA6B;CACvD,IAAI,OAAO,WAAW,aAAa,OAAO;CAC1C,IAAI;EACA,MAAM,SAAS,OAAO,aAAa,QAAQ,GAAG;EAC9C,OAAO,WAAW,OAAO,OAAO,WAAW;CAC/C,SAAS,GAAG;EAER,OAAO;CACX;AACJ;AAEA,SAAS,sBAAsB,KAAa,MAAe;CACvD,IAAI,OAAO,WAAW,aAAa;CACnC,IAAI;EACA,OAAO,aAAa,QAAQ,KAAK,OAAO,IAAI,CAAC;CACjD,SAAS,GAAG,CAEZ;AACJ;;;;;;;;;;;;AAoDA,IAAa,WAAW,MAAM,KAC1B,SAAS,SAAS,OAAyC;CAEvD,MAAM,EACF,UACA,iBAAiB,MACjB,oBAAoB,OACpB,MACA,WACA,OACA,UAAU,SACV;CAOJ,MAAM,UAAU,UACZ,MAAM,eAAe,KAAK,IACnB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BAAC,OAAD;GAAO,MAAM;GACT,aAAa;GACb,MAAM,MAAM;GACZ,cAAc,MAAM;GACpB,OAAO,EAAE,mBAAmB;GAC5B,kBAAkB;aAEjB;EACE,CAAA,CACT,EAAA,CAAA;CACN;CAEA,OACI,oBAAC,OAAD;EACI,WAAU;EACV,cAAc,MAAM;EACpB,aAAa,MAAM;EACnB,cAAc,MAAM;EACpB,OAAO;GACH,OAAO;GACP,UAAU;GACV,YAAY;EAChB;YAEC;CAEA,CAAA;AAEb"}
@@ -278,7 +278,7 @@ ul[data-type="taskList"] li > label {
278
278
  }
279
279
  [data-theme="dark"] ul[data-type="taskList"] li > label input[type="checkbox"] {
280
280
  background-color: rgb(30 41 59);
281
- border: 2px solid #666;
281
+ border: 2px solid #62676e;
282
282
  }
283
283
  [data-theme="dark"] ul[data-type="taskList"] li > label input[type="checkbox"]:hover { background-color: rgb(51 65 85); }
284
284
  [data-theme="dark"] ul[data-type="taskList"] li > label input[type="checkbox"]:active { background-color: rgb(71 85 105); }
@@ -292,7 +292,7 @@ ul[data-type="taskList"] li > label input[type="checkbox"] {
292
292
  height: 1.2em;
293
293
  position: relative;
294
294
  top: 5px;
295
- border: 2px solid #777;
295
+ border: 2px solid #72787f;
296
296
  border-radius: 0.25em;
297
297
  margin-right: 0.3rem;
298
298
  display: grid;
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","names":[],"sources":["../../src/editor/editor.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useState, useRef, useMemo } from \"react\";\nimport { EditorState, Selection } from \"prosemirror-state\";\nimport { cls, defaultBorderMixin, Separator, TextareaAutosize, useInjectStyles } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { EditorBubble, ImageBubble, SlashCommandMenu, TableBubble, type JSONContent } from \"./components\";\nimport { NodeSelector } from \"./selectors/node-selector\";\nimport { LinkSelector } from \"./selectors/link-selector\";\nimport { TextButtons } from \"./selectors/text-buttons\";\nimport { removeClassesFromJson } from \"./utils/remove_classes\";\nimport { parser, serializer } from \"./markdown\";\nimport { EditorAIController } from \"./types\";\nimport { useProseMirror } from \"./hooks/useProseMirror\";\nimport { ProseMirrorContext } from \"./hooks/useProseMirrorContext\";\nimport { highlightCommands } from \"./extensions/HighlightDecorationExtension\";\nimport { schema } from \"./schema\";\n\nexport type CustomEditorComponent = {\n name: string,\n component: React.FC\n};\n\nexport type RichTextEditorTextSize = \"sm\" | \"base\" | \"lg\";\n\n\nexport type RichTextEditorProps = {\n content?: JSONContent | string,\n onMarkdownContentChange?: (content: string) => void,\n onJsonContentChange?: (content: JSONContent | null) => void,\n onHtmlContentChange?: (content: string) => void,\n handleImageUpload: (file: File) => Promise<string>,\n /**\n * Turns an image's stored `src` into a URL to show. `handleImageUpload`\n * returns a `rebase-storage:` reference to keep in the text — a private\n * object's URL expires — and the editor asks this for a URL to display it.\n */\n resolveImageSrc?: (src: string) => Promise<string | null | undefined>,\n version?: number,\n textSize?: RichTextEditorTextSize,\n highlight?: { from: number, to: number },\n aiController?: EditorAIController,\n customComponents?: CustomEditorComponent[];\n disabled?: boolean;\n};\n\n\nconst proseClasses = {\n \"sm\": \"prose-sm\",\n \"base\": \"prose-base\",\n \"lg\": \"prose-lg\"\n}\n\nexport const RichTextEditor = ({\n content,\n onJsonContentChange,\n onHtmlContentChange,\n onMarkdownContentChange,\n version,\n textSize = \"base\",\n highlight,\n handleImageUpload,\n resolveImageSrc,\n aiController,\n disabled\n}: RichTextEditorProps) => {\n\n const { t } = useTranslation();\n\n const [openNode, setOpenNode] = useState(false);\n const [openLink, setOpenLink] = useState(false);\n\n const [isMarkdownMode, setIsMarkdownMode] = useState(false);\n const [internalMarkdown, setInternalMarkdown] = useState<string>(\"\");\n\n useEffect(() => {\n if (!isMarkdownMode) return;\n const timeout = setTimeout(() => {\n if (callbacksRef.current.onMarkdownContentChange) {\n callbacksRef.current.onMarkdownContentChange(internalMarkdown);\n }\n }, 250);\n return () => clearTimeout(timeout);\n }, [internalMarkdown, isMarkdownMode]);\n\n const handleToggleMarkdown = () => {\n if (!isMarkdownMode) {\n if (view) {\n setInternalMarkdown(serializer.serialize(view.state.doc));\n }\n setIsMarkdownMode(true);\n } else {\n if (view) {\n const newDoc = parser.parse(internalMarkdown);\n if (newDoc) {\n const tr = view.state.tr.replaceWith(0, view.state.doc.content.size, newDoc.content);\n view.dispatch(tr);\n }\n }\n setIsMarkdownMode(false);\n }\n };\n\n const handleMarkdownChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInternalMarkdown(e.target.value);\n };\n\n const handleMarkdownBlur = () => {\n const { onMarkdownContentChange, onJsonContentChange } = callbacksRef.current;\n if (onMarkdownContentChange) {\n onMarkdownContentChange(internalMarkdown);\n }\n if (onJsonContentChange) {\n try {\n const newDoc = parser.parse(internalMarkdown);\n if (newDoc) {\n onJsonContentChange(removeClassesFromJson(newDoc.toJSON()) as JSONContent);\n }\n } catch (e) {\n console.warn(\"Could not parse markdown to JSON\", e);\n }\n }\n };\n\n useInjectStyles(\"Editor\", cssStyles);\n\n const callbacksRef = useRef({ onMarkdownContentChange,\nonJsonContentChange });\n useEffect(() => {\n callbacksRef.current = { onMarkdownContentChange,\nonJsonContentChange };\n }, [onMarkdownContentChange, onJsonContentChange]);\n\n const flushChanges = (currentState: EditorState) => {\n const { onMarkdownContentChange, onJsonContentChange } = callbacksRef.current;\n if (onMarkdownContentChange) {\n try {\n const markdown = serializer.serialize(currentState.doc);\n onMarkdownContentChange(markdown);\n } catch (e) {\n console.warn(\"[RichTextEditor] Could not serialize editor state to markdown:\", e);\n }\n }\n if (onJsonContentChange) {\n const jsonContent = removeClassesFromJson(currentState.doc.toJSON()) as JSONContent;\n onJsonContentChange(jsonContent);\n }\n };\n\n const { state, view, editorRef } = useProseMirror({\n initialContent: content,\n editable: !disabled,\n handleImageUpload,\n resolveImageSrc\n });\n\n // When `version` changes externally (e.g. form discard/reset), re-parse the\n // `content` prop and replace the ProseMirror document so the editor reflects\n // the reverted value.\n const versionRef = useRef(version);\n useEffect(() => {\n if (versionRef.current === version) return; // skip initial render\n versionRef.current = version;\n if (!view) return;\n try {\n const newDoc = typeof content === \"string\"\n ? parser.parse(content ?? \"\")\n : content\n ? schema.nodeFromJSON(content)\n : schema.node(\"doc\", null, [schema.node(\"paragraph\")]);\n if (newDoc) {\n const tr = view.state.tr.replaceWith(0, view.state.doc.content.size, newDoc.content);\n view.dispatch(tr);\n }\n } catch (e) {\n console.warn(\"[RichTextEditor] Could not reset editor content:\", e);\n }\n // Also reset raw-markdown textarea if the user is in source mode\n if (isMarkdownMode) {\n setInternalMarkdown(typeof content === \"string\" ? content : \"\");\n }\n // Reset the settling window so the replacement dispatch above is NOT\n // treated as a user edit (which would fire onChange back to the form).\n mountTimeRef.current = Date.now();\n hasUserEditedRef.current = false;\n }, [version]);\n\n const doc = state?.doc;\n // Use a time-based settling window instead of a single-skip flag.\n // The trailingNodePlugin fires appendTransaction on mount (adding a trailing\n // paragraph), which creates a second doc change after the initial parse.\n // A single-skip flag misses that second change. Instead, we skip ALL doc\n // changes within the first 500ms after the view is created.\n const mountTimeRef = useRef(Date.now());\n const hasUserEditedRef = useRef(false);\n useEffect(() => {\n if (!state) return;\n // Skip all doc changes during the initial settling window (500ms).\n // This covers both the initial parse AND the trailingNodePlugin's\n // appendTransaction that adds a trailing paragraph.\n const elapsed = Date.now() - mountTimeRef.current;\n if (elapsed < 500 && !hasUserEditedRef.current) {\n return;\n }\n hasUserEditedRef.current = true;\n const timeout = setTimeout(() => {\n flushChanges(state);\n }, 250);\n return () => clearTimeout(timeout);\n }, [doc]);\n\n useEffect(() => {\n if (!view) return;\n const dom = view.dom;\n const handleBlur = () => {\n // Don't flush during the initial settling window — the editor\n // hasn't been interacted with yet, and the serialized output\n // may differ from the input due to parse→serialize normalization.\n if (!hasUserEditedRef.current) {\n const elapsed = Date.now() - mountTimeRef.current;\n if (elapsed < 500) return;\n }\n flushChanges(view.state);\n };\n dom.addEventListener(\"blur\", handleBlur);\n return () => dom.removeEventListener(\"blur\", handleBlur);\n }, [view]);\n\n\n useEffect(() => {\n if (view) {\n if (highlight) {\n highlightCommands.toggleAutocompleteHighlight(highlight)(view.state, view.dispatch);\n } else {\n highlightCommands.removeAutocompleteHighlight()(view.state, view.dispatch);\n }\n }\n }, [highlight?.from, highlight?.to]);\n\n const proseClass = proseClasses[textSize];\n\n\n return (\n <div className=\"relative min-h-[200px] w-full flex flex-col\">\n <button\n type=\"button\"\n onClick={handleToggleMarkdown}\n title={isMarkdownMode ? \"Switch to Visual Editor\" : \"Switch to Markdown\"}\n className=\"absolute top-2 right-2 z-10 px-2 py-1 text-xs font-medium text-surface-400 hover:text-surface-700 dark:text-surface-600 dark:hover:text-surface-300 transition-colors opacity-50 hover:opacity-100 bg-transparent rounded\"\n >\n {isMarkdownMode ? \"Visual\" : \"Markdown\"}\n </button>\n\n <ProseMirrorContext.Provider value={useMemo(() => ({ state,\nview }), [state, view])}>\n\n <div style={{ display: isMarkdownMode ? \"none\" : \"flex\" }} className=\"flex-1 flex flex-col\">\n <div\n ref={editorRef}\n onClick={(e) => {\n // If the click landed on the wrapper padding (not on the ProseMirror\n // content), focus the editor and place the cursor at the nearest position.\n if (view && e.target === e.currentTarget) {\n view.focus();\n // Place cursor at end of the document\n const end = view.state.doc.content.size;\n const tr = view.state.tr.setSelection(\n Selection.near(view.state.doc.resolve(end), -1)\n );\n view.dispatch(tr);\n }\n }}\n className={cls(\"relative prose dark:prose-invert cursor-text flex-1\", proseClass, \"prose-headings:font-title prose-headings:font-normal prose-strong:font-semibold prose-code:font-normal prose-blockquote:font-normal prose-a:font-normal font-default focus:outline-none max-w-full py-4\")}\n />\n\n {view && (\n <>\n <EditorBubble\n options={{\n placement: \"top\",\n offset: 6\n }}\n className={cls(\"flex w-fit max-w-[90vw] h-10 overflow-hidden rounded border bg-surface-card shadow\", defaultBorderMixin)}\n >\n <NodeSelector portalContainer={editorRef.current} open={openNode} onOpenChange={setOpenNode}/>\n <Separator orientation=\"vertical\"/>\n <LinkSelector open={openLink} onOpenChange={setOpenLink}/>\n <Separator orientation=\"vertical\"/>\n <TextButtons/>\n </EditorBubble>\n\n <ImageBubble\n options={{\n placement: \"bottom\",\n offset: 6\n }}\n />\n <TableBubble/>\n </>\n )}\n\n <SlashCommandMenu upload={handleImageUpload} aiController={aiController}/>\n </div>\n\n {isMarkdownMode && (\n <TextareaAutosize\n value={internalMarkdown}\n onChange={handleMarkdownChange}\n onBlur={handleMarkdownBlur}\n className={cls(\n \"w-full h-full min-h-[200px] px-12 py-4 bg-transparent resize-none font-mono focus:ring-0\",\n proseClass\n )}\n style={{\n tabSize: 4,\n outline: \"none\",\n border: \"none\",\n boxShadow: \"none\"\n }}\n />\n )}\n\n </ProseMirrorContext.Provider>\n </div>\n );\n};\n\n\nconst cssStyles = `\n.ProseMirror {\n box-shadow: none !important;\n padding-left: 2rem;\n padding-right: 2rem;\n min-height: 100%;\n /* What prosemirror-view's style/prosemirror.css sets on its root: the\n document's spaces are read back from the DOM, so they must not collapse. */\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0;\n}\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n.ProseMirror .is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: rgb(100 116 139); /* 500 */\n pointer-events: none;\n height: 0;\n}\n.ProseMirror .is-empty::before {\n content: attr(data-placeholder);\n float: left;\n color: rgb(100 116 139); /* 500 */\n pointer-events: none;\n height: 0;\n}\n\n[data-theme=\"dark\"] .ProseMirror .is-empty::before {\n color: rgb(100 116 139); /* 500 */\n}\n\n.is-empty {\n cursor: text;\n color: rgb(100 116 139); /* 500 */\n}\n\n.ProseMirror img {\n transition: filter 0.1s ease-in-out;\n}\n.ProseMirror img:hover {\n cursor: pointer;\n filter: brightness(90%);\n}\n.ProseMirror img.ProseMirror-selectednode {\n filter: brightness(90%);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000) !important;\n}\n\nul[data-type=\"taskList\"] li > label {\n margin-right: 0.2rem;\n user-select: none;\n}\n@media screen and (max-width: 768px) {\n ul[data-type=\"taskList\"] li > label {\n margin-right: 0.5rem;\n }\n}\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li > label input[type=\"checkbox\"] {\n background-color: rgb(30 41 59);\n border: 2px solid #666;\n}\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:hover { background-color: rgb(51 65 85); }\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:active { background-color: rgb(71 85 105); }\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"] {\n -webkit-appearance: none;\n appearance: none;\n background-color: white;\n margin: 0;\n cursor: pointer;\n width: 1.2em;\n height: 1.2em;\n position: relative;\n top: 5px;\n border: 2px solid #777;\n border-radius: 0.25em;\n margin-right: 0.3rem;\n display: grid;\n place-content: center;\n}\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:hover { background-color: rgb(241 245 249); }\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:active { background-color: rgb(226 232 240); }\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]::before {\n content: \"\";\n width: 0.65em;\n height: 0.65em;\n transform: scale(0);\n transition: 120ms transform ease-in-out;\n box-shadow: inset 1em 1em;\n transform-origin: center;\n clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);\n}\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:checked::before { transform: scale(1); }\n\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li[data-checked=\"true\"] > div > p {\n color: rgb(226 232 240);\n text-decoration: line-through;\n text-decoration-thickness: 2px;\n}\nul[data-type=\"taskList\"] li[data-checked=\"true\"] > div > p {\n color: rgb(51 65 85);\n text-decoration: line-through;\n text-decoration-thickness: 2px;\n}\n.tippy-box { max-width: 400px !important; }\n\n.ProseMirror:not(.dragging) .ProseMirror-selectednode {\n background-color: rgb(219 234 254);\n transition: background-color 0.2s;\n box-shadow: none;\n}\n[data-theme=\"dark\"] .ProseMirror:not(.dragging) .ProseMirror-selectednode {\n background-color: rgb(51 65 85);\n}\n.prose-base table p { margin: 0; }\n\n.drag-handle {\n position: absolute;\n opacity: 1;\n transition: opacity ease-in 0.2s;\n border-radius: 0.25rem;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' style='fill: rgba(128, 128, 128, 0.9)'%3E%3Cpath d='M3,2 C2.44771525,2 2,1.55228475 2,1 C2,0.44771525 2.44771525,0 3,0 C3.55228475,0 4,0.44771525 4,1 C4,1.55228475 3.55228475,2 3,2 Z M3,6 C2.44771525,6 2,5.55228475 2,5 C2,4.44771525 2.44771525,4 3,4 C3.55228475,4 4,4.44771525 4,5 C4,5.55228475 3.55228475,6 3,6 Z M3,10 C2.44771525,10 2,9.55228475 2,9 C2,8.44771525 2.44771525,8 3,8 C3.55228475,8 4,8.44771525 4,9 C4,9.55228475 3.55228475,10 3,10 Z M7,2 C6.44771525,2 6,1.55228475 6,1 C6,0.44771525 6.44771525,0 7,0 C7.55228475,0 8,0.44771525 8,1 C8,1.55228475 7.55228475,2 7,2 Z M7,6 C6.44771525,6 6,5.55228475 6,5 C6,4.44771525 6.44771525,4 7,4 C7.55228475,4 8,4.44771525 8,5 C8,5.55228475 7.55228475,6 7,6 Z M7,10 C6.44771525,10 6,9.55228475 6,9 C6,8.44771525 6.44771525,8 7,8 C7,8.44771525 7,9 7,9 C7,9.55228475 7,10 7,10 Z'%3E%3C/path%3E%3C/svg%3E\");\n background-size: calc(0.5em + 0.375rem) calc(0.5em + 0.375rem);\n background-repeat: no-repeat;\n background-position: center;\n width: 1.2rem;\n height: 1.5rem;\n z-index: 100;\n cursor: grab;\n}\n.drag-handle::before {\n content: '';\n position: absolute;\n top: -10px;\n bottom: -10px;\n left: -20px; \n right: 0px;\n z-index: -1;\n}\n.drag-handle:hover { background-color: rgb(241 245 249); transition: background-color 0.2s; }\n.drag-handle:active { background-color: rgb(226 232 240); transition: background-color 0.2s; }\n.drag-handle.hide { opacity: 0; pointer-events: none; }\n@media screen and (max-width: 600px) { .drag-handle { display: none; pointer-events: none; } }\n[data-theme=\"dark\"] .drag-handle:hover { background-color: rgb(51 65 85); }\n[data-theme=\"dark\"] .drag-handle:active { background-color: rgb(51 65 85); }\n.prosemirror-dropcursor-block {\n background-color: var(--color-surface-accent-600);\n}\n[data-theme=\"dark\"] .prosemirror-dropcursor-block {\n background-color: var(--color-surface-accent-300);\n}\n\n.ProseMirror table {\n border-collapse: separate;\n border-spacing: 0;\n table-layout: fixed;\n width: 100%;\n margin: 1em 0;\n overflow: hidden;\n border-radius: 0.375rem;\n border: 1px solid #e5e7eb;\n}\n[data-theme=\"dark\"] .ProseMirror table {\n border-color: #374151;\n}\n\n.ProseMirror td, .ProseMirror th {\n min-width: 1em;\n padding: 8px 10px;\n vertical-align: top;\n box-sizing: border-box;\n position: relative;\n border-right: 1px solid #e5e7eb;\n border-bottom: 1px solid #e5e7eb;\n}\n[data-theme=\"dark\"] .ProseMirror td, [data-theme=\"dark\"] .ProseMirror th {\n border-right-color: #374151;\n border-bottom-color: #374151;\n}\n\n.ProseMirror tr:last-child td, .ProseMirror tr:last-child th {\n border-bottom: none;\n}\n.ProseMirror th:last-child, .ProseMirror td:last-child {\n border-right: none;\n}\n\n.ProseMirror td {\n background-color: transparent;\n}\n\n.ProseMirror th {\n font-weight: 600;\n text-align: left;\n background-color: #f3f4f6;\n color: #374151;\n}\n[data-theme=\"dark\"] .ProseMirror td {\n background-color: transparent;\n}\n[data-theme=\"dark\"] .ProseMirror th {\n background-color: rgba(255, 255, 255, 0.05);\n color: #d1d5db;\n}\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CA,IAAM,eAAe;CACnB,MAAM;CACN,QAAQ;CACR,MAAM;AACR;AAEA,IAAa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K,MAAM;QAEX,MAAM,MAAM,KAAK,MAAM,IAAI,QAAQ;QACnC,MAAM,KAAK,KAAK,MAAM,GAAG,aACvB,UAAU,KAAK,KAAK,MAAM,IAAI,QAAQ,GAAG,GAAG,EAAE,CAChD;QACA,KAAK,SAAS,EAAE;OAClB;MACF;MACA,WAAW,IAAI,uDAAuD,YAAY,yMAAyM;KAC5R,CAAA;KAEA,QACD,qBAAA,UAAA,EAAA,UAAA;MACE,qBAAC,cAAD;OACE,SAAS;QACP,WAAW;QACX,QAAQ;OACV;OACA,WAAW,IAAI,sFAAsF,kBAAkB;iBALzH;QAOE,oBAAC,cAAD;SAAc,iBAAiB,UAAU;SAAS,MAAM;SAAU,cAAc;QAAa,CAAA;QAC7F,oBAAC,WAAD,EAAW,aAAY,WAAW,CAAA;QAClC,oBAAC,cAAD;SAAc,MAAM;SAAU,cAAc;QAAa,CAAA;QACzD,oBAAC,WAAD,EAAW,aAAY,WAAW,CAAA;QAClC,oBAAC,aAAD,CAAa,CAAA;OACD;;MAEd,oBAAC,aAAD,EACG,SAAS;OACR,WAAW;OACX,QAAQ;MACV,EACD,CAAA;MACD,oBAAC,aAAD,CAAa,CAAA;KACb,EAAA,CAAA;KAGJ,oBAAC,kBAAD;MAAkB,QAAQ;MAAiC;KAAc,CAAA;IACpE;OAEJ,kBACC,oBAAC,kBAAD;IACE,OAAO;IACP,UAAU;IACV,QAAQ;IACR,WAAW,IACT,4FACA,UACF;IACA,OAAO;KACL,SAAS;KACT,SAAS;KACT,QAAQ;KACR,WAAW;IACb;GACD,CAAA,CAGwB;IAC1B;;AAET;AAGA,IAAM,YAAY"}
1
+ {"version":3,"file":"editor.js","names":[],"sources":["../../src/editor/editor.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useState, useRef, useMemo } from \"react\";\nimport { EditorState, Selection } from \"prosemirror-state\";\nimport { cls, defaultBorderMixin, Separator, TextareaAutosize, useInjectStyles } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { EditorBubble, ImageBubble, SlashCommandMenu, TableBubble, type JSONContent } from \"./components\";\nimport { NodeSelector } from \"./selectors/node-selector\";\nimport { LinkSelector } from \"./selectors/link-selector\";\nimport { TextButtons } from \"./selectors/text-buttons\";\nimport { removeClassesFromJson } from \"./utils/remove_classes\";\nimport { parser, serializer } from \"./markdown\";\nimport { EditorAIController } from \"./types\";\nimport { useProseMirror } from \"./hooks/useProseMirror\";\nimport { ProseMirrorContext } from \"./hooks/useProseMirrorContext\";\nimport { highlightCommands } from \"./extensions/HighlightDecorationExtension\";\nimport { schema } from \"./schema\";\n\nexport type CustomEditorComponent = {\n name: string,\n component: React.FC\n};\n\nexport type RichTextEditorTextSize = \"sm\" | \"base\" | \"lg\";\n\n\nexport type RichTextEditorProps = {\n content?: JSONContent | string,\n onMarkdownContentChange?: (content: string) => void,\n onJsonContentChange?: (content: JSONContent | null) => void,\n onHtmlContentChange?: (content: string) => void,\n handleImageUpload: (file: File) => Promise<string>,\n /**\n * Turns an image's stored `src` into a URL to show. `handleImageUpload`\n * returns a `rebase-storage:` reference to keep in the text — a private\n * object's URL expires — and the editor asks this for a URL to display it.\n */\n resolveImageSrc?: (src: string) => Promise<string | null | undefined>,\n version?: number,\n textSize?: RichTextEditorTextSize,\n highlight?: { from: number, to: number },\n aiController?: EditorAIController,\n customComponents?: CustomEditorComponent[];\n disabled?: boolean;\n};\n\n\nconst proseClasses = {\n \"sm\": \"prose-sm\",\n \"base\": \"prose-base\",\n \"lg\": \"prose-lg\"\n}\n\nexport const RichTextEditor = ({\n content,\n onJsonContentChange,\n onHtmlContentChange,\n onMarkdownContentChange,\n version,\n textSize = \"base\",\n highlight,\n handleImageUpload,\n resolveImageSrc,\n aiController,\n disabled\n}: RichTextEditorProps) => {\n\n const { t } = useTranslation();\n\n const [openNode, setOpenNode] = useState(false);\n const [openLink, setOpenLink] = useState(false);\n\n const [isMarkdownMode, setIsMarkdownMode] = useState(false);\n const [internalMarkdown, setInternalMarkdown] = useState<string>(\"\");\n\n useEffect(() => {\n if (!isMarkdownMode) return;\n const timeout = setTimeout(() => {\n if (callbacksRef.current.onMarkdownContentChange) {\n callbacksRef.current.onMarkdownContentChange(internalMarkdown);\n }\n }, 250);\n return () => clearTimeout(timeout);\n }, [internalMarkdown, isMarkdownMode]);\n\n const handleToggleMarkdown = () => {\n if (!isMarkdownMode) {\n if (view) {\n setInternalMarkdown(serializer.serialize(view.state.doc));\n }\n setIsMarkdownMode(true);\n } else {\n if (view) {\n const newDoc = parser.parse(internalMarkdown);\n if (newDoc) {\n const tr = view.state.tr.replaceWith(0, view.state.doc.content.size, newDoc.content);\n view.dispatch(tr);\n }\n }\n setIsMarkdownMode(false);\n }\n };\n\n const handleMarkdownChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInternalMarkdown(e.target.value);\n };\n\n const handleMarkdownBlur = () => {\n const { onMarkdownContentChange, onJsonContentChange } = callbacksRef.current;\n if (onMarkdownContentChange) {\n onMarkdownContentChange(internalMarkdown);\n }\n if (onJsonContentChange) {\n try {\n const newDoc = parser.parse(internalMarkdown);\n if (newDoc) {\n onJsonContentChange(removeClassesFromJson(newDoc.toJSON()) as JSONContent);\n }\n } catch (e) {\n console.warn(\"Could not parse markdown to JSON\", e);\n }\n }\n };\n\n useInjectStyles(\"Editor\", cssStyles);\n\n const callbacksRef = useRef({ onMarkdownContentChange,\nonJsonContentChange });\n useEffect(() => {\n callbacksRef.current = { onMarkdownContentChange,\nonJsonContentChange };\n }, [onMarkdownContentChange, onJsonContentChange]);\n\n const flushChanges = (currentState: EditorState) => {\n const { onMarkdownContentChange, onJsonContentChange } = callbacksRef.current;\n if (onMarkdownContentChange) {\n try {\n const markdown = serializer.serialize(currentState.doc);\n onMarkdownContentChange(markdown);\n } catch (e) {\n console.warn(\"[RichTextEditor] Could not serialize editor state to markdown:\", e);\n }\n }\n if (onJsonContentChange) {\n const jsonContent = removeClassesFromJson(currentState.doc.toJSON()) as JSONContent;\n onJsonContentChange(jsonContent);\n }\n };\n\n const { state, view, editorRef } = useProseMirror({\n initialContent: content,\n editable: !disabled,\n handleImageUpload,\n resolveImageSrc\n });\n\n // When `version` changes externally (e.g. form discard/reset), re-parse the\n // `content` prop and replace the ProseMirror document so the editor reflects\n // the reverted value.\n const versionRef = useRef(version);\n useEffect(() => {\n if (versionRef.current === version) return; // skip initial render\n versionRef.current = version;\n if (!view) return;\n try {\n const newDoc = typeof content === \"string\"\n ? parser.parse(content ?? \"\")\n : content\n ? schema.nodeFromJSON(content)\n : schema.node(\"doc\", null, [schema.node(\"paragraph\")]);\n if (newDoc) {\n const tr = view.state.tr.replaceWith(0, view.state.doc.content.size, newDoc.content);\n view.dispatch(tr);\n }\n } catch (e) {\n console.warn(\"[RichTextEditor] Could not reset editor content:\", e);\n }\n // Also reset raw-markdown textarea if the user is in source mode\n if (isMarkdownMode) {\n setInternalMarkdown(typeof content === \"string\" ? content : \"\");\n }\n // Reset the settling window so the replacement dispatch above is NOT\n // treated as a user edit (which would fire onChange back to the form).\n mountTimeRef.current = Date.now();\n hasUserEditedRef.current = false;\n }, [version]);\n\n const doc = state?.doc;\n // Use a time-based settling window instead of a single-skip flag.\n // The trailingNodePlugin fires appendTransaction on mount (adding a trailing\n // paragraph), which creates a second doc change after the initial parse.\n // A single-skip flag misses that second change. Instead, we skip ALL doc\n // changes within the first 500ms after the view is created.\n const mountTimeRef = useRef(Date.now());\n const hasUserEditedRef = useRef(false);\n useEffect(() => {\n if (!state) return;\n // Skip all doc changes during the initial settling window (500ms).\n // This covers both the initial parse AND the trailingNodePlugin's\n // appendTransaction that adds a trailing paragraph.\n const elapsed = Date.now() - mountTimeRef.current;\n if (elapsed < 500 && !hasUserEditedRef.current) {\n return;\n }\n hasUserEditedRef.current = true;\n const timeout = setTimeout(() => {\n flushChanges(state);\n }, 250);\n return () => clearTimeout(timeout);\n }, [doc]);\n\n useEffect(() => {\n if (!view) return;\n const dom = view.dom;\n const handleBlur = () => {\n // Don't flush during the initial settling window — the editor\n // hasn't been interacted with yet, and the serialized output\n // may differ from the input due to parse→serialize normalization.\n if (!hasUserEditedRef.current) {\n const elapsed = Date.now() - mountTimeRef.current;\n if (elapsed < 500) return;\n }\n flushChanges(view.state);\n };\n dom.addEventListener(\"blur\", handleBlur);\n return () => dom.removeEventListener(\"blur\", handleBlur);\n }, [view]);\n\n\n useEffect(() => {\n if (view) {\n if (highlight) {\n highlightCommands.toggleAutocompleteHighlight(highlight)(view.state, view.dispatch);\n } else {\n highlightCommands.removeAutocompleteHighlight()(view.state, view.dispatch);\n }\n }\n }, [highlight?.from, highlight?.to]);\n\n const proseClass = proseClasses[textSize];\n\n\n return (\n <div className=\"relative min-h-[200px] w-full flex flex-col\">\n <button\n type=\"button\"\n onClick={handleToggleMarkdown}\n title={isMarkdownMode ? \"Switch to Visual Editor\" : \"Switch to Markdown\"}\n className=\"absolute top-2 right-2 z-10 px-2 py-1 text-xs font-medium text-surface-400 hover:text-surface-700 dark:text-surface-600 dark:hover:text-surface-300 transition-colors opacity-50 hover:opacity-100 bg-transparent rounded\"\n >\n {isMarkdownMode ? \"Visual\" : \"Markdown\"}\n </button>\n\n <ProseMirrorContext.Provider value={useMemo(() => ({ state,\nview }), [state, view])}>\n\n <div style={{ display: isMarkdownMode ? \"none\" : \"flex\" }} className=\"flex-1 flex flex-col\">\n <div\n ref={editorRef}\n onClick={(e) => {\n // If the click landed on the wrapper padding (not on the ProseMirror\n // content), focus the editor and place the cursor at the nearest position.\n if (view && e.target === e.currentTarget) {\n view.focus();\n // Place cursor at end of the document\n const end = view.state.doc.content.size;\n const tr = view.state.tr.setSelection(\n Selection.near(view.state.doc.resolve(end), -1)\n );\n view.dispatch(tr);\n }\n }}\n className={cls(\"relative prose dark:prose-invert cursor-text flex-1\", proseClass, \"prose-headings:font-title prose-headings:font-normal prose-strong:font-semibold prose-code:font-normal prose-blockquote:font-normal prose-a:font-normal font-default focus:outline-none max-w-full py-4\")}\n />\n\n {view && (\n <>\n <EditorBubble\n options={{\n placement: \"top\",\n offset: 6\n }}\n className={cls(\"flex w-fit max-w-[90vw] h-10 overflow-hidden rounded border bg-surface-card shadow\", defaultBorderMixin)}\n >\n <NodeSelector portalContainer={editorRef.current} open={openNode} onOpenChange={setOpenNode}/>\n <Separator orientation=\"vertical\"/>\n <LinkSelector open={openLink} onOpenChange={setOpenLink}/>\n <Separator orientation=\"vertical\"/>\n <TextButtons/>\n </EditorBubble>\n\n <ImageBubble\n options={{\n placement: \"bottom\",\n offset: 6\n }}\n />\n <TableBubble/>\n </>\n )}\n\n <SlashCommandMenu upload={handleImageUpload} aiController={aiController}/>\n </div>\n\n {isMarkdownMode && (\n <TextareaAutosize\n value={internalMarkdown}\n onChange={handleMarkdownChange}\n onBlur={handleMarkdownBlur}\n className={cls(\n \"w-full h-full min-h-[200px] px-12 py-4 bg-transparent resize-none font-mono focus:ring-0\",\n proseClass\n )}\n style={{\n tabSize: 4,\n outline: \"none\",\n border: \"none\",\n boxShadow: \"none\"\n }}\n />\n )}\n\n </ProseMirrorContext.Provider>\n </div>\n );\n};\n\n\nconst cssStyles = `\n.ProseMirror {\n box-shadow: none !important;\n padding-left: 2rem;\n padding-right: 2rem;\n min-height: 100%;\n /* What prosemirror-view's style/prosemirror.css sets on its root: the\n document's spaces are read back from the DOM, so they must not collapse. */\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0;\n}\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n.ProseMirror .is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: rgb(100 116 139); /* 500 */\n pointer-events: none;\n height: 0;\n}\n.ProseMirror .is-empty::before {\n content: attr(data-placeholder);\n float: left;\n color: rgb(100 116 139); /* 500 */\n pointer-events: none;\n height: 0;\n}\n\n[data-theme=\"dark\"] .ProseMirror .is-empty::before {\n color: rgb(100 116 139); /* 500 */\n}\n\n.is-empty {\n cursor: text;\n color: rgb(100 116 139); /* 500 */\n}\n\n.ProseMirror img {\n transition: filter 0.1s ease-in-out;\n}\n.ProseMirror img:hover {\n cursor: pointer;\n filter: brightness(90%);\n}\n.ProseMirror img.ProseMirror-selectednode {\n filter: brightness(90%);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000) !important;\n}\n\nul[data-type=\"taskList\"] li > label {\n margin-right: 0.2rem;\n user-select: none;\n}\n@media screen and (max-width: 768px) {\n ul[data-type=\"taskList\"] li > label {\n margin-right: 0.5rem;\n }\n}\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li > label input[type=\"checkbox\"] {\n background-color: rgb(30 41 59);\n border: 2px solid #62676e;\n}\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:hover { background-color: rgb(51 65 85); }\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:active { background-color: rgb(71 85 105); }\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"] {\n -webkit-appearance: none;\n appearance: none;\n background-color: white;\n margin: 0;\n cursor: pointer;\n width: 1.2em;\n height: 1.2em;\n position: relative;\n top: 5px;\n border: 2px solid #72787f;\n border-radius: 0.25em;\n margin-right: 0.3rem;\n display: grid;\n place-content: center;\n}\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:hover { background-color: rgb(241 245 249); }\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:active { background-color: rgb(226 232 240); }\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]::before {\n content: \"\";\n width: 0.65em;\n height: 0.65em;\n transform: scale(0);\n transition: 120ms transform ease-in-out;\n box-shadow: inset 1em 1em;\n transform-origin: center;\n clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);\n}\nul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]:checked::before { transform: scale(1); }\n\n[data-theme=\"dark\"] ul[data-type=\"taskList\"] li[data-checked=\"true\"] > div > p {\n color: rgb(226 232 240);\n text-decoration: line-through;\n text-decoration-thickness: 2px;\n}\nul[data-type=\"taskList\"] li[data-checked=\"true\"] > div > p {\n color: rgb(51 65 85);\n text-decoration: line-through;\n text-decoration-thickness: 2px;\n}\n.tippy-box { max-width: 400px !important; }\n\n.ProseMirror:not(.dragging) .ProseMirror-selectednode {\n background-color: rgb(219 234 254);\n transition: background-color 0.2s;\n box-shadow: none;\n}\n[data-theme=\"dark\"] .ProseMirror:not(.dragging) .ProseMirror-selectednode {\n background-color: rgb(51 65 85);\n}\n.prose-base table p { margin: 0; }\n\n.drag-handle {\n position: absolute;\n opacity: 1;\n transition: opacity ease-in 0.2s;\n border-radius: 0.25rem;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' style='fill: rgba(128, 128, 128, 0.9)'%3E%3Cpath d='M3,2 C2.44771525,2 2,1.55228475 2,1 C2,0.44771525 2.44771525,0 3,0 C3.55228475,0 4,0.44771525 4,1 C4,1.55228475 3.55228475,2 3,2 Z M3,6 C2.44771525,6 2,5.55228475 2,5 C2,4.44771525 2.44771525,4 3,4 C3.55228475,4 4,4.44771525 4,5 C4,5.55228475 3.55228475,6 3,6 Z M3,10 C2.44771525,10 2,9.55228475 2,9 C2,8.44771525 2.44771525,8 3,8 C3.55228475,8 4,8.44771525 4,9 C4,9.55228475 3.55228475,10 3,10 Z M7,2 C6.44771525,2 6,1.55228475 6,1 C6,0.44771525 6.44771525,0 7,0 C7.55228475,0 8,0.44771525 8,1 C8,1.55228475 7.55228475,2 7,2 Z M7,6 C6.44771525,6 6,5.55228475 6,5 C6,4.44771525 6.44771525,4 7,4 C7.55228475,4 8,4.44771525 8,5 C8,5.55228475 7.55228475,6 7,6 Z M7,10 C6.44771525,10 6,9.55228475 6,9 C6,8.44771525 6.44771525,8 7,8 C7,8.44771525 7,9 7,9 C7,9.55228475 7,10 7,10 Z'%3E%3C/path%3E%3C/svg%3E\");\n background-size: calc(0.5em + 0.375rem) calc(0.5em + 0.375rem);\n background-repeat: no-repeat;\n background-position: center;\n width: 1.2rem;\n height: 1.5rem;\n z-index: 100;\n cursor: grab;\n}\n.drag-handle::before {\n content: '';\n position: absolute;\n top: -10px;\n bottom: -10px;\n left: -20px; \n right: 0px;\n z-index: -1;\n}\n.drag-handle:hover { background-color: rgb(241 245 249); transition: background-color 0.2s; }\n.drag-handle:active { background-color: rgb(226 232 240); transition: background-color 0.2s; }\n.drag-handle.hide { opacity: 0; pointer-events: none; }\n@media screen and (max-width: 600px) { .drag-handle { display: none; pointer-events: none; } }\n[data-theme=\"dark\"] .drag-handle:hover { background-color: rgb(51 65 85); }\n[data-theme=\"dark\"] .drag-handle:active { background-color: rgb(51 65 85); }\n.prosemirror-dropcursor-block {\n background-color: var(--color-surface-accent-600);\n}\n[data-theme=\"dark\"] .prosemirror-dropcursor-block {\n background-color: var(--color-surface-accent-300);\n}\n\n.ProseMirror table {\n border-collapse: separate;\n border-spacing: 0;\n table-layout: fixed;\n width: 100%;\n margin: 1em 0;\n overflow: hidden;\n border-radius: 0.375rem;\n border: 1px solid #e5e7eb;\n}\n[data-theme=\"dark\"] .ProseMirror table {\n border-color: #374151;\n}\n\n.ProseMirror td, .ProseMirror th {\n min-width: 1em;\n padding: 8px 10px;\n vertical-align: top;\n box-sizing: border-box;\n position: relative;\n border-right: 1px solid #e5e7eb;\n border-bottom: 1px solid #e5e7eb;\n}\n[data-theme=\"dark\"] .ProseMirror td, [data-theme=\"dark\"] .ProseMirror th {\n border-right-color: #374151;\n border-bottom-color: #374151;\n}\n\n.ProseMirror tr:last-child td, .ProseMirror tr:last-child th {\n border-bottom: none;\n}\n.ProseMirror th:last-child, .ProseMirror td:last-child {\n border-right: none;\n}\n\n.ProseMirror td {\n background-color: transparent;\n}\n\n.ProseMirror th {\n font-weight: 600;\n text-align: left;\n background-color: #f3f4f6;\n color: #374151;\n}\n[data-theme=\"dark\"] .ProseMirror td {\n background-color: transparent;\n}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  const isDark = document.documentElement.getAttribute("data-theme") === "dark";
172
172
  const varName = isDark ? "--color-surface-accent-300" : "--color-surface-accent-600";
173
173
  const color = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
174
- el.style.backgroundColor = color || (isDark ? "#cbd5e1" : "#475569");
174
+ el.style.backgroundColor = color || (isDark ? "#d1d4d9" : "#50545b");
175
175
  }
176
176
  return new Plugin({ view(editorView) {
177
177
  dropCursorElement = document.createElement("div");
@@ -1 +1 @@
1
- {"version":3,"file":"drag-and-drop.js","names":[],"sources":["../../../src/editor/extensions/drag-and-drop.tsx"],"sourcesContent":["import { NodeSelection, Plugin } from \"prosemirror-state\";\nimport { EditorView } from \"prosemirror-view\";\nimport { Slice } from \"prosemirror-model\";\nimport { serializeForClipboard } from \"./clipboard\";\n\n/** ProseMirror internal drag state — not exposed in type definitions */\ninterface ProseMirrorDragState {\n slice: Slice;\n move: boolean;\n node?: NodeSelection;\n}\n\n/** EditorView with access to the internal `dragging` property */\ninterface EditorViewWithDrag extends EditorView {\n dragging: ProseMirrorDragState | null;\n}\n\nexport interface DragHandleOptions {\n /**\n * The width of the drag handle\n */\n dragHandleWidth: number;\n}\n\nfunction absoluteRect(element: Element) {\n const data = element.getBoundingClientRect();\n\n let ancestor = element.parentElement;\n while (ancestor && window.getComputedStyle(ancestor).position === \"static\") {\n ancestor = ancestor.parentElement;\n }\n const ancestorRect = ancestor?.getBoundingClientRect();\n\n return {\n top: data.top - (ancestorRect?.top ?? 0),\n left: data.left - (ancestorRect?.left ?? 0),\n width: data.width\n };\n}\n\nfunction nodeDOMAtCoords(coords: { x: number; y: number }, view: EditorView) {\n const editorRect = view.dom.getBoundingClientRect();\n\n // 0. Give up if outside vertical bounds or too far horizontally\n if (coords.y < editorRect.top || coords.y > editorRect.bottom) return undefined;\n if (coords.x < editorRect.left - 100 || coords.x > editorRect.right + 50) return undefined;\n\n const blockSelector = 'li, p, pre, blockquote, h1, h2, h3, h4, h5, h6, img, [data-type=\"taskList\"]';\n\n // 1. First probe exactly at the mouse coordinates\n const elem = document.elementFromPoint(coords.x, coords.y);\n const block = elem?.closest(blockSelector);\n if (block && view.dom.contains(block) && block.textContent?.trim()) {\n const li = block.closest(\"li\");\n return (li && view.dom.contains(li)) ? li : block;\n }\n\n // 2. If mouse is in the left gutter, probe horizontally into the editor\n const probeX = editorRect.left + Math.min(60, editorRect.width / 4);\n if (coords.x > probeX) return undefined;\n\n const probeElem = document.elementFromPoint(probeX, coords.y);\n const probeBlock = probeElem?.closest(blockSelector);\n if (probeBlock && probeBlock.textContent?.trim()) {\n // Ensure the found block is actually inside our editor\n if (view.dom.contains(probeBlock)) {\n const li = probeBlock.closest(\"li\");\n return (li && view.dom.contains(li)) ? li : probeBlock;\n }\n }\n\n return undefined;\n}\n\nfunction nodePosAtDOM(node: Element, view: EditorView, options: DragHandleOptions) {\n try {\n if (!view.dom.contains(node)) return null;\n const pos = view.posAtDOM(node, 0);\n const $pos = view.state.doc.resolve(pos);\n // posAtDOM(node, 0) generally returns the position inside the node.\n // We want the position right before the node to create a NodeSelection.\n if ($pos.depth > 0) {\n return $pos.before();\n }\n return pos;\n } catch (e) {\n return null;\n }\n}\n\nexport function dragHandlePlugin(options: DragHandleOptions = { dragHandleWidth: 24 }) {\n function handleDragStart(event: DragEvent, view: EditorView) {\n view.focus();\n\n if (!event.dataTransfer) return;\n\n const node = nodeDOMAtCoords({\n x: event.clientX,\n y: event.clientY\n }, view);\n\n if (!(node instanceof Element)) return;\n\n const nodePos = nodePosAtDOM(node, view, options);\n if (nodePos == null || nodePos < 0) return;\n\n const draggedNodeSelection = NodeSelection.create(view.state.doc, nodePos);\n view.dispatch(view.state.tr.setSelection(draggedNodeSelection));\n\n const slice = view.state.selection.content();\n const {\n dom,\n text\n } = serializeForClipboard(view as EditorViewWithDrag, slice);\n\n event.dataTransfer.clearData();\n event.dataTransfer.setData(\"text/html\", dom.innerHTML);\n event.dataTransfer.setData(\"text/plain\", text);\n event.dataTransfer.effectAllowed = \"copyMove\";\n\n event.dataTransfer.setDragImage(node, 0, 0);\n\n (view as EditorViewWithDrag).dragging = {\n slice,\n move: true,\n node: draggedNodeSelection\n };\n }\n\n function handleClick(event: MouseEvent, view: EditorView) {\n view.focus();\n\n view.dom.classList.remove(\"dragging\");\n\n const node = nodeDOMAtCoords({\n x: event.clientX,\n y: event.clientY\n }, view);\n\n if (!(node instanceof Element)) return;\n\n const nodePos = nodePosAtDOM(node, view, options);\n if (!nodePos) return;\n\n view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, nodePos)));\n }\n\n let dragHandleElement: HTMLElement | null = null;\n\n function hideDragHandle() {\n if (dragHandleElement) {\n dragHandleElement.classList.add(\"hide\");\n dragHandleElement.style.opacity = \"0\";\n dragHandleElement.style.pointerEvents = \"none\";\n }\n }\n\n function showDragHandle() {\n if (dragHandleElement) {\n dragHandleElement.classList.remove(\"hide\");\n dragHandleElement.style.opacity = \"1\";\n dragHandleElement.style.pointerEvents = \"auto\";\n }\n }\n\n return new Plugin({\n view: (view) => {\n dragHandleElement = document.createElement(\"div\");\n dragHandleElement.draggable = true;\n dragHandleElement.dataset.dragHandle = \"\";\n dragHandleElement.classList.add(\"drag-handle\");\n dragHandleElement.addEventListener(\"dragstart\", (e) => {\n handleDragStart(e, view);\n });\n dragHandleElement.addEventListener(\"click\", (e) => {\n handleClick(e, view);\n });\n const onMouseMove = (event: MouseEvent) => {\n if (!view.editable) {\n return;\n }\n\n const node = nodeDOMAtCoords({\n x: event.clientX,\n y: event.clientY\n }, view);\n\n if (!(node instanceof Element)) {\n hideDragHandle();\n return;\n }\n\n const compStyle = window.getComputedStyle(node);\n const lineHeight = parseInt(compStyle.lineHeight, 10);\n const paddingTop = parseInt(compStyle.paddingTop, 10);\n\n const rect = absoluteRect(node);\n if (!rect) {\n hideDragHandle();\n return;\n }\n\n rect.top += (lineHeight - 24) / 2;\n rect.top += paddingTop;\n // Li markers\n if (node.matches(\"ul:not([data-type=taskList]) li, ol li\")) {\n rect.left -= options.dragHandleWidth;\n }\n rect.width = options.dragHandleWidth;\n\n if (!dragHandleElement) return;\n\n dragHandleElement.style.left = `${rect.left - rect.width}px`;\n dragHandleElement.style.top = `${rect.top}px`;\n showDragHandle();\n };\n\n window.addEventListener(\"mousemove\", onMouseMove);\n\n hideDragHandle();\n\n view?.dom?.parentElement?.appendChild(dragHandleElement);\n\n return {\n destroy: () => {\n window.removeEventListener(\"mousemove\", onMouseMove);\n dragHandleElement?.remove?.();\n dragHandleElement = null;\n }\n };\n },\n props: {\n handleDOMEvents: {\n keydown: () => {\n hideDragHandle();\n },\n mousewheel: () => {\n hideDragHandle();\n },\n // dragging class is used for CSS\n dragstart: (view) => {\n view.dom.classList.add(\"dragging\");\n },\n drop: (view) => {\n view.dom.classList.remove(\"dragging\");\n },\n dragend: (view) => {\n view.dom.classList.remove(\"dragging\");\n }\n }\n }\n });\n}\n\nimport { dropPoint } from \"prosemirror-transform\";\n\nexport function globalDragDropPlugin() {\n let dropCursorElement: HTMLElement | null = null;\n let cleanup: (() => void) | null = null;\n\n function updateDropCursorColor(el: HTMLElement) {\n const isDark = document.documentElement.getAttribute(\"data-theme\") === \"dark\";\n const varName = isDark ? \"--color-surface-accent-300\" : \"--color-surface-accent-600\";\n const color = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();\n el.style.backgroundColor = color || (isDark ? \"#cbd5e1\" : \"#475569\");\n }\n\n return new Plugin({\n view(editorView) {\n dropCursorElement = document.createElement(\"div\");\n dropCursorElement.className = \"prosemirror-dropcursor-block\";\n dropCursorElement.style.cssText = \"position: absolute; z-index: 50; pointer-events: none; height: 2px;\";\n updateDropCursorColor(dropCursorElement);\n\n // Watch for theme changes\n const observer = new MutationObserver(() => {\n if (dropCursorElement) updateDropCursorColor(dropCursorElement);\n });\n observer.observe(document.documentElement, { attributes: true,\nattributeFilter: [\"data-theme\"] });\n\n const removeCursor = () => {\n if (dropCursorElement && dropCursorElement.parentNode) {\n dropCursorElement.parentNode.removeChild(dropCursorElement);\n }\n };\n\n const getBlockInsertionPoint = (event: DragEvent, clampedX: number) => {\n const pos = editorView.posAtCoords({ left: clampedX,\ntop: event.clientY });\n if (!pos) return null;\n\n const $pos = editorView.state.doc.resolve(pos.pos);\n\n let blockDepth = 0;\n for (let i = $pos.depth; i > 0; i--) {\n const name = $pos.node(i).type.name;\n if (name === \"list_item\" || name === \"taskItem\") {\n blockDepth = i;\n break;\n }\n if ($pos.node(i).isBlock && name !== \"bullet_list\" && name !== \"ordered_list\" && name !== \"taskList\") {\n blockDepth = i;\n }\n }\n\n if (blockDepth === 0) return pos.pos;\n\n const nodeBeforePos = $pos.before(blockDepth);\n const nodeAfterPos = $pos.after(blockDepth);\n\n const domNode = editorView.nodeDOM(nodeBeforePos);\n if (domNode instanceof HTMLElement) {\n const rect = domNode.getBoundingClientRect();\n const isTopHalf = event.clientY < rect.top + rect.height / 2;\n return isTopHalf ? nodeBeforePos : nodeAfterPos;\n }\n return pos.pos;\n };\n\n const handleDragOver = (event: DragEvent) => {\n if (!editorView.editable || !editorView.dragging) return;\n\n // If it's a native slice drag (no explicitly captured node from our drag handle)\n // then we bail out here and let ProseMirror native drop logic and native dropcursor handle it\n if (!((editorView as EditorViewWithDrag).dragging as ProseMirrorDragState | null & { node?: unknown })?.node) {\n removeCursor();\n return;\n }\n\n event.preventDefault(); // browser requires this to allow drop\n\n const editorRect = editorView.dom.getBoundingClientRect();\n const clampedX = Math.max(editorRect.left + 10, Math.min(event.clientX, editorRect.right - 10));\n\n const target = getBlockInsertionPoint(event, clampedX);\n if (target === null) {\n removeCursor();\n return;\n }\n\n const $pos = editorView.state.doc.resolve(target);\n\n let rect;\n const before = $pos.nodeBefore;\n const after = $pos.nodeAfter;\n\n if (before || after) {\n const nodeDOM = editorView.nodeDOM(target - (before ? before.nodeSize : 0));\n if (nodeDOM && nodeDOM instanceof HTMLElement) {\n const nodeRect = nodeDOM.getBoundingClientRect();\n let top = before ? nodeRect.bottom : nodeRect.top;\n if (before && after) {\n const afterDOM = editorView.nodeDOM(target);\n if (afterDOM && afterDOM instanceof HTMLElement) {\n top = (top + afterDOM.getBoundingClientRect().top) / 2;\n }\n }\n rect = { left: nodeRect.left,\nright: nodeRect.right,\ntop: top - 1,\nbottom: top + 1 };\n }\n }\n\n if (!rect) {\n const coords = editorView.coordsAtPos(target);\n rect = { left: editorRect.left + 50,\nright: editorRect.right - 50,\ntop: coords.top - 1,\nbottom: coords.top + 1 };\n }\n\n const parent = editorView.dom.offsetParent as HTMLElement;\n let parentLeft = 0;\n let parentTop = 0;\n if (parent && parent !== document.body && getComputedStyle(parent).position !== \"static\") {\n const parentRect = parent.getBoundingClientRect();\n parentLeft = parentRect.left - parent.scrollLeft;\n parentTop = parentRect.top - parent.scrollTop;\n }\n\n if (!dropCursorElement!.parentNode) {\n parent.appendChild(dropCursorElement!);\n }\n\n dropCursorElement!.style.left = `${rect.left - parentLeft}px`;\n dropCursorElement!.style.top = `${rect.top - parentTop}px`;\n dropCursorElement!.style.width = `${rect.right - rect.left}px`;\n };\n\n const handleDrop = (event: DragEvent) => {\n if (!editorView.editable || !editorView.dragging) return;\n\n if (!((editorView as EditorViewWithDrag).dragging as ProseMirrorDragState | null & { node?: unknown })?.node) {\n removeCursor();\n return;\n }\n\n event.preventDefault();\n removeCursor();\n editorView.dom.classList.remove(\"dragging\");\n\n const editorRect = editorView.dom.getBoundingClientRect();\n const clampedX = Math.max(editorRect.left + 10, Math.min(event.clientX, editorRect.right - 10));\n\n const targetPos = getBlockInsertionPoint(event, clampedX);\n if (targetPos === null) return;\n\n const dragging = (editorView as EditorViewWithDrag).dragging;\n if (dragging && dragging.slice) {\n let tr = editorView.state.tr;\n if (dragging.move) {\n const { node } = dragging;\n if (node) {\n node.replace(tr); // exact native ProseMirror delete\n } else {\n tr = tr.deleteSelection();\n }\n }\n\n const mappedTarget = tr.mapping.map(targetPos);\n const beforeInsert = tr.doc;\n\n const { node, slice } = dragging;\n\n if (node && node.node) {\n let nodeToInsert: import(\"prosemirror-model\").Node | import(\"prosemirror-model\").Fragment = node.node;\n const $mapped = tr.doc.resolve(mappedTarget);\n const parentName = $mapped.parent.type.name;\n\n const isTargetList = parentName === \"bullet_list\" || parentName === \"ordered_list\";\n const isTargetTaskList = parentName === \"taskList\";\n\n // 1. Unwrap incoming lists if they don't match the destination perfectly\n if (\"type\" in nodeToInsert && nodeToInsert.type.name === \"list_item\" && !isTargetList) {\n nodeToInsert = nodeToInsert.content;\n } else if (\"type\" in nodeToInsert && nodeToInsert.type.name === \"taskItem\" && !isTargetTaskList) {\n nodeToInsert = nodeToInsert.content;\n }\n\n // 2. Wrap incoming blocks/fragments into exactly the target list type\n const isFragment = !(\"type\" in nodeToInsert);\n const needsWrap = isFragment || (\"type\" in nodeToInsert && nodeToInsert.type.name !== \"list_item\" && nodeToInsert.type.name !== \"taskItem\");\n\n if (needsWrap) {\n if (isTargetList) {\n const listItemType = editorView.state.schema.nodes.list_item;\n if (listItemType) nodeToInsert = listItemType.create(null, nodeToInsert);\n } else if (isTargetTaskList) {\n const taskItemType = editorView.state.schema.nodes.taskItem;\n if (taskItemType) nodeToInsert = taskItemType.create({ checked: false }, nodeToInsert);\n }\n }\n\n // 3. Force insertion. tr.replace slices and splits lists. tr.insert preserves the explicit boundary.\n try {\n tr = tr.insert(mappedTarget, nodeToInsert);\n } catch (e) {\n console.warn(\"Could not insert dragged node exactly at target. Attempting fallback.\", e);\n const point = dropPoint(tr.doc, mappedTarget, slice);\n if (point !== null) {\n tr = tr.replace(point, point, slice);\n }\n }\n } else if (slice) {\n // For generic slices (e.g native image dragging), we MUST use dropPoint\n // so ProseMirror finds a schema-valid depth to insert the node structure natively.\n const point = dropPoint(tr.doc, mappedTarget, slice);\n const finalTarget = point !== null ? point : mappedTarget;\n tr = tr.replace(finalTarget, finalTarget, slice);\n }\n\n if (!tr.doc.eq(beforeInsert)) {\n editorView.dispatch(tr.setMeta(\"uiEvent\", \"drop\"));\n editorView.focus();\n }\n }\n\n (editorView as EditorViewWithDrag).dragging = null;\n };\n\n const handleDragEnd = () => {\n removeCursor();\n };\n\n window.addEventListener(\"dragover\", handleDragOver, { capture: true });\n window.addEventListener(\"drop\", handleDrop, { capture: true });\n window.addEventListener(\"dragend\", handleDragEnd, { capture: true });\n\n cleanup = () => {\n removeCursor();\n observer.disconnect();\n window.removeEventListener(\"dragover\", handleDragOver, { capture: true });\n window.removeEventListener(\"drop\", handleDrop, { capture: true });\n window.removeEventListener(\"dragend\", handleDragEnd, { capture: true });\n };\n\n return {\n destroy() {\n if (cleanup) cleanup();\n }\n };\n }\n });\n}\n\n\n"],"mappings":";;;;AAwBA,SAAS,aAAa,SAAkB;CACpC,MAAM,OAAO,QAAQ,sBAAsB;CAE3C,IAAI,WAAW,QAAQ;CACvB,OAAO,YAAY,OAAO,iBAAiB,QAAQ,CAAC,CAAC,aAAa,UAC9D,WAAW,SAAS;CAExB,MAAM,eAAe,UAAU,sBAAsB;CAErD,OAAO;EACH,KAAK,KAAK,OAAO,cAAc,OAAO;EACtC,MAAM,KAAK,QAAQ,cAAc,QAAQ;EACzC,OAAO,KAAK;CAChB;AACJ;AAEA,SAAS,gBAAgB,QAAkC,MAAkB;CACzE,MAAM,aAAa,KAAK,IAAI,sBAAsB;CAGlD,IAAI,OAAO,IAAI,WAAW,OAAO,OAAO,IAAI,WAAW,QAAQ,OAAO,KAAA;CACtE,IAAI,OAAO,IAAI,WAAW,OAAO,OAAO,OAAO,IAAI,WAAW,QAAQ,IAAI,OAAO,KAAA;CAEjF,MAAM,gBAAgB;CAItB,MAAM,QADO,SAAS,iBAAiB,OAAO,GAAG,OAAO,CAC1C,CAAA,EAAM,QAAQ,aAAa;CACzC,IAAI,SAAS,KAAK,IAAI,SAAS,KAAK,KAAK,MAAM,aAAa,KAAK,GAAG;EAChE,MAAM,KAAK,MAAM,QAAQ,IAAI;EAC7B,OAAQ,MAAM,KAAK,IAAI,SAAS,EAAE,IAAK,KAAK;CAChD;CAGA,MAAM,SAAS,WAAW,OAAO,KAAK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AAK,CAAC;EACrE,OAAO,iBAAiB,QAAQ,YAAY,EAAE,SAAS,KAAK,CAAC;EAC7D,OAAO,iBAAiB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;EAEnE,gBAAgB;GACZ,aAAa;GACb,SAAS,WAAW;GACpB,OAAO,oBAAoB,YAAY,gBAAgB,EAAE,SAAS,KAAK,CAAC;GACxE,OAAO,oBAAoB,QAAQ,YAAY,EAAE,SAAS,KAAK,CAAC;GAChE,OAAO,oBAAoB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;EAC1E;EAEA,OAAO,EACH,UAAU;GACN,IAAI,SAAS,QAAQ;EACzB,EACJ;CACJ,EACJ,CAAC;AACL"}
1
+ {"version":3,"file":"drag-and-drop.js","names":[],"sources":["../../../src/editor/extensions/drag-and-drop.tsx"],"sourcesContent":["import { NodeSelection, Plugin } from \"prosemirror-state\";\nimport { EditorView } from \"prosemirror-view\";\nimport { Slice } from \"prosemirror-model\";\nimport { serializeForClipboard } from \"./clipboard\";\n\n/** ProseMirror internal drag state — not exposed in type definitions */\ninterface ProseMirrorDragState {\n slice: Slice;\n move: boolean;\n node?: NodeSelection;\n}\n\n/** EditorView with access to the internal `dragging` property */\ninterface EditorViewWithDrag extends EditorView {\n dragging: ProseMirrorDragState | null;\n}\n\nexport interface DragHandleOptions {\n /**\n * The width of the drag handle\n */\n dragHandleWidth: number;\n}\n\nfunction absoluteRect(element: Element) {\n const data = element.getBoundingClientRect();\n\n let ancestor = element.parentElement;\n while (ancestor && window.getComputedStyle(ancestor).position === \"static\") {\n ancestor = ancestor.parentElement;\n }\n const ancestorRect = ancestor?.getBoundingClientRect();\n\n return {\n top: data.top - (ancestorRect?.top ?? 0),\n left: data.left - (ancestorRect?.left ?? 0),\n width: data.width\n };\n}\n\nfunction nodeDOMAtCoords(coords: { x: number; y: number }, view: EditorView) {\n const editorRect = view.dom.getBoundingClientRect();\n\n // 0. Give up if outside vertical bounds or too far horizontally\n if (coords.y < editorRect.top || coords.y > editorRect.bottom) return undefined;\n if (coords.x < editorRect.left - 100 || coords.x > editorRect.right + 50) return undefined;\n\n const blockSelector = 'li, p, pre, blockquote, h1, h2, h3, h4, h5, h6, img, [data-type=\"taskList\"]';\n\n // 1. First probe exactly at the mouse coordinates\n const elem = document.elementFromPoint(coords.x, coords.y);\n const block = elem?.closest(blockSelector);\n if (block && view.dom.contains(block) && block.textContent?.trim()) {\n const li = block.closest(\"li\");\n return (li && view.dom.contains(li)) ? li : block;\n }\n\n // 2. If mouse is in the left gutter, probe horizontally into the editor\n const probeX = editorRect.left + Math.min(60, editorRect.width / 4);\n if (coords.x > probeX) return undefined;\n\n const probeElem = document.elementFromPoint(probeX, coords.y);\n const probeBlock = probeElem?.closest(blockSelector);\n if (probeBlock && probeBlock.textContent?.trim()) {\n // Ensure the found block is actually inside our editor\n if (view.dom.contains(probeBlock)) {\n const li = probeBlock.closest(\"li\");\n return (li && view.dom.contains(li)) ? li : probeBlock;\n }\n }\n\n return undefined;\n}\n\nfunction nodePosAtDOM(node: Element, view: EditorView, options: DragHandleOptions) {\n try {\n if (!view.dom.contains(node)) return null;\n const pos = view.posAtDOM(node, 0);\n const $pos = view.state.doc.resolve(pos);\n // posAtDOM(node, 0) generally returns the position inside the node.\n // We want the position right before the node to create a NodeSelection.\n if ($pos.depth > 0) {\n return $pos.before();\n }\n return pos;\n } catch (e) {\n return null;\n }\n}\n\nexport function dragHandlePlugin(options: DragHandleOptions = { dragHandleWidth: 24 }) {\n function handleDragStart(event: DragEvent, view: EditorView) {\n view.focus();\n\n if (!event.dataTransfer) return;\n\n const node = nodeDOMAtCoords({\n x: event.clientX,\n y: event.clientY\n }, view);\n\n if (!(node instanceof Element)) return;\n\n const nodePos = nodePosAtDOM(node, view, options);\n if (nodePos == null || nodePos < 0) return;\n\n const draggedNodeSelection = NodeSelection.create(view.state.doc, nodePos);\n view.dispatch(view.state.tr.setSelection(draggedNodeSelection));\n\n const slice = view.state.selection.content();\n const {\n dom,\n text\n } = serializeForClipboard(view as EditorViewWithDrag, slice);\n\n event.dataTransfer.clearData();\n event.dataTransfer.setData(\"text/html\", dom.innerHTML);\n event.dataTransfer.setData(\"text/plain\", text);\n event.dataTransfer.effectAllowed = \"copyMove\";\n\n event.dataTransfer.setDragImage(node, 0, 0);\n\n (view as EditorViewWithDrag).dragging = {\n slice,\n move: true,\n node: draggedNodeSelection\n };\n }\n\n function handleClick(event: MouseEvent, view: EditorView) {\n view.focus();\n\n view.dom.classList.remove(\"dragging\");\n\n const node = nodeDOMAtCoords({\n x: event.clientX,\n y: event.clientY\n }, view);\n\n if (!(node instanceof Element)) return;\n\n const nodePos = nodePosAtDOM(node, view, options);\n if (!nodePos) return;\n\n view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, nodePos)));\n }\n\n let dragHandleElement: HTMLElement | null = null;\n\n function hideDragHandle() {\n if (dragHandleElement) {\n dragHandleElement.classList.add(\"hide\");\n dragHandleElement.style.opacity = \"0\";\n dragHandleElement.style.pointerEvents = \"none\";\n }\n }\n\n function showDragHandle() {\n if (dragHandleElement) {\n dragHandleElement.classList.remove(\"hide\");\n dragHandleElement.style.opacity = \"1\";\n dragHandleElement.style.pointerEvents = \"auto\";\n }\n }\n\n return new Plugin({\n view: (view) => {\n dragHandleElement = document.createElement(\"div\");\n dragHandleElement.draggable = true;\n dragHandleElement.dataset.dragHandle = \"\";\n dragHandleElement.classList.add(\"drag-handle\");\n dragHandleElement.addEventListener(\"dragstart\", (e) => {\n handleDragStart(e, view);\n });\n dragHandleElement.addEventListener(\"click\", (e) => {\n handleClick(e, view);\n });\n const onMouseMove = (event: MouseEvent) => {\n if (!view.editable) {\n return;\n }\n\n const node = nodeDOMAtCoords({\n x: event.clientX,\n y: event.clientY\n }, view);\n\n if (!(node instanceof Element)) {\n hideDragHandle();\n return;\n }\n\n const compStyle = window.getComputedStyle(node);\n const lineHeight = parseInt(compStyle.lineHeight, 10);\n const paddingTop = parseInt(compStyle.paddingTop, 10);\n\n const rect = absoluteRect(node);\n if (!rect) {\n hideDragHandle();\n return;\n }\n\n rect.top += (lineHeight - 24) / 2;\n rect.top += paddingTop;\n // Li markers\n if (node.matches(\"ul:not([data-type=taskList]) li, ol li\")) {\n rect.left -= options.dragHandleWidth;\n }\n rect.width = options.dragHandleWidth;\n\n if (!dragHandleElement) return;\n\n dragHandleElement.style.left = `${rect.left - rect.width}px`;\n dragHandleElement.style.top = `${rect.top}px`;\n showDragHandle();\n };\n\n window.addEventListener(\"mousemove\", onMouseMove);\n\n hideDragHandle();\n\n view?.dom?.parentElement?.appendChild(dragHandleElement);\n\n return {\n destroy: () => {\n window.removeEventListener(\"mousemove\", onMouseMove);\n dragHandleElement?.remove?.();\n dragHandleElement = null;\n }\n };\n },\n props: {\n handleDOMEvents: {\n keydown: () => {\n hideDragHandle();\n },\n mousewheel: () => {\n hideDragHandle();\n },\n // dragging class is used for CSS\n dragstart: (view) => {\n view.dom.classList.add(\"dragging\");\n },\n drop: (view) => {\n view.dom.classList.remove(\"dragging\");\n },\n dragend: (view) => {\n view.dom.classList.remove(\"dragging\");\n }\n }\n }\n });\n}\n\nimport { dropPoint } from \"prosemirror-transform\";\n\nexport function globalDragDropPlugin() {\n let dropCursorElement: HTMLElement | null = null;\n let cleanup: (() => void) | null = null;\n\n function updateDropCursorColor(el: HTMLElement) {\n const isDark = document.documentElement.getAttribute(\"data-theme\") === \"dark\";\n const varName = isDark ? \"--color-surface-accent-300\" : \"--color-surface-accent-600\";\n const color = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();\n el.style.backgroundColor = color || (isDark ? \"#d1d4d9\" : \"#50545b\");\n }\n\n return new Plugin({\n view(editorView) {\n dropCursorElement = document.createElement(\"div\");\n dropCursorElement.className = \"prosemirror-dropcursor-block\";\n dropCursorElement.style.cssText = \"position: absolute; z-index: 50; pointer-events: none; height: 2px;\";\n updateDropCursorColor(dropCursorElement);\n\n // Watch for theme changes\n const observer = new MutationObserver(() => {\n if (dropCursorElement) updateDropCursorColor(dropCursorElement);\n });\n observer.observe(document.documentElement, { attributes: true,\nattributeFilter: [\"data-theme\"] });\n\n const removeCursor = () => {\n if (dropCursorElement && dropCursorElement.parentNode) {\n dropCursorElement.parentNode.removeChild(dropCursorElement);\n }\n };\n\n const getBlockInsertionPoint = (event: DragEvent, clampedX: number) => {\n const pos = editorView.posAtCoords({ left: clampedX,\ntop: event.clientY });\n if (!pos) return null;\n\n const $pos = editorView.state.doc.resolve(pos.pos);\n\n let blockDepth = 0;\n for (let i = $pos.depth; i > 0; i--) {\n const name = $pos.node(i).type.name;\n if (name === \"list_item\" || name === \"taskItem\") {\n blockDepth = i;\n break;\n }\n if ($pos.node(i).isBlock && name !== \"bullet_list\" && name !== \"ordered_list\" && name !== \"taskList\") {\n blockDepth = i;\n }\n }\n\n if (blockDepth === 0) return pos.pos;\n\n const nodeBeforePos = $pos.before(blockDepth);\n const nodeAfterPos = $pos.after(blockDepth);\n\n const domNode = editorView.nodeDOM(nodeBeforePos);\n if (domNode instanceof HTMLElement) {\n const rect = domNode.getBoundingClientRect();\n const isTopHalf = event.clientY < rect.top + rect.height / 2;\n return isTopHalf ? nodeBeforePos : nodeAfterPos;\n }\n return pos.pos;\n };\n\n const handleDragOver = (event: DragEvent) => {\n if (!editorView.editable || !editorView.dragging) return;\n\n // If it's a native slice drag (no explicitly captured node from our drag handle)\n // then we bail out here and let ProseMirror native drop logic and native dropcursor handle it\n if (!((editorView as EditorViewWithDrag).dragging as ProseMirrorDragState | null & { node?: unknown })?.node) {\n removeCursor();\n return;\n }\n\n event.preventDefault(); // browser requires this to allow drop\n\n const editorRect = editorView.dom.getBoundingClientRect();\n const clampedX = Math.max(editorRect.left + 10, Math.min(event.clientX, editorRect.right - 10));\n\n const target = getBlockInsertionPoint(event, clampedX);\n if (target === null) {\n removeCursor();\n return;\n }\n\n const $pos = editorView.state.doc.resolve(target);\n\n let rect;\n const before = $pos.nodeBefore;\n const after = $pos.nodeAfter;\n\n if (before || after) {\n const nodeDOM = editorView.nodeDOM(target - (before ? before.nodeSize : 0));\n if (nodeDOM && nodeDOM instanceof HTMLElement) {\n const nodeRect = nodeDOM.getBoundingClientRect();\n let top = before ? nodeRect.bottom : nodeRect.top;\n if (before && after) {\n const afterDOM = editorView.nodeDOM(target);\n if (afterDOM && afterDOM instanceof HTMLElement) {\n top = (top + afterDOM.getBoundingClientRect().top) / 2;\n }\n }\n rect = { left: nodeRect.left,\nright: nodeRect.right,\ntop: top - 1,\nbottom: top + 1 };\n }\n }\n\n if (!rect) {\n const coords = editorView.coordsAtPos(target);\n rect = { left: editorRect.left + 50,\nright: editorRect.right - 50,\ntop: coords.top - 1,\nbottom: coords.top + 1 };\n }\n\n const parent = editorView.dom.offsetParent as HTMLElement;\n let parentLeft = 0;\n let parentTop = 0;\n if (parent && parent !== document.body && getComputedStyle(parent).position !== \"static\") {\n const parentRect = parent.getBoundingClientRect();\n parentLeft = parentRect.left - parent.scrollLeft;\n parentTop = parentRect.top - parent.scrollTop;\n }\n\n if (!dropCursorElement!.parentNode) {\n parent.appendChild(dropCursorElement!);\n }\n\n dropCursorElement!.style.left = `${rect.left - parentLeft}px`;\n dropCursorElement!.style.top = `${rect.top - parentTop}px`;\n dropCursorElement!.style.width = `${rect.right - rect.left}px`;\n };\n\n const handleDrop = (event: DragEvent) => {\n if (!editorView.editable || !editorView.dragging) return;\n\n if (!((editorView as EditorViewWithDrag).dragging as ProseMirrorDragState | null & { node?: unknown })?.node) {\n removeCursor();\n return;\n }\n\n event.preventDefault();\n removeCursor();\n editorView.dom.classList.remove(\"dragging\");\n\n const editorRect = editorView.dom.getBoundingClientRect();\n const clampedX = Math.max(editorRect.left + 10, Math.min(event.clientX, editorRect.right - 10));\n\n const targetPos = getBlockInsertionPoint(event, clampedX);\n if (targetPos === null) return;\n\n const dragging = (editorView as EditorViewWithDrag).dragging;\n if (dragging && dragging.slice) {\n let tr = editorView.state.tr;\n if (dragging.move) {\n const { node } = dragging;\n if (node) {\n node.replace(tr); // exact native ProseMirror delete\n } else {\n tr = tr.deleteSelection();\n }\n }\n\n const mappedTarget = tr.mapping.map(targetPos);\n const beforeInsert = tr.doc;\n\n const { node, slice } = dragging;\n\n if (node && node.node) {\n let nodeToInsert: import(\"prosemirror-model\").Node | import(\"prosemirror-model\").Fragment = node.node;\n const $mapped = tr.doc.resolve(mappedTarget);\n const parentName = $mapped.parent.type.name;\n\n const isTargetList = parentName === \"bullet_list\" || parentName === \"ordered_list\";\n const isTargetTaskList = parentName === \"taskList\";\n\n // 1. Unwrap incoming lists if they don't match the destination perfectly\n if (\"type\" in nodeToInsert && nodeToInsert.type.name === \"list_item\" && !isTargetList) {\n nodeToInsert = nodeToInsert.content;\n } else if (\"type\" in nodeToInsert && nodeToInsert.type.name === \"taskItem\" && !isTargetTaskList) {\n nodeToInsert = nodeToInsert.content;\n }\n\n // 2. Wrap incoming blocks/fragments into exactly the target list type\n const isFragment = !(\"type\" in nodeToInsert);\n const needsWrap = isFragment || (\"type\" in nodeToInsert && nodeToInsert.type.name !== \"list_item\" && nodeToInsert.type.name !== \"taskItem\");\n\n if (needsWrap) {\n if (isTargetList) {\n const listItemType = editorView.state.schema.nodes.list_item;\n if (listItemType) nodeToInsert = listItemType.create(null, nodeToInsert);\n } else if (isTargetTaskList) {\n const taskItemType = editorView.state.schema.nodes.taskItem;\n if (taskItemType) nodeToInsert = taskItemType.create({ checked: false }, nodeToInsert);\n }\n }\n\n // 3. Force insertion. tr.replace slices and splits lists. tr.insert preserves the explicit boundary.\n try {\n tr = tr.insert(mappedTarget, nodeToInsert);\n } catch (e) {\n console.warn(\"Could not insert dragged node exactly at target. Attempting fallback.\", e);\n const point = dropPoint(tr.doc, mappedTarget, slice);\n if (point !== null) {\n tr = tr.replace(point, point, slice);\n }\n }\n } else if (slice) {\n // For generic slices (e.g native image dragging), we MUST use dropPoint\n // so ProseMirror finds a schema-valid depth to insert the node structure natively.\n const point = dropPoint(tr.doc, mappedTarget, slice);\n const finalTarget = point !== null ? point : mappedTarget;\n tr = tr.replace(finalTarget, finalTarget, slice);\n }\n\n if (!tr.doc.eq(beforeInsert)) {\n editorView.dispatch(tr.setMeta(\"uiEvent\", \"drop\"));\n editorView.focus();\n }\n }\n\n (editorView as EditorViewWithDrag).dragging = null;\n };\n\n const handleDragEnd = () => {\n removeCursor();\n };\n\n window.addEventListener(\"dragover\", handleDragOver, { capture: true });\n window.addEventListener(\"drop\", handleDrop, { capture: true });\n window.addEventListener(\"dragend\", handleDragEnd, { capture: true });\n\n cleanup = () => {\n removeCursor();\n observer.disconnect();\n window.removeEventListener(\"dragover\", handleDragOver, { capture: true });\n window.removeEventListener(\"drop\", handleDrop, { capture: true });\n window.removeEventListener(\"dragend\", handleDragEnd, { capture: true });\n };\n\n return {\n destroy() {\n if (cleanup) cleanup();\n }\n };\n }\n });\n}\n\n\n"],"mappings":";;;;AAwBA,SAAS,aAAa,SAAkB;CACpC,MAAM,OAAO,QAAQ,sBAAsB;CAE3C,IAAI,WAAW,QAAQ;CACvB,OAAO,YAAY,OAAO,iBAAiB,QAAQ,CAAC,CAAC,aAAa,UAC9D,WAAW,SAAS;CAExB,MAAM,eAAe,UAAU,sBAAsB;CAErD,OAAO;EACH,KAAK,KAAK,OAAO,cAAc,OAAO;EACtC,MAAM,KAAK,QAAQ,cAAc,QAAQ;EACzC,OAAO,KAAK;CAChB;AACJ;AAEA,SAAS,gBAAgB,QAAkC,MAAkB;CACzE,MAAM,aAAa,KAAK,IAAI,sBAAsB;CAGlD,IAAI,OAAO,IAAI,WAAW,OAAO,OAAO,IAAI,WAAW,QAAQ,OAAO,KAAA;CACtE,IAAI,OAAO,IAAI,WAAW,OAAO,OAAO,OAAO,IAAI,WAAW,QAAQ,IAAI,OAAO,KAAA;CAEjF,MAAM,gBAAgB;CAItB,MAAM,QADO,SAAS,iBAAiB,OAAO,GAAG,OAAO,CAC1C,CAAA,EAAM,QAAQ,aAAa;CACzC,IAAI,SAAS,KAAK,IAAI,SAAS,KAAK,KAAK,MAAM,aAAa,KAAK,G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jD,WAAW,MAAM;IACrB;GACJ;GAEA,WAAmC,WAAW;EAClD;EAEA,MAAM,sBAAsB;GACxB,aAAa;EACjB;EAEA,OAAO,iBAAiB,YAAY,gBAAgB,EAAE,SAAS,KAAK,CAAC;EACrE,OAAO,iBAAiB,QAAQ,YAAY,EAAE,SAAS,KAAK,CAAC;EAC7D,OAAO,iBAAiB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;EAEnE,gBAAgB;GACZ,aAAa;GACb,SAAS,WAAW;GACpB,OAAO,oBAAoB,YAAY,gBAAgB,EAAE,SAAS,KAAK,CAAC;GACxE,OAAO,oBAAoB,QAAQ,YAAY,EAAE,SAAS,KAAK,CAAC;GAChE,OAAO,oBAAoB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;EAC1E;EAEA,OAAO,EACH,UAAU;GACN,IAAI,SAAS,QAAQ;EACzB,EACJ;CACJ,EACJ,CAAC;AACL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/cms",
3
- "version": "0.25.0-canary.ge06257e",
3
+ "version": "0.25.0",
4
4
  "description": "Rebase CMS — content management views, forms, and routing",
5
5
  "keywords": [
6
6
  "rebase",
@@ -93,14 +93,14 @@
93
93
  "react-use-measure": "^2.1.7",
94
94
  "read-excel-file": "^9.3.10",
95
95
  "zod": "^4.4.3",
96
- "@rebasepro/cms-types": "0.25.0-canary.ge06257e",
97
- "@rebasepro/app": "0.25.0-canary.ge06257e",
98
- "@rebasepro/common": "0.25.0-canary.ge06257e",
99
- "@rebasepro/inference": "0.25.0-canary.ge06257e",
100
- "@rebasepro/forms": "0.25.0-canary.ge06257e",
101
- "@rebasepro/ui": "0.25.0-canary.ge06257e",
102
- "@rebasepro/types": "0.25.0-canary.ge06257e",
103
- "@rebasepro/utils": "0.25.0-canary.ge06257e"
96
+ "@rebasepro/app": "0.25.0",
97
+ "@rebasepro/cms-types": "0.25.0",
98
+ "@rebasepro/common": "0.25.0",
99
+ "@rebasepro/forms": "0.25.0",
100
+ "@rebasepro/inference": "0.25.0",
101
+ "@rebasepro/ui": "0.25.0",
102
+ "@rebasepro/utils": "0.25.0",
103
+ "@rebasepro/types": "0.25.0"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^19.2.7",