forked from aguingand/tiptap-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
48 lines (40 loc) · 1.63 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Editor, Extension } from "@tiptap/core";
import { MarkdownSerializer, MarkdownSerializerState } from "prosemirror-markdown";
import * as Prosemirror from "prosemirror-model";
import * as MarkdownIt from "markdown-it";
export interface MarkdownOptions {
html?: Boolean,
tightLists?: Boolean,
tightListClass?: String,
bulletListMarker?: String,
linkify?: Boolean,
breaks?: Boolean,
transformPastedText?: Boolean,
transformCopiedText?: Boolean,
}
export interface MarkdownStorage {
options: MarkdownOptions,
getMarkdown(): string,
}
type SpecContext<Options> = {
options: Options,
editor: Editor,
}
export type MarkdownNodeSpec<O = any> = {
serialize(this: SpecContext<O>, state: MarkdownSerializerState, node: Prosemirror.Node, parent: Prosemirror.Node, index: number): void,
parse?: {
setup?(this: SpecContext<O>, markdownit: MarkdownIt): void,
updateDOM?(this: SpecContext<O>, element: HTMLElement): void
},
}
export type MarkdownMarkSpec<O = any> = {
serialize: typeof MarkdownSerializer.prototype.marks[string] & {
open: string | ((this: SpecContext<O>, state: MarkdownSerializerState, mark: Prosemirror.Mark, parent: Prosemirror.Node, index: number) => string);
close: string | ((this: SpecContext<O>, state: MarkdownSerializerState, mark: Prosemirror.Mark, parent: Prosemirror.Node, index: number) => string);
},
parse?: {
setup?(this: SpecContext<O>, markdownit: MarkdownIt): void,
updateDOM?(this: SpecContext<O>, element: HTMLElement): void
},
}
export declare const Markdown: Extension<MarkdownOptions, MarkdownStorage>;