quoin-editor 0.4.2 → 1.0.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 +205 -0
- package/MIGRATION.md +233 -0
- package/README.md +78 -716
- package/dist/ai.cjs +1107 -0
- package/dist/ai.cjs.map +1 -0
- package/dist/ai.d.cts +68 -0
- package/dist/ai.d.ts +68 -0
- package/dist/ai.js +1107 -0
- package/dist/ai.js.map +1 -0
- package/dist/catalogue.cjs +59 -0
- package/dist/catalogue.cjs.map +1 -0
- package/dist/catalogue.d.cts +39 -0
- package/dist/catalogue.d.ts +39 -0
- package/dist/catalogue.js +59 -0
- package/dist/catalogue.js.map +1 -0
- package/dist/chunk-2QCRZ7OL.cjs +319 -0
- package/dist/chunk-2QCRZ7OL.cjs.map +1 -0
- package/dist/chunk-2VDK27IF.cjs +6666 -0
- package/dist/chunk-2VDK27IF.cjs.map +1 -0
- package/dist/chunk-47MLKSI2.js +326 -0
- package/dist/chunk-47MLKSI2.js.map +1 -0
- package/dist/chunk-5DNCCN6X.cjs +326 -0
- package/dist/chunk-5DNCCN6X.cjs.map +1 -0
- package/dist/chunk-AEJXZBVR.cjs +1378 -0
- package/dist/chunk-AEJXZBVR.cjs.map +1 -0
- package/dist/chunk-CDELOHDY.cjs +239 -0
- package/dist/chunk-CDELOHDY.cjs.map +1 -0
- package/dist/chunk-E75EHRPA.cjs +175 -0
- package/dist/chunk-E75EHRPA.cjs.map +1 -0
- package/dist/chunk-EL2OEJQC.cjs +562 -0
- package/dist/chunk-EL2OEJQC.cjs.map +1 -0
- package/dist/chunk-GLLXHMH2.cjs +25 -0
- package/dist/chunk-GLLXHMH2.cjs.map +1 -0
- package/dist/chunk-GTTPVJSD.cjs +3286 -0
- package/dist/chunk-GTTPVJSD.cjs.map +1 -0
- package/dist/chunk-HELJTLNC.cjs +100 -0
- package/dist/chunk-HELJTLNC.cjs.map +1 -0
- package/dist/chunk-HJIQT3S5.js +4047 -0
- package/dist/chunk-HJIQT3S5.js.map +1 -0
- package/dist/chunk-HZSSEYJS.cjs +504 -0
- package/dist/chunk-HZSSEYJS.cjs.map +1 -0
- package/dist/chunk-JDPTZUBW.js +184 -0
- package/dist/chunk-JDPTZUBW.js.map +1 -0
- package/dist/chunk-JEIFJHEI.js +14 -0
- package/dist/chunk-JEIFJHEI.js.map +1 -0
- package/dist/chunk-K574XHMM.js +25 -0
- package/dist/chunk-K574XHMM.js.map +1 -0
- package/dist/chunk-KAVU6T6J.js +249 -0
- package/dist/chunk-KAVU6T6J.js.map +1 -0
- package/dist/chunk-KXOBZGQO.js +1378 -0
- package/dist/chunk-KXOBZGQO.js.map +1 -0
- package/dist/chunk-LCQSG4M6.js +3335 -0
- package/dist/chunk-LCQSG4M6.js.map +1 -0
- package/dist/chunk-MQ2XQ4MX.js +100 -0
- package/dist/chunk-MQ2XQ4MX.js.map +1 -0
- package/dist/chunk-ND5XJVK2.cjs +3335 -0
- package/dist/chunk-ND5XJVK2.cjs.map +1 -0
- package/dist/chunk-NNDYYEW5.js +504 -0
- package/dist/chunk-NNDYYEW5.js.map +1 -0
- package/dist/chunk-NOKWNK2O.js +319 -0
- package/dist/chunk-NOKWNK2O.js.map +1 -0
- package/dist/chunk-OMOBMXD5.cjs +57 -0
- package/dist/chunk-OMOBMXD5.cjs.map +1 -0
- package/dist/chunk-PMWCQSQX.js +239 -0
- package/dist/chunk-PMWCQSQX.js.map +1 -0
- package/dist/chunk-POBM7MGR.js +30 -0
- package/dist/chunk-POBM7MGR.js.map +1 -0
- package/dist/chunk-PWUEPDA3.cjs +598 -0
- package/dist/chunk-PWUEPDA3.cjs.map +1 -0
- package/dist/chunk-PZ4GT5JO.cjs +4047 -0
- package/dist/chunk-PZ4GT5JO.cjs.map +1 -0
- package/dist/chunk-QAW5NH6S.cjs +14 -0
- package/dist/chunk-QAW5NH6S.cjs.map +1 -0
- package/dist/chunk-RDG4VI6E.cjs +706 -0
- package/dist/chunk-RDG4VI6E.cjs.map +1 -0
- package/dist/chunk-RUDWMKYX.js +562 -0
- package/dist/chunk-RUDWMKYX.js.map +1 -0
- package/dist/chunk-SG37UBDO.js +706 -0
- package/dist/chunk-SG37UBDO.js.map +1 -0
- package/dist/chunk-SLVDAHHK.cjs +30 -0
- package/dist/chunk-SLVDAHHK.cjs.map +1 -0
- package/dist/chunk-T7SW6OWV.js +598 -0
- package/dist/chunk-T7SW6OWV.js.map +1 -0
- package/dist/chunk-TC4DARU2.js +175 -0
- package/dist/chunk-TC4DARU2.js.map +1 -0
- package/dist/chunk-WQHV3MRE.cjs +184 -0
- package/dist/chunk-WQHV3MRE.cjs.map +1 -0
- package/dist/chunk-WXMYDXPN.cjs +33 -0
- package/dist/chunk-WXMYDXPN.cjs.map +1 -0
- package/dist/chunk-XEBWC7ZL.js +57 -0
- package/dist/chunk-XEBWC7ZL.js.map +1 -0
- package/dist/chunk-ZC24WB7Y.cjs +249 -0
- package/dist/chunk-ZC24WB7Y.cjs.map +1 -0
- package/dist/chunk-ZGZEJCRV.js +6666 -0
- package/dist/chunk-ZGZEJCRV.js.map +1 -0
- package/dist/chunk-ZHOSSWUM.js +33 -0
- package/dist/chunk-ZHOSSWUM.js.map +1 -0
- package/dist/chunk-ZS2WA357.js +3286 -0
- package/dist/chunk-ZS2WA357.js.map +1 -0
- package/dist/comments.cjs +993 -0
- package/dist/comments.cjs.map +1 -0
- package/dist/comments.d.cts +88 -0
- package/dist/comments.d.ts +88 -0
- package/dist/comments.js +993 -0
- package/dist/comments.js.map +1 -0
- package/dist/diff.cjs +343 -0
- package/dist/diff.cjs.map +1 -0
- package/dist/diff.d.cts +67 -0
- package/dist/diff.d.ts +67 -0
- package/dist/diff.js +343 -0
- package/dist/diff.js.map +1 -0
- package/dist/docx.cjs +854 -0
- package/dist/docx.cjs.map +1 -0
- package/dist/docx.d.cts +27 -0
- package/dist/docx.d.ts +27 -0
- package/dist/docx.js +854 -0
- package/dist/docx.js.map +1 -0
- package/dist/embed-provider-jXwlRmnp.d.cts +19 -0
- package/dist/embed-provider-jXwlRmnp.d.ts +19 -0
- package/dist/embed.cjs +17 -0
- package/dist/embed.cjs.map +1 -0
- package/dist/embed.d.cts +56 -0
- package/dist/embed.d.ts +56 -0
- package/dist/embed.js +17 -0
- package/dist/embed.js.map +1 -0
- package/dist/emoji-data.cjs +1968 -0
- package/dist/emoji-data.cjs.map +1 -0
- package/dist/emoji-data.js +1968 -0
- package/dist/emoji-data.js.map +1 -0
- package/dist/emoji-extension-C12gDPm6.d.cts +46 -0
- package/dist/emoji-extension-DpQ43HjE.d.ts +46 -0
- package/dist/emoji.cjs +18 -0
- package/dist/emoji.cjs.map +1 -0
- package/dist/emoji.d.cts +31 -0
- package/dist/emoji.d.ts +31 -0
- package/dist/emoji.js +18 -0
- package/dist/emoji.js.map +1 -0
- package/dist/engine.cjs +119 -0
- package/dist/engine.cjs.map +1 -0
- package/dist/engine.d.cts +144 -0
- package/dist/engine.d.ts +144 -0
- package/dist/engine.js +119 -0
- package/dist/engine.js.map +1 -0
- package/dist/find-extension-DKqLLSuP.d.ts +41 -0
- package/dist/find-extension-_sbZEt3R.d.cts +41 -0
- package/dist/find.cjs +20 -0
- package/dist/find.cjs.map +1 -0
- package/dist/find.d.cts +44 -0
- package/dist/find.d.ts +44 -0
- package/dist/find.js +20 -0
- package/dist/find.js.map +1 -0
- package/dist/headless.cjs +151 -518
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +102 -69
- package/dist/headless.d.ts +102 -69
- package/dist/headless.js +149 -467
- package/dist/headless.js.map +1 -1
- package/dist/index-CgD72kHB.d.cts +65 -0
- package/dist/index-DNYbTK3w.d.ts +65 -0
- package/dist/index.cjs +183 -2753
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +345 -253
- package/dist/index.d.ts +345 -253
- package/dist/index.js +168 -2696
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +18 -0
- package/dist/math.cjs.map +1 -0
- package/dist/math.d.cts +49 -0
- package/dist/math.d.ts +49 -0
- package/dist/math.js +18 -0
- package/dist/math.js.map +1 -0
- package/dist/mention.cjs +18 -0
- package/dist/mention.cjs.map +1 -0
- package/dist/mention.d.cts +50 -0
- package/dist/mention.d.ts +50 -0
- package/dist/mention.js +18 -0
- package/dist/mention.js.map +1 -0
- package/dist/presence.cjs +565 -0
- package/dist/presence.cjs.map +1 -0
- package/dist/presence.d.cts +30 -0
- package/dist/presence.d.ts +30 -0
- package/dist/presence.js +565 -0
- package/dist/presence.js.map +1 -0
- package/dist/registry-CWBOSAHm.d.cts +121 -0
- package/dist/registry-CWBOSAHm.d.ts +121 -0
- package/dist/stats-extension-Bly88uio.d.ts +40 -0
- package/dist/stats-extension-CJPijvUb.d.cts +40 -0
- package/dist/stats.cjs +19 -0
- package/dist/stats.cjs.map +1 -0
- package/dist/stats.d.cts +19 -0
- package/dist/stats.d.ts +19 -0
- package/dist/stats.js +19 -0
- package/dist/stats.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/table-extension-BTLxFy2S.d.cts +57 -0
- package/dist/table-extension-Dzf4k6hI.d.ts +57 -0
- package/dist/table.cjs +50 -0
- package/dist/table.cjs.map +1 -0
- package/dist/table.d.cts +57 -0
- package/dist/table.d.ts +57 -0
- package/dist/table.js +50 -0
- package/dist/table.js.map +1 -0
- package/dist/to-html-C5t7xyaM.d.ts +21 -0
- package/dist/to-html-CNCITCln.d.cts +21 -0
- package/dist/toc-extension-B3-s6h2x.d.cts +25 -0
- package/dist/toc-extension-DWm5alVj.d.ts +25 -0
- package/dist/toc.cjs +18 -0
- package/dist/toc.cjs.map +1 -0
- package/dist/toc.d.cts +24 -0
- package/dist/toc.d.ts +24 -0
- package/dist/toc.js +18 -0
- package/dist/toc.js.map +1 -0
- package/dist/types-Cz7XJLaK.d.cts +366 -0
- package/dist/types-DULc8wwg.d.cts +120 -0
- package/dist/types-DULc8wwg.d.ts +120 -0
- package/dist/types-a1CRBlEh.d.ts +366 -0
- package/dist/view-controller-DSHw0ltQ.d.cts +118 -0
- package/dist/view-controller-UbpzblGl.d.ts +118 -0
- package/dist/view.cjs +23 -0
- package/dist/view.cjs.map +1 -0
- package/dist/view.d.cts +40 -0
- package/dist/view.d.ts +40 -0
- package/dist/view.js +23 -0
- package/dist/view.js.map +1 -0
- package/dist/yjs.cjs +1026 -0
- package/dist/yjs.cjs.map +1 -0
- package/dist/yjs.d.cts +22 -0
- package/dist/yjs.d.ts +22 -0
- package/dist/yjs.js +1026 -0
- package/dist/yjs.js.map +1 -0
- package/package.json +217 -18
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { E as EngineDoc, P as Pos, B as BlockAttrs, I as Inline, a as Selection, M as Mark, S as Schema, A as Attrs, Q as QuoinBlock, g as BlockSpec, k as MarkSpec, c as AtomSpec } from './types-DULc8wwg.cjs';
|
|
2
|
+
|
|
3
|
+
type Align = 'left' | 'center' | 'right' | 'justify';
|
|
4
|
+
|
|
5
|
+
type Assoc = -1 | 1;
|
|
6
|
+
type PosMap = (pos: Pos, assoc?: Assoc) => Pos;
|
|
7
|
+
type StepResult = {
|
|
8
|
+
doc: EngineDoc;
|
|
9
|
+
map: PosMap;
|
|
10
|
+
};
|
|
11
|
+
type StepJSON = {
|
|
12
|
+
readonly stepType: string;
|
|
13
|
+
} & Readonly<Record<string, unknown>>;
|
|
14
|
+
interface Step {
|
|
15
|
+
readonly stepType: string;
|
|
16
|
+
apply(doc: EngineDoc): StepResult;
|
|
17
|
+
invert(before: EngineDoc): Step;
|
|
18
|
+
toJSON(): StepJSON;
|
|
19
|
+
}
|
|
20
|
+
type CreatedBlock = {
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
attrs: BlockAttrs;
|
|
24
|
+
indent: number;
|
|
25
|
+
region: string;
|
|
26
|
+
regions?: Record<string, Inline>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type TransactionOrigin = 'input' | 'command' | 'paste' | 'drop' | 'remote' | 'reconcile' | 'ai' | 'history';
|
|
30
|
+
declare class Transaction {
|
|
31
|
+
readonly before: EditorState;
|
|
32
|
+
readonly time: number;
|
|
33
|
+
private currentDoc;
|
|
34
|
+
private currentSelection;
|
|
35
|
+
private currentStoredMarks;
|
|
36
|
+
private selectionWasSet;
|
|
37
|
+
private storedMarksWereSet;
|
|
38
|
+
private readonly stepList;
|
|
39
|
+
private readonly docList;
|
|
40
|
+
private readonly mapList;
|
|
41
|
+
private readonly metaValues;
|
|
42
|
+
constructor(state: EditorState, time?: number);
|
|
43
|
+
get doc(): EngineDoc;
|
|
44
|
+
get docs(): readonly EngineDoc[];
|
|
45
|
+
get steps(): readonly Step[];
|
|
46
|
+
get maps(): readonly PosMap[];
|
|
47
|
+
get docChanged(): boolean;
|
|
48
|
+
get selection(): Selection | null;
|
|
49
|
+
get selectionSet(): boolean;
|
|
50
|
+
get storedMarks(): readonly Mark[] | null;
|
|
51
|
+
get storedMarksSet(): boolean;
|
|
52
|
+
get meta(): ReadonlyMap<string, unknown>;
|
|
53
|
+
get origin(): TransactionOrigin;
|
|
54
|
+
get addToHistory(): boolean;
|
|
55
|
+
step(step: Step): this;
|
|
56
|
+
maybeStep(step: Step): boolean;
|
|
57
|
+
setSelection(selection: Selection | null): this;
|
|
58
|
+
setStoredMarks(marks: readonly Mark[] | null): this;
|
|
59
|
+
setOrigin(origin: TransactionOrigin): this;
|
|
60
|
+
setMeta(key: string, value: unknown): this;
|
|
61
|
+
getMeta<T>(key: string): T | undefined;
|
|
62
|
+
mapPos(pos: Pos, assoc?: Assoc, fromStep?: number): Pos;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type PluginKey<T> = {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly __value?: T;
|
|
68
|
+
};
|
|
69
|
+
declare function createPluginKey<T>(name: string): PluginKey<T>;
|
|
70
|
+
type PluginSpec<T> = {
|
|
71
|
+
readonly key: PluginKey<T>;
|
|
72
|
+
init(state: EditorState): T;
|
|
73
|
+
apply(tr: Transaction, value: T, oldState: EditorState, newState: EditorState): T;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type EditorState = {
|
|
77
|
+
readonly doc: EngineDoc;
|
|
78
|
+
readonly selection: Selection | null;
|
|
79
|
+
readonly storedMarks: readonly Mark[] | null;
|
|
80
|
+
readonly schema: Schema;
|
|
81
|
+
readonly plugins: readonly PluginSpec<unknown>[];
|
|
82
|
+
readonly pluginState: ReadonlyMap<string, unknown>;
|
|
83
|
+
readonly clock: () => number;
|
|
84
|
+
};
|
|
85
|
+
declare function createState(config: {
|
|
86
|
+
doc: EngineDoc;
|
|
87
|
+
schema: Schema;
|
|
88
|
+
selection?: Selection | null;
|
|
89
|
+
plugins?: readonly PluginSpec<unknown>[];
|
|
90
|
+
clock?: () => number;
|
|
91
|
+
}): EditorState;
|
|
92
|
+
declare function applyTransaction(state: EditorState, tr: Transaction): EditorState;
|
|
93
|
+
declare function getPluginState<T>(state: EditorState, key: PluginKey<T>): T;
|
|
94
|
+
|
|
95
|
+
type Command = (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
96
|
+
|
|
97
|
+
type BlockStructureOptions = {
|
|
98
|
+
newId?: () => string;
|
|
99
|
+
};
|
|
100
|
+
declare function duplicateBlocks(options?: BlockStructureOptions): Command;
|
|
101
|
+
declare function insertBlockAfter(type: string, attrs?: BlockAttrs, options?: BlockStructureOptions): Command;
|
|
102
|
+
|
|
103
|
+
declare function setAttrs(patch: Record<string, unknown>): Command;
|
|
104
|
+
declare function setTextAlign(align: Align | null): Command;
|
|
105
|
+
declare function setBlockColor(colors: {
|
|
106
|
+
color?: string | null;
|
|
107
|
+
background?: string | null;
|
|
108
|
+
}): Command;
|
|
109
|
+
|
|
110
|
+
type InsertTextOptions = {
|
|
111
|
+
origin?: TransactionOrigin;
|
|
112
|
+
newId?: () => string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Inserts `value` at the selection, in place of any selected text or blocks, as a command an extension can return. It is
|
|
116
|
+
* an undo step of its own unless `options.origin` is `input`, which groups it with the typing around it.
|
|
117
|
+
*/
|
|
118
|
+
declare function insertText(value: string, options?: InsertTextOptions): Command;
|
|
119
|
+
|
|
120
|
+
declare function toggleMark(type: string, attrs?: Attrs): Command;
|
|
121
|
+
declare function setMark(type: string, attrs?: Attrs): Command;
|
|
122
|
+
declare function unsetMark(type: string): Command;
|
|
123
|
+
declare function setLink(href: string, title?: string): Command;
|
|
124
|
+
declare function insertAtom(type: string, attrs: Attrs): Command;
|
|
125
|
+
declare function insertMention(mention: {
|
|
126
|
+
id: string;
|
|
127
|
+
label: string;
|
|
128
|
+
kind?: string;
|
|
129
|
+
}): Command;
|
|
130
|
+
|
|
131
|
+
/** Moves the blocks and their nested blocks to `toIndex`, counted among the blocks that stay, as one range. */
|
|
132
|
+
declare function moveBlocksTo(ids: readonly string[], toIndex: number, indent: number): Command;
|
|
133
|
+
|
|
134
|
+
declare function setSelection(selection: Selection | null): Command;
|
|
135
|
+
|
|
136
|
+
declare function splitBlock(options?: {
|
|
137
|
+
newId?: () => string;
|
|
138
|
+
}): Command;
|
|
139
|
+
|
|
140
|
+
declare function setBlockType(type: string, attrs?: BlockAttrs): Command;
|
|
141
|
+
|
|
142
|
+
type CommandFactories = Readonly<Record<string, (...args: never[]) => Command>>;
|
|
143
|
+
type BoundCommands<F extends CommandFactories> = {
|
|
144
|
+
[K in keyof F]: (...args: Parameters<F[K]>) => boolean;
|
|
145
|
+
};
|
|
146
|
+
type Chain<F extends CommandFactories> = {
|
|
147
|
+
[K in keyof F]: (...args: Parameters<F[K]>) => Chain<F>;
|
|
148
|
+
} & {
|
|
149
|
+
run(): boolean;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
type InputRuleRange = {
|
|
153
|
+
block: string;
|
|
154
|
+
region: string;
|
|
155
|
+
from: number;
|
|
156
|
+
to: number;
|
|
157
|
+
};
|
|
158
|
+
type InputRuleContext = {
|
|
159
|
+
readonly newId: () => string;
|
|
160
|
+
};
|
|
161
|
+
type InputRule = {
|
|
162
|
+
readonly name: string;
|
|
163
|
+
readonly match: RegExp;
|
|
164
|
+
readonly blockTypes?: readonly string[];
|
|
165
|
+
readonly kinds?: readonly string[];
|
|
166
|
+
handler(state: EditorState, match: RegExpExecArray, range: InputRuleRange, context?: InputRuleContext): Transaction | null;
|
|
167
|
+
};
|
|
168
|
+
declare function insertTextWithRules(value: string, rules: readonly InputRule[], options?: {
|
|
169
|
+
newId?: () => string;
|
|
170
|
+
}): Command;
|
|
171
|
+
|
|
172
|
+
type DOMParserLike = {
|
|
173
|
+
parseFromString(html: string, type: 'text/html'): {
|
|
174
|
+
readonly body: object;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
type FromHTMLOptions = {
|
|
178
|
+
parser?: DOMParserLike;
|
|
179
|
+
newId?: () => string;
|
|
180
|
+
};
|
|
181
|
+
declare function fromHTML(html: string, options?: FromHTMLOptions): QuoinBlock[];
|
|
182
|
+
|
|
183
|
+
type Slice = {
|
|
184
|
+
readonly blocks: readonly QuoinBlock[];
|
|
185
|
+
readonly openStart: boolean;
|
|
186
|
+
readonly openEnd: boolean;
|
|
187
|
+
/** Read from plain text: its first line takes the type of an empty block it is pasted into. */
|
|
188
|
+
readonly plainText?: boolean;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
type TextStats = {
|
|
192
|
+
characters: number;
|
|
193
|
+
words: number;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
declare function insertSlice(slice: Slice, options?: {
|
|
197
|
+
newId?: () => string;
|
|
198
|
+
}): Command;
|
|
199
|
+
|
|
200
|
+
declare function pasteLinkOverSelection(text: string): Command;
|
|
201
|
+
|
|
202
|
+
declare const coreCommands: {
|
|
203
|
+
insertSlice: typeof insertSlice;
|
|
204
|
+
pasteLinkOverSelection: typeof pasteLinkOverSelection;
|
|
205
|
+
insertTextWithRules: typeof insertTextWithRules;
|
|
206
|
+
insertText: typeof insertText;
|
|
207
|
+
insertHardBreak: () => Command;
|
|
208
|
+
deleteSelection: () => Command;
|
|
209
|
+
deleteBackward: () => Command;
|
|
210
|
+
deleteForward: () => Command;
|
|
211
|
+
deleteWordBackward: () => Command;
|
|
212
|
+
deleteWordForward: () => Command;
|
|
213
|
+
deleteToLineStart: () => Command;
|
|
214
|
+
deleteToLineEnd: () => Command;
|
|
215
|
+
splitBlock: typeof splitBlock;
|
|
216
|
+
undo: () => Command;
|
|
217
|
+
redo: () => Command;
|
|
218
|
+
undoInputRule: () => Command;
|
|
219
|
+
toggleMark: typeof toggleMark;
|
|
220
|
+
setMark: typeof setMark;
|
|
221
|
+
unsetMark: typeof unsetMark;
|
|
222
|
+
setLink: typeof setLink;
|
|
223
|
+
unsetLink: () => Command;
|
|
224
|
+
clearFormatting: () => Command;
|
|
225
|
+
insertAtom: typeof insertAtom;
|
|
226
|
+
insertMention: typeof insertMention;
|
|
227
|
+
setBlockType: typeof setBlockType;
|
|
228
|
+
setAttrs: typeof setAttrs;
|
|
229
|
+
toggleTask: () => Command;
|
|
230
|
+
indent: () => Command;
|
|
231
|
+
outdent: () => Command;
|
|
232
|
+
moveBlocksUp: () => Command;
|
|
233
|
+
moveBlocksDown: () => Command;
|
|
234
|
+
moveBlocksTo: typeof moveBlocksTo;
|
|
235
|
+
duplicateBlocks: typeof duplicateBlocks;
|
|
236
|
+
deleteBlocks: () => Command;
|
|
237
|
+
insertBlockAfter: typeof insertBlockAfter;
|
|
238
|
+
setTextAlign: typeof setTextAlign;
|
|
239
|
+
setBlockColor: typeof setBlockColor;
|
|
240
|
+
selectAll: () => Command;
|
|
241
|
+
selectBlock: () => Command;
|
|
242
|
+
setSelection: typeof setSelection;
|
|
243
|
+
};
|
|
244
|
+
type CoreCommands = typeof coreCommands;
|
|
245
|
+
type CoreExtensionOptions = {
|
|
246
|
+
typography?: {
|
|
247
|
+
dashes?: 'em' | 'en' | 'none';
|
|
248
|
+
} | false;
|
|
249
|
+
newId?: () => string;
|
|
250
|
+
};
|
|
251
|
+
declare function coreExtensions(options?: CoreExtensionOptions): Extension[];
|
|
252
|
+
|
|
253
|
+
type KeyLike = {
|
|
254
|
+
key: string;
|
|
255
|
+
code?: string;
|
|
256
|
+
altKey: boolean;
|
|
257
|
+
ctrlKey: boolean;
|
|
258
|
+
metaKey: boolean;
|
|
259
|
+
shiftKey: boolean;
|
|
260
|
+
};
|
|
261
|
+
declare function normalizeKey(name: string, isMac: boolean): string;
|
|
262
|
+
declare function keyName(event: KeyLike, isMac: boolean): string;
|
|
263
|
+
|
|
264
|
+
type EditorOptions = {
|
|
265
|
+
blocks: readonly QuoinBlock[];
|
|
266
|
+
extensions?: readonly Extension[];
|
|
267
|
+
onChange?: (blocks: QuoinBlock[]) => void;
|
|
268
|
+
onTransaction?: (tr: Transaction, state: EditorState) => void;
|
|
269
|
+
newId?: () => string;
|
|
270
|
+
now?: () => number;
|
|
271
|
+
isMac?: boolean;
|
|
272
|
+
/** Turns a storage key into the url written for IMAGE and FILE blocks in copies and, by default, in toMarkdown. */
|
|
273
|
+
resolveAssetUrl?: (key: string) => string;
|
|
274
|
+
};
|
|
275
|
+
type MarkdownOptions = {
|
|
276
|
+
comments?: boolean;
|
|
277
|
+
/** Write what markdown cannot hold as quoin comments. Plain export drops block-level extras and other data. */
|
|
278
|
+
lossless?: boolean;
|
|
279
|
+
resolveAssetUrl?: (key: string) => string;
|
|
280
|
+
};
|
|
281
|
+
type Editor<F extends CommandFactories = CoreCommands> = {
|
|
282
|
+
readonly state: EditorState;
|
|
283
|
+
readonly schema: Schema;
|
|
284
|
+
dispatch(tr: Transaction): void;
|
|
285
|
+
createTransaction(): Transaction;
|
|
286
|
+
subscribe(listener: (state: EditorState, tr: Transaction | null) => void): () => void;
|
|
287
|
+
readonly commands: BoundCommands<F>;
|
|
288
|
+
chain(): Chain<F>;
|
|
289
|
+
can(): BoundCommands<F>;
|
|
290
|
+
isActive(name: string, attrs?: Record<string, unknown>): boolean;
|
|
291
|
+
insertText(text: string): boolean;
|
|
292
|
+
handleKey(event: KeyLike): boolean;
|
|
293
|
+
paste(data: {
|
|
294
|
+
json?: string;
|
|
295
|
+
html?: string;
|
|
296
|
+
text?: string;
|
|
297
|
+
}, parser?: DOMParserLike): boolean;
|
|
298
|
+
copy(): {
|
|
299
|
+
json: string;
|
|
300
|
+
html: string;
|
|
301
|
+
text: string;
|
|
302
|
+
} | null;
|
|
303
|
+
getBlocks(): QuoinBlock[];
|
|
304
|
+
setBlocks(blocks: readonly QuoinBlock[]): boolean;
|
|
305
|
+
/** Runs the extensions' `onMount`, as a view does when it attaches; returns the means to end that mount. */
|
|
306
|
+
mount(): () => void;
|
|
307
|
+
decorations(): readonly Decoration[];
|
|
308
|
+
toMarkdown(options?: MarkdownOptions): string;
|
|
309
|
+
stats(): TextStats;
|
|
310
|
+
destroy(): void;
|
|
311
|
+
};
|
|
312
|
+
declare function createEditor<F extends CommandFactories = CoreCommands>(options: EditorOptions): Editor<F>;
|
|
313
|
+
|
|
314
|
+
type Decoration = {
|
|
315
|
+
readonly kind: 'inline';
|
|
316
|
+
readonly block: string;
|
|
317
|
+
readonly region: string;
|
|
318
|
+
readonly from: number;
|
|
319
|
+
readonly to: number;
|
|
320
|
+
readonly attrs: Attrs;
|
|
321
|
+
} | {
|
|
322
|
+
readonly kind: 'widget';
|
|
323
|
+
readonly block: string;
|
|
324
|
+
readonly region: string;
|
|
325
|
+
readonly offset: number;
|
|
326
|
+
readonly key: string;
|
|
327
|
+
readonly widget: string;
|
|
328
|
+
readonly attrs: Attrs;
|
|
329
|
+
readonly side?: -1 | 1;
|
|
330
|
+
}
|
|
331
|
+
/** Attributes written on the element of a whole block: `data-*` and `aria-*` names only. */
|
|
332
|
+
| {
|
|
333
|
+
readonly kind: 'block';
|
|
334
|
+
readonly block: string;
|
|
335
|
+
readonly attrs: Attrs;
|
|
336
|
+
};
|
|
337
|
+
type PasteRule = {
|
|
338
|
+
readonly name: string;
|
|
339
|
+
match(text: string, state: EditorState): Command | null;
|
|
340
|
+
};
|
|
341
|
+
type Extension = {
|
|
342
|
+
readonly name: string;
|
|
343
|
+
readonly priority?: number;
|
|
344
|
+
readonly blocks?: readonly BlockSpec[];
|
|
345
|
+
readonly marks?: readonly MarkSpec[];
|
|
346
|
+
readonly atoms?: readonly AtomSpec[];
|
|
347
|
+
readonly inputRules?: readonly InputRule[];
|
|
348
|
+
readonly pasteRules?: readonly PasteRule[];
|
|
349
|
+
readonly keymap?: Readonly<Record<string, Command>>;
|
|
350
|
+
readonly commands?: CommandFactories;
|
|
351
|
+
readonly plugins?: readonly PluginSpec<unknown>[];
|
|
352
|
+
readonly decorations?: (state: EditorState) => readonly Decoration[];
|
|
353
|
+
readonly onTransaction?: (tr: Transaction, state: EditorState) => void;
|
|
354
|
+
/**
|
|
355
|
+
* Refuses a transaction before it applies by returning false: the editor drops it whole. Undo and redo, the undo of an
|
|
356
|
+
* input rule, the blocks the host supplies and remote transactions are never filtered.
|
|
357
|
+
*/
|
|
358
|
+
readonly filterTransaction?: (tr: Transaction, state: EditorState) => boolean;
|
|
359
|
+
/** Returns false to refuse blocks the host supplies that differ from the document, which then stays as it is. */
|
|
360
|
+
readonly filterHostBlocks?: (blocks: readonly QuoinBlock[], state: EditorState) => boolean;
|
|
361
|
+
/** Runs on each `editor.mount()`; what it returns runs when that mount ends or the editor is destroyed. */
|
|
362
|
+
readonly onMount?: (editor: Editor<CommandFactories>) => (() => void) | void;
|
|
363
|
+
readonly ui?: unknown;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export { type Align as A, type BlockStructureOptions as B, type CommandFactories as C, type Decoration as D, type Extension as E, type FromHTMLOptions as F, createState as G, fromHTML as H, type InputRule as I, getPluginState as J, type KeyLike as K, insertBlockAfter as L, type MarkdownOptions as M, insertText as N, insertTextWithRules as O, type PluginKey as P, keyName as Q, normalizeKey as R, type Step as S, Transaction as T, setBlockType as U, toggleMark as V, type Editor as a, type Command as b, type EditorState as c, type PluginSpec as d, type Assoc as e, type BoundCommands as f, type Chain as g, type CoreCommands as h, type CoreExtensionOptions as i, type CreatedBlock as j, type DOMParserLike as k, type EditorOptions as l, type InputRuleContext as m, type InputRuleRange as n, type InsertTextOptions as o, type PasteRule as p, type PosMap as q, type Slice as r, type StepJSON as s, type StepResult as t, type TextStats as u, type TransactionOrigin as v, applyTransaction as w, coreExtensions as x, createEditor as y, createPluginKey as z };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
type Attrs = Readonly<Record<string, string>>;
|
|
2
|
+
type Mark = {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly attrs?: Attrs;
|
|
5
|
+
};
|
|
6
|
+
type TextNode = {
|
|
7
|
+
readonly kind: 'text';
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly marks: readonly Mark[];
|
|
10
|
+
};
|
|
11
|
+
type AtomNode = {
|
|
12
|
+
readonly kind: 'atom';
|
|
13
|
+
readonly type: string;
|
|
14
|
+
readonly attrs: Attrs;
|
|
15
|
+
readonly marks: readonly Mark[];
|
|
16
|
+
};
|
|
17
|
+
type InlineNode = TextNode | AtomNode;
|
|
18
|
+
type Inline = readonly InlineNode[];
|
|
19
|
+
type BlockAttrs = Readonly<Record<string, unknown>>;
|
|
20
|
+
type EngineBlock = {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly type: string;
|
|
23
|
+
readonly indent: number;
|
|
24
|
+
readonly attrs: BlockAttrs;
|
|
25
|
+
readonly regions: Readonly<Record<string, Inline>>;
|
|
26
|
+
};
|
|
27
|
+
type EngineDoc = {
|
|
28
|
+
readonly blocks: readonly EngineBlock[];
|
|
29
|
+
readonly index: ReadonlyMap<string, number>;
|
|
30
|
+
};
|
|
31
|
+
type Pos = {
|
|
32
|
+
readonly block: string;
|
|
33
|
+
readonly region: string;
|
|
34
|
+
readonly offset: number;
|
|
35
|
+
};
|
|
36
|
+
type TextSelection = {
|
|
37
|
+
readonly kind: 'text';
|
|
38
|
+
readonly anchor: Pos;
|
|
39
|
+
readonly head: Pos;
|
|
40
|
+
};
|
|
41
|
+
type NodeSelection = {
|
|
42
|
+
readonly kind: 'node';
|
|
43
|
+
readonly block: string;
|
|
44
|
+
};
|
|
45
|
+
type BlockRangeSelection = {
|
|
46
|
+
readonly kind: 'blocks';
|
|
47
|
+
readonly anchor: string;
|
|
48
|
+
readonly head: string;
|
|
49
|
+
};
|
|
50
|
+
type Selection = TextSelection | NodeSelection | BlockRangeSelection;
|
|
51
|
+
|
|
52
|
+
/** A document is an ordered array of these; `type` is looked up in the registered block definitions. */
|
|
53
|
+
type QuoinBlock = {
|
|
54
|
+
id: string;
|
|
55
|
+
type: string;
|
|
56
|
+
data: Record<string, unknown>;
|
|
57
|
+
/** Nesting depth shared by every block type, such as list nesting and toggle children; 0 when absent. */
|
|
58
|
+
indent?: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type ParseInlineOptions = {
|
|
62
|
+
softBreak?: 'newline' | 'space';
|
|
63
|
+
refs?: ReadonlyMap<string, {
|
|
64
|
+
href: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
type SerializeInlineOptions = {
|
|
69
|
+
escapeLineStart?: boolean;
|
|
70
|
+
escapePipes?: boolean;
|
|
71
|
+
hardBreak?: 'backslash' | 'br';
|
|
72
|
+
};
|
|
73
|
+
type InlineCodec = {
|
|
74
|
+
parse(markdown: string, options?: ParseInlineOptions): Inline;
|
|
75
|
+
serialize(inline: Inline, options?: SerializeInlineOptions): string;
|
|
76
|
+
};
|
|
77
|
+
type CodecContext = {
|
|
78
|
+
readonly inline: InlineCodec;
|
|
79
|
+
newId(): string;
|
|
80
|
+
};
|
|
81
|
+
type BlockContent = {
|
|
82
|
+
attrs: BlockAttrs;
|
|
83
|
+
regions: Record<string, Inline>;
|
|
84
|
+
};
|
|
85
|
+
type BlockFlow = 'text' | 'void' | 'structured';
|
|
86
|
+
type MarkdownExportContext = CodecContext & {
|
|
87
|
+
resolveAssetUrl(storageKey: string): string;
|
|
88
|
+
comments: boolean;
|
|
89
|
+
};
|
|
90
|
+
type BlockSpec = {
|
|
91
|
+
readonly type: string;
|
|
92
|
+
readonly flow: BlockFlow;
|
|
93
|
+
readonly primaryRegion?: string;
|
|
94
|
+
readonly enter?: 'split' | 'hardBreak';
|
|
95
|
+
fromData(data: Record<string, unknown>, ctx: CodecContext): BlockContent;
|
|
96
|
+
toData(block: EngineBlock, ctx: CodecContext): Record<string, unknown>;
|
|
97
|
+
initial(): BlockContent;
|
|
98
|
+
splitAttrs?(attrs: BlockAttrs): {
|
|
99
|
+
type: string;
|
|
100
|
+
attrs: BlockAttrs;
|
|
101
|
+
};
|
|
102
|
+
toMarkdown?(block: EngineBlock, ctx: MarkdownExportContext): string;
|
|
103
|
+
toPlainText?(block: EngineBlock): string;
|
|
104
|
+
};
|
|
105
|
+
type MarkSpec = {
|
|
106
|
+
readonly type: string;
|
|
107
|
+
readonly inclusive: boolean;
|
|
108
|
+
};
|
|
109
|
+
type AtomSpec = {
|
|
110
|
+
readonly type: string;
|
|
111
|
+
plainText(attrs: Attrs): string;
|
|
112
|
+
};
|
|
113
|
+
type Schema = {
|
|
114
|
+
readonly blocks: ReadonlyMap<string, BlockSpec>;
|
|
115
|
+
readonly marks: ReadonlyMap<string, MarkSpec>;
|
|
116
|
+
readonly atoms: ReadonlyMap<string, AtomSpec>;
|
|
117
|
+
readonly defaultTextBlock: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type { Attrs as A, BlockAttrs as B, CodecContext as C, EngineDoc as E, Inline as I, Mark as M, NodeSelection as N, Pos as P, QuoinBlock as Q, Schema as S, TextNode as T, Selection as a, AtomNode as b, AtomSpec as c, BlockContent as d, BlockFlow as e, BlockRangeSelection as f, BlockSpec as g, EngineBlock as h, InlineCodec as i, InlineNode as j, MarkSpec as k, MarkdownExportContext as l, ParseInlineOptions as m, SerializeInlineOptions as n, TextSelection as o };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
type Attrs = Readonly<Record<string, string>>;
|
|
2
|
+
type Mark = {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly attrs?: Attrs;
|
|
5
|
+
};
|
|
6
|
+
type TextNode = {
|
|
7
|
+
readonly kind: 'text';
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly marks: readonly Mark[];
|
|
10
|
+
};
|
|
11
|
+
type AtomNode = {
|
|
12
|
+
readonly kind: 'atom';
|
|
13
|
+
readonly type: string;
|
|
14
|
+
readonly attrs: Attrs;
|
|
15
|
+
readonly marks: readonly Mark[];
|
|
16
|
+
};
|
|
17
|
+
type InlineNode = TextNode | AtomNode;
|
|
18
|
+
type Inline = readonly InlineNode[];
|
|
19
|
+
type BlockAttrs = Readonly<Record<string, unknown>>;
|
|
20
|
+
type EngineBlock = {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly type: string;
|
|
23
|
+
readonly indent: number;
|
|
24
|
+
readonly attrs: BlockAttrs;
|
|
25
|
+
readonly regions: Readonly<Record<string, Inline>>;
|
|
26
|
+
};
|
|
27
|
+
type EngineDoc = {
|
|
28
|
+
readonly blocks: readonly EngineBlock[];
|
|
29
|
+
readonly index: ReadonlyMap<string, number>;
|
|
30
|
+
};
|
|
31
|
+
type Pos = {
|
|
32
|
+
readonly block: string;
|
|
33
|
+
readonly region: string;
|
|
34
|
+
readonly offset: number;
|
|
35
|
+
};
|
|
36
|
+
type TextSelection = {
|
|
37
|
+
readonly kind: 'text';
|
|
38
|
+
readonly anchor: Pos;
|
|
39
|
+
readonly head: Pos;
|
|
40
|
+
};
|
|
41
|
+
type NodeSelection = {
|
|
42
|
+
readonly kind: 'node';
|
|
43
|
+
readonly block: string;
|
|
44
|
+
};
|
|
45
|
+
type BlockRangeSelection = {
|
|
46
|
+
readonly kind: 'blocks';
|
|
47
|
+
readonly anchor: string;
|
|
48
|
+
readonly head: string;
|
|
49
|
+
};
|
|
50
|
+
type Selection = TextSelection | NodeSelection | BlockRangeSelection;
|
|
51
|
+
|
|
52
|
+
/** A document is an ordered array of these; `type` is looked up in the registered block definitions. */
|
|
53
|
+
type QuoinBlock = {
|
|
54
|
+
id: string;
|
|
55
|
+
type: string;
|
|
56
|
+
data: Record<string, unknown>;
|
|
57
|
+
/** Nesting depth shared by every block type, such as list nesting and toggle children; 0 when absent. */
|
|
58
|
+
indent?: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type ParseInlineOptions = {
|
|
62
|
+
softBreak?: 'newline' | 'space';
|
|
63
|
+
refs?: ReadonlyMap<string, {
|
|
64
|
+
href: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
type SerializeInlineOptions = {
|
|
69
|
+
escapeLineStart?: boolean;
|
|
70
|
+
escapePipes?: boolean;
|
|
71
|
+
hardBreak?: 'backslash' | 'br';
|
|
72
|
+
};
|
|
73
|
+
type InlineCodec = {
|
|
74
|
+
parse(markdown: string, options?: ParseInlineOptions): Inline;
|
|
75
|
+
serialize(inline: Inline, options?: SerializeInlineOptions): string;
|
|
76
|
+
};
|
|
77
|
+
type CodecContext = {
|
|
78
|
+
readonly inline: InlineCodec;
|
|
79
|
+
newId(): string;
|
|
80
|
+
};
|
|
81
|
+
type BlockContent = {
|
|
82
|
+
attrs: BlockAttrs;
|
|
83
|
+
regions: Record<string, Inline>;
|
|
84
|
+
};
|
|
85
|
+
type BlockFlow = 'text' | 'void' | 'structured';
|
|
86
|
+
type MarkdownExportContext = CodecContext & {
|
|
87
|
+
resolveAssetUrl(storageKey: string): string;
|
|
88
|
+
comments: boolean;
|
|
89
|
+
};
|
|
90
|
+
type BlockSpec = {
|
|
91
|
+
readonly type: string;
|
|
92
|
+
readonly flow: BlockFlow;
|
|
93
|
+
readonly primaryRegion?: string;
|
|
94
|
+
readonly enter?: 'split' | 'hardBreak';
|
|
95
|
+
fromData(data: Record<string, unknown>, ctx: CodecContext): BlockContent;
|
|
96
|
+
toData(block: EngineBlock, ctx: CodecContext): Record<string, unknown>;
|
|
97
|
+
initial(): BlockContent;
|
|
98
|
+
splitAttrs?(attrs: BlockAttrs): {
|
|
99
|
+
type: string;
|
|
100
|
+
attrs: BlockAttrs;
|
|
101
|
+
};
|
|
102
|
+
toMarkdown?(block: EngineBlock, ctx: MarkdownExportContext): string;
|
|
103
|
+
toPlainText?(block: EngineBlock): string;
|
|
104
|
+
};
|
|
105
|
+
type MarkSpec = {
|
|
106
|
+
readonly type: string;
|
|
107
|
+
readonly inclusive: boolean;
|
|
108
|
+
};
|
|
109
|
+
type AtomSpec = {
|
|
110
|
+
readonly type: string;
|
|
111
|
+
plainText(attrs: Attrs): string;
|
|
112
|
+
};
|
|
113
|
+
type Schema = {
|
|
114
|
+
readonly blocks: ReadonlyMap<string, BlockSpec>;
|
|
115
|
+
readonly marks: ReadonlyMap<string, MarkSpec>;
|
|
116
|
+
readonly atoms: ReadonlyMap<string, AtomSpec>;
|
|
117
|
+
readonly defaultTextBlock: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type { Attrs as A, BlockAttrs as B, CodecContext as C, EngineDoc as E, Inline as I, Mark as M, NodeSelection as N, Pos as P, QuoinBlock as Q, Schema as S, TextNode as T, Selection as a, AtomNode as b, AtomSpec as c, BlockContent as d, BlockFlow as e, BlockRangeSelection as f, BlockSpec as g, EngineBlock as h, InlineCodec as i, InlineNode as j, MarkSpec as k, MarkdownExportContext as l, ParseInlineOptions as m, SerializeInlineOptions as n, TextSelection as o };
|