rme 0.3.0-beta.8 → 0.3.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/dist/index.d.ts +387 -15
- package/dist/index.mjs +3720 -1256
- package/dist/index.mjs.map +4 -4
- package/package.json +13 -11
package/dist/index.d.ts
CHANGED
|
@@ -2,26 +2,82 @@ import * as _drl990114_codemirror_themes from '@drl990114/codemirror-themes';
|
|
|
2
2
|
import { CreateThemeOptions } from '@drl990114/codemirror-themes';
|
|
3
3
|
export { CreateThemeOptions, createTheme } from '@drl990114/codemirror-themes';
|
|
4
4
|
import { LanguageSupport, LanguageDescription } from '@codemirror/language';
|
|
5
|
+
import { SearchQuery } from '@codemirror/search';
|
|
5
6
|
import { Compartment, Extension } from '@codemirror/state';
|
|
6
7
|
import { EditorView, EditorViewConfig } from '@codemirror/view';
|
|
7
8
|
import { ProsemirrorNode, EditorView as EditorView$1 } from '@rme-sdk/pm';
|
|
8
9
|
import * as react from 'react';
|
|
9
|
-
import react__default, { CSSProperties, ReactNode, MouseEvent, JSX, FC } from 'react';
|
|
10
|
+
import react__default, { ErrorInfo, CSSProperties, ComponentType, ReactNode, MouseEvent, JSX, FC } from 'react';
|
|
10
11
|
import { RemirrorEventListenerProps, Extension as Extension$1, RemirrorManager as RemirrorManager$1, AnyExtension as AnyExtension$1 } from '@rme-sdk/main';
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
12
|
+
import * as _rme_sdk_core from '@rme-sdk/core';
|
|
13
|
+
import { AnyExtension, RemirrorManager, DelayedPromiseCreator, ProsemirrorAttributes, NodeExtension, EditorView as EditorView$2, ApplySchemaAttributes, NodeSpecOverride, NodeExtensionSpec, PrimitiveSelection, CommandFunction, ExtensionCommandReturn, InputRule as InputRule$1, KeyBindings, ProsemirrorPlugin, ProsemirrorNode as ProsemirrorNode$1, CommandDecoratorMessageProps, CoreIcon } from '@rme-sdk/core';
|
|
14
|
+
import { Node, Schema, NodeType, Mark, NodeRange } from '@rme-sdk/pm/model';
|
|
13
15
|
import { ReactFrameworkOutput } from '@rme-sdk/react-core';
|
|
14
|
-
import {
|
|
16
|
+
import { InputRule } from '@rme-sdk/pm/inputrules';
|
|
17
|
+
import { PasteRule } from '@rme-sdk/pm/paste-rules';
|
|
15
18
|
import Token from 'markdown-it/lib/token.mjs';
|
|
19
|
+
import { Token as Token$1 } from 'markdown-it/index.js';
|
|
20
|
+
import { NodeViewComponentProps } from '@rme-sdk/react';
|
|
16
21
|
export { useCommands, useHelpers, useKeymap, useRemirrorContext } from '@rme-sdk/react';
|
|
17
22
|
import * as styled_components from 'styled-components';
|
|
18
23
|
import * as styled_components_dist_types from 'styled-components/dist/types';
|
|
24
|
+
import { IndentListOptions, DedentListOptions, UnwrapListOptions, ToggleCollapsedOptions } from '@rme-sdk/prosemirror-flat-list';
|
|
19
25
|
|
|
20
26
|
type LoadLanguage = (lang: string) => Promise<LanguageSupport> | LanguageSupport | void;
|
|
21
27
|
|
|
28
|
+
type ClipboardReadFunction = typeof clipboardRead;
|
|
29
|
+
declare function clipboardRead(): Promise<{
|
|
30
|
+
html: string;
|
|
31
|
+
text: string;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
interface CommandKeymapOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Override default keyboard shortcuts
|
|
37
|
+
* @example
|
|
38
|
+
* { toggleStrong: 'mod-shift-b', toggleEmphasis: 'ctrl-i' }
|
|
39
|
+
*/
|
|
40
|
+
overrideShortcutMap?: Partial<Record<CommandName, string>>;
|
|
41
|
+
/**
|
|
42
|
+
* Disable all built-in shortcuts
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
disableAllBuildInShortcuts?: boolean;
|
|
46
|
+
clipboardReadFunction?: ClipboardReadFunction;
|
|
47
|
+
}
|
|
48
|
+
type CommandName = keyof typeof defaultCommandShortcutMap;
|
|
49
|
+
declare const defaultCommandShortcutMap: {
|
|
50
|
+
readonly copy: "mod-c";
|
|
51
|
+
readonly paste: "mod-v";
|
|
52
|
+
readonly undo: "mod-z";
|
|
53
|
+
readonly redo: "mod-shift-z";
|
|
54
|
+
readonly cut: "mod-x";
|
|
55
|
+
readonly toggleH1: "mod-1";
|
|
56
|
+
readonly toggleH2: "mod-2";
|
|
57
|
+
readonly toggleH3: "mod-3";
|
|
58
|
+
readonly toggleH4: "mod-4";
|
|
59
|
+
readonly toggleH5: "mod-5";
|
|
60
|
+
readonly toggleH6: "mod-6";
|
|
61
|
+
readonly toggleStrong: "mod-b";
|
|
62
|
+
readonly toggleEmphasis: "mod-i";
|
|
63
|
+
readonly toggleCodeText: "mod-e";
|
|
64
|
+
readonly toggleDelete: "mod-shift-s";
|
|
65
|
+
readonly insertLink: "mod-k";
|
|
66
|
+
readonly insertImage: "mod-alt-i";
|
|
67
|
+
};
|
|
68
|
+
|
|
22
69
|
type CustomCopyFunction = (code: string) => Promise<boolean> | boolean;
|
|
23
70
|
|
|
24
71
|
declare const changeTheme: (theme: CreateThemeOptions) => void;
|
|
72
|
+
declare const updateCodemirrorSearchQuery: (query: string, caseSensitive?: boolean) => void;
|
|
73
|
+
declare const updateCodemirrorSearchState: (query: string, caseSensitive?: boolean, activeMatch?: {
|
|
74
|
+
from: number;
|
|
75
|
+
to: number;
|
|
76
|
+
} | null) => void;
|
|
77
|
+
declare const scrollCodemirrorToMatch: (activeMatch?: {
|
|
78
|
+
from: number;
|
|
79
|
+
to: number;
|
|
80
|
+
} | null) => boolean;
|
|
25
81
|
declare const extractMatches: (view: EditorView) => any[];
|
|
26
82
|
type CreateCodemirrorOptions = {
|
|
27
83
|
/**
|
|
@@ -44,6 +100,10 @@ type CreateCodemirrorOptions = {
|
|
|
44
100
|
*/
|
|
45
101
|
customCopyFunction?: CustomCopyFunction;
|
|
46
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Command keymap options for customizing keyboard shortcuts
|
|
105
|
+
*/
|
|
106
|
+
commandKeymapOptions?: CommandKeymapOptions;
|
|
47
107
|
};
|
|
48
108
|
declare class MfCodemirrorView {
|
|
49
109
|
private readonly view;
|
|
@@ -51,6 +111,7 @@ declare class MfCodemirrorView {
|
|
|
51
111
|
private readonly languageConf;
|
|
52
112
|
private readonly toggleName;
|
|
53
113
|
private readonly schema;
|
|
114
|
+
private readonly searchQueryConf;
|
|
54
115
|
private languageName;
|
|
55
116
|
id: string;
|
|
56
117
|
cm: EditorView;
|
|
@@ -74,12 +135,22 @@ declare class MfCodemirrorView {
|
|
|
74
135
|
setSelection(anchor: number, head: number): void;
|
|
75
136
|
updateLanguage(): void;
|
|
76
137
|
destroy(): void;
|
|
138
|
+
setSearchState(query: SearchQuery, active: {
|
|
139
|
+
from: number;
|
|
140
|
+
to: number;
|
|
141
|
+
} | null): void;
|
|
142
|
+
scrollToPosition(pos: number): void;
|
|
143
|
+
getProsemirrorContentRange(): {
|
|
144
|
+
from: number;
|
|
145
|
+
to: number;
|
|
146
|
+
};
|
|
77
147
|
forwardSelection(): void;
|
|
78
148
|
private setLanguage;
|
|
79
149
|
private valueChanged;
|
|
80
150
|
private asProseMirrorSelection;
|
|
81
151
|
private codeMirrorKeymap;
|
|
82
152
|
private maybeEscape;
|
|
153
|
+
private focusLanguageInput;
|
|
83
154
|
/**
|
|
84
155
|
* Creates the copy button and adds it to the CodeMirror editor
|
|
85
156
|
*/
|
|
@@ -110,9 +181,11 @@ interface ErrorBoundaryProps {
|
|
|
110
181
|
error?: unknown;
|
|
111
182
|
fallback?: react__default.ComponentType<{
|
|
112
183
|
error: Error;
|
|
184
|
+
errorInfo?: ErrorInfo;
|
|
113
185
|
}>;
|
|
114
186
|
onError?: (params: {
|
|
115
187
|
error: Error;
|
|
188
|
+
errorInfo?: ErrorInfo;
|
|
116
189
|
}) => void;
|
|
117
190
|
}
|
|
118
191
|
|
|
@@ -129,6 +202,7 @@ type EditorRef = {
|
|
|
129
202
|
toggleType: (targetType: EditorViewType) => void;
|
|
130
203
|
getType: () => EditorViewType;
|
|
131
204
|
exportHtml: () => Promise<string>;
|
|
205
|
+
setContent: (nextContent: string) => void;
|
|
132
206
|
};
|
|
133
207
|
declare const defaultStyleToken: {
|
|
134
208
|
rootFontSize: string;
|
|
@@ -148,7 +222,8 @@ interface EditorProps {
|
|
|
148
222
|
rootLineHeight?: string;
|
|
149
223
|
};
|
|
150
224
|
content: string;
|
|
151
|
-
|
|
225
|
+
wysiwygTextContainerProps?: ITextProps;
|
|
226
|
+
sourceCodeTextContainerProps?: ITextProps;
|
|
152
227
|
isTesting?: boolean;
|
|
153
228
|
editable?: boolean;
|
|
154
229
|
delegateOptions?: CreateWysiwygDelegateOptions;
|
|
@@ -231,18 +306,24 @@ type EditorContext = ReactFrameworkOutput<Remirror.Extensions>;
|
|
|
231
306
|
type CreateSourceCodeManagerOptions = {
|
|
232
307
|
language?: string;
|
|
233
308
|
onCodemirrorViewLoad: (cm: MfCodemirrorView) => void;
|
|
309
|
+
/**
|
|
310
|
+
* Override default keyboard shortcuts
|
|
311
|
+
* @example
|
|
312
|
+
* { toggleStrong: 'mod-shift-b', toggleEmphasis: 'ctrl-i' }
|
|
313
|
+
*/
|
|
314
|
+
overrideShortcutMap?: Partial<Record<CommandName, string>>;
|
|
315
|
+
/**
|
|
316
|
+
* Disable all built-in shortcuts
|
|
317
|
+
* @default false
|
|
318
|
+
*/
|
|
319
|
+
disableAllBuildInShortcuts?: boolean;
|
|
320
|
+
clipboardReadFunction?: ClipboardReadFunction;
|
|
234
321
|
};
|
|
235
322
|
declare function createSourceCodeManager(options?: CreateSourceCodeManagerOptions): RemirrorManager$1<any>;
|
|
236
323
|
declare const createSourceCodeDelegate: (options?: CreateSourceCodeManagerOptions) => EditorDelegate<any>;
|
|
237
324
|
|
|
238
325
|
declare const _default$1: react__default.NamedExoticComponent<EditorProps>;
|
|
239
326
|
|
|
240
|
-
type ClipboardReadFunction = typeof clipboardRead;
|
|
241
|
-
declare function clipboardRead(): Promise<{
|
|
242
|
-
html: string;
|
|
243
|
-
text: string;
|
|
244
|
-
}>;
|
|
245
|
-
|
|
246
327
|
interface AIOptions {
|
|
247
328
|
defaultSelectProvider?: string;
|
|
248
329
|
supportProviderInfosMap: Record<string, {
|
|
@@ -254,7 +335,28 @@ interface AIOptions {
|
|
|
254
335
|
prompt: string;
|
|
255
336
|
temperature?: number;
|
|
256
337
|
}) => Promise<string | null>;
|
|
338
|
+
copilot?: CopilotOptions;
|
|
257
339
|
}
|
|
340
|
+
type CopilotContext = {
|
|
341
|
+
nodeType: string;
|
|
342
|
+
textBefore: string;
|
|
343
|
+
textAfter: string;
|
|
344
|
+
prevParagraph: string | null;
|
|
345
|
+
nextParagraph: string | null;
|
|
346
|
+
};
|
|
347
|
+
type CopilotOptions = {
|
|
348
|
+
generateText?: (options: {
|
|
349
|
+
context: CopilotContext;
|
|
350
|
+
}) => Promise<string | null>;
|
|
351
|
+
debounceMs?: number;
|
|
352
|
+
maxContextChars?: number;
|
|
353
|
+
maxSuggestionChars?: number;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
type CodemirrorOptions = {
|
|
357
|
+
lineWrapping?: boolean;
|
|
358
|
+
lineNumbers?: boolean;
|
|
359
|
+
};
|
|
258
360
|
|
|
259
361
|
type MarkdownItToken = string;
|
|
260
362
|
declare enum ParserRuleType {
|
|
@@ -322,6 +424,7 @@ declare class MarkdownParseState {
|
|
|
322
424
|
private marks;
|
|
323
425
|
private tokenHandlers;
|
|
324
426
|
private contextStack;
|
|
427
|
+
private contextTokenStack;
|
|
325
428
|
stack: StackItem[];
|
|
326
429
|
constructor(schema: Schema, tokenHandlers: TokenHandlers);
|
|
327
430
|
top(): StackItem;
|
|
@@ -334,9 +437,11 @@ declare class MarkdownParseState {
|
|
|
334
437
|
addNode(type: NodeType, attrs?: Record<string, any>, content?: Node[]): Node;
|
|
335
438
|
openNode(type: NodeType, attrs?: Record<string, any>): void;
|
|
336
439
|
closeNode(): Node;
|
|
337
|
-
openContext(context: ParserRuleContext): void;
|
|
440
|
+
openContext(context: ParserRuleContext, token: Token$1): void;
|
|
338
441
|
closeContext(): void;
|
|
442
|
+
closeContextToken(): Token$1 | undefined;
|
|
339
443
|
topContext(): ParserRuleContext | undefined;
|
|
444
|
+
topContextToken(): Token$1 | undefined;
|
|
340
445
|
}
|
|
341
446
|
declare class MarkdownParser {
|
|
342
447
|
private schema;
|
|
@@ -387,15 +492,280 @@ declare class MarkdownSerializer {
|
|
|
387
492
|
serialize(content: Node): string;
|
|
388
493
|
}
|
|
389
494
|
|
|
495
|
+
interface ImageNodeViewProps extends NodeViewComponentProps {
|
|
496
|
+
resizeable?: boolean;
|
|
497
|
+
defaultSyntaxType?: 'html' | 'md';
|
|
498
|
+
handleViewImgSrcUrl?: ExtensionsOptions['handleViewImgSrcUrl'];
|
|
499
|
+
imagePasteHandler?: ExtensionsOptions['imagePasteHandler'];
|
|
500
|
+
imageHostingHandler?: (src: string) => Promise<string>;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
type DelayedImage$1 = DelayedPromiseCreator<ImageAttributes$1>;
|
|
504
|
+
interface ImageOptions$1 {
|
|
505
|
+
createPlaceholder?: (view: EditorView$2, pos: number) => HTMLElement;
|
|
506
|
+
updatePlaceholder?: (view: EditorView$2, pos: number, element: HTMLElement, progress: number) => void;
|
|
507
|
+
handleViewImgSrcUrl?: ExtensionsOptions['handleViewImgSrcUrl'];
|
|
508
|
+
imagePasteHandler?: ExtensionsOptions['imagePasteHandler'];
|
|
509
|
+
destroyPlaceholder?: (view: EditorView$2, element: HTMLElement) => void;
|
|
510
|
+
/**
|
|
511
|
+
* The upload handler for the image extension.
|
|
512
|
+
*
|
|
513
|
+
* It receives a list of dropped or pasted files and returns a promise for the
|
|
514
|
+
* attributes which should be used to insert the image into the editor.
|
|
515
|
+
*
|
|
516
|
+
* @param files - a list of files to upload.
|
|
517
|
+
* @param setProgress - the progress handler.
|
|
518
|
+
*/
|
|
519
|
+
uploadHandler?: (files: FileWithProgress$1[]) => DelayedImage$1[];
|
|
520
|
+
/**
|
|
521
|
+
* The image hosting service upload handler.
|
|
522
|
+
* It receives the image src and returns a promise for the new src after uploading to image hosting service.
|
|
523
|
+
*
|
|
524
|
+
* @param src - the original image src
|
|
525
|
+
* @returns Promise<string> - the new image src after uploading
|
|
526
|
+
*/
|
|
527
|
+
imageHostingHandler?: (src: string) => Promise<string>;
|
|
528
|
+
/**
|
|
529
|
+
* When pasting mixed text and image content (usually from Microsoft Office products) the content on the clipboard is either:
|
|
530
|
+
*
|
|
531
|
+
* a. one large image: containing effectively a screenshot of the original content (an image with text in it).
|
|
532
|
+
* b. HTML content: containing usable text, but images with file protocol URLs (which cannot be resolved due to browser security restrictions).
|
|
533
|
+
*
|
|
534
|
+
* If true, this will extract the text from the clipboard data, and drop the images.
|
|
535
|
+
* If false, the "screenshot" image will be used and the text will be dropped.
|
|
536
|
+
*
|
|
537
|
+
* @defaultValue true
|
|
538
|
+
*/
|
|
539
|
+
preferPastedTextContent?: boolean;
|
|
540
|
+
}
|
|
541
|
+
interface FileWithProgress$1 {
|
|
542
|
+
file: File;
|
|
543
|
+
progress: SetProgress$1;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Set the progress.
|
|
547
|
+
*
|
|
548
|
+
* @param progress - a value between `0` and `1`.
|
|
549
|
+
*/
|
|
550
|
+
type SetProgress$1 = (progress: number) => void;
|
|
551
|
+
/**
|
|
552
|
+
* The image extension for placing images into your editor.
|
|
553
|
+
*
|
|
554
|
+
* TODO ->
|
|
555
|
+
* - Captions https://glitch.com/edit/#!/pet-figcaption?path=index.js%3A27%3A1 into a preset
|
|
556
|
+
*
|
|
557
|
+
* TODO => Split this into an image upload extension and image extension.
|
|
558
|
+
* - Add a base64 image
|
|
559
|
+
*/
|
|
560
|
+
declare class MdImgUriExtension extends NodeExtension<ImageOptions$1> {
|
|
561
|
+
get name(): "md_image";
|
|
562
|
+
ReactComponent: ComponentType<ImageNodeViewProps> | undefined;
|
|
563
|
+
createTags(): ("inline" | "media")[];
|
|
564
|
+
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
|
|
565
|
+
insertMarkdownImage(attributes: ImageAttributes$1, selection?: PrimitiveSelection): CommandFunction;
|
|
566
|
+
uploadImage: (value: DelayedPromiseCreator<ImageAttributes$1>, onElement?: ((element: HTMLElement) => void) | undefined) => CommandFunction;
|
|
567
|
+
/**
|
|
568
|
+
* Insert an image once the provide promise resolves.
|
|
569
|
+
*/
|
|
570
|
+
createCommands(): ExtensionCommandReturn;
|
|
571
|
+
uploadFiles: (options: {
|
|
572
|
+
files: File[];
|
|
573
|
+
pos?: number;
|
|
574
|
+
}) => CommandFunction;
|
|
575
|
+
private fileUploadFileHandler;
|
|
576
|
+
createPasteRules(): PasteRule[];
|
|
577
|
+
createInputRules(): InputRule[];
|
|
578
|
+
fromMarkdown(): readonly [{
|
|
579
|
+
readonly type: ParserRuleType.inline;
|
|
580
|
+
readonly token: "md_image";
|
|
581
|
+
readonly node: "md_image";
|
|
582
|
+
}];
|
|
583
|
+
toMarkdown({ state, node }: NodeSerializerOptions): void;
|
|
584
|
+
}
|
|
585
|
+
type ImageAttributes$1 = ProsemirrorAttributes<ImageExtensionAttributes$1>;
|
|
586
|
+
interface ImageExtensionAttributes$1 {
|
|
587
|
+
align?: 'center' | 'end' | 'justify' | 'left' | 'match-parent' | 'right' | 'start';
|
|
588
|
+
alt?: string;
|
|
589
|
+
height?: string | number;
|
|
590
|
+
width?: string | number;
|
|
591
|
+
rotate?: string;
|
|
592
|
+
src: string;
|
|
593
|
+
title?: string;
|
|
594
|
+
/** The file name used to create the image. */
|
|
595
|
+
'data-file-name'?: string;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
type DelayedImage = DelayedPromiseCreator<ImageAttributes>;
|
|
599
|
+
interface ImageOptions {
|
|
600
|
+
createPlaceholder?: (view: EditorView$2, pos: number) => HTMLElement;
|
|
601
|
+
updatePlaceholder?: (view: EditorView$2, pos: number, element: HTMLElement, progress: number) => void;
|
|
602
|
+
handleViewImgSrcUrl?: ExtensionsOptions['handleViewImgSrcUrl'];
|
|
603
|
+
imagePasteHandler?: ExtensionsOptions['imagePasteHandler'];
|
|
604
|
+
destroyPlaceholder?: (view: EditorView$2, element: HTMLElement) => void;
|
|
605
|
+
/**
|
|
606
|
+
* The upload handler for the image extension.
|
|
607
|
+
*
|
|
608
|
+
* It receives a list of dropped or pasted files and returns a promise for the
|
|
609
|
+
* attributes which should be used to insert the image into the editor.
|
|
610
|
+
*
|
|
611
|
+
* @param files - a list of files to upload.
|
|
612
|
+
* @param setProgress - the progress handler.
|
|
613
|
+
*/
|
|
614
|
+
uploadHandler?: (files: FileWithProgress[]) => DelayedImage[];
|
|
615
|
+
/**
|
|
616
|
+
* The image hosting service upload handler.
|
|
617
|
+
* It receives the image src and returns a promise for the new src after uploading to image hosting service.
|
|
618
|
+
*
|
|
619
|
+
* @param src - the original image src
|
|
620
|
+
* @returns Promise<string> - the new image src after uploading
|
|
621
|
+
*/
|
|
622
|
+
imageHostingHandler?: (src: string) => Promise<string>;
|
|
623
|
+
/**
|
|
624
|
+
* When pasting mixed text and image content (usually from Microsoft Office products) the content on the clipboard is either:
|
|
625
|
+
*
|
|
626
|
+
* a. one large image: containing effectively a screenshot of the original content (an image with text in it).
|
|
627
|
+
* b. HTML content: containing usable text, but images with file protocol URLs (which cannot be resolved due to browser security restrictions).
|
|
628
|
+
*
|
|
629
|
+
* If true, this will extract the text from the clipboard data, and drop the images.
|
|
630
|
+
* If false, the "screenshot" image will be used and the text will be dropped.
|
|
631
|
+
*
|
|
632
|
+
* @defaultValue true
|
|
633
|
+
*/
|
|
634
|
+
preferPastedTextContent?: boolean;
|
|
635
|
+
}
|
|
636
|
+
interface FileWithProgress {
|
|
637
|
+
file: File;
|
|
638
|
+
progress: SetProgress;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Set the progress.
|
|
642
|
+
*
|
|
643
|
+
* @param progress - a value between `0` and `1`.
|
|
644
|
+
*/
|
|
645
|
+
type SetProgress = (progress: number) => void;
|
|
646
|
+
/**
|
|
647
|
+
* The image extension for placing images into your editor.
|
|
648
|
+
*
|
|
649
|
+
* TODO ->
|
|
650
|
+
* - Captions https://glitch.com/edit/#!/pet-figcaption?path=index.js%3A27%3A1 into a preset
|
|
651
|
+
*
|
|
652
|
+
* TODO => Split this into an image upload extension and image extension.
|
|
653
|
+
* - Add a base64 image
|
|
654
|
+
*/
|
|
655
|
+
declare class HtmlImageExtension extends NodeExtension<ImageOptions> {
|
|
656
|
+
get name(): "html_image";
|
|
657
|
+
ReactComponent: ComponentType<ImageNodeViewProps> | undefined;
|
|
658
|
+
createTags(): ("inline" | "media")[];
|
|
659
|
+
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
|
|
660
|
+
insertImage(attributes: ImageAttributes, selection?: PrimitiveSelection): CommandFunction;
|
|
661
|
+
createInputRules(): InputRule$1[];
|
|
662
|
+
fromMarkdown(): readonly [{
|
|
663
|
+
readonly type: ParserRuleType.inline;
|
|
664
|
+
readonly token: "html_image";
|
|
665
|
+
readonly node: "html_image";
|
|
666
|
+
}];
|
|
667
|
+
toMarkdown({ state, node }: NodeSerializerOptions): void;
|
|
668
|
+
}
|
|
669
|
+
type ImageAttributes = ProsemirrorAttributes<ImageExtensionAttributes>;
|
|
670
|
+
interface ImageExtensionAttributes {
|
|
671
|
+
align?: 'center' | 'end' | 'justify' | 'left' | 'match-parent' | 'right' | 'start';
|
|
672
|
+
alt?: string;
|
|
673
|
+
height?: string | number;
|
|
674
|
+
width?: string | number;
|
|
675
|
+
rotate?: string;
|
|
676
|
+
src: string;
|
|
677
|
+
title?: string;
|
|
678
|
+
/** The file name used to create the image. */
|
|
679
|
+
'data-file-name'?: string;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* True when the provided file is an image file.
|
|
683
|
+
*/
|
|
684
|
+
declare function isImageFileType(file: File): boolean;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* @public @group Schema
|
|
688
|
+
*/
|
|
689
|
+
interface ListAttributes {
|
|
690
|
+
kind?: string;
|
|
691
|
+
order?: number | null;
|
|
692
|
+
checked?: boolean;
|
|
693
|
+
collapsed?: boolean;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
declare abstract class MarkdownNodeExtension {
|
|
697
|
+
abstract fromMarkdown: () => readonly ParserRule[];
|
|
698
|
+
abstract toMarkdown: NodeSerializerSpec;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* A Remirror extension for creating lists. It's a simple wrapper around the API from `prosemirror-flat-list`.
|
|
703
|
+
*
|
|
704
|
+
* @public
|
|
705
|
+
*/
|
|
706
|
+
declare class LineListExtension extends NodeExtension {
|
|
707
|
+
static disableExtraAttributes: boolean;
|
|
708
|
+
get name(): "list";
|
|
709
|
+
createInputRules(): InputRule$1[];
|
|
710
|
+
createTags(): "block"[];
|
|
711
|
+
createNodeSpec(): NodeExtensionSpec;
|
|
712
|
+
createKeymap(): KeyBindings;
|
|
713
|
+
createExternalPlugins(): ProsemirrorPlugin[];
|
|
714
|
+
createCommands(): {
|
|
715
|
+
readonly indentList: (props?: IndentListOptions) => _rme_sdk_core.CommandFunction<object>;
|
|
716
|
+
readonly dedentList: (props?: DedentListOptions) => _rme_sdk_core.CommandFunction<object>;
|
|
717
|
+
readonly unwrapList: (options?: UnwrapListOptions) => _rme_sdk_core.CommandFunction<object>;
|
|
718
|
+
readonly wrapInList: (getAttrs: ListAttributes | ((range: NodeRange) => ListAttributes | null)) => _rme_sdk_core.CommandFunction<object>;
|
|
719
|
+
readonly moveList: (direction: 'up' | 'down') => _rme_sdk_core.CommandFunction<object>;
|
|
720
|
+
readonly splitList: () => _rme_sdk_core.CommandFunction<object>;
|
|
721
|
+
readonly protectCollapsed: () => _rme_sdk_core.CommandFunction<object>;
|
|
722
|
+
readonly toggleCollapsed: (props?: ToggleCollapsedOptions) => _rme_sdk_core.CommandFunction<object>;
|
|
723
|
+
readonly toggleList: (attrs: ListAttributes) => _rme_sdk_core.CommandFunction<object>;
|
|
724
|
+
};
|
|
725
|
+
fromMarkdown(): readonly [{
|
|
726
|
+
readonly type: ParserRuleType.free;
|
|
727
|
+
readonly token: "list_item_open";
|
|
728
|
+
readonly handler: (state: MarkdownParseState, token: Token) => void;
|
|
729
|
+
}, {
|
|
730
|
+
readonly type: ParserRuleType.free;
|
|
731
|
+
readonly token: "list_checkbox";
|
|
732
|
+
readonly handler: (state: MarkdownParseState, tok: Token) => void;
|
|
733
|
+
}, {
|
|
734
|
+
readonly type: ParserRuleType.free;
|
|
735
|
+
readonly token: "list_item_close";
|
|
736
|
+
readonly handler: (state: MarkdownParseState) => void;
|
|
737
|
+
}, {
|
|
738
|
+
readonly type: ParserRuleType.context;
|
|
739
|
+
readonly token: "bullet_list";
|
|
740
|
+
readonly context: "bullet_list";
|
|
741
|
+
}, {
|
|
742
|
+
readonly type: ParserRuleType.context;
|
|
743
|
+
readonly token: "ordered_list";
|
|
744
|
+
readonly context: "ordered_list";
|
|
745
|
+
}];
|
|
746
|
+
toMarkdown({ state, node, counter }: NodeSerializerOptions): void;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Wrap the giving command function so that it always returns `true`. This is
|
|
750
|
+
* useful when we want pressing `Tab` and `Shift-Tab` won't blur the editor even
|
|
751
|
+
* if the keybinding command returns `false`
|
|
752
|
+
*
|
|
753
|
+
* @public
|
|
754
|
+
*/
|
|
755
|
+
declare function alwaysTrue<T extends unknown[]>(func: (...args: T) => boolean): (...args: T) => boolean;
|
|
756
|
+
declare function isOrderedListNode(node: ProsemirrorNode$1): boolean;
|
|
757
|
+
|
|
390
758
|
type ExtensionsOptions = {
|
|
391
759
|
disableAllBuildInShortcuts?: boolean;
|
|
392
760
|
handleViewImgSrcUrl?: (src: string) => Promise<string>;
|
|
393
761
|
imageHostingHandler?: (src: string) => Promise<string>;
|
|
394
|
-
|
|
762
|
+
imagePasteHandler?: (src: string) => Promise<string>;
|
|
395
763
|
ai?: AIOptions;
|
|
396
764
|
customCopyFunction?: CustomCopyFunction;
|
|
397
765
|
overrideShortcutMap?: Record<string, string>;
|
|
398
766
|
clipboardReadFunction?: ClipboardReadFunction;
|
|
767
|
+
codemirrorOptions?: CodemirrorOptions;
|
|
768
|
+
uploadImageHandler?: (files: FileWithProgress$1[]) => DelayedImage$1[];
|
|
399
769
|
};
|
|
400
770
|
declare function extensions(options: ExtensionsOptions): any[];
|
|
401
771
|
|
|
@@ -502,6 +872,7 @@ declare const darkTheme: {
|
|
|
502
872
|
contextMenuBgColorHover: string;
|
|
503
873
|
slashMenuBorderColor: string;
|
|
504
874
|
editorToolbarBgColor: string;
|
|
875
|
+
selectionMatchBgColor: string;
|
|
505
876
|
lineHeightBase: string;
|
|
506
877
|
titleBarHeight: string;
|
|
507
878
|
titleBarControlBtnWidth: string;
|
|
@@ -569,6 +940,7 @@ declare const lightTheme: {
|
|
|
569
940
|
contextMenuBgColorHover: string;
|
|
570
941
|
slashMenuBorderColor: string;
|
|
571
942
|
editorToolbarBgColor: string;
|
|
943
|
+
selectionMatchBgColor: string;
|
|
572
944
|
lineHeightBase: string;
|
|
573
945
|
titleBarHeight: string;
|
|
574
946
|
titleBarControlBtnWidth: string;
|
|
@@ -622,5 +994,5 @@ type WysiwygToolbarProps = {
|
|
|
622
994
|
};
|
|
623
995
|
declare const WysiwygToolbar: FC<WysiwygToolbarProps>;
|
|
624
996
|
|
|
625
|
-
export { CommandButton, CommandButtonIcon, Editor, extensions as EditorExtensions, EditorViewType, MfCodemirrorView, Preview, SourceCodeThemeWrapper, _default$1 as SourceEditor, ThemeProvider, _default as WysiwygEditor, WysiwygThemeWrapper, WysiwygToolbar, buildMarkdownParser, buildMarkdownSerializer, changeTheme, common, computeChange, createSourceCodeDelegate, createSourceCodeManager, createWysiwygDelegate, darkTheme, defaultStyleToken, extractMatches, getLanguageMap, lightTheme, loadLanguage, tableSelectorSize };
|
|
626
|
-
export type { CommandButtonIconProps, CommandButtonProps, CreateCodemirrorOptions, CreateWysiwygDelegateOptions, DocToString, EditorChangeEventParams, EditorChangeHandler, EditorContext, EditorDelegate, EditorProps, EditorRef, EditorState, HTMLAstNode, Note, StringToDoc, WysiwygToolbarProps };
|
|
997
|
+
export { CommandButton, CommandButtonIcon, Editor, extensions as EditorExtensions, EditorViewType, HtmlImageExtension, LineListExtension, MarkdownNodeExtension, MdImgUriExtension, MfCodemirrorView, Preview, SourceCodeThemeWrapper, _default$1 as SourceEditor, ThemeProvider, _default as WysiwygEditor, WysiwygThemeWrapper, WysiwygToolbar, alwaysTrue, buildMarkdownParser, buildMarkdownSerializer, changeTheme, common, computeChange, createSourceCodeDelegate, createSourceCodeManager, createWysiwygDelegate, darkTheme, defaultStyleToken, extractMatches, getLanguageMap, isImageFileType, isOrderedListNode, lightTheme, loadLanguage, scrollCodemirrorToMatch, tableSelectorSize, updateCodemirrorSearchQuery, updateCodemirrorSearchState };
|
|
998
|
+
export type { CommandButtonIconProps, CommandButtonProps, CreateCodemirrorOptions, CreateWysiwygDelegateOptions, DelayedImage$1 as DelayedImage, DocToString, EditorChangeEventParams, EditorChangeHandler, EditorContext, EditorDelegate, EditorProps, EditorRef, EditorState, ExtensionsOptions, FileWithProgress$1 as FileWithProgress, HTMLAstNode, ImageAttributes, ImageExtensionAttributes, ImageOptions, Note, StringToDoc, WysiwygToolbarProps };
|