@mrakomor/core 0.0.11 → 0.0.12
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/blockChrome.mjs +2 -2
- package/dist/blockInsertMenu.mjs +1 -1
- package/dist/chunk-2C6UDFD4.mjs +1 -0
- package/dist/chunk-5HWTMPF4.mjs +2 -0
- package/dist/{chunk-NR2BAMSW.mjs → chunk-6CG6EGQM.mjs} +2 -2
- package/dist/{chunk-K2DMHAUD.mjs → chunk-7CJLTNHZ.mjs} +1 -1
- package/dist/chunk-ERNLRJPB.mjs +1 -0
- package/dist/chunk-EXDY5TZH.mjs +1 -0
- package/dist/chunk-FAXIFXQK.mjs +4 -0
- package/dist/{chunk-2VURZA2E.mjs → chunk-GDDVUIEH.mjs} +1 -1
- package/dist/{chunk-VYTSZ4S6.mjs → chunk-JVQ2YGII.mjs} +1 -1
- package/dist/{chunk-SCFD3XBH.mjs → chunk-P7TUN2KD.mjs} +1 -1
- package/dist/chunk-S2W6LYHT.mjs +1 -0
- package/dist/chunk-TL5BHWDU.mjs +2 -0
- package/dist/chunk-ZHOZPQZH.mjs +1 -0
- package/dist/clipboard.cjs +3 -3
- package/dist/clipboard.mjs +3 -3
- package/dist/footer.cjs +2 -2
- package/dist/footer.mjs +2 -2
- package/dist/headline.cjs +2 -2
- package/dist/headline.mjs +1 -1
- package/dist/help.mjs +2 -2
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +4 -4
- package/dist/link.mjs +2 -2
- package/dist/list.cjs +3 -3
- package/dist/list.mjs +1 -1
- package/dist/paragraph.cjs +2 -2
- package/dist/paragraph.mjs +1 -1
- package/dist/slashCommand.cjs +2 -2
- package/dist/slashCommand.mjs +1 -1
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.mjs +2 -2
- package/dist/tts.cjs +8 -8
- package/dist/tts.mjs +3 -3
- package/dist/types/Mrakomor.d.mts +230 -0
- package/dist/types/component/AbstractComponent.d.mts +69 -0
- package/dist/types/component/Editor.d.mts +8 -0
- package/dist/types/component/block/BlockComponent.d.mts +105 -0
- package/dist/types/component/block/BlockRegister.d.mts +29 -0
- package/dist/types/component/block/ExternalComponent.d.mts +42 -0
- package/dist/types/component/block/UnknownComponent.d.mts +3 -0
- package/dist/types/component/block/blockItemEquals.d.mts +6 -0
- package/dist/types/component/block/helpers.d.mts +319 -0
- package/dist/types/component/editorContext.d.mts +4 -0
- package/dist/types/component/entityRange/EntityRangeElement.d.mts +15 -0
- package/dist/types/component/inlineStyle/Bold.d.mts +4 -0
- package/dist/types/component/inlineStyle/InlineElement.d.mts +10 -0
- package/dist/types/component/inlineStyle/Italic.d.mts +4 -0
- package/dist/types/component/inlineStyle/Subscript.d.mts +4 -0
- package/dist/types/component/inlineStyle/Superscript.d.mts +4 -0
- package/dist/types/component/inlineStyle/Underline.d.mts +4 -0
- package/dist/types/component/inlineStyle/index.d.mts +5 -0
- package/dist/types/component/overlayMount.d.mts +46 -0
- package/dist/types/dom.d.mts +161 -0
- package/dist/types/emitter.d.mts +38 -0
- package/dist/types/index.d.mts +7 -0
- package/dist/types/namespaces.d.mts +17 -0
- package/dist/types/plugin/blockChrome/BlockChrome.d.mts +11 -0
- package/dist/types/plugin/blockChrome/index.d.mts +1 -0
- package/dist/types/plugin/blockInsertMenu/BlockInsertMenu.d.mts +6 -0
- package/dist/types/plugin/blockInsertMenu/index.d.mts +1 -0
- package/dist/types/plugin/clipboard/clipboardHelpers.d.mts +151 -0
- package/dist/types/plugin/clipboard/clipboardPlugin.d.mts +6 -0
- package/dist/types/plugin/clipboard/index.d.mts +1 -0
- package/dist/types/plugin/default/defaultMrakomorPlugin.d.mts +21 -0
- package/dist/types/plugin/dialog/Dialog.d.mts +23 -0
- package/dist/types/plugin/footer/footerPlugin.d.mts +7 -0
- package/dist/types/plugin/footer/index.d.mts +1 -0
- package/dist/types/plugin/headline/Headline.d.mts +29 -0
- package/dist/types/plugin/headline/index.d.mts +1 -0
- package/dist/types/plugin/help/HelpRegister.d.mts +15 -0
- package/dist/types/plugin/help/helpPlugin.d.mts +26 -0
- package/dist/types/plugin/help/helpSchema.d.mts +11 -0
- package/dist/types/plugin/help/index.d.mts +1 -0
- package/dist/types/plugin/linkEntity/LinkEntity.d.mts +37 -0
- package/dist/types/plugin/linkEntity/index.d.mts +1 -0
- package/dist/types/plugin/list/List.d.mts +61 -0
- package/dist/types/plugin/list/index.d.mts +1 -0
- package/dist/types/plugin/list/listHelpers.d.mts +166 -0
- package/dist/types/plugin/menu/Menu.d.mts +22 -0
- package/dist/types/plugin/menu/menuPlugin.d.mts +6 -0
- package/dist/types/plugin/paragraph/Paragraph.d.mts +16 -0
- package/dist/types/plugin/paragraph/index.d.mts +1 -0
- package/dist/types/plugin/slashCommand/SlashActionRegister.d.mts +12 -0
- package/dist/types/plugin/slashCommand/index.d.mts +1 -0
- package/dist/types/plugin/slashCommand/slashActionSchema.d.mts +29 -0
- package/dist/types/plugin/slashCommand/slashCommandHelpers.d.mts +77 -0
- package/dist/types/plugin/slashCommand/slashCommandPlugin.d.mts +11 -0
- package/dist/types/plugin/slashCommand/slashHelp.d.mts +12 -0
- package/dist/types/plugin/tooltip/Tooltip.d.mts +16 -0
- package/dist/types/plugin/tooltip/index.d.mts +1 -0
- package/dist/types/plugin/tts/TtsHeadline.d.mts +27 -0
- package/dist/types/plugin/tts/TtsList.d.mts +19 -0
- package/dist/types/plugin/tts/TtsParagraph.d.mts +9 -0
- package/dist/types/plugin/tts/TtsVoice.d.mts +52 -0
- package/dist/types/plugin/tts/index.d.mts +4 -0
- package/dist/types/register/Register.d.mts +50 -0
- package/dist/types/register/sortRegisterEntries.d.mts +7 -0
- package/dist/types/schema/blockContent.d.mts +34 -0
- package/dist/types/schema/blockRegister.d.mts +14 -0
- package/dist/types/schema/config.d.mts +6 -0
- package/dist/types/types.d.mts +636 -0
- package/package.json +35 -22
- package/dist/chunk-5VPYPKGA.mjs +0 -1
- package/dist/chunk-BCE45I7Q.mjs +0 -2
- package/dist/chunk-N4I2WZWF.mjs +0 -1
- package/dist/chunk-T7OO472O.mjs +0 -1
- package/dist/chunk-WQWE5UCN.mjs +0 -1
- package/dist/chunk-YO4ZA6PJ.mjs +0 -2
- package/dist/chunk-ZDMD7SRT.mjs +0 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unwrap the selected list item as a text block (list → text namespace).
|
|
3
|
+
* Runs before default `transformBlockElement`; calls `preventDefault` so
|
|
4
|
+
* list `items` are not dropped. Text → list is now handled generically by
|
|
5
|
+
* default's `onTransformBlockElement` via `List.fromExchangeState`.
|
|
6
|
+
* @param {import('#src/types.mjs').EmitterEvent} event
|
|
7
|
+
*/
|
|
8
|
+
export function onTransformListItem(event: import("#src/types.mjs").EmitterEvent): void;
|
|
9
|
+
/**
|
|
10
|
+
* Shared list plugin wiring for {@link List} and TTS subclasses.
|
|
11
|
+
* @param {typeof List} Block
|
|
12
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
13
|
+
*/
|
|
14
|
+
export function createListPlugin(Block: typeof List): import("#src/types.mjs").Plugin;
|
|
15
|
+
/**
|
|
16
|
+
* Registers the list block (UL/OL insert-menu variants).
|
|
17
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
18
|
+
*/
|
|
19
|
+
export function listPlugin(): import("#src/types.mjs").Plugin;
|
|
20
|
+
export class List extends BlockComponent {
|
|
21
|
+
static get LABEL(): string;
|
|
22
|
+
static getStateSchema(node: any): import("@esmj/schema").SchemaInterface<{
|
|
23
|
+
component: string;
|
|
24
|
+
componentId: string;
|
|
25
|
+
properties: {
|
|
26
|
+
items: import("#src/types.mjs").ListItem[];
|
|
27
|
+
};
|
|
28
|
+
settings: {
|
|
29
|
+
style: "ORDERED" | "UNORDERED";
|
|
30
|
+
};
|
|
31
|
+
}, {
|
|
32
|
+
component: string;
|
|
33
|
+
componentId: string;
|
|
34
|
+
properties: {
|
|
35
|
+
items: import("#src/types.mjs").ListItem[];
|
|
36
|
+
};
|
|
37
|
+
settings: {
|
|
38
|
+
style: "ORDERED" | "UNORDERED";
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
getInlineStyleComponents(): any;
|
|
42
|
+
getEntityRangeComponents(): any;
|
|
43
|
+
/**
|
|
44
|
+
* Splice `newState` in at this list's block index and write it via the
|
|
45
|
+
* shared `updateBlockAt()` (normalizes only this entry, writes through the
|
|
46
|
+
* internal `_setContentState()`) instead of the public `setContent()` —
|
|
47
|
+
* avoids re-normalizing every other block's possibly-stale live state.
|
|
48
|
+
* @param {import('#src/types.mjs').BlockState} newState
|
|
49
|
+
*/
|
|
50
|
+
_commitState(newState: import("#src/types.mjs").BlockState): void;
|
|
51
|
+
_buildItemContent(item: any): DocumentFragment;
|
|
52
|
+
/**
|
|
53
|
+
* Each’s `tagName` is the list root (`ul`/`ol`), not a span inside it.
|
|
54
|
+
* `@esmj/dom` ≥0.3.3 applies `display:contents` only to the default span.
|
|
55
|
+
* @returns {HTMLElement}
|
|
56
|
+
*/
|
|
57
|
+
render(): HTMLElement;
|
|
58
|
+
onKeydown(event: any): void;
|
|
59
|
+
#private;
|
|
60
|
+
}
|
|
61
|
+
import { BlockComponent } from '#src/component/block/BlockComponent.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { List, listPlugin } from "./List.mjs";
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('#src/types.mjs').BlockState} BlockState
|
|
3
|
+
* @typedef {import('#src/types.mjs').ListItem} ListItem
|
|
4
|
+
* @typedef {import('#src/types.mjs').ListBlockState} ListBlockState
|
|
5
|
+
* @typedef {import('#src/types.mjs').RichTextComponents} RichTextComponents
|
|
6
|
+
* @typedef {import('#src/types.mjs').UnwrapListResult} UnwrapListResult
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Map a list root tag to ORDERED / UNORDERED settings.style.
|
|
10
|
+
* @param {Element | null | undefined} node
|
|
11
|
+
* @returns {'ORDERED' | 'UNORDERED' | undefined}
|
|
12
|
+
*/
|
|
13
|
+
export function listStyleFromNode(node: Element | null | undefined): "ORDERED" | "UNORDERED" | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Ensure Each keys stay unique even if CMS/DOM already duplicated ids.
|
|
16
|
+
* @param {ListItem[]} [items]
|
|
17
|
+
* @returns {ListItem[]}
|
|
18
|
+
*/
|
|
19
|
+
export function ensureUniqueListItemIds(items?: ListItem[]): ListItem[];
|
|
20
|
+
/**
|
|
21
|
+
* Collect `<li>` nodes that are items of `listRoot`.
|
|
22
|
+
* List `Each` uses `{ tagName: 'ul' | 'ol' }`, so live items are direct
|
|
23
|
+
* `ul/ol > li`. Nested `<li>` inside an item (native-drag debris) is ignored.
|
|
24
|
+
* @param {Element | null | undefined} listRoot
|
|
25
|
+
* @returns {Element[]}
|
|
26
|
+
*/
|
|
27
|
+
export function directListItemElements(listRoot: Element | null | undefined): Element[];
|
|
28
|
+
/**
|
|
29
|
+
* Character offset of the caret within a single list item.
|
|
30
|
+
* @param {Element} li
|
|
31
|
+
* @param {Range | null} range
|
|
32
|
+
* @returns {number}
|
|
33
|
+
*/
|
|
34
|
+
export function getCursorInListItem(li: Element, range: Range | null): number;
|
|
35
|
+
/**
|
|
36
|
+
* Split a list item state at cursor (item shape, not full block state).
|
|
37
|
+
* @param {ListItem} itemState
|
|
38
|
+
* @param {number} cursor
|
|
39
|
+
* @returns {{ before: ListItem, after: ListItem }}
|
|
40
|
+
*/
|
|
41
|
+
export function splitListItemByCursor(itemState: ListItem, cursor: number): {
|
|
42
|
+
before: ListItem;
|
|
43
|
+
after: ListItem;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Wrap a text-shaped or items-shaped exchange state as a list. Prefers
|
|
47
|
+
* `exchangeState.properties.items` (per-item `text`/`inlineStyleRanges`/
|
|
48
|
+
* `entityRanges`/`depth`) when present, so a List → exchangeState → List
|
|
49
|
+
* round trip (future transform/merge) preserves rich text and nesting
|
|
50
|
+
* losslessly. Falls back to wrapping `properties.text` /
|
|
51
|
+
* `inlineStyleRanges` / `entityRanges` as a single item — used for a plain
|
|
52
|
+
* text block (paragraph/headline) transformed into a list, which has no
|
|
53
|
+
* `items`.
|
|
54
|
+
* @param {BlockState | import('#src/types.mjs').ExchangeBlockState | null | undefined} exchangeState
|
|
55
|
+
* @param {{ style?: 'ORDERED' | 'UNORDERED' }} [options]
|
|
56
|
+
* @returns {ListBlockState}
|
|
57
|
+
*/
|
|
58
|
+
export function wrapTextBlockAsList(exchangeState: BlockState | import("#src/types.mjs").ExchangeBlockState | null | undefined, { style }?: {
|
|
59
|
+
style?: "ORDERED" | "UNORDERED";
|
|
60
|
+
}): ListBlockState;
|
|
61
|
+
/**
|
|
62
|
+
* Lift one list item to a text block, splitting the list around it. When
|
|
63
|
+
* `Constructor` is given, the lifted item's exchange state is passed through
|
|
64
|
+
* `Constructor.fromExchangeState()` (same contract slash's
|
|
65
|
+
* `buildTargetBlockState` uses) so a target block type's own reshaping is
|
|
66
|
+
* honored; omit it (or when the caller has no registry access, e.g. these
|
|
67
|
+
* unit tests) to fall back to the plain text-block shape.
|
|
68
|
+
* @param {ListBlockState} listState
|
|
69
|
+
* @param {number} itemIndex
|
|
70
|
+
* @param {{ namespace?: string, Constructor?: import('#src/types.mjs').BlockConstructor }} [options] target text-block namespace (default paragraph) and its resolved constructor
|
|
71
|
+
* @returns {UnwrapListResult}
|
|
72
|
+
*/
|
|
73
|
+
export function unwrapListItem(listState: ListBlockState, itemIndex: number, { namespace, Constructor }?: {
|
|
74
|
+
namespace?: string;
|
|
75
|
+
Constructor?: import("#src/types.mjs").BlockConstructor;
|
|
76
|
+
}): UnwrapListResult;
|
|
77
|
+
/**
|
|
78
|
+
* @typedef {object} MergeListBlocksResult
|
|
79
|
+
* @property {BlockState[]} content
|
|
80
|
+
* @property {number} listIndex index of the merged list
|
|
81
|
+
* @property {number} cursor caret offset in the last merged item at the join
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* List marker style used for merge compatibility (UL vs OL).
|
|
85
|
+
* @param {BlockState | null | undefined} state
|
|
86
|
+
* @returns {'ORDERED' | 'UNORDERED' | null}
|
|
87
|
+
*/
|
|
88
|
+
export function listBlockStyle(state: BlockState | null | undefined): "ORDERED" | "UNORDERED" | null;
|
|
89
|
+
/**
|
|
90
|
+
* Whether two adjacent list blocks can merge (same list type).
|
|
91
|
+
* @param {BlockState | null | undefined} left
|
|
92
|
+
* @param {BlockState | null | undefined} right
|
|
93
|
+
* @returns {boolean}
|
|
94
|
+
*/
|
|
95
|
+
export function canMergeListBlocks(left: BlockState | null | undefined, right: BlockState | null | undefined): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Append a list block onto the previous list: merge the first item into the
|
|
98
|
+
* last item of the previous list, then append the rest (Notion join).
|
|
99
|
+
* @param {BlockState[]} content
|
|
100
|
+
* @param {number} previousListIndex
|
|
101
|
+
* @param {number} currentListIndex
|
|
102
|
+
* @returns {MergeListBlocksResult | null}
|
|
103
|
+
*/
|
|
104
|
+
export function mergeListBlockIntoPreviousList(content: BlockState[], previousListIndex: number, currentListIndex: number): MergeListBlocksResult | null;
|
|
105
|
+
/**
|
|
106
|
+
* Append an incoming exchange state onto a list's last item (Backspace merge
|
|
107
|
+
* join). Handles two shapes generically via `exchangeState.properties.items`:
|
|
108
|
+
* a flat text block (Paragraph/Headline) produces a single-item exchange
|
|
109
|
+
* state, so only the join happens; a same-style List/TtsList's own
|
|
110
|
+
* `toExchangeState()` produces a multi-item exchange state, so `items[0]`
|
|
111
|
+
* joins the last item and `items.slice(1)` are appended as new list items
|
|
112
|
+
* instead of being flattened away (Notion: re-merging a split list restores
|
|
113
|
+
* every item, not one concatenated line). Does NOT gate on list style —
|
|
114
|
+
* that compatibility check is scenario-specific (only the "empty separator
|
|
115
|
+
* between two lists" Backspace re-merge cares whether mixing ORDERED/
|
|
116
|
+
* UNORDERED is acceptable) and lives in the caller that owns that scenario
|
|
117
|
+
* (`onBackspaceMergeAdjacentLists` in `List.mjs`, via `canMergeListBlocks`),
|
|
118
|
+
* not in this generic append primitive — a future caller (e.g. a
|
|
119
|
+
* user-triggered "merge into" action) may legitimately want to merge across
|
|
120
|
+
* styles. Pure state transform — no content-array indexing/splicing; the
|
|
121
|
+
* caller (`List.appendExchangeState`, itself called generically by
|
|
122
|
+
* default's `onMergeBlockElement` and the empty-block-removal Backspace
|
|
123
|
+
* path) owns array mutation. Returns `null` when the list has no items to
|
|
124
|
+
* append onto. The result's `itemIndex` names the joined item — needed
|
|
125
|
+
* because when extra items are appended, the joined item is no longer the
|
|
126
|
+
* list's last item, and `List.setCursor({ cursor })` alone can only target
|
|
127
|
+
* the last one.
|
|
128
|
+
* @param {ListBlockState} listState
|
|
129
|
+
* @param {import('#src/types.mjs').ExchangeBlockState} exchangeState
|
|
130
|
+
* @returns {{ state: ListBlockState, cursor: number, itemIndex: number } | null}
|
|
131
|
+
*/
|
|
132
|
+
export function mergeTextBlockIntoLastListItem(listState: ListBlockState, exchangeState: import("#src/types.mjs").ExchangeBlockState): {
|
|
133
|
+
state: ListBlockState;
|
|
134
|
+
cursor: number;
|
|
135
|
+
itemIndex: number;
|
|
136
|
+
} | null;
|
|
137
|
+
/**
|
|
138
|
+
* Build rich-text DOM fragment for one list item.
|
|
139
|
+
* @param {ListItem} item
|
|
140
|
+
* @param {RichTextComponents} components
|
|
141
|
+
* @returns {DocumentFragment}
|
|
142
|
+
*/
|
|
143
|
+
export function buildListItemContent(item: ListItem, components: RichTextComponents): DocumentFragment;
|
|
144
|
+
/**
|
|
145
|
+
* Parse one <li> into a list item state object.
|
|
146
|
+
* @param {Element} li
|
|
147
|
+
* @param {RichTextComponents} components
|
|
148
|
+
* @returns {ListItem}
|
|
149
|
+
*/
|
|
150
|
+
export function parseListItemFromHTML(li: Element, components: RichTextComponents): ListItem;
|
|
151
|
+
export type BlockState = import("#src/types.mjs").BlockState;
|
|
152
|
+
export type ListItem = import("#src/types.mjs").ListItem;
|
|
153
|
+
export type ListBlockState = import("#src/types.mjs").ListBlockState;
|
|
154
|
+
export type RichTextComponents = import("#src/types.mjs").RichTextComponents;
|
|
155
|
+
export type UnwrapListResult = import("#src/types.mjs").UnwrapListResult;
|
|
156
|
+
export type MergeListBlocksResult = {
|
|
157
|
+
content: BlockState[];
|
|
158
|
+
/**
|
|
159
|
+
* index of the merged list
|
|
160
|
+
*/
|
|
161
|
+
listIndex: number;
|
|
162
|
+
/**
|
|
163
|
+
* caret offset in the last merged item at the join
|
|
164
|
+
*/
|
|
165
|
+
cursor: number;
|
|
166
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating shared menu overlay (insert + slash).
|
|
3
|
+
* @param {{
|
|
4
|
+
* open: import('#src/types.mjs').Signal<boolean>,
|
|
5
|
+
* positionX: import('#src/types.mjs').Signal<number>,
|
|
6
|
+
* positionY: import('#src/types.mjs').Signal<number>,
|
|
7
|
+
* entries: import('#src/types.mjs').Signal<import('#src/types.mjs').BlockComponentRegistration[]>,
|
|
8
|
+
* highlightIndex: import('#src/types.mjs').Signal<number>,
|
|
9
|
+
* ariaLabel: import('#src/types.mjs').Signal<string>,
|
|
10
|
+
* menuRef: import('#src/types.mjs').ElementRef,
|
|
11
|
+
* }} props
|
|
12
|
+
* @returns {*}
|
|
13
|
+
*/
|
|
14
|
+
export function Menu({ open, positionX, positionY, entries, highlightIndex, ariaLabel, menuRef, }: {
|
|
15
|
+
open: import("#src/types.mjs").Signal<boolean>;
|
|
16
|
+
positionX: import("#src/types.mjs").Signal<number>;
|
|
17
|
+
positionY: import("#src/types.mjs").Signal<number>;
|
|
18
|
+
entries: import("#src/types.mjs").Signal<import("#src/types.mjs").BlockComponentRegistration[]>;
|
|
19
|
+
highlightIndex: import("#src/types.mjs").Signal<number>;
|
|
20
|
+
ariaLabel: import("#src/types.mjs").Signal<string>;
|
|
21
|
+
menuRef: import("#src/types.mjs").ElementRef;
|
|
22
|
+
}): any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared floating menu overlay (used by insert + slash plugins).
|
|
3
|
+
* @param {import('#src/types.mjs').PluginContext} options
|
|
4
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
5
|
+
*/
|
|
6
|
+
export function menuPlugin({ mrakomor }: import("#src/types.mjs").PluginContext): import("#src/types.mjs").Plugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the paragraph block type.
|
|
3
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
4
|
+
*/
|
|
5
|
+
export function paragraphPlugin(): import("#src/types.mjs").Plugin;
|
|
6
|
+
export class Paragraph extends BlockComponent {
|
|
7
|
+
static get LABEL(): string;
|
|
8
|
+
static getStateSchema(node: any): any;
|
|
9
|
+
getInlineStyleComponents(): any;
|
|
10
|
+
getEntityRangeComponents(): any;
|
|
11
|
+
parseFromHTML(node: any): import("#src/types.mjs").RichTextState;
|
|
12
|
+
_buildContent(state: any): DocumentFragment;
|
|
13
|
+
render(): any;
|
|
14
|
+
onKeydown(event: any): void;
|
|
15
|
+
}
|
|
16
|
+
import { BlockComponent } from '#src/component/block/BlockComponent.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Paragraph, paragraphPlugin } from "./Paragraph.mjs";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-block slash command register (`handler(ctx)` rows).
|
|
3
|
+
*/
|
|
4
|
+
export class SlashActionRegister extends Register {
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('#src/types.mjs').SlashActionRegistration} raw
|
|
7
|
+
* @param {number} index
|
|
8
|
+
* @returns {import('#src/types.mjs').SlashActionRegistration | null}
|
|
9
|
+
*/
|
|
10
|
+
normalize(raw: import("#src/types.mjs").SlashActionRegistration, index: number): import("#src/types.mjs").SlashActionRegistration | null;
|
|
11
|
+
}
|
|
12
|
+
import Register from '#src/register/Register.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { slashCommandPlugin } from "./slashCommandPlugin.mjs";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive bare slash action register id from label or fallback.
|
|
3
|
+
* @param {string | undefined} label
|
|
4
|
+
* @param {string | number} fallback
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function slashActionSlug(label: string | undefined, fallback: string | number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Derive stable slash action register id (bare slug).
|
|
10
|
+
* @param {object} input
|
|
11
|
+
* @param {string} [input.id]
|
|
12
|
+
* @param {string} [input.label]
|
|
13
|
+
* @param {string | number} [input.fallback]
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function slashActionRegistrationId({ id, label, fallback }: {
|
|
17
|
+
id?: string | undefined;
|
|
18
|
+
label?: string | undefined;
|
|
19
|
+
fallback?: string | number | undefined;
|
|
20
|
+
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* Parse one slash action register entry.
|
|
23
|
+
* @param {import('#src/types.mjs').SlashActionRegistration} entry
|
|
24
|
+
* @param {number} index
|
|
25
|
+
* @returns {import('#src/types.mjs').SlashActionRegistration}
|
|
26
|
+
*/
|
|
27
|
+
export function parseSlashActionRegistration(entry: import("#src/types.mjs").SlashActionRegistration, index?: number): import("#src/types.mjs").SlashActionRegistration;
|
|
28
|
+
/** @type {import('@esmj/schema').SchemaType<import('#src/types.mjs').SlashActionRegistration>} */
|
|
29
|
+
export const slashActionRegistrationRowSchema: import("@esmj/schema").SchemaType<import("#src/types.mjs").SlashActionRegistration>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot the block at `/` from live DOM (`_getBlockElementState` / stale `getState()`).
|
|
3
|
+
* Does not write `#content` — avoids re-render and caret loss while query chars stay DOM-only.
|
|
4
|
+
* @param {import('#src/types.mjs').Mrakomor} mrakomor
|
|
5
|
+
* @param {Element} blockElement
|
|
6
|
+
* @returns {import('#src/types.mjs').BlockState | null}
|
|
7
|
+
*/
|
|
8
|
+
export function storeSlashBaseline(mrakomor: import("#src/types.mjs").Mrakomor, blockElement: Element): import("#src/types.mjs").BlockState | null;
|
|
9
|
+
/**
|
|
10
|
+
* Whether `/` may open a slash session after this character (start or whitespace).
|
|
11
|
+
* @param {string | null | undefined} prevChar
|
|
12
|
+
* @returns {boolean}
|
|
13
|
+
*/
|
|
14
|
+
export function canOpenSlashAt(prevChar: string | null | undefined): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If the cursor sits inside a slash token, return its span and query.
|
|
17
|
+
* @param {string} text
|
|
18
|
+
* @param {number} cursorOffset
|
|
19
|
+
* @returns {{ slashStart: number, slashEnd: number, query: string } | null}
|
|
20
|
+
*/
|
|
21
|
+
export function parseSlashToken(text: string, cursorOffset: number): {
|
|
22
|
+
slashStart: number;
|
|
23
|
+
slashEnd: number;
|
|
24
|
+
query: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* Apply an input delta to an open slash session.
|
|
28
|
+
* @param {import('#src/types.mjs').SlashSession} session
|
|
29
|
+
* @param {{ inputType?: string, data?: string | null }} event
|
|
30
|
+
* @returns {import('#src/types.mjs').SlashSession | null}
|
|
31
|
+
*/
|
|
32
|
+
export function applyInputToSession(session: import("#src/types.mjs").SlashSession, event: {
|
|
33
|
+
inputType?: string;
|
|
34
|
+
data?: string | null;
|
|
35
|
+
}): import("#src/types.mjs").SlashSession | null;
|
|
36
|
+
/**
|
|
37
|
+
* Whether a slash menu entry is a non-block action (`handler`).
|
|
38
|
+
* @param {import('#src/types.mjs').SlashMenuEntry | null | undefined} entry
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export function isSlashAction(entry: import("#src/types.mjs").SlashMenuEntry | null | undefined): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Filter registrations by case-insensitive substring on label and keywords.
|
|
44
|
+
* @param {import('#src/types.mjs').SlashMenuEntry[]} entries
|
|
45
|
+
* @param {string} query
|
|
46
|
+
* @returns {import('#src/types.mjs').SlashMenuEntry[]}
|
|
47
|
+
*/
|
|
48
|
+
export function filterEntries(entries: import("#src/types.mjs").SlashMenuEntry[], query: string): import("#src/types.mjs").SlashMenuEntry[];
|
|
49
|
+
/**
|
|
50
|
+
* Build a normalized target block state for a slash registration. Converts
|
|
51
|
+
* the current text through `Constructor.fromExchangeState()` so block-type-
|
|
52
|
+
* specific shaping (e.g. List wrapping text into a one-item list) stays
|
|
53
|
+
* owned by the target component, not by slash.
|
|
54
|
+
* @param {import('#src/types.mjs').BlockComponentRegistration} registration
|
|
55
|
+
* @param {import('#src/types.mjs').BlockState | null} [afterState]
|
|
56
|
+
* @returns {import('#src/types.mjs').BlockState | null}
|
|
57
|
+
*/
|
|
58
|
+
export function buildTargetBlockState(registration: import("#src/types.mjs").BlockComponentRegistration, afterState?: import("#src/types.mjs").BlockState | null): import("#src/types.mjs").BlockState | null;
|
|
59
|
+
/**
|
|
60
|
+
* Run a non-block slash action: strip `/query`, replace block, then handler.
|
|
61
|
+
* @param {import('#src/types.mjs').SlashCommandContext} ctx
|
|
62
|
+
* @param {import('#src/types.mjs').SlashActionRegistration} registration
|
|
63
|
+
*/
|
|
64
|
+
export function applySlashActionCommand(ctx: import("#src/types.mjs").SlashCommandContext, registration: import("#src/types.mjs").SlashActionRegistration): void;
|
|
65
|
+
/**
|
|
66
|
+
* Restore baseline text, then replace or insert the target block.
|
|
67
|
+
* @param {import('#src/types.mjs').SlashCommandContext} ctx
|
|
68
|
+
* @param {import('#src/types.mjs').BlockComponentRegistration} registration
|
|
69
|
+
*/
|
|
70
|
+
export function applyBlockSlashCommand(ctx: import("#src/types.mjs").SlashCommandContext, registration: import("#src/types.mjs").BlockComponentRegistration): void;
|
|
71
|
+
/**
|
|
72
|
+
* Build slash context from the active session.
|
|
73
|
+
* @param {import('#src/types.mjs').Mrakomor} mrakomor
|
|
74
|
+
* @param {import('#src/types.mjs').SlashSession} session
|
|
75
|
+
* @returns {import('#src/types.mjs').SlashCommandContext}
|
|
76
|
+
*/
|
|
77
|
+
export function buildSlashContext(mrakomor: import("#src/types.mjs").Mrakomor, session: import("#src/types.mjs").SlashSession): import("#src/types.mjs").SlashCommandContext;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notion-style `/` command palette — drives the shared menuPlugin.
|
|
3
|
+
*
|
|
4
|
+
* 1. `/` INPUT — store baseline (`_getBlockElementState` clone, no re-render), open menu.
|
|
5
|
+
* 2. Query chars — session offsets only; query stays DOM-only.
|
|
6
|
+
* 3. Enter — strip `/query` from baseline, apply block or action.
|
|
7
|
+
*
|
|
8
|
+
* @param {import('#src/types.mjs').PluginContext} options
|
|
9
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
10
|
+
*/
|
|
11
|
+
export function slashCommandPlugin({ mrakomor }: import("#src/types.mjs").PluginContext): import("#src/types.mjs").Plugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash command token shown in help for an action (`/help`, …).
|
|
3
|
+
* @param {import('#src/types.mjs').SlashActionRegistration} action
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function slashActionHelpCommand(action: import("#src/types.mjs").SlashActionRegistration): string;
|
|
7
|
+
/**
|
|
8
|
+
* Map a normalized slash action to a help register row.
|
|
9
|
+
* @param {import('#src/types.mjs').SlashActionRegistration} action
|
|
10
|
+
* @returns {import('#src/types.mjs').HelpEntry}
|
|
11
|
+
*/
|
|
12
|
+
export function helpEntryFromSlashAction(action: import("#src/types.mjs").SlashActionRegistration): import("#src/types.mjs").HelpEntry;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating selection tooltip.
|
|
3
|
+
* @param {{ mrakomor: import('#src/types.mjs').Mrakomor, open: import('#src/types.mjs').Signal<boolean>, tooltipElement: import('#src/types.mjs').ElementRef }} props
|
|
4
|
+
* @returns {*}
|
|
5
|
+
*/
|
|
6
|
+
export function Tooltip({ mrakomor, open, tooltipElement }: {
|
|
7
|
+
mrakomor: import("#src/types.mjs").Mrakomor;
|
|
8
|
+
open: import("#src/types.mjs").Signal<boolean>;
|
|
9
|
+
tooltipElement: import("#src/types.mjs").ElementRef;
|
|
10
|
+
}): any;
|
|
11
|
+
/**
|
|
12
|
+
* Selection-driven formatting tooltip.
|
|
13
|
+
* @param {import('#src/types.mjs').PluginContext} options
|
|
14
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
15
|
+
*/
|
|
16
|
+
export function tooltipPlugin({ mrakomor }: import("#src/types.mjs").PluginContext): import("#src/types.mjs").Plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tooltip, tooltipPlugin } from "./Tooltip.mjs";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers TTS headline blocks (voice entity ranges on H1–H5).
|
|
3
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
4
|
+
*/
|
|
5
|
+
export function ttsHeadlinePlugin(): import("#src/types.mjs").Plugin;
|
|
6
|
+
export class TtsHeadlineComponent extends HeadlineComponent {
|
|
7
|
+
getInlineStyleComponents(): never[];
|
|
8
|
+
getEntityRangeComponents(): any;
|
|
9
|
+
parseFromHTML(node: any): import("#src/types.mjs").RichTextState;
|
|
10
|
+
_buildContent(state: any): DocumentFragment;
|
|
11
|
+
}
|
|
12
|
+
export class TtsHeadline1 extends TtsHeadlineComponent {
|
|
13
|
+
static get LABEL(): string;
|
|
14
|
+
}
|
|
15
|
+
export class TtsHeadline2 extends TtsHeadlineComponent {
|
|
16
|
+
static get LABEL(): string;
|
|
17
|
+
}
|
|
18
|
+
export class TtsHeadline3 extends TtsHeadlineComponent {
|
|
19
|
+
static get LABEL(): string;
|
|
20
|
+
}
|
|
21
|
+
export class TtsHeadline4 extends TtsHeadlineComponent {
|
|
22
|
+
static get LABEL(): string;
|
|
23
|
+
}
|
|
24
|
+
export class TtsHeadline5 extends TtsHeadlineComponent {
|
|
25
|
+
static get LABEL(): string;
|
|
26
|
+
}
|
|
27
|
+
import { HeadlineComponent } from '#src/plugin/headline/Headline.mjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the TTS list block (voice ranges on items, no inline styles).
|
|
3
|
+
* Use instead of `listPlugin` for TTS editor presets.
|
|
4
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
5
|
+
*/
|
|
6
|
+
export function ttsListPlugin(): import("#src/types.mjs").Plugin;
|
|
7
|
+
/**
|
|
8
|
+
* List block for TTS: same namespace/behavior as {@link List}, but items keep
|
|
9
|
+
* only `atom.tts.Voice` entity ranges and drop inline styles.
|
|
10
|
+
*/
|
|
11
|
+
export class TtsList extends List {
|
|
12
|
+
getInlineStyleComponents(): never[];
|
|
13
|
+
/**
|
|
14
|
+
* @param {Element | null | undefined} node
|
|
15
|
+
* @returns {import('#src/types.mjs').ListBlockState}
|
|
16
|
+
*/
|
|
17
|
+
parseFromHTML(node: Element | null | undefined): import("#src/types.mjs").ListBlockState;
|
|
18
|
+
}
|
|
19
|
+
import { List } from '#src/plugin/list/List.mjs';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the TTS paragraph (voice ranges only, no inline styles).
|
|
3
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
4
|
+
*/
|
|
5
|
+
export function ttsParagraphPlugin(): import("#src/types.mjs").Plugin;
|
|
6
|
+
export class TtsParagraph extends Paragraph {
|
|
7
|
+
getInlineStyleComponents(): never[];
|
|
8
|
+
}
|
|
9
|
+
import { Paragraph } from '#src/plugin/paragraph/Paragraph.mjs';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voice metadata for a TTS id, or the first voice if unknown.
|
|
3
|
+
* @param {string} voiceId
|
|
4
|
+
* @returns {{ id: string, label: string, gender: string, color: string }}
|
|
5
|
+
*/
|
|
6
|
+
export function getVoice(voiceId: string): {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
gender: string;
|
|
10
|
+
color: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Distinct accent color for a TTS voice id. Falls back to a hash-derived
|
|
14
|
+
* hue for ids not present in {@link VOICES} so future/unknown voices still
|
|
15
|
+
* get a stable, distinct color instead of sharing one default.
|
|
16
|
+
* @param {string} voiceId
|
|
17
|
+
* @returns {string} CSS color value
|
|
18
|
+
*/
|
|
19
|
+
export function getVoiceColor(voiceId: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Registers the TTS voice entity range.
|
|
22
|
+
* @returns {import('#src/types.mjs').Plugin}
|
|
23
|
+
*/
|
|
24
|
+
export function ttsVoicePlugin(): import("#src/types.mjs").Plugin;
|
|
25
|
+
export const VOICES: {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
gender: string;
|
|
29
|
+
color: string;
|
|
30
|
+
}[];
|
|
31
|
+
export class TtsVoice extends EntityRangeElement {
|
|
32
|
+
static get LABEL(): string;
|
|
33
|
+
static getStateSchema(node: any): import("@esmj/schema").SchemaInterface<{
|
|
34
|
+
entity: {
|
|
35
|
+
type: string;
|
|
36
|
+
data: unknown;
|
|
37
|
+
};
|
|
38
|
+
length: number;
|
|
39
|
+
offset: number;
|
|
40
|
+
}, {
|
|
41
|
+
entity: {
|
|
42
|
+
type: string;
|
|
43
|
+
data: unknown;
|
|
44
|
+
};
|
|
45
|
+
length: number;
|
|
46
|
+
offset: number;
|
|
47
|
+
}>;
|
|
48
|
+
onMount(): void;
|
|
49
|
+
onUnmount(): void;
|
|
50
|
+
#private;
|
|
51
|
+
}
|
|
52
|
+
import { EntityRangeElement } from '../../component/entityRange/EntityRangeElement.mjs';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { TtsHeadlineComponent, ttsHeadlinePlugin } from "./TtsHeadline.mjs";
|
|
2
|
+
export { TtsList, ttsListPlugin } from "./TtsList.mjs";
|
|
3
|
+
export { TtsParagraph, ttsParagraphPlugin } from "./TtsParagraph.mjs";
|
|
4
|
+
export { getVoice, TtsVoice, ttsVoicePlugin, VOICES } from "./TtsVoice.mjs";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map-backed register: normalize on `add`, sorted `list()`, {@link Observable} on change.
|
|
3
|
+
* Subclasses implement {@link Register.normalize}.
|
|
4
|
+
*/
|
|
5
|
+
export class Register {
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('#src/types.mjs').Mrakomor} mrakomor
|
|
8
|
+
* @param {object} [options]
|
|
9
|
+
* @param {function(*[]): *[]} [options.sort]
|
|
10
|
+
*/
|
|
11
|
+
constructor(mrakomor: import("#src/types.mjs").Mrakomor, options?: {
|
|
12
|
+
sort?: ((arg0: any[]) => any[]) | undefined;
|
|
13
|
+
});
|
|
14
|
+
/** @type {import('#src/types.mjs').Mrakomor} */
|
|
15
|
+
mrakomor: import("#src/types.mjs").Mrakomor;
|
|
16
|
+
/**
|
|
17
|
+
* Parse one raw row for storage. Return `null` to skip invalid input.
|
|
18
|
+
* @param {*} _raw
|
|
19
|
+
* @param {number} _index
|
|
20
|
+
* @returns {*|null}
|
|
21
|
+
*/
|
|
22
|
+
normalize(_raw: any, _index: number): any | null;
|
|
23
|
+
/**
|
|
24
|
+
* Normalize and upsert one or many entries by id.
|
|
25
|
+
* @param {*|*[]} raw
|
|
26
|
+
* @returns {*|null|*[]}
|
|
27
|
+
*/
|
|
28
|
+
add(raw: any | any[]): any | null | any[];
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} id
|
|
31
|
+
* @returns {*|undefined}
|
|
32
|
+
*/
|
|
33
|
+
get(id: string): any | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} id
|
|
36
|
+
* @returns {boolean}
|
|
37
|
+
*/
|
|
38
|
+
has(id: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} id
|
|
41
|
+
* @returns {boolean}
|
|
42
|
+
*/
|
|
43
|
+
remove(id: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @returns {*[]}
|
|
46
|
+
*/
|
|
47
|
+
list(): any[];
|
|
48
|
+
#private;
|
|
49
|
+
}
|
|
50
|
+
export { Register as default };
|