@prosekit/web 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{get-default-state-CIEy7xrl.js → get-default-state-Bqluw34o.js} +2 -2
- package/dist/{get-default-state-CIEy7xrl.js.map → get-default-state-Bqluw34o.js.map} +1 -1
- package/dist/{get-safe-editor-view-DENm4avv.js → get-safe-editor-view-DJlcheeV.js} +2 -2
- package/dist/{get-safe-editor-view-DENm4avv.js.map → get-safe-editor-view-DJlcheeV.js.map} +1 -1
- package/dist/{inject-style-BJQNFufI.js → inject-style-DYQXx-cE.js} +4 -6
- package/dist/{inject-style-BJQNFufI.js.map → inject-style-DYQXx-cE.js.map} +1 -1
- package/dist/prosekit-web-autocomplete.d.ts.map +1 -1
- package/dist/prosekit-web-autocomplete.js +5 -7
- package/dist/prosekit-web-autocomplete.js.map +1 -1
- package/dist/prosekit-web-block-handle.d.ts.map +1 -1
- package/dist/prosekit-web-block-handle.js +23 -19
- package/dist/prosekit-web-block-handle.js.map +1 -1
- package/dist/prosekit-web-drop-indicator.d.ts.map +1 -1
- package/dist/prosekit-web-drop-indicator.js +4 -5
- package/dist/prosekit-web-drop-indicator.js.map +1 -1
- package/dist/prosekit-web-inline-popover.d.ts.map +1 -1
- package/dist/prosekit-web-inline-popover.js +4 -7
- package/dist/prosekit-web-inline-popover.js.map +1 -1
- package/dist/prosekit-web-resizable.d.ts.map +1 -1
- package/dist/prosekit-web-resizable.js +3 -6
- package/dist/prosekit-web-resizable.js.map +1 -1
- package/dist/prosekit-web-table-handle.d.ts.map +1 -1
- package/dist/prosekit-web-table-handle.js +23 -36
- package/dist/prosekit-web-table-handle.js.map +1 -1
- package/dist/prosekit-web.d.ts +1 -1
- package/dist/{use-editor-extension-Cc7ZG7uj.js → use-editor-extension-B_5BbYvf.js} +2 -2
- package/dist/{use-editor-extension-Cc7ZG7uj.js.map → use-editor-extension-B_5BbYvf.js.map} +1 -1
- package/dist/{use-scrolling-BNfsQs3S.js → use-scrolling-BjI3cuLt.js} +2 -2
- package/dist/{use-scrolling-BNfsQs3S.js.map → use-scrolling-BjI3cuLt.js.map} +1 -1
- package/package.json +10 -10
- package/src/components/block-handle/block-handle-popover/pointer-move.ts +19 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEditorExtension } from "./use-editor-extension-
|
|
2
|
-
import { assignStyles, useScrolling } from "./use-scrolling-
|
|
1
|
+
import { t as useEditorExtension } from "./use-editor-extension-B_5BbYvf.js";
|
|
2
|
+
import { n as assignStyles, t as useScrolling } from "./use-scrolling-BjI3cuLt.js";
|
|
3
3
|
import { createComputed, createSignal, defineCustomElement, registerCustomElement, useEffect } from "@aria-ui/core";
|
|
4
4
|
import { usePresence } from "@aria-ui/presence";
|
|
5
5
|
import { defineDropIndicator } from "@prosekit/extensions/drop-indicator";
|
|
@@ -17,10 +17,9 @@ function useDropIndicator(host, { state }) {
|
|
|
17
17
|
useEditorExtension(host, state.editor, extension);
|
|
18
18
|
const line = createComputed(() => context.get()?.line);
|
|
19
19
|
const scrolling = useScrolling(host);
|
|
20
|
-
|
|
20
|
+
usePresence(host, createComputed(() => {
|
|
21
21
|
return !!context.get() && !scrolling.get();
|
|
22
|
-
});
|
|
23
|
-
usePresence(host, presence);
|
|
22
|
+
}));
|
|
24
23
|
useEffect(host, () => {
|
|
25
24
|
const lineValue = line.get();
|
|
26
25
|
const lineWidth = state.width.get();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-drop-indicator.js","names":["width: number","height: number","top: number","left: number","dropIndicatorProps: PropDeclarations<DropIndicatorProps>","dropIndicatorEvents: EventDeclarations<DropIndicatorEvents>","DropIndicatorElementBase: BaseElementConstructor<DropIndicatorProps>"],"sources":["../src/components/drop-indicator/drop-indicator/setup.ts","../src/components/drop-indicator/drop-indicator/types.ts","../src/components/drop-indicator/drop-indicator/element.gen.ts"],"sourcesContent":["import {\n createComputed,\n createSignal,\n useEffect,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { usePresence } from '@aria-ui/presence'\nimport {\n defineDropIndicator,\n type ShowHandlerOptions,\n} from '@prosekit/extensions/drop-indicator'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useScrolling } from '../../../hooks/use-scrolling'\nimport { assignStyles } from '../../../utils/assign-styles'\n\nimport type {\n DropIndicatorEvents,\n DropIndicatorProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useDropIndicator(\n host: ConnectableElement,\n { state }: SetupOptions<DropIndicatorProps, DropIndicatorEvents>,\n): void {\n type DropIndicatorContext = ShowHandlerOptions | null\n const context = createSignal<DropIndicatorContext>(null)\n\n const extension = defineDropIndicator({\n onShow: (options) => context.set(options),\n onHide: () => context.set(null),\n })\n\n useEditorExtension(host, state.editor, extension)\n\n const line = createComputed(() => context.get()?.line)\n const scrolling = useScrolling(host)\n const presence = createComputed(() => {\n return !!context.get() && !scrolling.get()\n })\n usePresence(host, presence)\n\n useEffect(\n host,\n () => {\n const lineValue = line.get()\n const lineWidth = state.width.get()\n\n if (!lineValue) return\n\n const { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } } = lineValue\n const horizontal = y1 === y2\n\n let width: number\n let height: number\n let top: number = y1\n let left: number = x1\n\n if (horizontal) {\n width = x2 - x1\n height = lineWidth\n top -= lineWidth / 2\n } else {\n width = lineWidth\n height = y2 - y1\n left -= lineWidth / 2\n }\n\n top = Math.round(top)\n left = Math.round(left)\n\n assignStyles(host, {\n position: 'fixed',\n pointerEvents: 'none',\n width: `${width}px`,\n height: `${height}px`,\n transform: `translate(${left}px, ${top}px)`,\n left: '0px',\n top: '0px',\n })\n },\n )\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface DropIndicatorProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The line width in pixels.\n *\n * @default 2\n */\n width: number\n}\n\n/** @internal */\nexport const dropIndicatorProps: PropDeclarations<DropIndicatorProps> = Object.freeze({\n editor: { default: null },\n width: { default: 2 },\n})\n\nexport interface DropIndicatorEvents {\n}\n\n/** @internal */\nexport const dropIndicatorEvents: EventDeclarations<DropIndicatorEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useDropIndicator } from \"./setup\"\nimport { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from \"./types\"\n\nconst DropIndicatorElementBase: BaseElementConstructor<DropIndicatorProps> = defineCustomElement<\n DropIndicatorProps,\n DropIndicatorEvents\n>({\n props: dropIndicatorProps,\n events: dropIndicatorEvents,\n setup: useDropIndicator,\n})\nclass DropIndicatorElement extends DropIndicatorElementBase {}\n\nregisterCustomElement('prosekit-drop-indicator', DropIndicatorElement)\n \nexport { DropIndicatorElement }\n"],"mappings":";;;;;;;;;;AAyBA,SAAgB,iBACd,MACA,EAAE,SACI;CAEN,MAAM,UAAU,aAAmC,KAAK;CAExD,MAAM,YAAY,oBAAoB;EACpC,SAAS,YAAY,QAAQ,IAAI,QAAQ;EACzC,cAAc,QAAQ,IAAI,KAAK;EAChC,CAAC;AAEF,oBAAmB,MAAM,MAAM,QAAQ,UAAU;CAEjD,MAAM,OAAO,qBAAqB,QAAQ,KAAK,EAAE,KAAK;CACtD,MAAM,YAAY,aAAa,KAAK;
|
|
1
|
+
{"version":3,"file":"prosekit-web-drop-indicator.js","names":["width: number","height: number","top: number","left: number","dropIndicatorProps: PropDeclarations<DropIndicatorProps>","dropIndicatorEvents: EventDeclarations<DropIndicatorEvents>","DropIndicatorElementBase: BaseElementConstructor<DropIndicatorProps>"],"sources":["../src/components/drop-indicator/drop-indicator/setup.ts","../src/components/drop-indicator/drop-indicator/types.ts","../src/components/drop-indicator/drop-indicator/element.gen.ts"],"sourcesContent":["import {\n createComputed,\n createSignal,\n useEffect,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { usePresence } from '@aria-ui/presence'\nimport {\n defineDropIndicator,\n type ShowHandlerOptions,\n} from '@prosekit/extensions/drop-indicator'\n\nimport { useEditorExtension } from '../../../hooks/use-editor-extension'\nimport { useScrolling } from '../../../hooks/use-scrolling'\nimport { assignStyles } from '../../../utils/assign-styles'\n\nimport type {\n DropIndicatorEvents,\n DropIndicatorProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useDropIndicator(\n host: ConnectableElement,\n { state }: SetupOptions<DropIndicatorProps, DropIndicatorEvents>,\n): void {\n type DropIndicatorContext = ShowHandlerOptions | null\n const context = createSignal<DropIndicatorContext>(null)\n\n const extension = defineDropIndicator({\n onShow: (options) => context.set(options),\n onHide: () => context.set(null),\n })\n\n useEditorExtension(host, state.editor, extension)\n\n const line = createComputed(() => context.get()?.line)\n const scrolling = useScrolling(host)\n const presence = createComputed(() => {\n return !!context.get() && !scrolling.get()\n })\n usePresence(host, presence)\n\n useEffect(\n host,\n () => {\n const lineValue = line.get()\n const lineWidth = state.width.get()\n\n if (!lineValue) return\n\n const { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } } = lineValue\n const horizontal = y1 === y2\n\n let width: number\n let height: number\n let top: number = y1\n let left: number = x1\n\n if (horizontal) {\n width = x2 - x1\n height = lineWidth\n top -= lineWidth / 2\n } else {\n width = lineWidth\n height = y2 - y1\n left -= lineWidth / 2\n }\n\n top = Math.round(top)\n left = Math.round(left)\n\n assignStyles(host, {\n position: 'fixed',\n pointerEvents: 'none',\n width: `${width}px`,\n height: `${height}px`,\n transform: `translate(${left}px, ${top}px)`,\n left: '0px',\n top: '0px',\n })\n },\n )\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport type { Editor } from '@prosekit/core'\n\nexport interface DropIndicatorProps {\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * The line width in pixels.\n *\n * @default 2\n */\n width: number\n}\n\n/** @internal */\nexport const dropIndicatorProps: PropDeclarations<DropIndicatorProps> = Object.freeze({\n editor: { default: null },\n width: { default: 2 },\n})\n\nexport interface DropIndicatorEvents {\n}\n\n/** @internal */\nexport const dropIndicatorEvents: EventDeclarations<DropIndicatorEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useDropIndicator } from \"./setup\"\nimport { dropIndicatorEvents, dropIndicatorProps, type DropIndicatorEvents, type DropIndicatorProps } from \"./types\"\n\nconst DropIndicatorElementBase: BaseElementConstructor<DropIndicatorProps> = defineCustomElement<\n DropIndicatorProps,\n DropIndicatorEvents\n>({\n props: dropIndicatorProps,\n events: dropIndicatorEvents,\n setup: useDropIndicator,\n})\nclass DropIndicatorElement extends DropIndicatorElementBase {}\n\nregisterCustomElement('prosekit-drop-indicator', DropIndicatorElement)\n \nexport { DropIndicatorElement }\n"],"mappings":";;;;;;;;;;AAyBA,SAAgB,iBACd,MACA,EAAE,SACI;CAEN,MAAM,UAAU,aAAmC,KAAK;CAExD,MAAM,YAAY,oBAAoB;EACpC,SAAS,YAAY,QAAQ,IAAI,QAAQ;EACzC,cAAc,QAAQ,IAAI,KAAK;EAChC,CAAC;AAEF,oBAAmB,MAAM,MAAM,QAAQ,UAAU;CAEjD,MAAM,OAAO,qBAAqB,QAAQ,KAAK,EAAE,KAAK;CACtD,MAAM,YAAY,aAAa,KAAK;AAIpC,aAAY,MAHK,qBAAqB;AACpC,SAAO,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,UAAU,KAAK;GAC1C,CACyB;AAE3B,WACE,YACM;EACJ,MAAM,YAAY,KAAK,KAAK;EAC5B,MAAM,YAAY,MAAM,MAAM,KAAK;AAEnC,MAAI,CAAC,UAAW;EAEhB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,MAAM,IAAI,EAAE,GAAG,IAAI,GAAG,SAAS;EACvD,MAAM,aAAa,OAAO;EAE1B,IAAIA;EACJ,IAAIC;EACJ,IAAIC,MAAc;EAClB,IAAIC,OAAe;AAEnB,MAAI,YAAY;AACd,WAAQ,KAAK;AACb,YAAS;AACT,UAAO,YAAY;SACd;AACL,WAAQ;AACR,YAAS,KAAK;AACd,WAAQ,YAAY;;AAGtB,QAAM,KAAK,MAAM,IAAI;AACrB,SAAO,KAAK,MAAM,KAAK;AAEvB,eAAa,MAAM;GACjB,UAAU;GACV,eAAe;GACf,OAAO,GAAG,MAAM;GAChB,QAAQ,GAAG,OAAO;GAClB,WAAW,aAAa,KAAK,MAAM,IAAI;GACvC,MAAM;GACN,KAAK;GACN,CAAC;GAEL;;;;;;AC7DH,MAAaC,qBAA2D,OAAO,OAAO;CACpF,QAAQ,EAAE,SAAS,MAAM;CACzB,OAAO,EAAE,SAAS,GAAG;CACtB,CAAC;;AAMF,MAAaC,sBAA8D,EAAE;;;;AC5B7E,MAAMC,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts","../src/components/inline-popover/inline-popover/setup.ts"],"sourcesContent":[],"mappings":";;;;;UAYiB,kBAAA,SACf,KACE;;AAFJ;;;;;
|
|
1
|
+
{"version":3,"file":"prosekit-web-inline-popover.d.ts","names":[],"sources":["../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts","../src/components/inline-popover/inline-popover/setup.ts"],"sourcesContent":[],"mappings":";;;;;UAYiB,kBAAA,SACf,KACE;;AAFJ;;;;;EAyDQ,MAAA,EA7CE,MA6CF,GAAA,IAAA;EAKG;;;;;AAcX;AAeA;AAQA;;;;EC1GM;AAAgD;;;;ACsBtD;;;EAEW,IAAA,EAAA,OAAA;EAAqB;;;;;;;;;;aF8BnB;;;;UAKH;;;;QAKF;;;;WAKG;;;;UAKD;;;;mBAKS;;;cAIN,oBAAoB,iBAAiB;UAejC,mBAAA,SAA4B;;;;cAI/B;;;cAID,qBAAqB,kBAAkB;;;cC1G9C,0BAA0B,uBAAuB;cAQjD,oBAAA,SAA6B,wBAAA;;;;;;ADDlB,iBEeD,gBAAA,CFfoB,IAAA,EEgB5B,kBFhB4B,EAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EEiBjB,YFjBiB,CEiBJ,kBFjBI,EEiBgB,mBFjBhB,CAAA,CAAA,EAAA,IAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEditorExtension } from "./use-editor-extension-
|
|
1
|
+
import { t as useEditorExtension } from "./use-editor-extension-B_5BbYvf.js";
|
|
2
2
|
import { createComputed, createSignal, defineCustomElement, registerCustomElement, useAttribute, useEffect } from "@aria-ui/core";
|
|
3
3
|
import { containsInlineNode, defineFocusChangeHandler, defineKeymap, defineUpdateHandler, isInCodeBlock, isTextSelection } from "@prosekit/core";
|
|
4
4
|
import { useOverlayPositionerState } from "@aria-ui/overlay/elements";
|
|
@@ -10,8 +10,7 @@ import { overlayPositionerEvents as overlayPositionerEvents$1, overlayPositioner
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
function useEditorFocusChangeEvent(host, editor, handler) {
|
|
13
|
-
|
|
14
|
-
useEditorExtension(host, editor, extension);
|
|
13
|
+
useEditorExtension(host, editor, defineFocusChangeHandler(handler));
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
//#endregion
|
|
@@ -20,15 +19,13 @@ function useEditorFocusChangeEvent(host, editor, handler) {
|
|
|
20
19
|
* @internal
|
|
21
20
|
*/
|
|
22
21
|
function useEditorUpdateEvent(host, editor, handler) {
|
|
23
|
-
|
|
24
|
-
useEditorExtension(host, editor, extension);
|
|
22
|
+
useEditorExtension(host, editor, defineUpdateHandler(handler));
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
//#endregion
|
|
28
26
|
//#region src/hooks/use-keymap.ts
|
|
29
27
|
function useKeymap(host, editor, keymap) {
|
|
30
|
-
|
|
31
|
-
useEditorExtension(host, editor, extension);
|
|
28
|
+
useEditorExtension(host, editor, defineKeymap(keymap));
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-inline-popover.js","names":["inlinePopoverProps: PropDeclarations<InlinePopoverProps>","overlayPositionerProps","inlinePopoverEvents: EventDeclarations<InlinePopoverEvents>","overlayPositionerEvents","InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps>"],"sources":["../src/hooks/use-editor-focus-event.ts","../src/hooks/use-editor-update-event.ts","../src/hooks/use-keymap.ts","../src/components/inline-popover/inline-popover/virtual-selection-element.ts","../src/components/inline-popover/inline-popover/setup.ts","../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts"],"sourcesContent":["import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineFocusChangeHandler,\n type Editor,\n type FocusChangeHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorFocusChangeEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: FocusChangeHandler,\n): void {\n const extension = defineFocusChangeHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineUpdateHandler,\n type Editor,\n type UpdateHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorUpdateEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: UpdateHandler,\n): void {\n const extension = defineUpdateHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineKeymap,\n type Editor,\n type Keymap,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\nexport function useKeymap(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n keymap: Keymap,\n): void {\n const extension = defineKeymap(keymap)\n useEditorExtension(host, editor, extension)\n}\n","import type { ReferenceElement } from '@floating-ui/dom'\nimport {\n containsInlineNode,\n isInCodeBlock,\n isTextSelection,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nexport function getVirtualSelectionElement(\n view: EditorView,\n): ReferenceElement | undefined {\n if (typeof window === 'undefined' || view.isDestroyed) {\n return\n }\n\n const selection = view.state.selection\n\n if (\n !selection.empty\n && !isInCodeBlock(selection)\n && isTextSelection(selection)\n && containsInlineNode(view.state.doc, selection.from, selection.to)\n ) {\n return getDomDecoration(view) || getInlineDecoration(view)\n }\n}\n\nfunction getDomDecoration(view: EditorView): ReferenceElement | undefined {\n const range = getDomRange(view)\n if (range) {\n // To get it work properly in Safari, we cannot return the range directly.\n // We have to return a contextElement.\n return {\n contextElement: view.dom,\n getBoundingClientRect: () => range.getBoundingClientRect(),\n getClientRects: () => range.getClientRects(),\n }\n }\n}\n\nfunction getDomRange(view: EditorView): Range | undefined {\n const win = view.dom.ownerDocument.defaultView\n const selection = win?.getSelection()\n if (!selection || selection.isCollapsed) {\n return\n }\n\n const range = typeof selection.rangeCount === 'number'\n && selection.rangeCount > 0\n && selection.getRangeAt(0)\n\n if (!range) {\n return\n }\n\n return range\n}\n\nfunction getInlineDecoration(view: EditorView): ReferenceElement | undefined {\n const match = view.dom.querySelectorAll('.prosekit-virtual-selection')\n\n if (match.length === 0) {\n return\n }\n if (match.length === 1) {\n return match[0]\n }\n\n const items = Array.from(match)\n return {\n contextElement: items[0],\n getBoundingClientRect: () => items[0].getBoundingClientRect(),\n getClientRects: () => items.map((item) => item.getBoundingClientRect()),\n }\n}\n","import {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport type { ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'\nimport { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'\nimport { useKeymap } from '../../../hooks/use-keymap'\n\nimport type {\n InlinePopoverEvents,\n InlinePopoverProps,\n} from './types'\nimport { getVirtualSelectionElement } from './virtual-selection-element'\n\n/**\n * @internal\n */\nexport function useInlinePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<InlinePopoverProps, InlinePopoverEvents>,\n): void {\n const { editor, defaultOpen, open, ...overlayState } = state\n\n const reference = useInlinePopoverReference(host, editor)\n const hasReference = createComputed(() => !!reference.get())\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n const openValue = open.peek()\n\n if (defaultOpenValue || openValue) {\n emit('openChange', hasReferenceValue)\n }\n })\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n\n if (hasReferenceValue && defaultOpenValue) {\n open.set(true)\n } else if (!hasReferenceValue) {\n open.set(false)\n }\n })\n\n useKeymap(host, editor, {\n Escape: () => {\n if (!state.dismissOnEscape.peek() || !open.peek()) {\n return false\n }\n open.set(false)\n emit('openChange', false)\n return true\n },\n })\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useInlinePopoverReference(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n) {\n const reference = createSignal<ReferenceElement | null>(null)\n let editorFocused = false\n\n useEditorFocusChangeEvent(host, editor, (focus) => {\n editorFocused = focus\n })\n\n useEditorUpdateEvent(host, editor, (view) => {\n const isPopoverFocused = !editorFocused && host.contains(host.ownerDocument.activeElement)\n\n if (isPopoverFocused) {\n return\n }\n\n reference.set(getVirtualSelectionElement(view) || null)\n })\n\n return reference\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay'\nimport type { Editor } from '@prosekit/core'\n\nexport interface InlinePopoverProps extends\n Omit<\n OverlayPositionerProps,\n 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'\n >\n{\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * When `defaultOpen` is true, the popover will open or close based on the\n * inline selection. When `defaultOpen` is false, the popover will never be\n * opened unless the `open` prop is true.\n *\n * @default true\n */\n defaultOpen: boolean\n\n /**\n * Whether the popover is open.\n *\n * Notice that the popover will be always hidden if the inline selection is\n * empty.\n *\n * @default false\n */\n open: boolean\n\n /**\n * Whether the inline popover should be dismissed when the editor receives an\n * Escape key press.\n *\n * @default true\n */\n dismissOnEscape: boolean\n\n /**\n * @default \"top\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * @default 12\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n hide: OverlayPositionerProps['hide']\n\n /**\n * @default true\n */\n overlap: OverlayPositionerProps['overlap']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const inlinePopoverProps: PropDeclarations<InlinePopoverProps> = Object.freeze({\n ...overlayPositionerProps,\n editor: { default: null },\n defaultOpen: { default: true },\n open: { default: false },\n dismissOnEscape: { default: true },\n\n placement: { default: 'top' },\n offset: { default: 12 },\n hide: { default: true },\n overlap: { default: true },\n inline: { default: true },\n overflowPadding: { default: 8 },\n})\n\nexport interface InlinePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n}\n\n/** @internal */\nexport const inlinePopoverEvents: EventDeclarations<InlinePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useInlinePopover } from \"./setup\"\nimport { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from \"./types\"\n\nconst InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps> = defineCustomElement<\n InlinePopoverProps,\n InlinePopoverEvents\n>({\n props: inlinePopoverProps,\n events: inlinePopoverEvents,\n setup: useInlinePopover,\n})\nclass InlinePopoverElement extends InlinePopoverElementBase {}\n\nregisterCustomElement('prosekit-inline-popover', InlinePopoverElement)\n \nexport { InlinePopoverElement }\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,0BACd,MACA,QACA,SACM;CACN,MAAM,YAAY,yBAAyB,QAAQ;AACnD,oBAAmB,MAAM,QAAQ,UAAU;;;;;;;;ACN7C,SAAgB,qBACd,MACA,QACA,SACM;CACN,MAAM,YAAY,oBAAoB,QAAQ;AAC9C,oBAAmB,MAAM,QAAQ,UAAU;;;;;ACT7C,SAAgB,UACd,MACA,QACA,QACM;CACN,MAAM,YAAY,aAAa,OAAO;AACtC,oBAAmB,MAAM,QAAQ,UAAU;;;;;ACV7C,SAAgB,2BACd,MAC8B;AAC9B,KAAI,OAAO,WAAW,eAAe,KAAK,YACxC;CAGF,MAAM,YAAY,KAAK,MAAM;AAE7B,KACE,CAAC,UAAU,SACR,CAAC,cAAc,UAAU,IACzB,gBAAgB,UAAU,IAC1B,mBAAmB,KAAK,MAAM,KAAK,UAAU,MAAM,UAAU,GAAG,CAEnE,QAAO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BAA2B,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"prosekit-web-inline-popover.js","names":["inlinePopoverProps: PropDeclarations<InlinePopoverProps>","overlayPositionerProps","inlinePopoverEvents: EventDeclarations<InlinePopoverEvents>","overlayPositionerEvents","InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps>"],"sources":["../src/hooks/use-editor-focus-event.ts","../src/hooks/use-editor-update-event.ts","../src/hooks/use-keymap.ts","../src/components/inline-popover/inline-popover/virtual-selection-element.ts","../src/components/inline-popover/inline-popover/setup.ts","../src/components/inline-popover/inline-popover/types.ts","../src/components/inline-popover/inline-popover/element.gen.ts"],"sourcesContent":["import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineFocusChangeHandler,\n type Editor,\n type FocusChangeHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorFocusChangeEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: FocusChangeHandler,\n): void {\n const extension = defineFocusChangeHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineUpdateHandler,\n type Editor,\n type UpdateHandler,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\n/**\n * @internal\n */\nexport function useEditorUpdateEvent(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n handler: UpdateHandler,\n): void {\n const extension = defineUpdateHandler(handler)\n useEditorExtension(host, editor, extension)\n}\n","import type {\n ConnectableElement,\n ReadonlySignal,\n} from '@aria-ui/core'\nimport {\n defineKeymap,\n type Editor,\n type Keymap,\n} from '@prosekit/core'\n\nimport { useEditorExtension } from './use-editor-extension'\n\nexport function useKeymap(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n keymap: Keymap,\n): void {\n const extension = defineKeymap(keymap)\n useEditorExtension(host, editor, extension)\n}\n","import type { ReferenceElement } from '@floating-ui/dom'\nimport {\n containsInlineNode,\n isInCodeBlock,\n isTextSelection,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nexport function getVirtualSelectionElement(\n view: EditorView,\n): ReferenceElement | undefined {\n if (typeof window === 'undefined' || view.isDestroyed) {\n return\n }\n\n const selection = view.state.selection\n\n if (\n !selection.empty\n && !isInCodeBlock(selection)\n && isTextSelection(selection)\n && containsInlineNode(view.state.doc, selection.from, selection.to)\n ) {\n return getDomDecoration(view) || getInlineDecoration(view)\n }\n}\n\nfunction getDomDecoration(view: EditorView): ReferenceElement | undefined {\n const range = getDomRange(view)\n if (range) {\n // To get it work properly in Safari, we cannot return the range directly.\n // We have to return a contextElement.\n return {\n contextElement: view.dom,\n getBoundingClientRect: () => range.getBoundingClientRect(),\n getClientRects: () => range.getClientRects(),\n }\n }\n}\n\nfunction getDomRange(view: EditorView): Range | undefined {\n const win = view.dom.ownerDocument.defaultView\n const selection = win?.getSelection()\n if (!selection || selection.isCollapsed) {\n return\n }\n\n const range = typeof selection.rangeCount === 'number'\n && selection.rangeCount > 0\n && selection.getRangeAt(0)\n\n if (!range) {\n return\n }\n\n return range\n}\n\nfunction getInlineDecoration(view: EditorView): ReferenceElement | undefined {\n const match = view.dom.querySelectorAll('.prosekit-virtual-selection')\n\n if (match.length === 0) {\n return\n }\n if (match.length === 1) {\n return match[0]\n }\n\n const items = Array.from(match)\n return {\n contextElement: items[0],\n getBoundingClientRect: () => items[0].getBoundingClientRect(),\n getClientRects: () => items.map((item) => item.getBoundingClientRect()),\n }\n}\n","import {\n createComputed,\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SetupOptions,\n} from '@aria-ui/core'\nimport { useOverlayPositionerState } from '@aria-ui/overlay/elements'\nimport { usePresence } from '@aria-ui/presence'\nimport type { ReferenceElement } from '@floating-ui/dom'\nimport type { Editor } from '@prosekit/core'\n\nimport { useEditorFocusChangeEvent } from '../../../hooks/use-editor-focus-event'\nimport { useEditorUpdateEvent } from '../../../hooks/use-editor-update-event'\nimport { useKeymap } from '../../../hooks/use-keymap'\n\nimport type {\n InlinePopoverEvents,\n InlinePopoverProps,\n} from './types'\nimport { getVirtualSelectionElement } from './virtual-selection-element'\n\n/**\n * @internal\n */\nexport function useInlinePopover(\n host: ConnectableElement,\n { state, emit }: SetupOptions<InlinePopoverProps, InlinePopoverEvents>,\n): void {\n const { editor, defaultOpen, open, ...overlayState } = state\n\n const reference = useInlinePopoverReference(host, editor)\n const hasReference = createComputed(() => !!reference.get())\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n const openValue = open.peek()\n\n if (defaultOpenValue || openValue) {\n emit('openChange', hasReferenceValue)\n }\n })\n\n useEffect(host, () => {\n const hasReferenceValue = hasReference.get()\n const defaultOpenValue = defaultOpen.peek()\n\n if (hasReferenceValue && defaultOpenValue) {\n open.set(true)\n } else if (!hasReferenceValue) {\n open.set(false)\n }\n })\n\n useKeymap(host, editor, {\n Escape: () => {\n if (!state.dismissOnEscape.peek() || !open.peek()) {\n return false\n }\n open.set(false)\n emit('openChange', false)\n return true\n },\n })\n\n useOverlayPositionerState(host, overlayState, { reference })\n\n useAttribute(host, 'data-state', () => (open.get() ? 'open' : 'closed'))\n usePresence(host, open)\n}\n\nfunction useInlinePopoverReference(\n host: ConnectableElement,\n editor: ReadonlySignal<Editor | null>,\n) {\n const reference = createSignal<ReferenceElement | null>(null)\n let editorFocused = false\n\n useEditorFocusChangeEvent(host, editor, (focus) => {\n editorFocused = focus\n })\n\n useEditorUpdateEvent(host, editor, (view) => {\n const isPopoverFocused = !editorFocused && host.contains(host.ownerDocument.activeElement)\n\n if (isPopoverFocused) {\n return\n }\n\n reference.set(getVirtualSelectionElement(view) || null)\n })\n\n return reference\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\nimport {\n overlayPositionerEvents,\n overlayPositionerProps,\n type OverlayPositionerEvents,\n type OverlayPositionerProps,\n} from '@aria-ui/overlay'\nimport type { Editor } from '@prosekit/core'\n\nexport interface InlinePopoverProps extends\n Omit<\n OverlayPositionerProps,\n 'placement' | 'offset' | 'hide' | 'overlap' | 'inline' | 'overflowPadding'\n >\n{\n /**\n * The ProseKit editor instance.\n *\n * @default null\n * @hidden\n */\n editor: Editor | null\n\n /**\n * Whether the popover is open by default when some inline content is\n * selected.\n *\n * When `defaultOpen` is true, the popover will open or close based on the\n * inline selection. When `defaultOpen` is false, the popover will never be\n * opened unless the `open` prop is true.\n *\n * @default true\n */\n defaultOpen: boolean\n\n /**\n * Whether the popover is open.\n *\n * Notice that the popover will be always hidden if the inline selection is\n * empty.\n *\n * @default false\n */\n open: boolean\n\n /**\n * Whether the inline popover should be dismissed when the editor receives an\n * Escape key press.\n *\n * @default true\n */\n dismissOnEscape: boolean\n\n /**\n * @default \"top\"\n */\n placement: OverlayPositionerProps['placement']\n\n /**\n * @default 12\n */\n offset: OverlayPositionerProps['offset']\n\n /**\n * @default true\n */\n hide: OverlayPositionerProps['hide']\n\n /**\n * @default true\n */\n overlap: OverlayPositionerProps['overlap']\n\n /**\n * @default true\n */\n inline: OverlayPositionerProps['inline']\n\n /**\n * @default 8\n */\n overflowPadding: OverlayPositionerProps['overflowPadding']\n}\n\n/** @internal */\nexport const inlinePopoverProps: PropDeclarations<InlinePopoverProps> = Object.freeze({\n ...overlayPositionerProps,\n editor: { default: null },\n defaultOpen: { default: true },\n open: { default: false },\n dismissOnEscape: { default: true },\n\n placement: { default: 'top' },\n offset: { default: 12 },\n hide: { default: true },\n overlap: { default: true },\n inline: { default: true },\n overflowPadding: { default: 8 },\n})\n\nexport interface InlinePopoverEvents extends OverlayPositionerEvents {\n /**\n * Fired when the open state changes.\n */\n openChange: CustomEvent<boolean>\n}\n\n/** @internal */\nexport const inlinePopoverEvents: EventDeclarations<InlinePopoverEvents> = {\n ...overlayPositionerEvents,\n openChange: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useInlinePopover } from \"./setup\"\nimport { inlinePopoverEvents, inlinePopoverProps, type InlinePopoverEvents, type InlinePopoverProps } from \"./types\"\n\nconst InlinePopoverElementBase: BaseElementConstructor<InlinePopoverProps> = defineCustomElement<\n InlinePopoverProps,\n InlinePopoverEvents\n>({\n props: inlinePopoverProps,\n events: inlinePopoverEvents,\n setup: useInlinePopover,\n})\nclass InlinePopoverElement extends InlinePopoverElementBase {}\n\nregisterCustomElement('prosekit-inline-popover', InlinePopoverElement)\n \nexport { InlinePopoverElement }\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,0BACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,yBAAyB,QAAQ,CACR;;;;;;;;ACN7C,SAAgB,qBACd,MACA,QACA,SACM;AAEN,oBAAmB,MAAM,QADP,oBAAoB,QAAQ,CACH;;;;;ACT7C,SAAgB,UACd,MACA,QACA,QACM;AAEN,oBAAmB,MAAM,QADP,aAAa,OAAO,CACK;;;;;ACV7C,SAAgB,2BACd,MAC8B;AAC9B,KAAI,OAAO,WAAW,eAAe,KAAK,YACxC;CAGF,MAAM,YAAY,KAAK,MAAM;AAE7B,KACE,CAAC,UAAU,SACR,CAAC,cAAc,UAAU,IACzB,gBAAgB,UAAU,IAC1B,mBAAmB,KAAK,MAAM,KAAK,UAAU,MAAM,UAAU,GAAG,CAEnE,QAAO,iBAAiB,KAAK,IAAI,oBAAoB,KAAK;;AAI9D,SAAS,iBAAiB,MAAgD;CACxE,MAAM,QAAQ,YAAY,KAAK;AAC/B,KAAI,MAGF,QAAO;EACL,gBAAgB,KAAK;EACrB,6BAA6B,MAAM,uBAAuB;EAC1D,sBAAsB,MAAM,gBAAgB;EAC7C;;AAIL,SAAS,YAAY,MAAqC;CAExD,MAAM,YADM,KAAK,IAAI,cAAc,aACZ,cAAc;AACrC,KAAI,CAAC,aAAa,UAAU,YAC1B;CAGF,MAAM,QA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,SAAS,SAAU;AACxE,aAAY,MAAM,KAAK;;AAGzB,SAAS,0BACP,MACA,QACA;CACA,MAAM,YAAY,aAAsC,KAAK;CAC7D,IAAI,gBAAgB;AAEpB,2BAA0B,MAAM,SAAS,UAAU;AACjD,kBAAgB;GAChB;AAEF,sBAAqB,MAAM,SAAS,SAAS;AAG3C,MAFyB,CAAC,iBAAiB,KAAK,SAAS,KAAK,cAAc,cAAc,CAGxF;AAGF,YAAU,IAAI,2BAA2B,KAAK,IAAI,KAAK;GACvD;AAEF,QAAO;;;;;;ACPT,MAAaA,qBAA2D,OAAO,OAAO;CACpF,GAAGC;CACH,QAAQ,EAAE,SAAS,MAAM;CACzB,aAAa,EAAE,SAAS,MAAM;CAC9B,MAAM,EAAE,SAAS,OAAO;CACxB,iBAAiB,EAAE,SAAS,MAAM;CAElC,WAAW,EAAE,SAAS,OAAO;CAC7B,QAAQ,EAAE,SAAS,IAAI;CACvB,MAAM,EAAE,SAAS,MAAM;CACvB,SAAS,EAAE,SAAS,MAAM;CAC1B,QAAQ,EAAE,SAAS,MAAM;CACzB,iBAAiB,EAAE,SAAS,GAAG;CAChC,CAAC;;AAUF,MAAaC,sBAA8D;CACzE,GAAGC;CACH,YAAY,EAAE;CACf;;;;AC7GD,MAAMC,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-resizable.d.ts","names":[],"sources":["../src/components/resizable/resizable-handle/types.ts","../src/components/resizable/resizable-handle/element.gen.ts","../src/components/resizable/resizable-handle/setup.ts","../src/components/resizable/resizable-root/types.ts","../src/components/resizable/resizable-root/element.gen.ts","../src/components/resizable/resizable-root/setup.ts"],"sourcesContent":[],"mappings":";;;UAKiB,oBAAA;;AAAjB;AAkBA
|
|
1
|
+
{"version":3,"file":"prosekit-web-resizable.d.ts","names":[],"sources":["../src/components/resizable/resizable-handle/types.ts","../src/components/resizable/resizable-handle/element.gen.ts","../src/components/resizable/resizable-handle/setup.ts","../src/components/resizable/resizable-root/types.ts","../src/components/resizable/resizable-root/element.gen.ts","../src/components/resizable/resizable-root/setup.ts"],"sourcesContent":[],"mappings":";;;UAKiB,oBAAA;;AAAjB;AAkBA;AAKA;AAGA;;;;AC1BM,cDkBO,oBCXX,EDWiC,gBClBsB,CDkBL,oBClBlB,CAAA;AAAsB;UDuBvC,qBAAA;;AEJD,cFOH,qBEPqB,EFOE,iBEPF,CFOoB,qBEPpB,CAAA;;;cDnB5B,4BAA4B,uBAAuB;ADAzD,cCQM,sBAAA,SAA+B,0BAAA,CDRA;;;;AAArC;AAkBA;AAKiB,iBEJD,kBAAA,CFIsB,IAAA,EEH9B,kBFG8B,EAAA;EAAA;CAAA,EAAA;EAGzB,KAAA,EELS,WFKT,CELqB,oBFKoB,CAAA;;;;UG1BrC,kBAAA;;EHAA,MAAA,EAAA,MAAA,GAAA,IAAA;EAkBJ,WAAA,EAAA,MAAA,GAAA,IAEZ;AAGD;AAGA;cGnBa,oBAAoB,iBAAiB;UAMjC,mBAAA;eACF;IFdT,KAAA,EAAA,MAAA;IAQA,MAAA,EAAA,MAAA;;aEOO;;IDIG,MAAA,EAAA,MAAA;EACR,CAAA,CAAA;;;AACc,cCFT,mBDES,ECFY,iBDEZ,CCF8B,mBDE9B,CAAA;;;cErBhB,0BAA0B,uBAAuB;AJAvD,cIQM,oBAAA,SAA6B,wBAAA,CJRE;;;;AAArC;AAkBA;AAKiB,iBKFD,gBAAA,CLEsB,IAAA,EKD9B,kBLC8B,EAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EKAnB,YLAmB,CKAN,kBLAM,EKAc,mBLAd,CAAA,CAAA,EAAA,IAAA"}
|
|
@@ -100,13 +100,10 @@ function clamp([w, h]) {
|
|
|
100
100
|
* @internal
|
|
101
101
|
*/
|
|
102
102
|
function useResizableHandle(host, { state }) {
|
|
103
|
-
const onResize = onResizeContext.consume(host);
|
|
104
|
-
const onResizeStart = onResizeStartContext.consume(host);
|
|
105
|
-
const onResizeEnd = onResizeEndContext.consume(host);
|
|
106
103
|
useResizableHandleState(host, state, {
|
|
107
|
-
onResize,
|
|
108
|
-
onResizeStart,
|
|
109
|
-
onResizeEnd
|
|
104
|
+
onResize: onResizeContext.consume(host),
|
|
105
|
+
onResizeStart: onResizeStartContext.consume(host),
|
|
106
|
+
onResizeEnd: onResizeEndContext.consume(host)
|
|
110
107
|
});
|
|
111
108
|
}
|
|
112
109
|
function useResizableHandleState(host, state, context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-resizable.js","names":["onResizeContext: Context<OnResize>","onResizeStartContext: Context<OnResizeStart>","onResizeEndContext: Context<OnResizeEnd>","calcBottomRightResize: CalcResize","calcBottomLeftResize: CalcResize","calcTopRightResize: CalcResize","calcTopLeftResize: CalcResize","calcTopResize: CalcResize","calcRightResize: CalcResize","calcBottomResize: CalcResize","calcLeftResize: CalcResize","resizableHandleProps: PropDeclarations<ResizableHandleProps>","resizableHandleEvents: EventDeclarations<ResizableHandleEvents>","ResizableHandleElementBase: BaseElementConstructor<ResizableHandleProps>","onResizeStart: OnResizeStart","aspectRatio: number","onResize: OnResize","onResizeEnd: OnResizeEnd","resizableRootProps: PropDeclarations<ResizableRootProps>","resizableRootEvents: EventDeclarations<ResizableRootEvents>","ResizableRootElementBase: BaseElementConstructor<ResizableRootProps>"],"sources":["../src/components/resizable/context.ts","../src/utils/is-finite-positive-number.ts","../src/components/resizable/resizable-handle/calc-resize.ts","../src/components/resizable/resizable-handle/setup.ts","../src/components/resizable/resizable-handle/types.ts","../src/components/resizable/resizable-handle/element.gen.ts","../src/components/resizable/resizable-root/setup.ts","../src/components/resizable/resizable-root/types.ts","../src/components/resizable/resizable-root/element.gen.ts"],"sourcesContent":["import {\n createContext,\n type Context,\n} from '@aria-ui/core'\n\n/**\n * @internal\n */\nexport const onResizeContext: Context<OnResize> = createContext(\n 'prosekit/resizable/onResize',\n null,\n)\n\n/**\n * @internal\n */\nexport const onResizeStartContext: Context<OnResizeStart> = createContext(\n 'prosekit/resizable/onResizeStart',\n null,\n)\n\n/**\n * @internal\n */\nexport const onResizeEndContext: Context<OnResizeEnd> = createContext(\n 'prosekit/resizable/onResizeEnd',\n null,\n)\n\n/**\n * @internal\n */\nexport type OnResize = ((width: number, height: number) => void) | null\n\n/**\n * @internal\n */\nexport type OnResizeStart =\n | (() => readonly [width: number, height: number, aspectRatio: number])\n | null\n\n/**\n * @internal\n */\nexport type OnResizeEnd = (() => void) | null\n","export function isFinitePositiveNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value > 0\n}\n","import { isFinitePositiveNumber } from '../../../utils/is-finite-positive-number'\n\nexport function calcResize(\n position:\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right',\n w: number,\n h: number,\n dx: number,\n dy: number,\n aspectRatio: number | null | undefined,\n): [w: number, h: number] {\n aspectRatio = aspectRatio ? aspectRatio : w / h\n aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1\n\n switch (position) {\n case 'bottom-right':\n return clamp(calcBottomRightResize(w, h, dx, dy, aspectRatio))\n case 'bottom-left':\n return clamp(calcBottomLeftResize(w, h, dx, dy, aspectRatio))\n case 'top-right':\n return clamp(calcTopRightResize(w, h, dx, dy, aspectRatio))\n case 'top-left':\n return clamp(calcTopLeftResize(w, h, dx, dy, aspectRatio))\n case 'top':\n return clamp(calcTopResize(w, h, dx, dy, aspectRatio))\n case 'right':\n return clamp(calcRightResize(w, h, dx, dy, aspectRatio))\n case 'bottom':\n return clamp(calcBottomResize(w, h, dx, dy, aspectRatio))\n case 'left':\n return clamp(calcLeftResize(w, h, dx, dy, aspectRatio))\n default:\n throw new RangeError(`Invalid position: ${position}`)\n }\n}\n\ntype CalcResize = (\n w: number,\n h: number,\n dx: number,\n dy: number,\n aspectRatio: number,\n) => [w: number, h: number]\n\nconst calcBottomRightResize: CalcResize = (w, h, dx, dy, r) => {\n w += dx\n h += dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcBottomLeftResize: CalcResize = (w, h, dx, dy, r) => {\n w -= dx\n h += dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcTopRightResize: CalcResize = (w, h, dx, dy, r) => {\n w += dx\n h -= dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcTopLeftResize: CalcResize = (w, h, dx, dy, r) => {\n w -= dx\n h -= dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcTopResize: CalcResize = (w, h, dx, dy, r) => {\n h -= dy\n w = h * r\n return [w, h]\n}\n\nconst calcRightResize: CalcResize = (w, h, dx, dy, r) => {\n w += dx\n h = w / r\n return [w, h]\n}\n\nconst calcBottomResize: CalcResize = (w, h, dx, dy, r) => {\n h += dy\n w = h * r\n return [w, h]\n}\n\nconst calcLeftResize: CalcResize = (w, h, dx, dy, r) => {\n w -= dx\n h = w / r\n return [w, h]\n}\n\nfunction clamp([w, h]: [number, number]): [number, number] {\n return [\n Math.max(w, 1),\n Math.max(h, 1),\n ]\n}\n","import {\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SignalState,\n} from '@aria-ui/core'\nimport { getWindow } from '@ocavue/utils'\n\nimport {\n onResizeContext,\n onResizeEndContext,\n onResizeStartContext,\n type OnResize,\n type OnResizeEnd,\n type OnResizeStart,\n} from '../context'\n\nimport { calcResize } from './calc-resize'\nimport type { ResizableHandleProps } from './types'\n\n/**\n * @internal\n */\nexport function useResizableHandle(\n host: ConnectableElement,\n { state }: { state: SignalState<ResizableHandleProps> },\n): void {\n const onResize = onResizeContext.consume(host)\n const onResizeStart = onResizeStartContext.consume(host)\n const onResizeEnd = onResizeEndContext.consume(host)\n\n useResizableHandleState(host, state, { onResize, onResizeStart, onResizeEnd })\n}\n\nfunction useResizableHandleState(\n host: ConnectableElement,\n state: SignalState<ResizableHandleProps>,\n context: {\n onResizeStart: ReadonlySignal<OnResizeStart>\n onResize: ReadonlySignal<OnResize>\n onResizeEnd: ReadonlySignal<OnResizeEnd>\n },\n) {\n let startX = 0\n let startY = 0\n let width = 0\n let height = 0\n let aspectRatio = 1\n\n const pointerPressing = createSignal(false)\n\n const handlePointerDown = (event: PointerEvent) => {\n event.preventDefault()\n pointerPressing.set(true)\n\n startX = event.x\n startY = event.y\n\n const size = context.onResizeStart.get()?.()\n if (size) {\n ;[width, height, aspectRatio] = size\n }\n }\n\n const handlePointerMove = (event: PointerEvent) => {\n event.preventDefault()\n\n const dx = event.x - startX\n const dy = event.y - startY\n\n const [w, h] = calcResize(\n state.position.peek(),\n width,\n height,\n dx,\n dy,\n aspectRatio,\n )\n\n context.onResize.get()?.(w, h)\n }\n\n const handlePointerUp = (event: PointerEvent) => {\n event.preventDefault()\n pointerPressing.set(false)\n\n context.onResizeEnd.get()?.()\n }\n\n useEffect(host, () => {\n host.addEventListener('pointerdown', handlePointerDown)\n return () => {\n host.removeEventListener('pointerdown', handlePointerDown)\n }\n })\n\n useEffect(host, () => {\n if (!pointerPressing.get()) {\n return\n }\n\n const win = getWindow(host)\n\n win.addEventListener('pointermove', handlePointerMove)\n win.addEventListener('pointerup', handlePointerUp)\n return () => {\n win.removeEventListener('pointermove', handlePointerMove)\n win.removeEventListener('pointerup', handlePointerUp)\n }\n })\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\n\nexport interface ResizableHandleProps {\n /**\n * The position of the handle.\n *\n * @default \"bottom-right\"\n */\n position:\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right'\n}\n\n/** @internal */\nexport const resizableHandleProps: PropDeclarations<ResizableHandleProps> = {\n position: { default: 'bottom-right' },\n}\n\n/** @internal */\nexport interface ResizableHandleEvents {}\n\n/** @internal */\nexport const resizableHandleEvents: EventDeclarations<ResizableHandleEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useResizableHandle } from \"./setup\"\nimport { resizableHandleEvents, resizableHandleProps, type ResizableHandleEvents, type ResizableHandleProps } from \"./types\"\n\nconst ResizableHandleElementBase: BaseElementConstructor<ResizableHandleProps> = defineCustomElement<\n ResizableHandleProps,\n ResizableHandleEvents\n>({\n props: resizableHandleProps,\n events: resizableHandleEvents,\n setup: useResizableHandle,\n})\nclass ResizableHandleElement extends ResizableHandleElementBase {}\n\nregisterCustomElement('prosekit-resizable-handle', ResizableHandleElement)\n \nexport { ResizableHandleElement }\n","import {\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\n\nimport { isFinitePositiveNumber } from '../../../utils/is-finite-positive-number'\nimport {\n onResizeContext,\n onResizeEndContext,\n onResizeStartContext,\n type OnResize,\n type OnResizeEnd,\n type OnResizeStart,\n} from '../context'\n\nimport type {\n ResizableRootEvents,\n ResizableRootProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useResizableRoot(\n host: ConnectableElement,\n { state, emit }: SetupOptions<ResizableRootProps, ResizableRootEvents>,\n): void {\n const resizing = createSignal(false)\n\n const onResizeStart: OnResizeStart = () => {\n const { width, height } = host.getBoundingClientRect()\n\n let aspectRatio: number = state.aspectRatio.peek() ?? width / height\n\n if (!isFinitePositiveNumber(aspectRatio)) {\n aspectRatio = 0\n }\n\n emit('resizeStart', { width, height })\n resizing.set(true)\n return [width, height, aspectRatio]\n }\n\n const onResize: OnResize = (width, height) => {\n state.width.set(width)\n state.height.set(height)\n }\n\n const onResizeEnd: OnResizeEnd = () => {\n const { width, height } = host.getBoundingClientRect()\n emit('resizeEnd', { width, height })\n resizing.set(false)\n }\n\n onResizeStartContext.provide(host, createSignal(onResizeStart))\n onResizeContext.provide(host, createSignal(onResize))\n onResizeEndContext.provide(host, createSignal(onResizeEnd))\n\n useEffect(host, () => {\n updateResizableRootStyles(\n host,\n Math.max(state.width.get() || 0, 1),\n Math.max(state.height.get() || 0, 1),\n state.aspectRatio.get(),\n )\n })\n\n useAttribute(host, 'data-resizing', () => (resizing.get() ? '' : undefined))\n}\n\nfunction updateResizableRootStyles(\n host: ConnectableElement,\n width: number,\n height: number,\n aspectRatio: number | null,\n) {\n host.style.width = isFinitePositiveNumber(width) ? `${width}px` : ''\n\n host.style.height = isFinitePositiveNumber(height) ? `${height}px` : ''\n\n if (isFinitePositiveNumber(aspectRatio)) {\n host.style.aspectRatio = `${aspectRatio}`\n\n if (width && width > 0 && aspectRatio >= 1) {\n host.style.height = 'auto'\n } else if (height && height > 0 && aspectRatio <= 1) {\n host.style.width = 'min-content'\n }\n }\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\n\nexport interface ResizableRootProps {\n width: number | null\n height: number | null\n aspectRatio: number | null\n}\n\n/** @internal */\nexport const resizableRootProps: PropDeclarations<ResizableRootProps> = {\n width: { default: null },\n height: { default: null },\n aspectRatio: { default: null },\n}\n\nexport interface ResizableRootEvents {\n resizeStart: CustomEvent<{ width: number; height: number }>\n resizeEnd: CustomEvent<{ width: number; height: number }>\n}\n\n/** @internal */\nexport const resizableRootEvents: EventDeclarations<ResizableRootEvents> = {\n resizeStart: {},\n resizeEnd: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useResizableRoot } from \"./setup\"\nimport { resizableRootEvents, resizableRootProps, type ResizableRootEvents, type ResizableRootProps } from \"./types\"\n\nconst ResizableRootElementBase: BaseElementConstructor<ResizableRootProps> = defineCustomElement<\n ResizableRootProps,\n ResizableRootEvents\n>({\n props: resizableRootProps,\n events: resizableRootEvents,\n setup: useResizableRoot,\n})\nclass ResizableRootElement extends ResizableRootElementBase {}\n\nregisterCustomElement('prosekit-resizable-root', ResizableRootElement)\n \nexport { ResizableRootElement }\n"],"mappings":";;;;;;;AAQA,MAAaA,kBAAqC,cAChD,+BACA,KACD;;;;AAKD,MAAaC,uBAA+C,cAC1D,oCACA,KACD;;;;AAKD,MAAaC,qBAA2C,cACtD,kCACA,KACD;;;;AC3BD,SAAgB,uBAAuB,OAAiC;AACtE,QAAO,OAAO,UAAU,YAAY,OAAO,SAAS,MAAM,IAAI,QAAQ;;;;;ACCxE,SAAgB,WACd,UASA,GACA,GACA,IACA,IACA,aACwB;AACxB,eAAc,cAAc,cAAc,IAAI;AAC9C,eAAc,uBAAuB,YAAY,GAAG,cAAc;AAElE,SAAQ,UAAR;EACE,KAAK,eACH,QAAO,MAAM,sBAAsB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAChE,KAAK,cACH,QAAO,MAAM,qBAAqB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC/D,KAAK,YACH,QAAO,MAAM,mBAAmB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC7D,KAAK,WACH,QAAO,MAAM,kBAAkB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC5D,KAAK,MACH,QAAO,MAAM,cAAc,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EACxD,KAAK,QACH,QAAO,MAAM,gBAAgB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC1D,KAAK,SACH,QAAO,MAAM,iBAAiB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC3D,KAAK,OACH,QAAO,MAAM,eAAe,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EACzD,QACE,OAAM,IAAI,WAAW,qBAAqB,WAAW;;;AAY3D,MAAMC,yBAAqC,GAAG,GAAG,IAAI,IAAI,MAAM;AAC7D,MAAK;AACL,MAAK;CAEL,MAAM,MAAM,IAAI;AAChB,KAAI,OAAO,IAAI;AACf,KA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AK,MAAM,SAAS,uBAAuB,OAAO,GAAG,GAAG,OAAO,MAAM;AAErE,KAAI,uBAAuB,YAAY,EAAE;AACvC,OAAK,MAAM,cAAc,GAAG;AAE5B,MAAI,SAAS,QAAQ,KAAK,eAAe,EACvC,MAAK,MAAM,SAAS;WACX,UAAU,SAAS,KAAK,eAAe,EAChD,MAAK,MAAM,QAAQ;;;;;;;AC7EzB,MAAaC,qBAA2D;CACtE,OAAO,EAAE,SAAS,MAAM;CACxB,QAAQ,EAAE,SAAS,MAAM;CACzB,aAAa,EAAE,SAAS,MAAM;CAC/B;;AAQD,MAAaC,sBAA8D;CACzE,aAAa,EAAE;CACf,WAAW,EAAE;CACd;;;;ACtBD,MAAMC,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"prosekit-web-resizable.js","names":["onResizeContext: Context<OnResize>","onResizeStartContext: Context<OnResizeStart>","onResizeEndContext: Context<OnResizeEnd>","calcBottomRightResize: CalcResize","calcBottomLeftResize: CalcResize","calcTopRightResize: CalcResize","calcTopLeftResize: CalcResize","calcTopResize: CalcResize","calcRightResize: CalcResize","calcBottomResize: CalcResize","calcLeftResize: CalcResize","resizableHandleProps: PropDeclarations<ResizableHandleProps>","resizableHandleEvents: EventDeclarations<ResizableHandleEvents>","ResizableHandleElementBase: BaseElementConstructor<ResizableHandleProps>","onResizeStart: OnResizeStart","aspectRatio: number","onResize: OnResize","onResizeEnd: OnResizeEnd","resizableRootProps: PropDeclarations<ResizableRootProps>","resizableRootEvents: EventDeclarations<ResizableRootEvents>","ResizableRootElementBase: BaseElementConstructor<ResizableRootProps>"],"sources":["../src/components/resizable/context.ts","../src/utils/is-finite-positive-number.ts","../src/components/resizable/resizable-handle/calc-resize.ts","../src/components/resizable/resizable-handle/setup.ts","../src/components/resizable/resizable-handle/types.ts","../src/components/resizable/resizable-handle/element.gen.ts","../src/components/resizable/resizable-root/setup.ts","../src/components/resizable/resizable-root/types.ts","../src/components/resizable/resizable-root/element.gen.ts"],"sourcesContent":["import {\n createContext,\n type Context,\n} from '@aria-ui/core'\n\n/**\n * @internal\n */\nexport const onResizeContext: Context<OnResize> = createContext(\n 'prosekit/resizable/onResize',\n null,\n)\n\n/**\n * @internal\n */\nexport const onResizeStartContext: Context<OnResizeStart> = createContext(\n 'prosekit/resizable/onResizeStart',\n null,\n)\n\n/**\n * @internal\n */\nexport const onResizeEndContext: Context<OnResizeEnd> = createContext(\n 'prosekit/resizable/onResizeEnd',\n null,\n)\n\n/**\n * @internal\n */\nexport type OnResize = ((width: number, height: number) => void) | null\n\n/**\n * @internal\n */\nexport type OnResizeStart =\n | (() => readonly [width: number, height: number, aspectRatio: number])\n | null\n\n/**\n * @internal\n */\nexport type OnResizeEnd = (() => void) | null\n","export function isFinitePositiveNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value > 0\n}\n","import { isFinitePositiveNumber } from '../../../utils/is-finite-positive-number'\n\nexport function calcResize(\n position:\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right',\n w: number,\n h: number,\n dx: number,\n dy: number,\n aspectRatio: number | null | undefined,\n): [w: number, h: number] {\n aspectRatio = aspectRatio ? aspectRatio : w / h\n aspectRatio = isFinitePositiveNumber(aspectRatio) ? aspectRatio : 1\n\n switch (position) {\n case 'bottom-right':\n return clamp(calcBottomRightResize(w, h, dx, dy, aspectRatio))\n case 'bottom-left':\n return clamp(calcBottomLeftResize(w, h, dx, dy, aspectRatio))\n case 'top-right':\n return clamp(calcTopRightResize(w, h, dx, dy, aspectRatio))\n case 'top-left':\n return clamp(calcTopLeftResize(w, h, dx, dy, aspectRatio))\n case 'top':\n return clamp(calcTopResize(w, h, dx, dy, aspectRatio))\n case 'right':\n return clamp(calcRightResize(w, h, dx, dy, aspectRatio))\n case 'bottom':\n return clamp(calcBottomResize(w, h, dx, dy, aspectRatio))\n case 'left':\n return clamp(calcLeftResize(w, h, dx, dy, aspectRatio))\n default:\n throw new RangeError(`Invalid position: ${position}`)\n }\n}\n\ntype CalcResize = (\n w: number,\n h: number,\n dx: number,\n dy: number,\n aspectRatio: number,\n) => [w: number, h: number]\n\nconst calcBottomRightResize: CalcResize = (w, h, dx, dy, r) => {\n w += dx\n h += dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcBottomLeftResize: CalcResize = (w, h, dx, dy, r) => {\n w -= dx\n h += dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcTopRightResize: CalcResize = (w, h, dx, dy, r) => {\n w += dx\n h -= dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcTopLeftResize: CalcResize = (w, h, dx, dy, r) => {\n w -= dx\n h -= dy\n\n const sum = w + h\n h = sum / (r + 1)\n w = sum - h\n return [w, h]\n}\n\nconst calcTopResize: CalcResize = (w, h, dx, dy, r) => {\n h -= dy\n w = h * r\n return [w, h]\n}\n\nconst calcRightResize: CalcResize = (w, h, dx, dy, r) => {\n w += dx\n h = w / r\n return [w, h]\n}\n\nconst calcBottomResize: CalcResize = (w, h, dx, dy, r) => {\n h += dy\n w = h * r\n return [w, h]\n}\n\nconst calcLeftResize: CalcResize = (w, h, dx, dy, r) => {\n w -= dx\n h = w / r\n return [w, h]\n}\n\nfunction clamp([w, h]: [number, number]): [number, number] {\n return [\n Math.max(w, 1),\n Math.max(h, 1),\n ]\n}\n","import {\n createSignal,\n useEffect,\n type ConnectableElement,\n type ReadonlySignal,\n type SignalState,\n} from '@aria-ui/core'\nimport { getWindow } from '@ocavue/utils'\n\nimport {\n onResizeContext,\n onResizeEndContext,\n onResizeStartContext,\n type OnResize,\n type OnResizeEnd,\n type OnResizeStart,\n} from '../context'\n\nimport { calcResize } from './calc-resize'\nimport type { ResizableHandleProps } from './types'\n\n/**\n * @internal\n */\nexport function useResizableHandle(\n host: ConnectableElement,\n { state }: { state: SignalState<ResizableHandleProps> },\n): void {\n const onResize = onResizeContext.consume(host)\n const onResizeStart = onResizeStartContext.consume(host)\n const onResizeEnd = onResizeEndContext.consume(host)\n\n useResizableHandleState(host, state, { onResize, onResizeStart, onResizeEnd })\n}\n\nfunction useResizableHandleState(\n host: ConnectableElement,\n state: SignalState<ResizableHandleProps>,\n context: {\n onResizeStart: ReadonlySignal<OnResizeStart>\n onResize: ReadonlySignal<OnResize>\n onResizeEnd: ReadonlySignal<OnResizeEnd>\n },\n) {\n let startX = 0\n let startY = 0\n let width = 0\n let height = 0\n let aspectRatio = 1\n\n const pointerPressing = createSignal(false)\n\n const handlePointerDown = (event: PointerEvent) => {\n event.preventDefault()\n pointerPressing.set(true)\n\n startX = event.x\n startY = event.y\n\n const size = context.onResizeStart.get()?.()\n if (size) {\n ;[width, height, aspectRatio] = size\n }\n }\n\n const handlePointerMove = (event: PointerEvent) => {\n event.preventDefault()\n\n const dx = event.x - startX\n const dy = event.y - startY\n\n const [w, h] = calcResize(\n state.position.peek(),\n width,\n height,\n dx,\n dy,\n aspectRatio,\n )\n\n context.onResize.get()?.(w, h)\n }\n\n const handlePointerUp = (event: PointerEvent) => {\n event.preventDefault()\n pointerPressing.set(false)\n\n context.onResizeEnd.get()?.()\n }\n\n useEffect(host, () => {\n host.addEventListener('pointerdown', handlePointerDown)\n return () => {\n host.removeEventListener('pointerdown', handlePointerDown)\n }\n })\n\n useEffect(host, () => {\n if (!pointerPressing.get()) {\n return\n }\n\n const win = getWindow(host)\n\n win.addEventListener('pointermove', handlePointerMove)\n win.addEventListener('pointerup', handlePointerUp)\n return () => {\n win.removeEventListener('pointermove', handlePointerMove)\n win.removeEventListener('pointerup', handlePointerUp)\n }\n })\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\n\nexport interface ResizableHandleProps {\n /**\n * The position of the handle.\n *\n * @default \"bottom-right\"\n */\n position:\n | 'top'\n | 'right'\n | 'bottom'\n | 'left'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right'\n}\n\n/** @internal */\nexport const resizableHandleProps: PropDeclarations<ResizableHandleProps> = {\n position: { default: 'bottom-right' },\n}\n\n/** @internal */\nexport interface ResizableHandleEvents {}\n\n/** @internal */\nexport const resizableHandleEvents: EventDeclarations<ResizableHandleEvents> = {}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useResizableHandle } from \"./setup\"\nimport { resizableHandleEvents, resizableHandleProps, type ResizableHandleEvents, type ResizableHandleProps } from \"./types\"\n\nconst ResizableHandleElementBase: BaseElementConstructor<ResizableHandleProps> = defineCustomElement<\n ResizableHandleProps,\n ResizableHandleEvents\n>({\n props: resizableHandleProps,\n events: resizableHandleEvents,\n setup: useResizableHandle,\n})\nclass ResizableHandleElement extends ResizableHandleElementBase {}\n\nregisterCustomElement('prosekit-resizable-handle', ResizableHandleElement)\n \nexport { ResizableHandleElement }\n","import {\n createSignal,\n useAttribute,\n useEffect,\n type ConnectableElement,\n type SetupOptions,\n} from '@aria-ui/core'\n\nimport { isFinitePositiveNumber } from '../../../utils/is-finite-positive-number'\nimport {\n onResizeContext,\n onResizeEndContext,\n onResizeStartContext,\n type OnResize,\n type OnResizeEnd,\n type OnResizeStart,\n} from '../context'\n\nimport type {\n ResizableRootEvents,\n ResizableRootProps,\n} from './types'\n\n/**\n * @internal\n */\nexport function useResizableRoot(\n host: ConnectableElement,\n { state, emit }: SetupOptions<ResizableRootProps, ResizableRootEvents>,\n): void {\n const resizing = createSignal(false)\n\n const onResizeStart: OnResizeStart = () => {\n const { width, height } = host.getBoundingClientRect()\n\n let aspectRatio: number = state.aspectRatio.peek() ?? width / height\n\n if (!isFinitePositiveNumber(aspectRatio)) {\n aspectRatio = 0\n }\n\n emit('resizeStart', { width, height })\n resizing.set(true)\n return [width, height, aspectRatio]\n }\n\n const onResize: OnResize = (width, height) => {\n state.width.set(width)\n state.height.set(height)\n }\n\n const onResizeEnd: OnResizeEnd = () => {\n const { width, height } = host.getBoundingClientRect()\n emit('resizeEnd', { width, height })\n resizing.set(false)\n }\n\n onResizeStartContext.provide(host, createSignal(onResizeStart))\n onResizeContext.provide(host, createSignal(onResize))\n onResizeEndContext.provide(host, createSignal(onResizeEnd))\n\n useEffect(host, () => {\n updateResizableRootStyles(\n host,\n Math.max(state.width.get() || 0, 1),\n Math.max(state.height.get() || 0, 1),\n state.aspectRatio.get(),\n )\n })\n\n useAttribute(host, 'data-resizing', () => (resizing.get() ? '' : undefined))\n}\n\nfunction updateResizableRootStyles(\n host: ConnectableElement,\n width: number,\n height: number,\n aspectRatio: number | null,\n) {\n host.style.width = isFinitePositiveNumber(width) ? `${width}px` : ''\n\n host.style.height = isFinitePositiveNumber(height) ? `${height}px` : ''\n\n if (isFinitePositiveNumber(aspectRatio)) {\n host.style.aspectRatio = `${aspectRatio}`\n\n if (width && width > 0 && aspectRatio >= 1) {\n host.style.height = 'auto'\n } else if (height && height > 0 && aspectRatio <= 1) {\n host.style.width = 'min-content'\n }\n }\n}\n","import type {\n EventDeclarations,\n PropDeclarations,\n} from '@aria-ui/core'\n\nexport interface ResizableRootProps {\n width: number | null\n height: number | null\n aspectRatio: number | null\n}\n\n/** @internal */\nexport const resizableRootProps: PropDeclarations<ResizableRootProps> = {\n width: { default: null },\n height: { default: null },\n aspectRatio: { default: null },\n}\n\nexport interface ResizableRootEvents {\n resizeStart: CustomEvent<{ width: number; height: number }>\n resizeEnd: CustomEvent<{ width: number; height: number }>\n}\n\n/** @internal */\nexport const resizableRootEvents: EventDeclarations<ResizableRootEvents> = {\n resizeStart: {},\n resizeEnd: {},\n}\n","import { defineCustomElement, registerCustomElement, type BaseElementConstructor } from \"@aria-ui/core\"\n\nimport { useResizableRoot } from \"./setup\"\nimport { resizableRootEvents, resizableRootProps, type ResizableRootEvents, type ResizableRootProps } from \"./types\"\n\nconst ResizableRootElementBase: BaseElementConstructor<ResizableRootProps> = defineCustomElement<\n ResizableRootProps,\n ResizableRootEvents\n>({\n props: resizableRootProps,\n events: resizableRootEvents,\n setup: useResizableRoot,\n})\nclass ResizableRootElement extends ResizableRootElementBase {}\n\nregisterCustomElement('prosekit-resizable-root', ResizableRootElement)\n \nexport { ResizableRootElement }\n"],"mappings":";;;;;;;AAQA,MAAaA,kBAAqC,cAChD,+BACA,KACD;;;;AAKD,MAAaC,uBAA+C,cAC1D,oCACA,KACD;;;;AAKD,MAAaC,qBAA2C,cACtD,kCACA,KACD;;;;AC3BD,SAAgB,uBAAuB,OAAiC;AACtE,QAAO,OAAO,UAAU,YAAY,OAAO,SAAS,MAAM,IAAI,QAAQ;;;;;ACCxE,SAAgB,WACd,UASA,GACA,GACA,IACA,IACA,aACwB;AACxB,eAAc,cAAc,cAAc,IAAI;AAC9C,eAAc,uBAAuB,YAAY,GAAG,cAAc;AAElE,SAAQ,UAAR;EACE,KAAK,eACH,QAAO,MAAM,sBAAsB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAChE,KAAK,cACH,QAAO,MAAM,qBAAqB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC/D,KAAK,YACH,QAAO,MAAM,mBAAmB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC7D,KAAK,WACH,QAAO,MAAM,kBAAkB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC5D,KAAK,MACH,QAAO,MAAM,cAAc,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EACxD,KAAK,QACH,QAAO,MAAM,gBAAgB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC1D,KAAK,SACH,QAAO,MAAM,iBAAiB,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EAC3D,KAAK,OACH,QAAO,MAAM,eAAe,GAAG,GAAG,IAAI,IAAI,YAAY,CAAC;EACzD,QACE,OAAM,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AAG,KAAK,OAAW;;AAG9E,SAAS,0BACP,MACA,OACA,QACA,aACA;AACA,MAAK,MAAM,QAAQ,uBAAuB,MAAM,GAAG,GAAG,MAAM,MAAM;AAElE,MAAK,MAAM,SAAS,uBAAuB,OAAO,GAAG,GAAG,OAAO,MAAM;AAErE,KAAI,uBAAuB,YAAY,EAAE;AACvC,OAAK,MAAM,cAAc,GAAG;AAE5B,MAAI,SAAS,QAAQ,KAAK,eAAe,EACvC,MAAK,MAAM,SAAS;WACX,UAAU,SAAS,KAAK,eAAe,EAChD,MAAK,MAAM,QAAQ;;;;;;;AC7EzB,MAAaC,qBAA2D;CACtE,OAAO,EAAE,SAAS,MAAM;CACxB,QAAQ,EAAE,SAAS,MAAM;CACzB,aAAa,EAAE,SAAS,MAAM;CAC/B;;AAQD,MAAaC,sBAA8D;CACzE,aAAa,EAAE;CACf,WAAW,EAAE;CACd;;;;ACtBD,MAAMC,2BAAuE,oBAG3E;CACA,OAAO;CACP,QAAQ;CACR,OAAO;CACR,CAAC;AACF,IAAM,uBAAN,cAAmC,yBAAyB;AAE5D,sBAAsB,2BAA2B,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosekit-web-table-handle.d.ts","names":[],"sources":["../src/components/table-handle/table-handle-column-root/types.ts","../src/components/table-handle/table-handle-column-root/element.gen.ts","../src/components/table-handle/table-handle-column-root/setup.ts","../src/components/table-handle/table-handle-column-trigger/types.ts","../src/components/table-handle/table-handle-column-trigger/element.gen.ts","../src/components/table-handle/table-handle-column-trigger/setup.ts","../src/components/table-handle/table-handle-drag-preview/types.ts","../src/components/table-handle/table-handle-drag-preview/element.gen.ts","../src/components/table-handle/table-handle-drag-preview/setup.ts","../src/components/table-handle/table-handle-drop-indicator/types.ts","../src/components/table-handle/table-handle-drop-indicator/element.gen.ts","../src/components/table-handle/table-handle-drop-indicator/setup.ts","../src/components/table-handle/table-handle-popover-content/types.ts","../src/components/table-handle/table-handle-popover-content/element.gen.ts","../src/components/table-handle/table-handle-popover-content/setup.ts","../src/components/table-handle/table-handle-popover-item/types.ts","../src/components/table-handle/table-handle-popover-item/element.gen.ts","../src/components/table-handle/table-handle-popover-item/setup.ts","../src/components/table-handle/table-handle-root/types.ts","../src/components/table-handle/table-handle-root/element.gen.ts","../src/components/table-handle/table-handle-root/setup.ts","../src/components/table-handle/table-handle-row-root/types.ts","../src/components/table-handle/table-handle-row-root/element.gen.ts","../src/components/table-handle/table-handle-row-root/setup.ts","../src/components/table-handle/table-handle-row-trigger/types.ts","../src/components/table-handle/table-handle-row-trigger/element.gen.ts","../src/components/table-handle/table-handle-row-trigger/setup.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAaiB,0BAAA,SAAmC,KAAK;;;;;AAAzD;;
|
|
1
|
+
{"version":3,"file":"prosekit-web-table-handle.d.ts","names":[],"sources":["../src/components/table-handle/table-handle-column-root/types.ts","../src/components/table-handle/table-handle-column-root/element.gen.ts","../src/components/table-handle/table-handle-column-root/setup.ts","../src/components/table-handle/table-handle-column-trigger/types.ts","../src/components/table-handle/table-handle-column-trigger/element.gen.ts","../src/components/table-handle/table-handle-column-trigger/setup.ts","../src/components/table-handle/table-handle-drag-preview/types.ts","../src/components/table-handle/table-handle-drag-preview/element.gen.ts","../src/components/table-handle/table-handle-drag-preview/setup.ts","../src/components/table-handle/table-handle-drop-indicator/types.ts","../src/components/table-handle/table-handle-drop-indicator/element.gen.ts","../src/components/table-handle/table-handle-drop-indicator/setup.ts","../src/components/table-handle/table-handle-popover-content/types.ts","../src/components/table-handle/table-handle-popover-content/element.gen.ts","../src/components/table-handle/table-handle-popover-content/setup.ts","../src/components/table-handle/table-handle-popover-item/types.ts","../src/components/table-handle/table-handle-popover-item/element.gen.ts","../src/components/table-handle/table-handle-popover-item/setup.ts","../src/components/table-handle/table-handle-root/types.ts","../src/components/table-handle/table-handle-root/element.gen.ts","../src/components/table-handle/table-handle-root/setup.ts","../src/components/table-handle/table-handle-row-root/types.ts","../src/components/table-handle/table-handle-row-root/element.gen.ts","../src/components/table-handle/table-handle-row-root/setup.ts","../src/components/table-handle/table-handle-row-trigger/types.ts","../src/components/table-handle/table-handle-row-trigger/element.gen.ts","../src/components/table-handle/table-handle-row-trigger/setup.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAaiB,0BAAA,SAAmC,KAAK;;;;;AAAzD;;EAOU,MAAA,EAAA,MAAA,GAAA,IAAA;EAOG;;;AA8Bb;AAeA;EAGa,SAAA,EAhDA,SAgDA;;;;ACxEuI;AAEtF;;;;ACoB9D;;;EAEkC,IAAA,EAAA,OAAA;EAAZ;;;;;ECpBjB;AAEL;AAKA;AAKA;EAGa,IAAA,EAAA,OAAA;;;cHmCA,4BAA4B,iBAAiB;AItDsG;AAU1J,UJ2DW,2BAAA,SAAoC,uBI3DP,CAAA;;cJ8DjC,6BAA6B,kBAAkB;;;cCtEtD,kCAAkC,uBAAuB;cAQzD,4BAAA,SAAqC,gCAAA;;;;;;iBCY3B,wBAAA,OACR;;;SACc,YAAY;;;;KCpB7B,wBAAA,GAAyB,kBAAkB;UAE/B,6BAAA;UACP,OAAO;;;cAIJ,+BAA+B,iBAAiB;AHD7D;AAAyD,UGMxC,8BAAA,CHNwC;;AAAL,cGSvC,8BHTuC,EGSP,iBHTO,CGSW,8BHTX,CAAA;;;cIR9C,qCAAqC,uBAAuB;cAQ5D,+BAAA,SAAwC,mCAAA;;;;;;iBCU9B,2BAAA,OACR;;GACK,aAAa,+BAA+B;;;UCnBxC,2BAAA;UACP;;cAGG,6BAA6B,iBAAiB;UAI1C,4BAAA;cAEJ,8BAA8B,kBAAkB;;;cCXvD,mCAAmC,uBAAuB;cAQ1D,6BAAA,SAAsC,iCAAA;;;;;;iBCS5B,yBAAA,OAAgC;;;SAAwC,YAAY;;;;UCfnF,6BAAA;UACP,OAAO;;cAGJ,+BAA+B,iBAAiB;UAI5C,8BAAA;ATFA,cSIJ,8BTJ+B,ESIC,iBTJD,CSImB,8BTJnB,CAAA;;;cURt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C,IAAA,EAAA,OAAA;EAAZ;;;;;ECpBjB;AAEL;AAKA;AAKA;EAGa,IAAA,EAAA,OAAA;;;ckBkCA,yBAAyB,iBAAiB;AjBrDyG;AAU1J,UiB0DW,wBAAA,SAAiC,uBjB1DJ,CAAA;;ciB6DjC,0BAA0B,kBAAkB;;;cCrEnD,+BAA+B,uBAAuB;cAQtD,yBAAA,SAAkC,6BAAA;;;;;;iBCgBxB,qBAAA,OACR;;GACK,aAAa,yBAAyB;;;KCxB9C,wBAAA,GAAyB,kBAAkB;UAE/B,0BAAA;UACP,OAAO;;;cAIJ,4BAA4B,iBAAiB;AxBDzC,UwBKA,2BAAA,CxBL2B;EAAa,MAAA,EwBM/C,WxBN+C,CAAA,IAAA,CAAA;;;AAAL,cwBUvC,2BxBVuC,EwBUV,iBxBVU,CwBUQ,2BxBVR,CAAA;;;cyBR9C,kCAAkC,uBAAuB;cAQzD,4BAAA,SAAqC,gCAAA;;;;;;iBCU3B,wBAAA,OACR;;GACK,aAAa,4BAA4B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getStateWithDefaults } from "./get-default-state-
|
|
2
|
-
import { useEditorExtension } from "./use-editor-extension-
|
|
3
|
-
import { getSafeEditorView } from "./get-safe-editor-view-
|
|
4
|
-
import { assignStyles, useScrolling } from "./use-scrolling-
|
|
5
|
-
import { cloneElement, deepCloneElement, injectStyle } from "./inject-style-
|
|
1
|
+
import { t as getStateWithDefaults } from "./get-default-state-Bqluw34o.js";
|
|
2
|
+
import { t as useEditorExtension } from "./use-editor-extension-B_5BbYvf.js";
|
|
3
|
+
import { t as getSafeEditorView } from "./get-safe-editor-view-DJlcheeV.js";
|
|
4
|
+
import { n as assignStyles, t as useScrolling } from "./use-scrolling-BjI3cuLt.js";
|
|
5
|
+
import { n as cloneElement, r as deepCloneElement, t as injectStyle } from "./inject-style-DYQXx-cE.js";
|
|
6
6
|
import { createComputed, createContext, createSignal, defineCustomElement, defineEmit, registerCustomElement, useAttribute, useEffect, useEventListener } from "@aria-ui/core";
|
|
7
7
|
import { defineDOMEventHandler, union } from "@prosekit/core";
|
|
8
8
|
import { useOverlayPositionerState } from "@aria-ui/overlay/elements";
|
|
@@ -64,9 +64,8 @@ function useTableHandleColumnRoot(host, { state }) {
|
|
|
64
64
|
const presence = createComputed(() => !!referenceCell.get());
|
|
65
65
|
useAttribute(host, "data-state", () => presence.get() ? "open" : "closed");
|
|
66
66
|
usePresence(host, presence);
|
|
67
|
-
const menuRootState = getStateWithDefaults({ open: contentOpen }, menuRootProps);
|
|
68
67
|
useMenuRoot(host, {
|
|
69
|
-
state:
|
|
68
|
+
state: getStateWithDefaults({ open: contentOpen }, menuRootProps),
|
|
70
69
|
emit: () => void 0
|
|
71
70
|
});
|
|
72
71
|
}
|
|
@@ -278,8 +277,7 @@ const isColorMixSupported = once(() => {
|
|
|
278
277
|
function fadeColor(color, opacity) {
|
|
279
278
|
if (isColorMixSupported()) {
|
|
280
279
|
const transparentWeight = (1 - opacity) * 100;
|
|
281
|
-
|
|
282
|
-
return `color-mix(in srgb, ${color} ${colorWeight}%, transparent ${transparentWeight}%)`;
|
|
280
|
+
return `color-mix(in srgb, ${color} ${opacity * 100}%, transparent ${transparentWeight}%)`;
|
|
283
281
|
}
|
|
284
282
|
}
|
|
285
283
|
|
|
@@ -475,12 +473,10 @@ function findDragOverElement(elements, pointer, axis) {
|
|
|
475
473
|
function getDragOverColumn(table, pointerX) {
|
|
476
474
|
const firstRow = table.querySelector("tr");
|
|
477
475
|
if (!firstRow) return;
|
|
478
|
-
|
|
479
|
-
return findDragOverElement(cells, pointerX, "x");
|
|
476
|
+
return findDragOverElement(Array.from(firstRow.children), pointerX, "x");
|
|
480
477
|
}
|
|
481
478
|
function getDragOverRow(table, pointerY) {
|
|
482
|
-
|
|
483
|
-
return findDragOverElement(rows, pointerY, "y");
|
|
479
|
+
return findDragOverElement(Array.from(table.querySelectorAll("tr")), pointerY, "y");
|
|
484
480
|
}
|
|
485
481
|
|
|
486
482
|
//#endregion
|
|
@@ -610,15 +606,13 @@ registerCustomElement("prosekit-table-handle-drop-indicator", TableHandleDropInd
|
|
|
610
606
|
*/
|
|
611
607
|
function useTableHandlePopoverContent(host, { state, emit }) {
|
|
612
608
|
const rootContext = tableHandleRootContext.consume(host);
|
|
613
|
-
const
|
|
614
|
-
const keyDownTarget = useKeyDownTarget(host, open);
|
|
615
|
-
const menuContentState = getStateWithDefaults({
|
|
616
|
-
placement: state.placement,
|
|
617
|
-
offset: state.offset,
|
|
618
|
-
eventTarget: createSignal(keyDownTarget)
|
|
619
|
-
}, menuContentProps);
|
|
609
|
+
const keyDownTarget = useKeyDownTarget(host, createComputed(() => !!rootContext.get()));
|
|
620
610
|
useMenuContent(host, {
|
|
621
|
-
state:
|
|
611
|
+
state: getStateWithDefaults({
|
|
612
|
+
placement: state.placement,
|
|
613
|
+
offset: state.offset,
|
|
614
|
+
eventTarget: createSignal(keyDownTarget)
|
|
615
|
+
}, menuContentProps),
|
|
622
616
|
emit
|
|
623
617
|
});
|
|
624
618
|
}
|
|
@@ -711,8 +705,7 @@ function useEditorTyping(host, editor) {
|
|
|
711
705
|
const handlePointerMove = () => {
|
|
712
706
|
typing.set(false);
|
|
713
707
|
};
|
|
714
|
-
|
|
715
|
-
useEditorExtension(host, editor, extension);
|
|
708
|
+
useEditorExtension(host, editor, union(defineDOMEventHandler("keypress", handleKeypress), defineDOMEventHandler("pointermove", handlePointerMove)));
|
|
716
709
|
return typing;
|
|
717
710
|
}
|
|
718
711
|
|
|
@@ -861,8 +854,7 @@ function getHoveringCell(view, event) {
|
|
|
861
854
|
}
|
|
862
855
|
function getCellPos(map, tableStart, rowIndex, colIndex) {
|
|
863
856
|
const cellIndex = getCellIndex(map, rowIndex, colIndex);
|
|
864
|
-
|
|
865
|
-
return tableStart + posInTable;
|
|
857
|
+
return tableStart + map.map[cellIndex];
|
|
866
858
|
}
|
|
867
859
|
function getCellIndex(map, rowIndex, colIndex) {
|
|
868
860
|
return map.width * rowIndex + colIndex;
|
|
@@ -879,8 +871,7 @@ function useTableHandleRoot(host, { state }) {
|
|
|
879
871
|
const dndContext = createSignal(defaultTableHandleDndContext);
|
|
880
872
|
const hoveringCell = useHoveringCell(host, editor);
|
|
881
873
|
const typing = useEditorTyping(host, editor);
|
|
882
|
-
const
|
|
883
|
-
const selecting = useSelecting(host, editor, isInTable);
|
|
874
|
+
const selecting = useSelecting(host, editor, createComputed(() => !!hoveringCell.get()));
|
|
884
875
|
const scrolling = useScrolling(host);
|
|
885
876
|
const canShow = createComputed(() => {
|
|
886
877
|
return !typing.get() && !selecting.get() && !scrolling.get();
|
|
@@ -894,17 +885,14 @@ function useTableHandleRoot(host, { state }) {
|
|
|
894
885
|
}
|
|
895
886
|
function useHoveringCell(host, editor) {
|
|
896
887
|
const hoveringCell = createSignal(null);
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
});
|
|
901
|
-
useEditorExtension(host, editor, extension);
|
|
888
|
+
useEditorExtension(host, editor, defineCellHoverHandler((curr) => {
|
|
889
|
+
if (!isHoveringCellInfoEqual(hoveringCell.peek(), curr)) hoveringCell.set(curr);
|
|
890
|
+
}));
|
|
902
891
|
return hoveringCell;
|
|
903
892
|
}
|
|
904
893
|
function defineCellHoverHandler(handler) {
|
|
905
894
|
const pointerHandler = (view, event) => {
|
|
906
|
-
|
|
907
|
-
return handler(hoveringCell ?? null);
|
|
895
|
+
return handler(getHoveringCell(view, event) ?? null);
|
|
908
896
|
};
|
|
909
897
|
return defineDOMEventHandler("pointerover", pointerHandler);
|
|
910
898
|
}
|
|
@@ -952,9 +940,8 @@ function useTableHandleRowRoot(host, { state }) {
|
|
|
952
940
|
const presence = createComputed(() => !!referenceCell.get());
|
|
953
941
|
useAttribute(host, "data-state", () => presence.get() ? "open" : "closed");
|
|
954
942
|
usePresence(host, presence);
|
|
955
|
-
const menuRootState = getStateWithDefaults({ open: contentOpen }, menuRootProps);
|
|
956
943
|
useMenuRoot(host, {
|
|
957
|
-
state:
|
|
944
|
+
state: getStateWithDefaults({ open: contentOpen }, menuRootProps),
|
|
958
945
|
emit: defineEmit(host, menuRootEvents)
|
|
959
946
|
});
|
|
960
947
|
}
|