@mikedown/core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +121 -2
- package/dist/ai/engines-page.d.ts +137 -0
- package/dist/ai/engines-page.js +11 -0
- package/dist/ai/engines-page.js.map +1 -0
- package/dist/ai/index.d.ts +2722 -0
- package/dist/ai/index.js +684 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai-ui-QFYFN73D.js +6397 -0
- package/dist/ai-ui-QFYFN73D.js.map +1 -0
- package/dist/chunk-APPBNQEY.js +216 -0
- package/dist/chunk-APPBNQEY.js.map +1 -0
- package/dist/chunk-DWXGWVA3.js +5748 -0
- package/dist/chunk-DWXGWVA3.js.map +1 -0
- package/dist/chunk-GWCRPPCX.js +18 -0
- package/dist/chunk-GWCRPPCX.js.map +1 -0
- package/dist/chunk-IWCXWUWW.js +6958 -0
- package/dist/chunk-IWCXWUWW.js.map +1 -0
- package/dist/chunk-L4FO63DF.js +113 -0
- package/dist/chunk-L4FO63DF.js.map +1 -0
- package/dist/chunk-N4N54LK2.js +39 -0
- package/dist/chunk-N4N54LK2.js.map +1 -0
- package/dist/chunk-QWKT57TR.js +62 -0
- package/dist/chunk-QWKT57TR.js.map +1 -0
- package/dist/chunk-TSP7BAV3.js +22 -0
- package/dist/chunk-TSP7BAV3.js.map +1 -0
- package/dist/index.d.ts +19 -463
- package/dist/index.js +7717 -2103
- package/dist/index.js.map +1 -1
- package/dist/schema-DVfssxQX.d.ts +100 -0
- package/dist/shared/anchoring.js +4 -16
- package/dist/shared/anchoring.js.map +1 -1
- package/dist/shared/imagePaste.js +3 -57
- package/dist/shared/imagePaste.js.map +1 -1
- package/dist/shared/sha1.js +3 -57
- package/dist/shared/sha1.js.map +1 -1
- package/dist/shared/wordCount.js +4 -12
- package/dist/shared/wordCount.js.map +1 -1
- package/dist/styles.css +4562 -108
- package/dist/types-2TZErbJr.d.ts +619 -0
- package/dist/types-DO8UBybZ.d.ts +741 -0
- package/package.json +11 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,470 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as MikeDownOptions, b as MikeDownEditorHandle, c as MikeDownHost } from './types-2TZErbJr.js';
|
|
2
|
+
export { B as BacklinkItem, D as DEFAULT_FEATURES, d as DEFAULT_TOOLBAR_LAYOUT, e as DiffBaseline, I as ImageInsertResult, f as ImagePathMapping, g as ImageResizeRequest, h as ImageResizeResult, i as ImageUploadRequest, L as LinkCheckRequest, j as LinkOpenBehavior, k as LinkSuggestion, l as MikeDownCommand, m as MikeDownEvent, n as MikeDownFeatures, o as MikeDownSettings, p as MikeDownSettingsPatch, q as MikeDownSettingsSection, r as MikeDownSettingsSectionBuild, M as MikeDownSettingsSectionContext, s as MikeDownSidebarPrefs, t as MikeDownStats, u as MikeDownViewState, N as NoopHost, v as NormalizationStyle, S as SidebarFooterLink, w as SidebarStateUpdate, T as TagCount, x as ToolbarLayout, W as WikilinkResolution, y as normalizeToolbarLayout } from './types-2TZErbJr.js';
|
|
3
|
+
export { r as AiCompletionRequest, q as AiCompletionResult, a as AiEngineStatus, t as AiError, p as AiErrorCode, s as AiMessage, aa as AiMessagePart, ad as AiServedBy, A as AiSettings, M as MikeDownAiHost } from './types-DO8UBybZ.js';
|
|
4
|
+
import '@tiptap/core';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
7
|
+
* Toolbar item ids, the default order and the pinned/removable table.
|
|
5
8
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Rules (see core-extraction-decisions.md section 5):
|
|
12
|
-
*
|
|
13
|
-
* - `onChange` is the only required method.
|
|
14
|
-
* - Every other method is optional. An absent method turns its feature off
|
|
15
|
-
* and hides its UI (toolbar button, slash command, sidebar section,
|
|
16
|
-
* settings control).
|
|
17
|
-
* - Request/response pairs are Promise-returning methods. Correlation ids,
|
|
18
|
-
* retries and transport details stay inside the host implementation.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/** How a link should open. Absent means the host's default. */
|
|
22
|
-
type LinkOpenBehavior = 'navigateCurrentTab' | 'openNewTab';
|
|
23
|
-
/** A link target offered by the link dialog autocomplete. */
|
|
24
|
-
interface LinkSuggestion {
|
|
25
|
-
label: string;
|
|
26
|
-
href: string;
|
|
27
|
-
type: 'file' | 'anchor' | 'inDoc' | 'external';
|
|
28
|
-
/** Heading level (1-6) for anchor items, used for hierarchical indentation. */
|
|
29
|
-
level?: number;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Result of resolving one `[[wikilink]]` target. `href` is null when no
|
|
33
|
-
* document matches. `count` is how many documents share the name: 0 means
|
|
34
|
-
* unresolved, 1 unique, more than 1 ambiguous (the host picked the nearest).
|
|
35
|
-
*/
|
|
36
|
-
interface WikilinkResolution {
|
|
37
|
-
target: string;
|
|
38
|
-
href: string | null;
|
|
39
|
-
count?: number;
|
|
40
|
-
}
|
|
41
|
-
/** One workspace tag with the number of documents that carry it. */
|
|
42
|
-
interface TagCount {
|
|
43
|
-
tag: string;
|
|
44
|
-
count: number;
|
|
45
|
-
}
|
|
46
|
-
/** A backlink to the current document, rendered in the sidebar. */
|
|
47
|
-
interface BacklinkItem {
|
|
48
|
-
uri: string;
|
|
49
|
-
displayPath: string;
|
|
50
|
-
line: number;
|
|
51
|
-
lineText?: string;
|
|
52
|
-
/** Href of the link in the source doc, so the opened doc can scroll to it. */
|
|
53
|
-
linkHref?: string;
|
|
54
|
-
/** Which occurrence of linkHref this is (0-based). */
|
|
55
|
-
occurrence?: number;
|
|
56
|
-
}
|
|
57
|
-
/** Image bytes from a paste or drop. */
|
|
58
|
-
interface ImageUploadRequest {
|
|
59
|
-
mime: string;
|
|
60
|
-
bytes: Uint8Array;
|
|
61
|
-
name?: string;
|
|
62
|
-
}
|
|
63
|
-
/** Where an uploaded or picked image lives, as the editor should render it. */
|
|
64
|
-
interface ImageInsertResult {
|
|
65
|
-
src: string;
|
|
66
|
-
alt?: string;
|
|
67
|
-
}
|
|
68
|
-
/** A downscaled copy of an image already in the document. */
|
|
69
|
-
interface ImageResizeRequest {
|
|
70
|
-
/** The image's current `src` attribute. */
|
|
71
|
-
currentSrc: string;
|
|
72
|
-
mime: string;
|
|
73
|
-
bytes: Uint8Array;
|
|
74
|
-
/** Percentage of the natural size (1 to 200). */
|
|
75
|
-
percent: number;
|
|
76
|
-
}
|
|
77
|
-
interface ImageResizeResult {
|
|
78
|
-
/** The `src` to render the resized image from. */
|
|
79
|
-
src: string;
|
|
80
|
-
/** True when the original file was replaced (the editor cache-busts the src). */
|
|
81
|
-
overwritten: boolean;
|
|
82
|
-
}
|
|
83
|
-
/** A link the editor asks the host to validate. */
|
|
84
|
-
interface LinkCheckRequest {
|
|
85
|
-
href: string;
|
|
86
|
-
type: 'anchor' | 'file' | 'fileAnchor';
|
|
87
|
-
}
|
|
88
|
-
/** The committed version of the document, for change highlighting. */
|
|
89
|
-
interface DiffBaseline {
|
|
90
|
-
headContent: string | null;
|
|
91
|
-
hasChanges: boolean;
|
|
92
|
-
}
|
|
93
|
-
/** Status-bar style statistics. Either field may be present. */
|
|
94
|
-
interface MikeDownStats {
|
|
95
|
-
/** Full plain text of the document (for word count and reading time). */
|
|
96
|
-
document?: string;
|
|
97
|
-
/** Selection size, or null when nothing is selected. */
|
|
98
|
-
selection?: {
|
|
99
|
-
words: number;
|
|
100
|
-
chars: number;
|
|
101
|
-
} | null;
|
|
102
|
-
}
|
|
103
|
-
/** Sidebar preference persistence. Absent means in-memory defaults. */
|
|
104
|
-
interface MikeDownSidebarPrefs {
|
|
105
|
-
/** Ask for the persisted sidebar state; the host answers with `handle.setSidebarState`. */
|
|
106
|
-
requestState(): void;
|
|
107
|
-
/** The pin toggle changed the default visibility for new documents. */
|
|
108
|
-
setPref(pref: 'always' | 'never'): void;
|
|
109
|
-
/** "Apply to open documents" in Settings. */
|
|
110
|
-
applyDefaults(): void;
|
|
111
|
-
/** A sidebar section was collapsed or expanded by the user. */
|
|
112
|
-
sectionCollapsed(section: string, collapsed: boolean): void;
|
|
113
|
-
}
|
|
114
|
-
interface MikeDownHost {
|
|
115
|
-
/**
|
|
116
|
-
* The document changed. `pristine` is true when the content matches the
|
|
117
|
-
* last load or save exactly (the user undid every change), in which case
|
|
118
|
-
* `markdown` is the original text byte for byte.
|
|
119
|
-
*/
|
|
120
|
-
onChange(markdown: string, meta: {
|
|
121
|
-
pristine: boolean;
|
|
122
|
-
}): void;
|
|
123
|
-
/** Word count and selection statistics. */
|
|
124
|
-
onStats?(stats: MikeDownStats): void;
|
|
125
|
-
/**
|
|
126
|
-
* Open a link. Absent means external links open in a new browser tab and
|
|
127
|
-
* relative links are ignored. `reveal` asks the target document to scroll
|
|
128
|
-
* to a link back to this one (sidebar backlinks).
|
|
129
|
-
*/
|
|
130
|
-
openLink?(href: string, behavior?: LinkOpenBehavior, reveal?: {
|
|
131
|
-
href?: string;
|
|
132
|
-
occurrence?: number;
|
|
133
|
-
}): void;
|
|
134
|
-
/**
|
|
135
|
-
* Persist settings. Absent means changes made in the Settings modal last
|
|
136
|
-
* for the session only. `source: 'slashMenu'` marks the slash menu's
|
|
137
|
-
* "Turn off slash commands" row; `silent` marks background saves (wheel
|
|
138
|
-
* zoom, Add to Dictionary) that should not show a confirmation.
|
|
139
|
-
*/
|
|
140
|
-
saveSettings?(patch: MikeDownSettingsPatch, opts?: {
|
|
141
|
-
source?: 'slashMenu';
|
|
142
|
-
silent?: boolean;
|
|
143
|
-
}): void;
|
|
144
|
-
/** Flip light and dark. Absent means the editor flips its own theme. */
|
|
145
|
-
toggleTheme?(): void;
|
|
146
|
-
/** "Customize" button on the Hotkeys settings tab. Hidden when absent. */
|
|
147
|
-
openKeybindings?(): void;
|
|
148
|
-
/** Store pasted or dropped image bytes. Absent disables image paste and drop. */
|
|
149
|
-
uploadImage?(file: ImageUploadRequest): Promise<ImageInsertResult>;
|
|
150
|
-
/** Native file picker. Resolves null when cancelled. Absent hides `/image`. */
|
|
151
|
-
pickImage?(): Promise<ImageInsertResult | null>;
|
|
152
|
-
/** Save a resized copy of an image. Absent hides the resize menu items. */
|
|
153
|
-
resizeImage?(req: ImageResizeRequest): Promise<ImageResizeResult>;
|
|
154
|
-
/**
|
|
155
|
-
* Image source policy. The core renders `http:`, `https:`, `data:` and
|
|
156
|
-
* `blob:` sources as they are. For any other source (a relative or
|
|
157
|
-
* absolute path) it calls this and renders the non-null result. Absent, or
|
|
158
|
-
* returning null, the image shows the missing-image placeholder with the raw
|
|
159
|
-
* path. Only the rendered `<img src>` changes; the stored `src`, and so the
|
|
160
|
-
* markdown, is never rewritten.
|
|
161
|
-
*/
|
|
162
|
-
resolveImageSrc?(src: string): string | null;
|
|
163
|
-
/** Files and anchors for link autocomplete and `[[` wikilink autocomplete. */
|
|
164
|
-
getLinkSuggestions?(): Promise<LinkSuggestion[]>;
|
|
165
|
-
/** Heading anchors of another document, for `file.md#` completion. */
|
|
166
|
-
getFileHeadings?(path: string): Promise<LinkSuggestion[]>;
|
|
167
|
-
/** Resolve `[[wikilink]]` targets to hrefs. */
|
|
168
|
-
resolveWikilinks?(targets: string[]): Promise<WikilinkResolution[]>;
|
|
169
|
-
/**
|
|
170
|
-
* Cmd/Ctrl+click on an unresolved wikilink (only when the
|
|
171
|
-
* `wikilinkCreateOnClick` setting is on). May resolve with the new
|
|
172
|
-
* resolution so the link lights up without a reload.
|
|
173
|
-
*/
|
|
174
|
-
createWikilink?(target: string): Promise<WikilinkResolution[] | void> | void;
|
|
175
|
-
/** Validate relative links. Resolves with the hrefs that are broken. */
|
|
176
|
-
checkLinks?(links: LinkCheckRequest[]): Promise<string[]>;
|
|
177
|
-
/** Workspace tag index. Also enables the sidebar Tags section and `#` autocomplete. */
|
|
178
|
-
getTags?(): Promise<TagCount[]>;
|
|
179
|
-
/** Tag click (sidebar or Cmd/Ctrl+click in the document). */
|
|
180
|
-
openTag?(tag: string): void;
|
|
181
|
-
/** Committed version of the document for change highlighting. */
|
|
182
|
-
getDiffBaseline?(): Promise<DiffBaseline>;
|
|
183
|
-
/** A heading's anchor slug changed; in-document links are already fixed. */
|
|
184
|
-
onHeadingRenamed?(oldSlug: string, newSlug: string): void;
|
|
185
|
-
/** A renamed heading's slug is duplicated in the document; nothing was fixed. */
|
|
186
|
-
onHeadingRenameAmbiguous?(baseName: string): void;
|
|
187
|
-
exportHtml?(html: string): void;
|
|
188
|
-
printDocument?(html: string): void;
|
|
189
|
-
viewInBrowser?(html: string): void;
|
|
190
|
-
sidebarPrefs?: MikeDownSidebarPrefs;
|
|
191
|
-
}
|
|
192
|
-
/** A host with every optional method absent. `onChange` does nothing. */
|
|
193
|
-
declare class NoopHost implements MikeDownHost {
|
|
194
|
-
onChange(_markdown: string, _meta: {
|
|
195
|
-
pristine: boolean;
|
|
196
|
-
}): void;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Public types for the MikeDown editor core: settings, feature flags, the
|
|
201
|
-
* factory options and the editor handle. The host adapter lives in host.ts.
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
interface NormalizationStyle {
|
|
205
|
-
boldMarker: '**' | '__';
|
|
206
|
-
italicMarker: '*' | '_';
|
|
207
|
-
listMarker: '-' | '*' | '+';
|
|
208
|
-
headingStyle: 'atx' | 'setext';
|
|
209
|
-
}
|
|
210
|
-
/** A webview-resolvable URL prefix and the on-disk folder it maps to. */
|
|
211
|
-
interface ImagePathMapping {
|
|
212
|
-
prefix: string;
|
|
213
|
-
fsPath: string;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Settings the editor core owns (decisions section 6). Field names match the
|
|
217
|
-
* keys the editor sends to `host.saveSettings`.
|
|
9
|
+
* Pure data, no DOM: shared by the toolbar registry (`toolbar-registry.ts`)
|
|
10
|
+
* and the layout model (`toolbar-layout.ts`) so neither depends on the other.
|
|
11
|
+
* The ids are the registry ids, which match the `data-action` attribute on
|
|
12
|
+
* each toolbar button (`zoom` is the wrapper around `zoomOut`, `zoomReset`
|
|
13
|
+
* and `zoomIn`).
|
|
218
14
|
*/
|
|
219
|
-
interface MikeDownSettings {
|
|
220
|
-
fontFamily: string;
|
|
221
|
-
headingFontFamily: string;
|
|
222
|
-
/** Pixels. */
|
|
223
|
-
fontSize: number;
|
|
224
|
-
/** CSS max width of the content column, e.g. "100%" or "780px". */
|
|
225
|
-
contentWidth: string;
|
|
226
|
-
ctrlWheelZoom: boolean;
|
|
227
|
-
editorTheme: 'auto' | 'light' | 'dark';
|
|
228
|
-
headingNumbering: 'off' | 'fromH1' | 'fromH2';
|
|
229
|
-
linkClickBehavior: 'navigateCurrentTab' | 'openNewTab' | 'showContextMenu';
|
|
230
|
-
slashCommandsEnabled: boolean;
|
|
231
|
-
slashCommandsDateFormat: 'iso' | 'long';
|
|
232
|
-
/** "local", "UTC" or an IANA zone. */
|
|
233
|
-
slashCommandsTimeZone: string;
|
|
234
|
-
renderMermaidDiagrams: boolean;
|
|
235
|
-
renderMath: boolean;
|
|
236
|
-
tagsEnabled: boolean;
|
|
237
|
-
markdownNormalization: 'preserve' | 'normalize';
|
|
238
|
-
normalizationStyle: NormalizationStyle;
|
|
239
|
-
spellCheckEnabled: boolean;
|
|
240
|
-
spellCheckLanguage: 'en' | 'en-GB';
|
|
241
|
-
spellCheckIgnoreCodeBlocks: boolean;
|
|
242
|
-
spellCheckUserWords: string[];
|
|
243
|
-
/** Words accepted by the spell checker but owned elsewhere (read-only chips). */
|
|
244
|
-
spellCheckExternalWords?: string[];
|
|
245
|
-
/** Cmd/Ctrl+click on an unresolved wikilink calls `host.createWikilink`. */
|
|
246
|
-
wikilinkCreateOnClick?: boolean;
|
|
247
|
-
/** `never` turns off in-document link fixing and `onHeadingRenamed`. */
|
|
248
|
-
headingRenameUpdateLinks?: 'ask' | 'always' | 'never';
|
|
249
|
-
/** Image src rewriting for display in the image popover. */
|
|
250
|
-
imagePathMappings?: ImagePathMapping[];
|
|
251
|
-
/** On-disk folder of the current document (pairs with imagePathMappings). */
|
|
252
|
-
docDir?: string;
|
|
253
|
-
}
|
|
254
15
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* through to `host.saveSettings` untouched.
|
|
16
|
+
* Every registry item id, in default toolbar order, then the optional ones
|
|
17
|
+
* (offered in the Customize tray but not in the default layout).
|
|
258
18
|
*/
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
interface MikeDownFeatures {
|
|
265
|
-
/** Formatting toolbar. Default on. */
|
|
266
|
-
toolbar: boolean;
|
|
267
|
-
/** Outline / Properties / Backlinks / Tags sidebar. Default off. */
|
|
268
|
-
sidebar: boolean;
|
|
269
|
-
/** CodeMirror source view (Cmd+/). Default on. */
|
|
270
|
-
sourceMode: boolean;
|
|
271
|
-
/** `/` command menu. Default on. */
|
|
272
|
-
slashCommands: boolean;
|
|
273
|
-
/** Spell checking. Default on, but inert unless `spellcheckDictionaryUrl` is set. */
|
|
274
|
-
spellcheck: boolean;
|
|
275
|
-
/** KaTeX math rendering. Default on. */
|
|
276
|
-
math: boolean;
|
|
277
|
-
/** Mermaid diagram rendering. Default on. */
|
|
278
|
-
mermaid: boolean;
|
|
279
|
-
/** Support entry point in the sidebar footer (VS Code only). Default off. */
|
|
280
|
-
supportCard: boolean;
|
|
281
|
-
/** Find and replace bar (Cmd+F / Cmd+H). Default on. */
|
|
282
|
-
findReplace: boolean;
|
|
283
|
-
/** Collapsible frontmatter block above the document. Default on. */
|
|
284
|
-
frontmatter: boolean;
|
|
285
|
-
}
|
|
286
|
-
declare const DEFAULT_FEATURES: MikeDownFeatures;
|
|
287
|
-
/** Row builders the Settings modal hands to host sections, so they match. */
|
|
288
|
-
interface MikeDownSettingsSectionContext {
|
|
289
|
-
makeRow(label: string, description: string, layout?: 'inline' | 'stacked'): HTMLElement;
|
|
290
|
-
makeGroup(...rows: HTMLElement[]): HTMLDivElement;
|
|
291
|
-
makeFieldLabel(text: string, hint: string, layout?: 'inline' | 'stacked'): HTMLLabelElement;
|
|
292
|
-
makeCheckboxRow(label: string, description: string, current: boolean): {
|
|
293
|
-
row: HTMLElement;
|
|
294
|
-
input: HTMLInputElement;
|
|
295
|
-
};
|
|
296
|
-
makeSelectRow<T extends string>(label: string, description: string, current: T, options: Array<{
|
|
297
|
-
value: T;
|
|
298
|
-
label: string;
|
|
299
|
-
}>): {
|
|
300
|
-
row: HTMLElement;
|
|
301
|
-
select: HTMLSelectElement;
|
|
302
|
-
};
|
|
303
|
-
/** Close the modal without saving. */
|
|
304
|
-
close(): void;
|
|
305
|
-
}
|
|
306
|
-
interface MikeDownSettingsSectionBuild {
|
|
307
|
-
/** Rows appended to the tab, in order. */
|
|
308
|
-
rows: HTMLElement[];
|
|
309
|
-
/** Values merged into the patch sent to `host.saveSettings` on Save. */
|
|
310
|
-
collect?(): Record<string, unknown>;
|
|
311
|
-
/** Runs after Save, once the patch was sent. */
|
|
312
|
-
onSaved?(): void;
|
|
313
|
-
}
|
|
314
|
-
/** A host-owned block of rows in the Settings modal. */
|
|
315
|
-
interface MikeDownSettingsSection {
|
|
316
|
-
/** Core tab id ('appearance', 'behavior', 'markdown', 'spelling', 'hotkeys') or a new tab id. */
|
|
317
|
-
tab: string;
|
|
318
|
-
/** Label for a new tab. Ignored for core tabs. */
|
|
319
|
-
tabLabel?: string;
|
|
320
|
-
/** Insert a new tab after this tab id. Default: after the last tab. */
|
|
321
|
-
afterTab?: string;
|
|
322
|
-
/** Extra class on a new tab's panel (e.g. 'settings-panel--about'). */
|
|
323
|
-
panelClassName?: string;
|
|
324
|
-
/**
|
|
325
|
-
* Where the rows go inside the tab: before the core rows, after them
|
|
326
|
-
* (default), or after the core row with this setting key.
|
|
327
|
-
*/
|
|
328
|
-
placement?: 'start' | 'end' | {
|
|
329
|
-
after: keyof MikeDownSettings;
|
|
330
|
-
};
|
|
331
|
-
build(ctx: MikeDownSettingsSectionContext): MikeDownSettingsSectionBuild;
|
|
332
|
-
}
|
|
333
|
-
interface MikeDownOptions {
|
|
334
|
-
host: MikeDownHost;
|
|
335
|
-
/** Loaded as the pristine baseline. */
|
|
336
|
-
initialMarkdown?: string;
|
|
337
|
-
/** Initial core settings. */
|
|
338
|
-
settings?: Partial<MikeDownSettings>;
|
|
339
|
-
features?: Partial<MikeDownFeatures>;
|
|
340
|
-
/** Overrides `settings.editorTheme`. */
|
|
341
|
-
theme?: 'light' | 'dark' | 'auto';
|
|
342
|
-
readOnly?: boolean;
|
|
343
|
-
/** Base URL of the spell-check dictionaries (contains `en/` and `en-GB/`). */
|
|
344
|
-
spellcheckDictionaryUrl?: string;
|
|
345
|
-
/** Host sections in the Settings modal. */
|
|
346
|
-
extraSettingsSections?: MikeDownSettingsSection[];
|
|
347
|
-
/** Text beside the Settings modal's Save button. */
|
|
348
|
-
settingsFooterNote?: string;
|
|
349
|
-
/**
|
|
350
|
-
* True when the host binds editor shortcuts itself, as the VS Code
|
|
351
|
-
* keybinding does for Cmd/Ctrl+/. The core then leaves `Mod-/` alone so the
|
|
352
|
-
* source toggle never fires twice. Default false: the core binds it, in both
|
|
353
|
-
* the rich editor and source mode.
|
|
354
|
-
*/
|
|
355
|
-
hostOwnsShortcuts?: boolean;
|
|
356
|
-
/** Empty-document placeholder. Default: "Type / for commands…" or "Start writing…". */
|
|
357
|
-
placeholder?: string;
|
|
358
|
-
/** `id` of the editable surface (the contenteditable, and the source view's content). */
|
|
359
|
-
id?: string;
|
|
360
|
-
/** Accessible name of the editable surface. Default "Document text". */
|
|
361
|
-
ariaLabel?: string;
|
|
362
|
-
/** Id of the element that names the editable surface. Wins over `ariaLabel`'s default. */
|
|
363
|
-
ariaLabelledBy?: string;
|
|
364
|
-
/**
|
|
365
|
-
* Put `role="main"` on the editor container. Default true (VS Code, Desktop).
|
|
366
|
-
* Embedded form fields pass false, since a field is not a page landmark.
|
|
367
|
-
*/
|
|
368
|
-
landmark?: boolean;
|
|
369
|
-
}
|
|
370
|
-
type MikeDownCommand = 'toggleBold' | 'toggleItalic' | 'toggleStrike' | 'toggleHighlight' | 'toggleCode' | 'toggleBulletList' | 'toggleOrderedList' | 'toggleTaskList' | 'pasteWithoutFormatting' | 'openEmojiPicker' | 'undo' | 'redo' | 'toggleSource' | 'toggleSidebar' | 'openSettings' | 'copyAsRichText' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'openFind' | 'openFindReplace' | 'insertTable' | 'insertLink' | 'insertImage' | 'zoomIn' | 'zoomOut' | 'zoomReset';
|
|
371
|
-
type MikeDownEvent = 'change' | 'focus' | 'blur' | 'ready';
|
|
372
|
-
/**
|
|
373
|
-
* Where the user is in the document: which view is showing, the caret and
|
|
374
|
-
* the scroll offset of that view. A host that keeps several documents in one
|
|
375
|
-
* editor (tabs) saves it when a tab deactivates and restores it when the tab
|
|
376
|
-
* comes back, or across sessions.
|
|
377
|
-
*/
|
|
378
|
-
interface MikeDownViewState {
|
|
379
|
-
sourceMode: boolean;
|
|
380
|
-
/** Caret position in the showing view: a ProseMirror position in rich text, a character offset in source mode. */
|
|
381
|
-
cursor: number;
|
|
382
|
-
/** Scroll offset of the showing view's scroller, in CSS pixels. */
|
|
383
|
-
scrollTop: number;
|
|
384
|
-
}
|
|
385
|
-
/** Sidebar layout and per-document section state pushed by the host. */
|
|
386
|
-
interface SidebarStateUpdate {
|
|
387
|
-
pref?: 'always' | 'never';
|
|
388
|
-
width?: number;
|
|
389
|
-
position?: 'left' | 'right';
|
|
390
|
-
sectionPrefs?: Record<string, boolean>;
|
|
391
|
-
}
|
|
392
|
-
/** Sidebar footer link (the VS Code support appeal uses it). */
|
|
393
|
-
interface SidebarFooterLink {
|
|
394
|
-
label: string;
|
|
395
|
-
dismissLabel: string;
|
|
396
|
-
dismissConfirmation: string;
|
|
397
|
-
onOpen(): void;
|
|
398
|
-
onDismiss(): void;
|
|
399
|
-
}
|
|
400
|
-
interface MikeDownEditorHandle {
|
|
401
|
-
/** Replace the document. `pristine` (default true) makes it the clean baseline. */
|
|
402
|
-
setMarkdown(markdown: string, opts?: {
|
|
403
|
-
pristine?: boolean;
|
|
404
|
-
}): void;
|
|
405
|
-
getMarkdown(): string;
|
|
406
|
-
focus(): void;
|
|
407
|
-
setReadOnly(readOnly: boolean): void;
|
|
408
|
-
setTheme(theme: 'light' | 'dark' | 'auto'): void;
|
|
409
|
-
/** Run a toolbar or keybinding command. `openSettings` takes `{ tab }`. */
|
|
410
|
-
command(name: MikeDownCommand, args?: {
|
|
411
|
-
tab?: string;
|
|
412
|
-
}): void;
|
|
413
|
-
/** Apply settings without persisting them. */
|
|
414
|
-
updateSettings(patch: Partial<MikeDownSettings>): void;
|
|
415
|
-
/** The host saved the document; `content` (default: current markdown) is the new baseline. */
|
|
416
|
-
markSaved(content?: string): void;
|
|
417
|
-
/** Rendered HTML of the document (for export and print). */
|
|
418
|
-
getHtml(): string;
|
|
419
|
-
scrollToAnchor(slug: string): void;
|
|
420
|
-
/** Scroll to and flash the Nth link with this href. */
|
|
421
|
-
revealLink(href: string, occurrence?: number): void;
|
|
422
|
-
/**
|
|
423
|
-
* Select and scroll to a match in the markdown source: 1-based `line`,
|
|
424
|
-
* 1-based `column` in UTF-16 units, `length` of the match. Exact in source
|
|
425
|
-
* mode; in rich text the matched string is found again in the rendered text.
|
|
426
|
-
*/
|
|
427
|
-
revealText(line: number, column: number, length?: number): void;
|
|
428
|
-
/** Mark images rendered from `src` as missing or present again. */
|
|
429
|
-
setImageStatus(src: string, status: 'found' | 'missing', detail?: string): void;
|
|
430
|
-
/** Insert a link at the cursor (rich text or source mode). `text` defaults to the href. */
|
|
431
|
-
insertLink(href: string, text?: string): void;
|
|
432
|
-
/** Insert an image at the cursor, e.g. the result of `host.uploadImage` for a dropped file. */
|
|
433
|
-
insertImage(image: ImageInsertResult): void;
|
|
434
|
-
/**
|
|
435
|
-
* Files around the document changed: re-resolve `[[wikilinks]]`, re-check
|
|
436
|
-
* relative links and refresh file suggestions. Also call it after adding
|
|
437
|
-
* the knowledge-base host methods to a host that started without them.
|
|
438
|
-
*/
|
|
439
|
-
refreshLinks(): void;
|
|
440
|
-
setTags(tags: TagCount[]): void;
|
|
441
|
-
/** Push link suggestions without being asked (same data as `host.getLinkSuggestions`). */
|
|
442
|
-
setLinkSuggestions(suggestions: LinkSuggestion[]): void;
|
|
443
|
-
setBacklinks(items: BacklinkItem[]): void;
|
|
444
|
-
setDocMeta(meta: {
|
|
445
|
-
mtimeMs?: number | null;
|
|
446
|
-
}): void;
|
|
447
|
-
setSidebarState(state: SidebarStateUpdate): void;
|
|
448
|
-
/** Show or hide the sidebar footer link (requires `features.supportCard`). */
|
|
449
|
-
setSidebarFooterLink(link: SidebarFooterLink | null): void;
|
|
450
|
-
setDiffAvailable(available: boolean): void;
|
|
451
|
-
/** True while the Settings modal or another core modal is open. */
|
|
452
|
-
isModalOpen(): boolean;
|
|
453
|
-
/** Which view is showing, where the caret is and how far it is scrolled. */
|
|
454
|
-
getViewState(): MikeDownViewState;
|
|
455
|
-
/**
|
|
456
|
-
* Restore a saved view state: switches views when `sourceMode` differs,
|
|
457
|
-
* then places the caret (clamped to the document) and the scroll offset.
|
|
458
|
-
* Call it after `setMarkdown`. Missing fields keep their current value.
|
|
459
|
-
*/
|
|
460
|
-
setViewState(state: Partial<MikeDownViewState>): void;
|
|
461
|
-
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
462
|
-
on(event: MikeDownEvent, fn: (...args: any[]) => void): () => void;
|
|
463
|
-
/** Tear down the editor and every listener it attached to window or document. */
|
|
464
|
-
destroy(): void;
|
|
465
|
-
/** The underlying TipTap editor. Escape hatch for tests and advanced hosts; not a stable API. */
|
|
466
|
-
readonly tiptap: Editor;
|
|
467
|
-
}
|
|
19
|
+
declare const TOOLBAR_ITEM_IDS: readonly ["textFormat", "listBlock", "link", "insert", "emoji", "headingNumbers", "ai", "undo", "redo", "sourceToggle", "share", "selectAll", "zoom", "themeToggle", "settings", "more", "fontPicker"];
|
|
20
|
+
/** A registry item id. */
|
|
21
|
+
type ToolbarItemId = (typeof TOOLBAR_ITEM_IDS)[number];
|
|
22
|
+
/** One entry of a layout: a registry id, a separator (`'|'`) or a flexible spacer (`'~'`). */
|
|
23
|
+
type ToolbarLayoutToken = ToolbarItemId | '|' | '~';
|
|
468
24
|
|
|
469
25
|
declare function createMikeDownEditor(container: HTMLElement, options: MikeDownOptions): MikeDownEditorHandle;
|
|
470
26
|
|
|
@@ -520,5 +76,5 @@ interface MikeDownBinding {
|
|
|
520
76
|
}
|
|
521
77
|
declare function bindMikeDownValue(container: HTMLElement, options?: MikeDownBindingOptions): MikeDownBinding;
|
|
522
78
|
|
|
523
|
-
export {
|
|
524
|
-
export type {
|
|
79
|
+
export { MikeDownEditorHandle, MikeDownHost, MikeDownOptions, TOOLBAR_ITEM_IDS, bindMikeDownValue, createMikeDownEditor };
|
|
80
|
+
export type { BindingTheme, MikeDownBinding, MikeDownBindingOptions, ToolbarItemId, ToolbarLayoutToken };
|