@embedpdf/plugin-selection 2.15.0 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +192 -21
- package/dist/index.cjs +575 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +167 -0
- package/dist/index.d.ts +167 -1
- package/dist/index.js +549 -1508
- package/dist/index.js.map +1 -1
- package/package.json +21 -62
- package/dist/lib/actions.d.ts +0 -103
- package/dist/lib/handlers/index.d.ts +0 -2
- package/dist/lib/handlers/marquee-selection.handler.d.ts +0 -30
- package/dist/lib/handlers/text-selection.handler.d.ts +0 -52
- package/dist/lib/index.d.ts +0 -9
- package/dist/lib/manifest.d.ts +0 -4
- package/dist/lib/reducer.d.ts +0 -5
- package/dist/lib/selection-plugin.d.ts +0 -121
- package/dist/lib/selectors.d.ts +0 -14
- package/dist/lib/types.d.ts +0 -268
- package/dist/lib/utils.d.ts +0 -108
- package/dist/preact/adapter.d.ts +0 -4
- package/dist/preact/core.d.ts +0 -1
- package/dist/preact/index.cjs +0 -2
- package/dist/preact/index.cjs.map +0 -1
- package/dist/preact/index.d.ts +0 -1
- package/dist/preact/index.js +0 -218
- package/dist/preact/index.js.map +0 -1
- package/dist/preact/interaction-manager.d.ts +0 -1
- package/dist/preact/utils.d.ts +0 -1
- package/dist/react/adapter.d.ts +0 -2
- package/dist/react/core.d.ts +0 -1
- package/dist/react/index.cjs +0 -2
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.js +0 -217
- package/dist/react/index.js.map +0 -1
- package/dist/react/interaction-manager.d.ts +0 -1
- package/dist/react/utils.d.ts +0 -1
- package/dist/shared/components/copy-to-clipboard.d.ts +0 -1
- package/dist/shared/components/index.d.ts +0 -4
- package/dist/shared/components/marquee-selection.d.ts +0 -36
- package/dist/shared/components/selection-layer.d.ts +0 -29
- package/dist/shared/components/text-selection.d.ts +0 -21
- package/dist/shared/hooks/index.d.ts +0 -1
- package/dist/shared/hooks/use-selection.d.ts +0 -11
- package/dist/shared/index.d.ts +0 -5
- package/dist/shared/types.d.ts +0 -7
- package/dist/shared-preact/components/copy-to-clipboard.d.ts +0 -1
- package/dist/shared-preact/components/index.d.ts +0 -4
- package/dist/shared-preact/components/marquee-selection.d.ts +0 -36
- package/dist/shared-preact/components/selection-layer.d.ts +0 -29
- package/dist/shared-preact/components/text-selection.d.ts +0 -21
- package/dist/shared-preact/hooks/index.d.ts +0 -1
- package/dist/shared-preact/hooks/use-selection.d.ts +0 -11
- package/dist/shared-preact/index.d.ts +0 -5
- package/dist/shared-preact/types.d.ts +0 -7
- package/dist/shared-react/components/copy-to-clipboard.d.ts +0 -1
- package/dist/shared-react/components/index.d.ts +0 -4
- package/dist/shared-react/components/marquee-selection.d.ts +0 -36
- package/dist/shared-react/components/selection-layer.d.ts +0 -29
- package/dist/shared-react/components/text-selection.d.ts +0 -21
- package/dist/shared-react/hooks/index.d.ts +0 -1
- package/dist/shared-react/hooks/use-selection.d.ts +0 -11
- package/dist/shared-react/index.d.ts +0 -5
- package/dist/shared-react/types.d.ts +0 -7
- package/dist/svelte/components/CopyToClipboard.svelte.d.ts +0 -3
- package/dist/svelte/components/MarqueeSelection.svelte.d.ts +0 -27
- package/dist/svelte/components/SelectionLayer.svelte.d.ts +0 -32
- package/dist/svelte/components/TextSelection.svelte.d.ts +0 -22
- package/dist/svelte/components/index.d.ts +0 -4
- package/dist/svelte/hooks/index.d.ts +0 -1
- package/dist/svelte/hooks/use-selection.svelte.d.ts +0 -19
- package/dist/svelte/index.cjs +0 -2
- package/dist/svelte/index.cjs.map +0 -1
- package/dist/svelte/index.d.ts +0 -5
- package/dist/svelte/index.js +0 -359
- package/dist/svelte/index.js.map +0 -1
- package/dist/svelte/types.d.ts +0 -7
- package/dist/vue/components/copy-to-clipboard.vue.d.ts +0 -3
- package/dist/vue/components/index.d.ts +0 -4
- package/dist/vue/components/marquee-selection.vue.d.ts +0 -29
- package/dist/vue/components/selection-layer.vue.d.ts +0 -60
- package/dist/vue/components/text-selection.vue.d.ts +0 -51
- package/dist/vue/hooks/index.d.ts +0 -1
- package/dist/vue/hooks/use-selection.d.ts +0 -11
- package/dist/vue/index.cjs +0 -2
- package/dist/vue/index.cjs.map +0 -1
- package/dist/vue/index.d.ts +0 -5
- package/dist/vue/index.js +0 -311
- package/dist/vue/index.js.map +0 -1
- package/dist/vue/types.d.ts +0 -7
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
interface MarqueeSelectionProps {
|
|
2
|
-
/** Document ID */
|
|
3
|
-
documentId: string;
|
|
4
|
-
/** Index of the page this layer lives on */
|
|
5
|
-
pageIndex: number;
|
|
6
|
-
/** Scale of the page (optional, defaults to document scale) */
|
|
7
|
-
scale?: number;
|
|
8
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
9
|
-
className?: string;
|
|
10
|
-
/** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */
|
|
11
|
-
background?: string;
|
|
12
|
-
/** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */
|
|
13
|
-
borderColor?: string;
|
|
14
|
-
/** Border style. Default: 'dashed' */
|
|
15
|
-
borderStyle?: 'solid' | 'dashed' | 'dotted';
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `borderColor` instead.
|
|
18
|
-
*/
|
|
19
|
-
stroke?: string;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `background` instead.
|
|
22
|
-
*/
|
|
23
|
-
fill?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* MarqueeSelection renders a selection rectangle when the user drags to select items.
|
|
27
|
-
* It registers the marquee handler on the page.
|
|
28
|
-
*
|
|
29
|
-
* Other plugins (e.g., annotation, form, redaction) can subscribe to `onMarqueeEnd` to
|
|
30
|
-
* determine which objects intersect with the marquee rect.
|
|
31
|
-
*
|
|
32
|
-
* Use this component directly for advanced cases, or use `SelectionLayer`
|
|
33
|
-
* which composes both `TextSelection` and `MarqueeSelection`.
|
|
34
|
-
*/
|
|
35
|
-
export declare const MarqueeSelection: ({ documentId, pageIndex, scale, className, background, borderColor, borderStyle, stroke, fill, }: MarqueeSelectionProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
36
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Rotation } from '@embedpdf/models';
|
|
2
|
-
import { TextSelectionStyle, MarqueeSelectionStyle } from '../../index.ts';
|
|
3
|
-
import { SelectionSelectionMenuRenderFn } from '../types';
|
|
4
|
-
type Props = {
|
|
5
|
-
documentId: string;
|
|
6
|
-
pageIndex: number;
|
|
7
|
-
scale?: number;
|
|
8
|
-
rotation?: Rotation;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use `textStyle.background` instead.
|
|
11
|
-
*/
|
|
12
|
-
background?: string;
|
|
13
|
-
/** Styling options for text selection highlights */
|
|
14
|
-
textStyle?: TextSelectionStyle;
|
|
15
|
-
/** Styling options for the marquee selection rectangle */
|
|
16
|
-
marqueeStyle?: MarqueeSelectionStyle;
|
|
17
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
18
|
-
marqueeClassName?: string;
|
|
19
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* SelectionLayer is a convenience component that composes both text selection
|
|
23
|
-
* and marquee selection on a single page.
|
|
24
|
-
*
|
|
25
|
-
* For advanced use cases, you can use `TextSelection` and `MarqueeSelection`
|
|
26
|
-
* individually.
|
|
27
|
-
*/
|
|
28
|
-
export declare function SelectionLayer({ documentId, pageIndex, scale, rotation, background, textStyle, marqueeStyle, marqueeClassName, selectionMenu, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Rotation } from '@embedpdf/models';
|
|
2
|
-
import { SelectionSelectionMenuRenderFn } from '../types';
|
|
3
|
-
type TextSelectionProps = {
|
|
4
|
-
documentId: string;
|
|
5
|
-
pageIndex: number;
|
|
6
|
-
scale?: number;
|
|
7
|
-
rotation?: Rotation;
|
|
8
|
-
/** Background color for text selection highlights. Default: 'rgba(33,150,243)' */
|
|
9
|
-
background?: string;
|
|
10
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* TextSelection renders text selection highlight rects and the selection menu.
|
|
14
|
-
* It registers the text selection handler on the page and subscribes to menu
|
|
15
|
-
* placement changes.
|
|
16
|
-
*
|
|
17
|
-
* Use this component directly for advanced cases, or use `SelectionLayer`
|
|
18
|
-
* which composes both `TextSelection` and `MarqueeSelection`.
|
|
19
|
-
*/
|
|
20
|
-
export declare function TextSelection({ documentId, pageIndex, scale: scaleOverride, rotation: rotationOverride, background, selectionMenu, }: TextSelectionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-selection';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SelectionPlugin } from '../../index.ts';
|
|
2
|
-
export declare const useSelectionCapability: () => {
|
|
3
|
-
provides: Readonly<import('../../index.ts').SelectionCapability> | null;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
ready: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const useSelectionPlugin: () => {
|
|
8
|
-
plugin: SelectionPlugin | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
package/dist/shared/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
|
-
export * from './components';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export * from '../index.ts';
|
|
5
|
-
export declare const SelectionPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../index.ts').SelectionPlugin, import('../index.ts').SelectionPluginConfig, import('../index.ts').SelectionState, import('../lib/actions').SelectionAction>>;
|
package/dist/shared/types.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SelectionMenuRenderFn, SelectionMenuPropsBase } from '../react/utils.ts';
|
|
2
|
-
export interface SelectionSelectionContext {
|
|
3
|
-
type: 'selection';
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
}
|
|
6
|
-
export type SelectionSelectionMenuRenderFn = SelectionMenuRenderFn<SelectionSelectionContext>;
|
|
7
|
-
export type SelectionSelectionMenuProps = SelectionMenuPropsBase<SelectionSelectionContext>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function CopyToClipboard(): null;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
interface MarqueeSelectionProps {
|
|
2
|
-
/** Document ID */
|
|
3
|
-
documentId: string;
|
|
4
|
-
/** Index of the page this layer lives on */
|
|
5
|
-
pageIndex: number;
|
|
6
|
-
/** Scale of the page (optional, defaults to document scale) */
|
|
7
|
-
scale?: number;
|
|
8
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
9
|
-
className?: string;
|
|
10
|
-
/** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */
|
|
11
|
-
background?: string;
|
|
12
|
-
/** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */
|
|
13
|
-
borderColor?: string;
|
|
14
|
-
/** Border style. Default: 'dashed' */
|
|
15
|
-
borderStyle?: 'solid' | 'dashed' | 'dotted';
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `borderColor` instead.
|
|
18
|
-
*/
|
|
19
|
-
stroke?: string;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `background` instead.
|
|
22
|
-
*/
|
|
23
|
-
fill?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* MarqueeSelection renders a selection rectangle when the user drags to select items.
|
|
27
|
-
* It registers the marquee handler on the page.
|
|
28
|
-
*
|
|
29
|
-
* Other plugins (e.g., annotation, form, redaction) can subscribe to `onMarqueeEnd` to
|
|
30
|
-
* determine which objects intersect with the marquee rect.
|
|
31
|
-
*
|
|
32
|
-
* Use this component directly for advanced cases, or use `SelectionLayer`
|
|
33
|
-
* which composes both `TextSelection` and `MarqueeSelection`.
|
|
34
|
-
*/
|
|
35
|
-
export declare const MarqueeSelection: ({ documentId, pageIndex, scale, className, background, borderColor, borderStyle, stroke, fill, }: MarqueeSelectionProps) => import("preact").JSX.Element | null;
|
|
36
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Rotation } from '@embedpdf/models';
|
|
2
|
-
import { TextSelectionStyle, MarqueeSelectionStyle } from '../../lib/index.ts';
|
|
3
|
-
import { SelectionSelectionMenuRenderFn } from '../types';
|
|
4
|
-
type Props = {
|
|
5
|
-
documentId: string;
|
|
6
|
-
pageIndex: number;
|
|
7
|
-
scale?: number;
|
|
8
|
-
rotation?: Rotation;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use `textStyle.background` instead.
|
|
11
|
-
*/
|
|
12
|
-
background?: string;
|
|
13
|
-
/** Styling options for text selection highlights */
|
|
14
|
-
textStyle?: TextSelectionStyle;
|
|
15
|
-
/** Styling options for the marquee selection rectangle */
|
|
16
|
-
marqueeStyle?: MarqueeSelectionStyle;
|
|
17
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
18
|
-
marqueeClassName?: string;
|
|
19
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* SelectionLayer is a convenience component that composes both text selection
|
|
23
|
-
* and marquee selection on a single page.
|
|
24
|
-
*
|
|
25
|
-
* For advanced use cases, you can use `TextSelection` and `MarqueeSelection`
|
|
26
|
-
* individually.
|
|
27
|
-
*/
|
|
28
|
-
export declare function SelectionLayer({ documentId, pageIndex, scale, rotation, background, textStyle, marqueeStyle, marqueeClassName, selectionMenu, }: Props): import("preact").JSX.Element;
|
|
29
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Rotation } from '@embedpdf/models';
|
|
2
|
-
import { SelectionSelectionMenuRenderFn } from '../types';
|
|
3
|
-
type TextSelectionProps = {
|
|
4
|
-
documentId: string;
|
|
5
|
-
pageIndex: number;
|
|
6
|
-
scale?: number;
|
|
7
|
-
rotation?: Rotation;
|
|
8
|
-
/** Background color for text selection highlights. Default: 'rgba(33,150,243)' */
|
|
9
|
-
background?: string;
|
|
10
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* TextSelection renders text selection highlight rects and the selection menu.
|
|
14
|
-
* It registers the text selection handler on the page and subscribes to menu
|
|
15
|
-
* placement changes.
|
|
16
|
-
*
|
|
17
|
-
* Use this component directly for advanced cases, or use `SelectionLayer`
|
|
18
|
-
* which composes both `TextSelection` and `MarqueeSelection`.
|
|
19
|
-
*/
|
|
20
|
-
export declare function TextSelection({ documentId, pageIndex, scale: scaleOverride, rotation: rotationOverride, background, selectionMenu, }: TextSelectionProps): import("preact").JSX.Element | null;
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-selection';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SelectionPlugin } from '../../lib/index.ts';
|
|
2
|
-
export declare const useSelectionCapability: () => {
|
|
3
|
-
provides: Readonly<import('../../lib/index.ts').SelectionCapability> | null;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
ready: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const useSelectionPlugin: () => {
|
|
8
|
-
plugin: SelectionPlugin | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
|
-
export * from './components';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export * from '../lib/index.ts';
|
|
5
|
-
export declare const SelectionPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').SelectionPlugin, import('../lib/index.ts').SelectionPluginConfig, import('../lib/index.ts').SelectionState, import('../lib/actions').SelectionAction>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SelectionMenuRenderFn, SelectionMenuPropsBase } from '../preact/utils.ts';
|
|
2
|
-
export interface SelectionSelectionContext {
|
|
3
|
-
type: 'selection';
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
}
|
|
6
|
-
export type SelectionSelectionMenuRenderFn = SelectionMenuRenderFn<SelectionSelectionContext>;
|
|
7
|
-
export type SelectionSelectionMenuProps = SelectionMenuPropsBase<SelectionSelectionContext>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function CopyToClipboard(): null;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
interface MarqueeSelectionProps {
|
|
2
|
-
/** Document ID */
|
|
3
|
-
documentId: string;
|
|
4
|
-
/** Index of the page this layer lives on */
|
|
5
|
-
pageIndex: number;
|
|
6
|
-
/** Scale of the page (optional, defaults to document scale) */
|
|
7
|
-
scale?: number;
|
|
8
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
9
|
-
className?: string;
|
|
10
|
-
/** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */
|
|
11
|
-
background?: string;
|
|
12
|
-
/** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */
|
|
13
|
-
borderColor?: string;
|
|
14
|
-
/** Border style. Default: 'dashed' */
|
|
15
|
-
borderStyle?: 'solid' | 'dashed' | 'dotted';
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `borderColor` instead.
|
|
18
|
-
*/
|
|
19
|
-
stroke?: string;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `background` instead.
|
|
22
|
-
*/
|
|
23
|
-
fill?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* MarqueeSelection renders a selection rectangle when the user drags to select items.
|
|
27
|
-
* It registers the marquee handler on the page.
|
|
28
|
-
*
|
|
29
|
-
* Other plugins (e.g., annotation, form, redaction) can subscribe to `onMarqueeEnd` to
|
|
30
|
-
* determine which objects intersect with the marquee rect.
|
|
31
|
-
*
|
|
32
|
-
* Use this component directly for advanced cases, or use `SelectionLayer`
|
|
33
|
-
* which composes both `TextSelection` and `MarqueeSelection`.
|
|
34
|
-
*/
|
|
35
|
-
export declare const MarqueeSelection: ({ documentId, pageIndex, scale, className, background, borderColor, borderStyle, stroke, fill, }: MarqueeSelectionProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
36
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Rotation } from '@embedpdf/models';
|
|
2
|
-
import { TextSelectionStyle, MarqueeSelectionStyle } from '../../lib/index.ts';
|
|
3
|
-
import { SelectionSelectionMenuRenderFn } from '../types';
|
|
4
|
-
type Props = {
|
|
5
|
-
documentId: string;
|
|
6
|
-
pageIndex: number;
|
|
7
|
-
scale?: number;
|
|
8
|
-
rotation?: Rotation;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use `textStyle.background` instead.
|
|
11
|
-
*/
|
|
12
|
-
background?: string;
|
|
13
|
-
/** Styling options for text selection highlights */
|
|
14
|
-
textStyle?: TextSelectionStyle;
|
|
15
|
-
/** Styling options for the marquee selection rectangle */
|
|
16
|
-
marqueeStyle?: MarqueeSelectionStyle;
|
|
17
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
18
|
-
marqueeClassName?: string;
|
|
19
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* SelectionLayer is a convenience component that composes both text selection
|
|
23
|
-
* and marquee selection on a single page.
|
|
24
|
-
*
|
|
25
|
-
* For advanced use cases, you can use `TextSelection` and `MarqueeSelection`
|
|
26
|
-
* individually.
|
|
27
|
-
*/
|
|
28
|
-
export declare function SelectionLayer({ documentId, pageIndex, scale, rotation, background, textStyle, marqueeStyle, marqueeClassName, selectionMenu, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Rotation } from '@embedpdf/models';
|
|
2
|
-
import { SelectionSelectionMenuRenderFn } from '../types';
|
|
3
|
-
type TextSelectionProps = {
|
|
4
|
-
documentId: string;
|
|
5
|
-
pageIndex: number;
|
|
6
|
-
scale?: number;
|
|
7
|
-
rotation?: Rotation;
|
|
8
|
-
/** Background color for text selection highlights. Default: 'rgba(33,150,243)' */
|
|
9
|
-
background?: string;
|
|
10
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* TextSelection renders text selection highlight rects and the selection menu.
|
|
14
|
-
* It registers the text selection handler on the page and subscribes to menu
|
|
15
|
-
* placement changes.
|
|
16
|
-
*
|
|
17
|
-
* Use this component directly for advanced cases, or use `SelectionLayer`
|
|
18
|
-
* which composes both `TextSelection` and `MarqueeSelection`.
|
|
19
|
-
*/
|
|
20
|
-
export declare function TextSelection({ documentId, pageIndex, scale: scaleOverride, rotation: rotationOverride, background, selectionMenu, }: TextSelectionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-selection';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SelectionPlugin } from '../../lib/index.ts';
|
|
2
|
-
export declare const useSelectionCapability: () => {
|
|
3
|
-
provides: Readonly<import('../../lib/index.ts').SelectionCapability> | null;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
ready: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const useSelectionPlugin: () => {
|
|
8
|
-
plugin: SelectionPlugin | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
|
-
export * from './components';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export * from '../lib/index.ts';
|
|
5
|
-
export declare const SelectionPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').SelectionPlugin, import('../lib/index.ts').SelectionPluginConfig, import('../lib/index.ts').SelectionState, import('../lib/actions').SelectionAction>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SelectionMenuRenderFn, SelectionMenuPropsBase } from '../react/utils.ts';
|
|
2
|
-
export interface SelectionSelectionContext {
|
|
3
|
-
type: 'selection';
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
}
|
|
6
|
-
export type SelectionSelectionMenuRenderFn = SelectionMenuRenderFn<SelectionSelectionContext>;
|
|
7
|
-
export type SelectionSelectionMenuProps = SelectionMenuPropsBase<SelectionSelectionContext>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
interface MarqueeSelectionProps {
|
|
2
|
-
/** The ID of the document */
|
|
3
|
-
documentId: string;
|
|
4
|
-
/** Index of the page this layer lives on */
|
|
5
|
-
pageIndex: number;
|
|
6
|
-
/** Scale of the page (optional, defaults to document scale) */
|
|
7
|
-
scale?: number;
|
|
8
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
9
|
-
class?: string;
|
|
10
|
-
/** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */
|
|
11
|
-
background?: string;
|
|
12
|
-
/** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */
|
|
13
|
-
borderColor?: string;
|
|
14
|
-
/** Border style. Default: 'dashed' */
|
|
15
|
-
borderStyle?: 'solid' | 'dashed' | 'dotted';
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `borderColor` instead.
|
|
18
|
-
*/
|
|
19
|
-
stroke?: string;
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated Use `background` instead.
|
|
22
|
-
*/
|
|
23
|
-
fill?: string;
|
|
24
|
-
}
|
|
25
|
-
declare const MarqueeSelection: import('svelte', { with: { "resolution-mode": "import" } }).Component<MarqueeSelectionProps, {}, "">;
|
|
26
|
-
type MarqueeSelection = ReturnType<typeof MarqueeSelection>;
|
|
27
|
-
export default MarqueeSelection;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Snippet } from 'svelte';
|
|
2
|
-
import { Rotation } from '@embedpdf/models';
|
|
3
|
-
import { TextSelectionStyle, MarqueeSelectionStyle } from '../../lib/index.ts';
|
|
4
|
-
import { SelectionSelectionMenuRenderFn, SelectionSelectionMenuProps } from '../types';
|
|
5
|
-
interface SelectionLayerProps {
|
|
6
|
-
/** Document ID */
|
|
7
|
-
documentId: string;
|
|
8
|
-
/** Index of the page this layer lives on */
|
|
9
|
-
pageIndex: number;
|
|
10
|
-
/** Scale of the page (optional, defaults to document scale) */
|
|
11
|
-
scale?: number;
|
|
12
|
-
/** Rotation of the page (optional, defaults to document rotation) */
|
|
13
|
-
rotation?: Rotation;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use `textStyle.background` instead.
|
|
16
|
-
* Background color for selection rectangles.
|
|
17
|
-
*/
|
|
18
|
-
background?: string;
|
|
19
|
-
/** Styling options for text selection highlights */
|
|
20
|
-
textStyle?: TextSelectionStyle;
|
|
21
|
-
/** Styling options for the marquee selection rectangle */
|
|
22
|
-
marqueeStyle?: MarqueeSelectionStyle;
|
|
23
|
-
/** Optional CSS class applied to the marquee rectangle */
|
|
24
|
-
marqueeClass?: string;
|
|
25
|
-
/** Render function for selection menu (schema-driven approach) */
|
|
26
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
27
|
-
/** Snippet for custom selection menu (slot-based approach) */
|
|
28
|
-
selectionMenuSnippet?: Snippet<[SelectionSelectionMenuProps]>;
|
|
29
|
-
}
|
|
30
|
-
declare const SelectionLayer: import('svelte', { with: { "resolution-mode": "import" } }).Component<SelectionLayerProps, {}, "">;
|
|
31
|
-
type SelectionLayer = ReturnType<typeof SelectionLayer>;
|
|
32
|
-
export default SelectionLayer;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Snippet } from 'svelte';
|
|
2
|
-
import { Rotation } from '@embedpdf/models';
|
|
3
|
-
import { SelectionSelectionMenuRenderFn, SelectionSelectionMenuProps } from '../types';
|
|
4
|
-
interface TextSelectionProps {
|
|
5
|
-
/** Document ID */
|
|
6
|
-
documentId: string;
|
|
7
|
-
/** Index of the page this layer lives on */
|
|
8
|
-
pageIndex: number;
|
|
9
|
-
/** Scale of the page (optional, defaults to document scale) */
|
|
10
|
-
scale?: number;
|
|
11
|
-
/** Rotation of the page (optional, defaults to document rotation) */
|
|
12
|
-
rotation?: Rotation;
|
|
13
|
-
/** Background color for text selection highlights. Default: 'rgba(33,150,243)' */
|
|
14
|
-
background?: string;
|
|
15
|
-
/** Render function for selection menu (schema-driven approach) */
|
|
16
|
-
selectionMenu?: SelectionSelectionMenuRenderFn;
|
|
17
|
-
/** Snippet for custom selection menu (slot-based approach) */
|
|
18
|
-
selectionMenuSnippet?: Snippet<[SelectionSelectionMenuProps]>;
|
|
19
|
-
}
|
|
20
|
-
declare const TextSelection: import('svelte', { with: { "resolution-mode": "import" } }).Component<TextSelectionProps, {}, "">;
|
|
21
|
-
type TextSelection = ReturnType<typeof TextSelection>;
|
|
22
|
-
export default TextSelection;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { default as SelectionLayer } from './SelectionLayer.svelte';
|
|
2
|
-
export { default as TextSelection } from './TextSelection.svelte';
|
|
3
|
-
export { default as CopyToClipboard } from './CopyToClipboard.svelte';
|
|
4
|
-
export { default as MarqueeSelection } from './MarqueeSelection.svelte';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-selection.svelte';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SelectionPlugin } from '../../lib/index.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to get the selection plugin's capability API.
|
|
4
|
-
* This provides methods for controlling and listening to selection events.
|
|
5
|
-
*/
|
|
6
|
-
export declare const useSelectionCapability: () => {
|
|
7
|
-
provides: Readonly<import('../../lib/index.ts').SelectionCapability> | null;
|
|
8
|
-
isLoading: boolean;
|
|
9
|
-
ready: Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Hook to get the raw selection plugin instance.
|
|
13
|
-
* Useful for accessing plugin-specific properties or methods not exposed in the capability.
|
|
14
|
-
*/
|
|
15
|
-
export declare const useSelectionPlugin: () => {
|
|
16
|
-
plugin: SelectionPlugin | null;
|
|
17
|
-
isLoading: boolean;
|
|
18
|
-
ready: Promise<void>;
|
|
19
|
-
};
|
package/dist/svelte/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-selection");require("svelte/internal/disclose-version");const n=require("svelte/internal/client");require("@embedpdf/models");const r=require("@embedpdf/core/svelte"),o=require("@embedpdf/utils/svelte");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const l=i(n),d=()=>r.useCapability(t.SelectionPlugin.id),s=()=>r.usePlugin(t.SelectionPlugin.id);var u=l.from_html("<div></div>"),c=l.from_html("<div></div> <!>",1);function g(e,t){l.push(t,!0);let n=l.prop(t,"background",3,"rgba(33,150,243)");const i=s(),d=r.useDocumentState(()=>t.documentId),g=l.derived(()=>{var e,n,r;return null==(r=null==(n=null==(e=d.current)?void 0:e.document)?void 0:n.pages)?void 0:r[t.pageIndex]});let a=l.state(l.proxy([])),p=l.state(null),v=l.state(null);const f=l.derived(()=>{var e;return void 0!==t.scale?t.scale:(null==(e=d.current)?void 0:e.scale)??1}),m=l.derived(()=>{var e,n;if(void 0!==t.rotation)return t.rotation;return(((null==(e=l.get(g))?void 0:e.rotation)??0)+((null==(n=d.current)?void 0:n.rotation)??0))%4}),b=l.derived(()=>Boolean(l.get(v)&&l.get(v).pageIndex===t.pageIndex&&l.get(v).isVisible&&(t.selectionMenu||t.selectionMenuSnippet)));l.user_effect(()=>i.plugin&&t.documentId?i.plugin.registerSelectionOnPage({documentId:t.documentId,pageIndex:t.pageIndex,onRectsChange:({rects:e,boundingRect:t})=>{l.set(a,e,!0),l.set(p,t,!0)}}):(l.set(a,[],!0),void l.set(p,null))),l.user_effect(()=>{if(i.plugin&&t.documentId)return i.plugin.onMenuPlacement(t.documentId,e=>{l.set(v,e,!0)});l.set(v,null)});var x=l.comment(),h=l.first_child(x),y=e=>{var r=c(),i=l.first_child(r);let d;l.each(i,21,()=>l.get(a),l.index,(e,t)=>{var r=u();let o;l.template_effect(()=>o=l.set_style(r,"",o,{position:"absolute",left:(l.get(t).origin.x-l.get(p).origin.x)*l.get(f)+"px",top:(l.get(t).origin.y-l.get(p).origin.y)*l.get(f)+"px",width:l.get(t).size.width*l.get(f)+"px",height:l.get(t).size.height*l.get(f)+"px",background:n(),"pointer-events":"none"})),l.append(e,r)}),l.reset(i);var s=l.sibling(i,2),g=e=>{{const n=(e,n)=>{const r=l.derived(()=>function(e,n){return{context:{type:"selection",pageIndex:t.pageIndex},selected:!0,rect:e,placement:{suggestTop:(null==(r=l.get(v))?void 0:r.suggestTop)??!1,spaceAbove:(null==(o=l.get(v))?void 0:o.spaceAbove)??0,spaceBelow:(null==(i=l.get(v))?void 0:i.spaceBelow)??0},menuWrapperProps:n};var r,o,i}(null==n?void 0:n().rect,null==n?void 0:n().menuWrapperProps));var o=l.comment(),i=l.first_child(o),d=e=>{const n=l.derived(()=>t.selectionMenu(l.get(r)));var o=l.comment(),i=l.first_child(o),d=e=>{var t=l.comment(),r=l.first_child(t);l.component(r,()=>l.get(n).component,(e,t)=>{t(e,l.spread_props(()=>l.get(n).props))}),l.append(e,t)};l.if(i,e=>{l.get(n)&&e(d)}),l.append(e,o)},s=e=>{var n=l.comment(),o=l.first_child(n),i=e=>{var n=l.comment(),o=l.first_child(n);l.snippet(o,()=>t.selectionMenuSnippet,()=>l.get(r)),l.append(e,n)};l.if(o,e=>{t.selectionMenuSnippet&&e(i)},!0),l.append(e,n)};l.if(i,e=>{t.selectionMenu?e(d):e(s,!1)}),l.append(e,o)};let r=l.derived(()=>({origin:{x:l.get(v).rect.origin.x*l.get(f),y:l.get(v).rect.origin.y*l.get(f)},size:{width:l.get(v).rect.size.width*l.get(f),height:l.get(v).rect.size.height*l.get(f)}}));o.CounterRotate(e,{get rect(){return l.get(r)},get rotation(){return l.get(m)},children:n,$$slots:{default:!0}})}};l.if(s,e=>{l.get(b)&&l.get(v)&&e(g)}),l.template_effect(()=>d=l.set_style(i,"",d,{position:"absolute",left:l.get(p).origin.x*l.get(f)+"px",top:l.get(p).origin.y*l.get(f)+"px",width:l.get(p).size.width*l.get(f)+"px",height:l.get(p).size.height*l.get(f)+"px","mix-blend-mode":"multiply",isolation:"isolate","pointer-events":"none"})),l.append(e,r)};l.if(h,e=>{l.get(p)&&e(y)}),l.append(e,x),l.pop()}var a=l.from_html("<div></div>");function p(e,t){l.push(t,!0);let n=l.prop(t,"borderStyle",3,"dashed");const o=s(),i=r.useDocumentState(()=>t.documentId),d=l.derived(()=>t.borderColor??t.stroke??"rgba(0,122,204,0.8)"),u=l.derived(()=>t.background??t.fill??"rgba(0,122,204,0.15)");let c=l.state(null);const g=l.derived(()=>{var e;return void 0!==t.scale?t.scale:(null==(e=i.current)?void 0:e.scale)??1});l.user_effect(()=>{if(l.set(c,null),o.plugin)return o.plugin.registerMarqueeOnPage({documentId:t.documentId,pageIndex:t.pageIndex,scale:l.get(g),onRectChange:e=>{l.set(c,e,!0)}})});var p=l.comment(),v=l.first_child(p),f=e=>{var r=a();let o;l.template_effect(()=>{l.set_class(r,1,l.clsx(t.class)),o=l.set_style(r,"",o,{position:"absolute","pointer-events":"none",left:l.get(c).origin.x*l.get(g)+"px",top:l.get(c).origin.y*l.get(g)+"px",width:l.get(c).size.width*l.get(g)+"px",height:l.get(c).size.height*l.get(g)+"px",border:`1px ${n()} ${l.get(d)}`,background:l.get(u),"box-sizing":"border-box","z-index":"1000"})}),l.append(e,r)};l.if(v,e=>{l.get(c)&&e(f)}),l.append(e,p),l.pop()}var v=l.from_html("<!> <!>",1);function f(e,t){l.push(t,!0);const n=d();l.user_effect(()=>{if(n.provides)return n.provides.onCopyToClipboard(({text:e})=>{navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy text to clipboard:",e)})})}),l.pop()}const m=e.createPluginPackage(t.SelectionPluginPackage).addUtility(f).build();exports.CopyToClipboard=f,exports.MarqueeSelection=p,exports.SelectionLayer=function(e,t){l.push(t,!0);const n=l.derived(()=>{var e;return(null==(e=t.textStyle)?void 0:e.background)??t.background});var r=v(),o=l.first_child(r);g(o,{get documentId(){return t.documentId},get pageIndex(){return t.pageIndex},get scale(){return t.scale},get rotation(){return t.rotation},get background(){return l.get(n)},get selectionMenu(){return t.selectionMenu},get selectionMenuSnippet(){return t.selectionMenuSnippet}});var i=l.sibling(o,2);{let e=l.derived(()=>{var e;return null==(e=t.marqueeStyle)?void 0:e.background}),n=l.derived(()=>{var e;return null==(e=t.marqueeStyle)?void 0:e.borderColor}),r=l.derived(()=>{var e;return null==(e=t.marqueeStyle)?void 0:e.borderStyle});p(i,{get documentId(){return t.documentId},get pageIndex(){return t.pageIndex},get scale(){return t.scale},get background(){return l.get(e)},get borderColor(){return l.get(n)},get borderStyle(){return l.get(r)},get class(){return t.marqueeClass}})}l.append(e,r),l.pop()},exports.SelectionPluginPackage=m,exports.TextSelection=g,exports.useSelectionCapability=d,exports.useSelectionPlugin=s,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-selection.svelte.ts","../../src/svelte/components/TextSelection.svelte","../../src/svelte/components/MarqueeSelection.svelte","../../src/svelte/components/CopyToClipboard.svelte","../../src/svelte/index.ts","../../src/svelte/components/SelectionLayer.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\n/**\n * Hook to get the selection plugin's capability API.\n * This provides methods for controlling and listening to selection events.\n */\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\n\n/**\n * Hook to get the raw selection plugin instance.\n * Useful for accessing plugin-specific properties or methods not exposed in the capability.\n */\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { Rect } from '@embedpdf/models';\n import { Rotation } from '@embedpdf/models';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import {\n CounterRotate,\n type MenuWrapperProps,\n type SelectionMenuPlacement,\n } from '@embedpdf/utils/svelte';\n import { useSelectionPlugin } from '../hooks/use-selection.svelte';\n import type {\n SelectionSelectionMenuRenderFn,\n SelectionSelectionMenuProps,\n SelectionSelectionContext,\n } from '../types';\n import type { SelectionMenuPlacement as UtilsSelectionMenuPlacement } from '@embedpdf/plugin-selection';\n\n interface TextSelectionProps {\n /** Document ID */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page (optional, defaults to document scale) */\n scale?: number;\n /** Rotation of the page (optional, defaults to document rotation) */\n rotation?: Rotation;\n /** Background color for text selection highlights. Default: 'rgba(33,150,243)' */\n background?: string;\n /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: SelectionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[SelectionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n rotation: rotationOverride,\n background = 'rgba(33,150,243)',\n selectionMenu,\n selectionMenuSnippet,\n }: TextSelectionProps = $props();\n\n const selectionPlugin = useSelectionPlugin();\n const documentState = useDocumentState(() => documentId);\n\n const page = $derived(documentState.current?.document?.pages?.[pageIndex]);\n\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n let placement = $state<UtilsSelectionMenuPlacement | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n const actualRotation = $derived.by(() => {\n if (rotationOverride !== undefined) return rotationOverride;\n // Combine page intrinsic rotation with document rotation\n const pageRotation = page?.rotation ?? 0;\n const docRotation = documentState.current?.rotation ?? 0;\n return ((pageRotation + docRotation) % 4) as Rotation;\n });\n\n // Check if menu should render: placement is valid AND (render fn OR snippet exists)\n const shouldRenderMenu = $derived(\n Boolean(\n placement &&\n placement.pageIndex === pageIndex &&\n placement.isVisible &&\n (selectionMenu || selectionMenuSnippet),\n ),\n );\n\n // Track selection rectangles on this page\n $effect(() => {\n if (!selectionPlugin.plugin || !documentId) {\n rects = [];\n boundingRect = null;\n return;\n }\n\n return selectionPlugin.plugin.registerSelectionOnPage({\n documentId,\n pageIndex,\n onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {\n rects = newRects;\n boundingRect = newBoundingRect;\n },\n });\n });\n\n // Track menu placement for this document\n $effect(() => {\n if (!selectionPlugin.plugin || !documentId) {\n placement = null;\n return;\n }\n\n return selectionPlugin.plugin.onMenuPlacement(documentId, (newPlacement) => {\n placement = newPlacement;\n });\n });\n\n // --- Selection Menu Logic ---\n\n // Build context object for selection menu\n function buildContext(): SelectionSelectionContext {\n return {\n type: 'selection',\n pageIndex,\n };\n }\n\n // Build placement hints from plugin placement data\n function buildMenuPlacement(): SelectionMenuPlacement {\n return {\n suggestTop: placement?.suggestTop ?? false,\n spaceAbove: placement?.spaceAbove ?? 0,\n spaceBelow: placement?.spaceBelow ?? 0,\n };\n }\n\n // Build menu props\n function buildMenuProps(\n rect: Rect,\n menuWrapperProps: MenuWrapperProps,\n ): SelectionSelectionMenuProps {\n return {\n context: buildContext(),\n selected: true, // Selection is always \"selected\" when visible\n rect,\n placement: buildMenuPlacement(),\n menuWrapperProps,\n };\n }\n</script>\n\n{#if boundingRect}\n <!-- Highlight layer -->\n <div\n style:position=\"absolute\"\n style:left={`${boundingRect.origin.x * actualScale}px`}\n style:top={`${boundingRect.origin.y * actualScale}px`}\n style:width={`${boundingRect.size.width * actualScale}px`}\n style:height={`${boundingRect.size.height * actualScale}px`}\n style:mix-blend-mode=\"multiply\"\n style:isolation=\"isolate\"\n style:pointer-events=\"none\"\n >\n {#each rects as rect, i (i)}\n <div\n style:position=\"absolute\"\n style:left={`${(rect.origin.x - boundingRect.origin.x) * actualScale}px`}\n style:top={`${(rect.origin.y - boundingRect.origin.y) * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:background\n style:pointer-events=\"none\"\n ></div>\n {/each}\n </div>\n\n <!-- Selection menu (counter-rotated) -->\n {#if shouldRenderMenu && placement}\n <CounterRotate\n rect={{\n origin: {\n x: placement.rect.origin.x * actualScale,\n y: placement.rect.origin.y * actualScale,\n },\n size: {\n width: placement.rect.size.width * actualScale,\n height: placement.rect.size.height * actualScale,\n },\n }}\n rotation={actualRotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(rect, menuWrapperProps)}\n {#if selectionMenu}\n <!-- Priority 1: Render function (schema-driven) -->\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n <!-- Priority 2: Snippet (manual customization) -->\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n{/if}\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { useSelectionPlugin } from '../hooks';\n\n interface MarqueeSelectionProps {\n /** The ID of the document */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page (optional, defaults to document scale) */\n scale?: number;\n /** Optional CSS class applied to the marquee rectangle */\n class?: string;\n /** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */\n background?: string;\n /** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */\n borderColor?: string;\n /** Border style. Default: 'dashed' */\n borderStyle?: 'solid' | 'dashed' | 'dotted';\n /**\n * @deprecated Use `borderColor` instead.\n */\n stroke?: string;\n /**\n * @deprecated Use `background` instead.\n */\n fill?: string;\n }\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n class: propsClass,\n background,\n borderColor,\n borderStyle = 'dashed',\n stroke,\n fill,\n }: MarqueeSelectionProps = $props();\n\n const selectionPlugin = useSelectionPlugin();\n const documentState = useDocumentState(() => documentId);\n\n // Resolve deprecated props: new CSS-standard props take precedence\n const resolvedBorderColor = $derived(borderColor ?? stroke ?? 'rgba(0,122,204,0.8)');\n const resolvedBackground = $derived(background ?? fill ?? 'rgba(0,122,204,0.15)');\n\n let rect = $state<Rect | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n rect = null;\n\n if (!selectionPlugin.plugin) {\n return;\n }\n\n return selectionPlugin.plugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n onRectChange: (newRect) => {\n rect = newRect;\n },\n });\n });\n</script>\n\n{#if rect}\n <div\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * actualScale}px`}\n style:top={`${rect.origin.y * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:border={`1px ${borderStyle} ${resolvedBorderColor}`}\n style:background={resolvedBackground}\n style:box-sizing=\"border-box\"\n style:z-index=\"1000\"\n class={propsClass}\n ></div>\n{/if}\n","<script lang=\"ts\">\n import { useSelectionCapability } from '../hooks/use-selection.svelte';\n\n const selectionCapability = useSelectionCapability();\n\n $effect(() => {\n if (!selectionCapability.provides) return;\n\n return selectionCapability.provides.onCopyToClipboard(({ text }) => {\n navigator.clipboard.writeText(text).catch((err) => {\n console.error('Failed to copy text to clipboard:', err);\n });\n });\n });\n</script>\n\n<!-- This component renders nothing to the DOM -->\n","import { createPluginPackage } from '@embedpdf/core';\nimport { SelectionPluginPackage as BaseSelectionPluginPackage } from '@embedpdf/plugin-selection';\n\nimport { CopyToClipboard } from './components';\n\nexport * from './hooks';\nexport * from './components';\nexport * from './types';\nexport * from '@embedpdf/plugin-selection';\n\nexport const SelectionPluginPackage = createPluginPackage(BaseSelectionPluginPackage)\n .addUtility(CopyToClipboard)\n .build();\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { Rotation } from '@embedpdf/models';\n import type { TextSelectionStyle, MarqueeSelectionStyle } from '@embedpdf/plugin-selection';\n import type { SelectionSelectionMenuRenderFn, SelectionSelectionMenuProps } from '../types';\n import TextSelection from './TextSelection.svelte';\n import MarqueeSelection from './MarqueeSelection.svelte';\n\n interface SelectionLayerProps {\n /** Document ID */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page (optional, defaults to document scale) */\n scale?: number;\n /** Rotation of the page (optional, defaults to document rotation) */\n rotation?: Rotation;\n /**\n * @deprecated Use `textStyle.background` instead.\n * Background color for selection rectangles.\n */\n background?: string;\n /** Styling options for text selection highlights */\n textStyle?: TextSelectionStyle;\n /** Styling options for the marquee selection rectangle */\n marqueeStyle?: MarqueeSelectionStyle;\n /** Optional CSS class applied to the marquee rectangle */\n marqueeClass?: string;\n /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: SelectionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[SelectionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation,\n background,\n textStyle,\n marqueeStyle,\n marqueeClass,\n selectionMenu,\n selectionMenuSnippet,\n }: SelectionLayerProps = $props();\n\n const resolvedTextBackground = $derived(textStyle?.background ?? background);\n</script>\n\n<TextSelection\n {documentId}\n {pageIndex}\n {scale}\n {rotation}\n background={resolvedTextBackground}\n {selectionMenu}\n {selectionMenuSnippet}\n/>\n<MarqueeSelection\n {documentId}\n {pageIndex}\n {scale}\n background={marqueeStyle?.background}\n borderColor={marqueeStyle?.borderColor}\n borderStyle={marqueeStyle?.borderStyle}\n class={marqueeClass}\n/>\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","useSelectionPlugin","usePlugin","background","selectionPlugin","documentState","useDocumentState","$$props","documentId","page","_c","_b","_a","current","document","pages","pageIndex","rects","$","state","proxy","boundingRect","placement","actualScale","derived","scale","actualRotation","rotation","get","shouldRenderMenu","Boolean","isVisible","selectionMenu","selectionMenuSnippet","user_effect","plugin","registerSelectionOnPage","onRectsChange","newRects","newBoundingRect","set","onMenuPlacement","newPlacement","div","first_child","fragment_1","index","$$anchor","rect","div_1","root_2","styles_1","origin","x","y","width","size","height","children","$$arg0","menuProps","menuWrapperProps","context","type","selected","suggestTop","spaceAbove","spaceBelow","buildMenuProps","result","result_component","spread_props","props","consequent","CounterRotate","$$render","consequent_3","styles","left","top","consequent_4","borderStyle","resolvedBorderColor","resolvedBackground","registerMarqueeOnPage","onRectChange","newRect","root_1","clsx","class","border","selectionCapability","provides","onCopyToClipboard","text","navigator","clipboard","writeText","catch","err","console","error","SelectionPluginPackage","createPluginPackage","BaseSelectionPluginPackage","addUtility","CopyToClipboard","build","resolvedTextBackground","TextSelection","node","borderColor","MarqueeSelection","node_1"],"mappings":"inBAOaA,EAAA,IAA+BC,gBAA+BC,EAAAA,gBAAgBC,IAM9EC,EAAA,IAA2BC,YAA2BH,EAAAA,gBAAgBC,qGC2B/E,IAAAG,0BAAa,oBA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AAoB,GAAKQ,KAAKD,YAAQhC,GAAlB,KACCkC,OAAAvC,EAAAU,IAAAoB,GAAKQ,KAAKC,aAASlC,GAAnB,KACImE,OAAA,OAAAT,aAAeC,sBAClBC,6DARnBxC,qBADEK,MAAIyB,0BAFD,6DCpEA,MAAAkB,EAAsB9F,IAE5BqB,EAAAgB,YAAO,KACA,GAAAyD,EAAoBC,SAElB,OAAAD,EAAoBC,SAASC,kBAAiB,EAAIC,WACvDC,UAAUC,UAAUC,UAAUH,GAAMI,MAAOC,IACzCC,QAAQC,MAAM,oCAAqCF,gBAInD,CCJD,MAAMG,EAAyBC,EAAAA,oBAAoBC,EAAAA,wBACvDC,WAAWC,GACXC,+GCmCK,MAAAC,6DAA6CzG,aAAUI,EAAAJ,0CAG9D0G,EAAYC,EAAA,uKAKCF,sMAQczG,6EACC4G,8EACA9B,cAN5B+B,EAAeC,EAAA,yQAXR"}
|
package/dist/svelte/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
|
-
export * from './components';
|
|
3
|
-
export * from './types';
|
|
4
|
-
export * from '../lib/index.ts';
|
|
5
|
-
export declare const SelectionPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').SelectionPlugin, import('../lib/index.ts').SelectionPluginConfig, import('../lib/index.ts').SelectionState, import('src/lib/actions').SelectionAction>>;
|