themed-markdown 0.1.92 → 0.1.93
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +683 -149
- package/dist/industryMarkdown/components/IndustryMarkdownComponents.d.ts +16 -12
- package/dist/industryMarkdown/components/IndustryMarkdownComponents.d.ts.map +1 -1
- package/dist/industryMarkdown/components/IndustryMarkdownSlide.d.ts +34 -0
- package/dist/industryMarkdown/components/IndustryMarkdownSlide.d.ts.map +1 -1
- package/dist/industryMarkdown/utils/blockDeletion.d.ts +57 -0
- package/dist/industryMarkdown/utils/blockDeletion.d.ts.map +1 -0
- package/dist/industryMarkdown/utils/rehypeSourcePositions.d.ts +45 -0
- package/dist/industryMarkdown/utils/rehypeSourcePositions.d.ts.map +1 -0
- package/dist/industryMarkdown/utils/useBlockSelection.d.ts +45 -0
- package/dist/industryMarkdown/utils/useBlockSelection.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -18,23 +18,27 @@ interface IndustryMarkdownComponentsProps {
|
|
|
18
18
|
index: number;
|
|
19
19
|
repositoryInfo?: RepositoryInfo;
|
|
20
20
|
editable?: boolean;
|
|
21
|
+
selectableBlocks?: boolean;
|
|
22
|
+
onDeleteListItem?: (chunkIndex: number, startLine: number, endLine: number) => void;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Creates markdown components using industryTheme.
|
|
24
26
|
* This directly uses Theme UI spec values from the industryTheme.
|
|
25
27
|
*/
|
|
26
|
-
export declare const createIndustryMarkdownComponents: ({ theme, slideIdPrefix, slideIndex, onLinkClick, onCheckboxChange, checkedItems, setCheckedItems, openHtmlModal, openPlaceholderModal, handleRunBashCommand, enableHtmlPopout, slideHeaderMarginTopOverride, index, repositoryInfo, editable, }: IndustryMarkdownComponentsProps) => {
|
|
27
|
-
h1: ({ children, ...props }: HeadingProps) => React.JSX.Element;
|
|
28
|
-
h2: ({ children, ...props }: HeadingProps) => React.JSX.Element;
|
|
29
|
-
h3: ({ children, ...props }: HeadingProps) => React.JSX.Element;
|
|
30
|
-
h4: ({ children, ...props }: HeadingProps) => React.JSX.Element;
|
|
31
|
-
h5: ({ children, ...props }: HeadingProps) => React.JSX.Element;
|
|
32
|
-
h6: ({ children, ...props }: HeadingProps) => React.JSX.Element;
|
|
33
|
-
p: ({ children, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
34
|
-
ul: ({ children, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
35
|
-
ol: ({ children, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
36
|
-
li: ({ children, ...props }: ListItemProps) => React.JSX.Element;
|
|
37
|
-
|
|
28
|
+
export declare const createIndustryMarkdownComponents: ({ theme, slideIdPrefix, slideIndex, onLinkClick, onCheckboxChange, checkedItems, setCheckedItems, openHtmlModal, openPlaceholderModal, handleRunBashCommand, enableHtmlPopout, slideHeaderMarginTopOverride, index, repositoryInfo, editable, selectableBlocks, onDeleteListItem, }: IndustryMarkdownComponentsProps) => {
|
|
29
|
+
h1: ({ children, node, ...props }: HeadingProps) => React.JSX.Element;
|
|
30
|
+
h2: ({ children, node, ...props }: HeadingProps) => React.JSX.Element;
|
|
31
|
+
h3: ({ children, node, ...props }: HeadingProps) => React.JSX.Element;
|
|
32
|
+
h4: ({ children, node, ...props }: HeadingProps) => React.JSX.Element;
|
|
33
|
+
h5: ({ children, node, ...props }: HeadingProps) => React.JSX.Element;
|
|
34
|
+
h6: ({ children, node, ...props }: HeadingProps) => React.JSX.Element;
|
|
35
|
+
p: ({ children, node, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
36
|
+
ul: ({ children, node, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
37
|
+
ol: ({ children, node, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
38
|
+
li: ({ children, node, ...props }: ListItemProps) => React.JSX.Element;
|
|
39
|
+
blockquote: ({ children, node, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
40
|
+
hr: ({ node, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
41
|
+
table: ({ children, node, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
38
42
|
thead: ({ children, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
39
43
|
th: ({ children, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
40
44
|
td: ({ children, ...props }: MarkdownComponentProps) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndustryMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EAEf,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EAEZ,MAAM,6BAA6B,CAAC;AAMrC,UAAU,+BAA+B;IACvC,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACzD,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtF,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC/E,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/E,oBAAoB,CAAC,EAAE,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,kBAAkB,KACzB,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"IndustryMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EAEf,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EAEZ,MAAM,6BAA6B,CAAC;AAMrC,UAAU,+BAA+B;IACvC,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACzD,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtF,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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Info } from '@principa
|
|
|
63
63
|
import React from 'react';
|
|
64
64
|
import type { Annotation, AnnotationSelection } from '../types/annotations';
|
|
65
65
|
import { KeyboardBinding } from '../types/keyboard';
|
|
66
|
+
import { type BlockDeletionTarget } from '../utils/blockDeletion';
|
|
66
67
|
export interface IndustryMarkdownSlideProps {
|
|
67
68
|
content: string;
|
|
68
69
|
slideIdPrefix: string;
|
|
@@ -109,6 +110,39 @@ export interface IndustryMarkdownSlideProps {
|
|
|
109
110
|
keyboardScrollConfig?: KeyboardScrollConfig;
|
|
110
111
|
repositoryInfo?: RepositoryInfo;
|
|
111
112
|
editable?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* When true, highlighting text inside the slide resolves to the top-level
|
|
115
|
+
* block(s) it touches and surfaces a floating delete button. The button is
|
|
116
|
+
* only shown when a delete handler (`onContentChange` or `onDeleteBlocks`)
|
|
117
|
+
* is also provided.
|
|
118
|
+
*/
|
|
119
|
+
selectableBlocks?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* How a highlight is resolved for deletion:
|
|
122
|
+
* - 'block' (default): removes the whole top-level block(s) the highlight
|
|
123
|
+
* touches — robust, and works alongside search highlighting.
|
|
124
|
+
* - 'text': removes the exact highlighted text, mapped back to the markdown
|
|
125
|
+
* source. Falls back to whole-block removal when a precise range can't be
|
|
126
|
+
* resolved (e.g. selections inside code or spanning blocks). Note that
|
|
127
|
+
* partially selecting inline-formatted text (e.g. the word inside
|
|
128
|
+
* `**bold**`) can leave the surrounding markers behind.
|
|
129
|
+
*/
|
|
130
|
+
deletionMode?: 'block' | 'text';
|
|
131
|
+
/**
|
|
132
|
+
* Called with the full slide content after the selected block(s) are
|
|
133
|
+
* removed. The slide is presentational — the consumer owns `content` and is
|
|
134
|
+
* expected to persist this and feed it back in.
|
|
135
|
+
*/
|
|
136
|
+
onContentChange?: (newContent: string) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Optional richer notification fired alongside `onContentChange` when a
|
|
139
|
+
* block deletion occurs.
|
|
140
|
+
*/
|
|
141
|
+
onDeleteBlocks?: (info: {
|
|
142
|
+
newContent: string;
|
|
143
|
+
removedText: string;
|
|
144
|
+
targets: BlockDeletionTarget[];
|
|
145
|
+
}) => void;
|
|
112
146
|
annotations?: Annotation[];
|
|
113
147
|
activeAnnotationId?: string | null;
|
|
114
148
|
renderAnnotation?: (annotation: Annotation) => React.ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndustryMarkdownSlide.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMarkdownSlide.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,KAAK,EAAyB,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACf,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"IndustryMarkdownSlide.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/components/IndustryMarkdownSlide.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,KAAK,EAAyB,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACf,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAA6E,MAAM,OAAO,CAAC;AASlG,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,wBAAwB,CAAC;AAahC,MAAM,WAAW,0BAA0B;IAEzC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,U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M,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAGD,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,eAAe,EAAE,CA8D7F;AAED,eAAO,MAAM,qBAAqB,wDA22BhC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block deletion helpers.
|
|
3
|
+
*
|
|
4
|
+
* The slide renders markdown as a list of chunks; each rendered block element
|
|
5
|
+
* is tagged (via `data-md-chunk` / `data-md-start` / `data-md-end`) with the
|
|
6
|
+
* chunk it belongs to and its 1-based source line range *within that chunk's
|
|
7
|
+
* content*. When a user highlights text we resolve the highlight to the
|
|
8
|
+
* top-level blocks it touches, then splice those blocks' source lines out of
|
|
9
|
+
* the full slide content.
|
|
10
|
+
*
|
|
11
|
+
* Mapping chunk-relative line ranges back to the full `content` relies on the
|
|
12
|
+
* fact that each `markdown_chunk.content` is an exact substring of the slide
|
|
13
|
+
* content (the parser slices without trimming what it stores), so a chunk's
|
|
14
|
+
* absolute character offset can be recovered with a forward `indexOf`.
|
|
15
|
+
*/
|
|
16
|
+
export interface BlockDeletionTarget {
|
|
17
|
+
/** Index of the chunk in the slide's chunk list. */
|
|
18
|
+
chunkIndex: number;
|
|
19
|
+
/** 1-based, inclusive start line relative to the chunk's content. */
|
|
20
|
+
startLine: number;
|
|
21
|
+
/** 1-based, inclusive end line relative to the chunk's content. */
|
|
22
|
+
endLine: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ResolvedDeletion {
|
|
25
|
+
/** Slide content with the targeted blocks removed. */
|
|
26
|
+
newContent: string;
|
|
27
|
+
/** The exact source text that was removed. */
|
|
28
|
+
removedText: string;
|
|
29
|
+
/** Absolute character ranges removed from `content` (merged, sorted). */
|
|
30
|
+
ranges: Array<{
|
|
31
|
+
start: number;
|
|
32
|
+
end: number;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
interface ChunkLike {
|
|
36
|
+
content: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve each chunk's absolute character offset within `content`. Chunks
|
|
40
|
+
* whose content can't be located resolve to -1. A forward cursor keeps the
|
|
41
|
+
* search monotonic so duplicate chunk bodies still map to distinct offsets.
|
|
42
|
+
*/
|
|
43
|
+
export declare function computeChunkOffsets(content: string, chunks: ChunkLike[]): number[];
|
|
44
|
+
/**
|
|
45
|
+
* Compute the result of deleting `targets` from `content`. Overlapping or
|
|
46
|
+
* adjacent ranges are merged; each block's trailing newline is consumed so the
|
|
47
|
+
* surrounding text collapses cleanly.
|
|
48
|
+
*/
|
|
49
|
+
export declare function computeDeletion(content: string, chunks: ChunkLike[], targets: BlockDeletionTarget[]): ResolvedDeletion;
|
|
50
|
+
/**
|
|
51
|
+
* Delete an exact source character range (precise "text" deletion). The
|
|
52
|
+
* offsets are relative to the owning chunk's content; they're mapped to the
|
|
53
|
+
* full slide content via the chunk's absolute offset.
|
|
54
|
+
*/
|
|
55
|
+
export declare function computeTextDeletion(content: string, chunks: ChunkLike[], chunkIndex: number, startOffset: number, endOffset: number): ResolvedDeletion;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=blockDeletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockDeletion.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/utils/blockDeletion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/C;AAED,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAuBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAelF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,EAAE,EACnB,OAAO,EAAE,mBAAmB,EAAE,GAC7B,gBAAgB,CAkDlB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,EAAE,EACnB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,gBAAgB,CAoBlB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rehype plugin: wrap each prose text node in a
|
|
3
|
+
* `<span data-src-start data-src-end>` carrying its source character offsets
|
|
4
|
+
* (into the markdown string that was parsed). This lets a DOM text selection
|
|
5
|
+
* be mapped back to an exact source range for precise ("text") deletion.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* - Code (`<pre>` / `<code>`) subtrees are skipped — their rendered text omits
|
|
9
|
+
* the surrounding fences/backticks, so offset math would be misleading.
|
|
10
|
+
* - Pure-whitespace and position-less text nodes (e.g. the synthetic newlines
|
|
11
|
+
* between block elements) are left untouched.
|
|
12
|
+
* - The offsets are relative to the exact string handed to the parser, so this
|
|
13
|
+
* must not be combined with content transforms that shift offsets (e.g.
|
|
14
|
+
* search-match highlighting). Callers gate on that.
|
|
15
|
+
*/
|
|
16
|
+
interface HastText {
|
|
17
|
+
type: 'text';
|
|
18
|
+
value: string;
|
|
19
|
+
position?: {
|
|
20
|
+
start?: {
|
|
21
|
+
offset?: number;
|
|
22
|
+
};
|
|
23
|
+
end?: {
|
|
24
|
+
offset?: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface HastElement {
|
|
29
|
+
type: 'element';
|
|
30
|
+
tagName: string;
|
|
31
|
+
properties?: Record<string, unknown>;
|
|
32
|
+
children?: HastNode[];
|
|
33
|
+
position?: unknown;
|
|
34
|
+
}
|
|
35
|
+
interface HastRoot {
|
|
36
|
+
type: 'root';
|
|
37
|
+
children?: HastNode[];
|
|
38
|
+
}
|
|
39
|
+
type HastNode = HastText | HastElement | HastRoot | {
|
|
40
|
+
type: string;
|
|
41
|
+
children?: HastNode[];
|
|
42
|
+
};
|
|
43
|
+
export declare function rehypeSourcePositions(): (tree: HastRoot) => void;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=rehypeSourcePositions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rehypeSourcePositions.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/utils/rehypeSourcePositions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,GAAG,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CACvE;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,KAAK,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC;AAQ5F,wBAAgB,qBAAqB,KAC3B,MAAM,QAAQ,UAgCvB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { BlockDeletionTarget } from './blockDeletion';
|
|
3
|
+
export declare const BLOCK_SELECTED_ATTR = "data-md-selected";
|
|
4
|
+
export type DeletionMode = 'block' | 'text';
|
|
5
|
+
interface SelectionAnchor {
|
|
6
|
+
/** Position for the floating action button, relative to the slide root. */
|
|
7
|
+
top: number;
|
|
8
|
+
left: number;
|
|
9
|
+
}
|
|
10
|
+
export type ResolvedDeletionSelection = {
|
|
11
|
+
kind: 'block';
|
|
12
|
+
targets: BlockDeletionTarget[];
|
|
13
|
+
anchor: SelectionAnchor;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'text';
|
|
16
|
+
chunkIndex: number;
|
|
17
|
+
startOffset: number;
|
|
18
|
+
endOffset: number;
|
|
19
|
+
anchor: SelectionAnchor;
|
|
20
|
+
};
|
|
21
|
+
interface UseBlockSelectionParams {
|
|
22
|
+
rootRef: RefObject<HTMLElement | null>;
|
|
23
|
+
/** When false the hook is inert (no listeners, no resolution). */
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 'block' resolves a highlight to whole top-level blocks; 'text' resolves it
|
|
27
|
+
* to the exact source character range, falling back to block resolution when
|
|
28
|
+
* the precise range can't be determined.
|
|
29
|
+
*/
|
|
30
|
+
mode: DeletionMode;
|
|
31
|
+
}
|
|
32
|
+
interface UseBlockSelectionResult {
|
|
33
|
+
selection: ResolvedDeletionSelection | null;
|
|
34
|
+
/** Clear the current selection outline + state. */
|
|
35
|
+
clear: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a live text highlight inside `rootRef` to a deletion target. In
|
|
39
|
+
* 'text' mode this is the exact source character range under the highlight; in
|
|
40
|
+
* 'block' mode (or when a precise range can't be resolved) it's the outermost
|
|
41
|
+
* top-level block(s) the highlight overlaps.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useBlockSelection({ rootRef, enabled, mode, }: UseBlockSelectionParams): UseBlockSelectionResult;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=useBlockSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlockSelection.d.ts","sourceRoot":"","sources":["../../../industryMarkdown/utils/useBlockSelection.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5C,UAAU,eAAe;IACvB,2EAA2E;IAC3E,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,yBAAyB,GACjC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GAC1E;IACE,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEN,UAAU,uBAAuB;IAC/B,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACvC,kEAAkE;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,UAAU,uBAAuB;IAC/B,SAAS,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC5C,mDAAmD;IACnD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAgGD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,OAAO,EACP,IAAI,GACL,EAAE,uBAAuB,GAAG,uBAAuB,CAkGnD"}
|