@novaprose/core 0.5.3 → 0.7.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/README.md +57 -20
- package/dist/{advlist-FH3K3AAQ.js → advlist-5FNKPLUX.js} +11 -20
- package/dist/advlist-5FNKPLUX.js.map +1 -0
- package/dist/{autolink-IDJWAL2V.js → autolink-45LTODWB.js} +7 -4
- package/dist/{autolink-IDJWAL2V.js.map → autolink-45LTODWB.js.map} +1 -1
- package/dist/{autoresize-4ZEPQCHP.js → autoresize-UB3GOA6D.js} +2 -2
- package/dist/{autosave-DH7SO4UQ.js → autosave-GMWJ5BPE.js} +7 -11
- package/dist/autosave-GMWJ5BPE.js.map +1 -0
- package/dist/{charmap-F7EVJ56K.js → charmap-2GC7LF7G.js} +7 -12
- package/dist/charmap-2GC7LF7G.js.map +1 -0
- package/dist/{chunk-MOO4PJGI.js → chunk-5AW2HHG6.js} +16 -1
- package/dist/chunk-5AW2HHG6.js.map +1 -0
- package/dist/{chunk-55LD2TT2.js → chunk-DWZLSZDG.js} +1550 -935
- package/dist/chunk-DWZLSZDG.js.map +1 -0
- package/dist/{chunk-YZPJQB3I.js → chunk-FCMZ7TUQ.js} +308 -34
- package/dist/chunk-FCMZ7TUQ.js.map +1 -0
- package/dist/{chunk-6GWG2BLC.js → chunk-HPLT3XRZ.js} +1 -1
- package/dist/chunk-HPLT3XRZ.js.map +1 -0
- package/dist/{chunk-HZRIBOPW.js → chunk-JPJVTB45.js} +38 -2
- package/dist/chunk-JPJVTB45.js.map +1 -0
- package/dist/{chunk-6AL2IS6V.js → chunk-KPE3QRPB.js} +206 -404
- package/dist/chunk-KPE3QRPB.js.map +1 -0
- package/dist/chunk-KWXFL4WS.js +174 -0
- package/dist/chunk-KWXFL4WS.js.map +1 -0
- package/dist/chunk-ND2CWNVG.js +51 -0
- package/dist/chunk-ND2CWNVG.js.map +1 -0
- package/dist/chunk-PVFKXRID.js +27 -0
- package/dist/chunk-PVFKXRID.js.map +1 -0
- package/dist/chunk-R2UMUCVI.js +351 -0
- package/dist/chunk-R2UMUCVI.js.map +1 -0
- package/dist/{chunk-GHEFKKRC.js → chunk-T3GY6IVK.js} +41 -24
- package/dist/chunk-T3GY6IVK.js.map +1 -0
- package/dist/{comments-panel-FYJE3U64.js → comments-panel-HXMWSRAW.js} +5 -3
- package/dist/comments-panel-HXMWSRAW.js.map +1 -0
- package/dist/{directionality-MF5HDXH3.js → directionality-5JLWQGP2.js} +13 -11
- package/dist/directionality-5JLWQGP2.js.map +1 -0
- package/dist/editor-CXkltf1R.d.ts +1886 -0
- package/dist/editor-CgSBFTke.d.cts +1886 -0
- package/dist/{emoticons-SONBUCFV.js → emoticons-ZD6ZRIWG.js} +7 -12
- package/dist/emoticons-ZD6ZRIWG.js.map +1 -0
- package/dist/form-dialog-QH6KAERD.js +180 -0
- package/dist/form-dialog-QH6KAERD.js.map +1 -0
- package/dist/html-rules-api-D3fKQi-R.d.cts +40 -0
- package/dist/html-rules-api-D3fKQi-R.d.ts +40 -0
- package/dist/html-rules.cjs +480 -0
- package/dist/html-rules.cjs.map +1 -0
- package/dist/html-rules.d.cts +87 -0
- package/dist/html-rules.d.ts +87 -0
- package/dist/html-rules.js +413 -0
- package/dist/html-rules.js.map +1 -0
- package/dist/i18n/de.cjs +324 -0
- package/dist/i18n/de.cjs.map +1 -0
- package/dist/i18n/de.d.cts +9 -0
- package/dist/i18n/de.d.ts +9 -0
- package/dist/i18n/de.js +303 -0
- package/dist/i18n/de.js.map +1 -0
- package/dist/i18n/es.cjs +324 -0
- package/dist/i18n/es.cjs.map +1 -0
- package/dist/i18n/es.d.cts +9 -0
- package/dist/i18n/es.d.ts +9 -0
- package/dist/i18n/es.js +303 -0
- package/dist/i18n/es.js.map +1 -0
- package/dist/i18n/fr.cjs +324 -0
- package/dist/i18n/fr.cjs.map +1 -0
- package/dist/i18n/fr.d.cts +9 -0
- package/dist/i18n/fr.d.ts +9 -0
- package/dist/i18n/fr.js +303 -0
- package/dist/i18n/fr.js.map +1 -0
- package/dist/i18n/it.cjs +324 -0
- package/dist/i18n/it.cjs.map +1 -0
- package/dist/i18n/it.d.cts +9 -0
- package/dist/i18n/it.d.ts +9 -0
- package/dist/i18n/it.js +303 -0
- package/dist/i18n/it.js.map +1 -0
- package/dist/i18n/pt-BR.cjs +324 -0
- package/dist/i18n/pt-BR.cjs.map +1 -0
- package/dist/i18n/pt-BR.d.cts +9 -0
- package/dist/i18n/pt-BR.d.ts +9 -0
- package/dist/i18n/pt-BR.js +303 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/i18n/ru.cjs +324 -0
- package/dist/i18n/ru.cjs.map +1 -0
- package/dist/i18n/ru.d.cts +10 -0
- package/dist/i18n/ru.d.ts +10 -0
- package/dist/i18n/ru.js +303 -0
- package/dist/i18n/ru.js.map +1 -0
- package/dist/index-C603bU6r.d.cts +216 -0
- package/dist/index-C603bU6r.d.ts +216 -0
- package/dist/index.cjs +3422 -1179
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -1555
- package/dist/index.d.ts +50 -1555
- package/dist/index.js +278 -147
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-X2T4ZY6R.js → insertdatetime-CRO7TJAQ.js} +10 -16
- package/dist/insertdatetime-CRO7TJAQ.js.map +1 -0
- package/dist/markdown.cjs +273 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +23 -0
- package/dist/markdown.d.ts +23 -0
- package/dist/markdown.js +241 -0
- package/dist/markdown.js.map +1 -0
- package/dist/{nonbreaking-PP4KIJSR.js → nonbreaking-66LFZV2W.js} +8 -7
- package/dist/nonbreaking-66LFZV2W.js.map +1 -0
- package/dist/paste-office-F3QW4WWO.js +440 -0
- package/dist/paste-office-F3QW4WWO.js.map +1 -0
- package/dist/{quickbars-3WKHLKAR.js → quickbars-7E2QRS7J.js} +13 -9
- package/dist/quickbars-7E2QRS7J.js.map +1 -0
- package/dist/{revisionhistory-FYRVDGRA.js → revisionhistory-DXE7KU4R.js} +18 -32
- package/dist/revisionhistory-DXE7KU4R.js.map +1 -0
- package/dist/table-SSNABG5W.js +301 -0
- package/dist/table-SSNABG5W.js.map +1 -0
- package/dist/{visualblocks-NPTMWFXD.js → visualblocks-6DLBXYOA.js} +8 -7
- package/dist/visualblocks-6DLBXYOA.js.map +1 -0
- package/package.json +45 -5
- package/src/style.css +291 -29
- package/dist/advlist-FH3K3AAQ.js.map +0 -1
- package/dist/autosave-DH7SO4UQ.js.map +0 -1
- package/dist/charmap-F7EVJ56K.js.map +0 -1
- package/dist/chunk-55LD2TT2.js.map +0 -1
- package/dist/chunk-6AL2IS6V.js.map +0 -1
- package/dist/chunk-6GWG2BLC.js.map +0 -1
- package/dist/chunk-6RJENZXT.js +0 -104
- package/dist/chunk-6RJENZXT.js.map +0 -1
- package/dist/chunk-GHEFKKRC.js.map +0 -1
- package/dist/chunk-HZRIBOPW.js.map +0 -1
- package/dist/chunk-MOO4PJGI.js.map +0 -1
- package/dist/chunk-YZPJQB3I.js.map +0 -1
- package/dist/comments-panel-FYJE3U64.js.map +0 -1
- package/dist/directionality-MF5HDXH3.js.map +0 -1
- package/dist/emoticons-SONBUCFV.js.map +0 -1
- package/dist/insertdatetime-X2T4ZY6R.js.map +0 -1
- package/dist/nonbreaking-PP4KIJSR.js.map +0 -1
- package/dist/quickbars-3WKHLKAR.js.map +0 -1
- package/dist/revisionhistory-FYRVDGRA.js.map +0 -1
- package/dist/visualblocks-NPTMWFXD.js.map +0 -1
- /package/dist/{autoresize-4ZEPQCHP.js.map → autoresize-UB3GOA6D.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,1536 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Плагин autosave: черновик в localStorage браузера, чтобы текст не пропал при закрытой вкладке,
|
|
10
|
-
* перезагрузке или сбое. Если при открытии найден черновик, отличный от текущего содержимого,
|
|
11
|
-
* появляется уведомление, а кнопка «Восстановить черновик» (restoredraft) становится активной.
|
|
12
|
-
*
|
|
13
|
-
* `plugins: ['autosave']`, настройки — `pluginOptions.autosave`:
|
|
14
|
-
* - key — ключ хранилища (по умолчанию адрес страницы + id элемента);
|
|
15
|
-
* - delay — задержка сохранения после изменения, мс (1000);
|
|
16
|
-
* - retention — сколько хранить черновик, минут (7 дней).
|
|
17
|
-
*/
|
|
18
|
-
interface AutosaveOptions {
|
|
19
|
-
key?: string;
|
|
20
|
-
delay?: number;
|
|
21
|
-
retention?: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Комментарии к тексту: модель данных и хранилище.
|
|
26
|
-
*
|
|
27
|
-
* Текст документа хранит только якорь — марку `<span data-comment="id">` вокруг обсуждаемого фрагмента.
|
|
28
|
-
* Сами обсуждения (ветки) лежат в хранилище: по умолчанию в памяти (сохраняйте их через `onChange`
|
|
29
|
-
* рядом с HTML), при совместном редактировании — в общем Y.Doc (`collabSession.commentStore()`),
|
|
30
|
-
* или в вашем собственном хранилище с тем же интерфейсом.
|
|
31
|
-
*/
|
|
32
|
-
interface CommentAuthor {
|
|
33
|
-
id: string;
|
|
34
|
-
name: string;
|
|
35
|
-
}
|
|
36
|
-
interface Comment {
|
|
37
|
-
id: string;
|
|
38
|
-
author: CommentAuthor;
|
|
39
|
-
text: string;
|
|
40
|
-
/** Время создания, мс с 1970 (Date.now()). */
|
|
41
|
-
createdAt: number;
|
|
42
|
-
editedAt?: number;
|
|
43
|
-
/** Упомянутые через «@» (в тексте — «@Имя»): кого уведомить. */
|
|
44
|
-
mentions?: CommentAuthor[];
|
|
45
|
-
}
|
|
46
|
-
interface CommentThread {
|
|
47
|
-
/** Совпадает с data-comment у фрагмента текста. */
|
|
48
|
-
id: string;
|
|
49
|
-
createdAt: number;
|
|
50
|
-
/** Первый комментарий — суть обсуждения, остальные — ответы. */
|
|
51
|
-
comments: Comment[];
|
|
52
|
-
/** Ветка решена: подсветка в тексте скрывается, обсуждение остаётся в истории. */
|
|
53
|
-
resolved?: {
|
|
54
|
-
by: CommentAuthor;
|
|
55
|
-
at: number;
|
|
56
|
-
} | null;
|
|
57
|
-
}
|
|
58
|
-
/** Хранилище веток. Методы синхронные: интерфейс обновляется сразу, сохранение — на вашей стороне. */
|
|
59
|
-
interface CommentStore {
|
|
60
|
-
/** Снимок всех веток (новый массив после каждого изменения). */
|
|
61
|
-
threads(): readonly CommentThread[];
|
|
62
|
-
/** Подписка на любые изменения (в том числе пришедшие от других участников). Возвращает отписку. */
|
|
63
|
-
subscribe(listener: () => void): () => void;
|
|
64
|
-
createThread(thread: CommentThread): void;
|
|
65
|
-
reply(threadId: string, comment: Comment): void;
|
|
66
|
-
editComment(threadId: string, commentId: string, text: string): void;
|
|
67
|
-
deleteComment(threadId: string, commentId: string): void;
|
|
68
|
-
setResolved(threadId: string, resolved: CommentThread['resolved']): void;
|
|
69
|
-
deleteThread(threadId: string): void;
|
|
70
|
-
}
|
|
71
|
-
declare function newCommentId(prefix?: string): string;
|
|
72
|
-
/** Привести данные из внешнего источника (JSON, сеть) к безопасному виду; негодное — отбросить. */
|
|
73
|
-
declare function sanitizeThread(value: unknown): CommentThread | null;
|
|
74
|
-
/**
|
|
75
|
-
* Хранилище в памяти. `initial` — ветки, сохранённые раньше (из вашего бэкенда), `onChange` — сохранить.
|
|
76
|
-
*
|
|
77
|
-
* ```ts
|
|
78
|
-
* const store = createCommentStore(saved.threads, (threads) => api.saveComments(postId, threads));
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
declare function createCommentStore(initial?: readonly unknown[], onChange?: (threads: readonly CommentThread[]) => void): CommentStore;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Плагин mentions: «@» в тексте → список людей → упоминание `<span data-mention="id">@Имя</span>`.
|
|
85
|
-
* `plugins: ['mentions']`, список людей — `pluginOptions.mentions.fetch` (обычно поиск в вашем API).
|
|
86
|
-
* Тот же источник используют комментарии: «@» в поле комментария.
|
|
87
|
-
*/
|
|
88
|
-
interface MentionUser {
|
|
89
|
-
id: string;
|
|
90
|
-
name: string;
|
|
91
|
-
/** Вторая строка в списке: должность, e-mail. */
|
|
92
|
-
description?: string;
|
|
93
|
-
}
|
|
94
|
-
interface MentionsOptions {
|
|
95
|
-
/** Поиск людей по началу имени (запрос без «@»). Может вернуть Promise. */
|
|
96
|
-
fetch: (query: string) => MentionUser[] | Promise<MentionUser[]>;
|
|
97
|
-
/** Человека упомянули в тексте (для уведомлений — или соберите их при сохранении: getMentions). */
|
|
98
|
-
onMention?: (user: MentionUser, editor: Editor) => void;
|
|
99
|
-
/** Сколько показывать в списке (по умолчанию 8). */
|
|
100
|
-
maxResults?: number;
|
|
101
|
-
}
|
|
102
|
-
/** id пользователя: UUID, числа, e-mail, логины — без пробелов, кавычек и угловых скобок. */
|
|
103
|
-
declare const MENTION_ID_RE: RegExp;
|
|
104
|
-
/** Кто упомянут в документе (без повторов, в порядке появления) — например, чтобы уведомить. */
|
|
105
|
-
declare function getMentions(editorOrDoc: Editor | Node): MentionUser[];
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Плагин comments: обсуждения фрагментов текста (как комментарии в Google Docs / Word).
|
|
109
|
-
* `plugins: ['comments']`, настройки — `pluginOptions.comments` ({@link CommentsOptions}).
|
|
110
|
-
* Кнопки (имена TinyMCE): `addcomment`, `showcomments`. Ctrl+Alt+M — комментировать выделение.
|
|
111
|
-
*
|
|
112
|
-
* Марка в схеме — поэтому плагин подключается сразу; панель обсуждений грузится лениво при открытии.
|
|
113
|
-
*/
|
|
114
|
-
interface CommentsOptions {
|
|
115
|
-
/** Кто комментирует. По умолчанию — «Гость». */
|
|
116
|
-
author?: CommentAuthor;
|
|
117
|
-
/** Хранилище веток. По умолчанию — в памяти, с `threads` и `onChange`. */
|
|
118
|
-
store?: CommentStore;
|
|
119
|
-
/** Сохранённые ранее ветки (для хранилища по умолчанию). */
|
|
120
|
-
threads?: readonly CommentThread[];
|
|
121
|
-
/** Ветки изменились — сохраните их (для хранилища по умолчанию). */
|
|
122
|
-
onChange?: (threads: readonly CommentThread[]) => void;
|
|
123
|
-
/** Можно ли менять и удалять комментарий. По умолчанию — только автору. */
|
|
124
|
-
canEdit?: (comment: Comment, author: CommentAuthor) => boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Поиск людей для «@» в комментариях. По умолчанию — `pluginOptions.mentions.fetch` (плагин mentions).
|
|
127
|
-
*/
|
|
128
|
-
mentions?: MentionsOptions['fetch'];
|
|
129
|
-
/** В новом комментарии кого-то упомянули — отправьте уведомление. */
|
|
130
|
-
onMention?: (event: {
|
|
131
|
-
threadId: string;
|
|
132
|
-
comment: Comment;
|
|
133
|
-
users: CommentAuthor[];
|
|
134
|
-
}) => void;
|
|
135
|
-
}
|
|
136
|
-
declare const LABELS: {
|
|
137
|
-
en: {
|
|
138
|
-
add: string;
|
|
139
|
-
show: string;
|
|
140
|
-
panel: string;
|
|
141
|
-
guest: string;
|
|
142
|
-
newComment: string;
|
|
143
|
-
placeholder: string;
|
|
144
|
-
replyPlaceholder: string;
|
|
145
|
-
comment: string;
|
|
146
|
-
reply: string;
|
|
147
|
-
cancel: string;
|
|
148
|
-
save: string;
|
|
149
|
-
edit: string;
|
|
150
|
-
remove: string;
|
|
151
|
-
resolve: string;
|
|
152
|
-
reopen: string;
|
|
153
|
-
deleteThread: string;
|
|
154
|
-
close: string;
|
|
155
|
-
showResolved: string;
|
|
156
|
-
resolvedBy: string;
|
|
157
|
-
orphan: string;
|
|
158
|
-
empty: string;
|
|
159
|
-
people: string;
|
|
160
|
-
noPeople: string;
|
|
161
|
-
edited: string;
|
|
162
|
-
you: string;
|
|
163
|
-
count: string;
|
|
164
|
-
};
|
|
165
|
-
ru: {
|
|
166
|
-
add: string;
|
|
167
|
-
show: string;
|
|
168
|
-
panel: string;
|
|
169
|
-
guest: string;
|
|
170
|
-
newComment: string;
|
|
171
|
-
placeholder: string;
|
|
172
|
-
replyPlaceholder: string;
|
|
173
|
-
comment: string;
|
|
174
|
-
reply: string;
|
|
175
|
-
cancel: string;
|
|
176
|
-
save: string;
|
|
177
|
-
edit: string;
|
|
178
|
-
remove: string;
|
|
179
|
-
resolve: string;
|
|
180
|
-
reopen: string;
|
|
181
|
-
deleteThread: string;
|
|
182
|
-
close: string;
|
|
183
|
-
showResolved: string;
|
|
184
|
-
resolvedBy: string;
|
|
185
|
-
orphan: string;
|
|
186
|
-
empty: string;
|
|
187
|
-
people: string;
|
|
188
|
-
noPeople: string;
|
|
189
|
-
edited: string;
|
|
190
|
-
you: string;
|
|
191
|
-
count: string;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
type CommentsLabels = typeof LABELS.en;
|
|
195
|
-
interface PluginState {
|
|
196
|
-
/** Выделение, к которому пишется новый комментарий (ещё не сохранён — без марки в тексте). */
|
|
197
|
-
pending: {
|
|
198
|
-
from: number;
|
|
199
|
-
to: number;
|
|
200
|
-
} | null;
|
|
201
|
-
active: string | null;
|
|
202
|
-
}
|
|
203
|
-
/** Управление комментариями редактора — общий объект для плагина и ленивой панели. */
|
|
204
|
-
interface CommentsController {
|
|
205
|
-
readonly editor: Editor;
|
|
206
|
-
readonly store: CommentStore;
|
|
207
|
-
readonly author: CommentAuthor;
|
|
208
|
-
readonly labels: CommentsLabels;
|
|
209
|
-
readonly shortcut: string;
|
|
210
|
-
pending(): PluginState['pending'];
|
|
211
|
-
active(): string | null;
|
|
212
|
-
setActive(id: string | null, scroll?: boolean): void;
|
|
213
|
-
/** Начать комментарий к выделению: подсветить его и открыть панель с полем ввода. */
|
|
214
|
-
startComment(): boolean;
|
|
215
|
-
cancelPending(): void;
|
|
216
|
-
/** Сохранить новый комментарий к отложенному выделению. Возвращает id ветки. */
|
|
217
|
-
submitPending(text: string, mentions?: CommentAuthor[]): string | null;
|
|
218
|
-
reply(threadId: string, text: string, mentions?: CommentAuthor[]): void;
|
|
219
|
-
/** Поиск людей для «@» (null — источник не настроен, упоминания в комментариях выключены). */
|
|
220
|
-
findUsers: ((query: string) => Promise<MentionUser[]>) | null;
|
|
221
|
-
/** Фрагменты текста ветки (пусто — текст удалён). */
|
|
222
|
-
ranges(id: string): {
|
|
223
|
-
from: number;
|
|
224
|
-
to: number;
|
|
225
|
-
}[];
|
|
226
|
-
quote(id: string): string;
|
|
227
|
-
/** Порядок веток по месту в документе. */
|
|
228
|
-
positionOf(id: string): number;
|
|
229
|
-
deleteThread(id: string): void;
|
|
230
|
-
setResolved(id: string, resolved: boolean): void;
|
|
231
|
-
canEdit(comment: Comment): boolean;
|
|
232
|
-
isPanelOpen(): boolean;
|
|
233
|
-
openPanel(): Promise<void>;
|
|
234
|
-
closePanel(): void;
|
|
235
|
-
}
|
|
236
|
-
/** Контроллер комментариев редактора (если подключён плагин comments). */
|
|
237
|
-
declare function getComments(editor: Editor): CommentsController | undefined;
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Quickbars: панели «по месту», как одноимённый плагин TinyMCE.
|
|
241
|
-
* - над выделенным текстом — быстрое форматирование;
|
|
242
|
-
* - на пустой строке — быстрая вставка (картинка, таблица).
|
|
243
|
-
*
|
|
244
|
-
* Настройки (pluginOptions.quickbars), false — выключить панель:
|
|
245
|
-
* { selection: 'bold italic | quicklink h2 h3 blockquote', insert: 'quickimage quicktable' }
|
|
246
|
-
*/
|
|
247
|
-
interface QuickbarsOptions {
|
|
248
|
-
selection?: string | false;
|
|
249
|
-
insert?: string | false;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Плагин revisionhistory (имя как у TinyMCE): история версий документа.
|
|
254
|
-
* Список версий, просмотр версии с подсветкой отличий от текущего текста, восстановление
|
|
255
|
-
* (обычная правка — отменяется Ctrl+Z). Откуда версии — решает приложение: `pluginOptions.revisionhistory`
|
|
256
|
-
* ({@link RevisionHistoryOptions}); при совместном редактировании — `sync.versions()` из @novaprose/collab.
|
|
257
|
-
*/
|
|
258
|
-
interface Revision {
|
|
259
|
-
id: string;
|
|
260
|
-
/** Время версии, мс с 1970. */
|
|
261
|
-
createdAt: number;
|
|
262
|
-
/** Кто менял документ в этой версии. */
|
|
263
|
-
authors?: string[];
|
|
264
|
-
/** Имя версии («Отправлено юристам»), если её сохранили вручную. */
|
|
265
|
-
label?: string | null;
|
|
266
|
-
}
|
|
267
|
-
interface RevisionHistoryOptions {
|
|
268
|
-
/** Список версий (порядок не важен — показываем новые сверху). */
|
|
269
|
-
list: () => Promise<Revision[]>;
|
|
270
|
-
/** Содержимое версии: HTML или JSON документа. */
|
|
271
|
-
load: (revision: Revision, editor: Editor) => Promise<string | Record<string, unknown>>;
|
|
272
|
-
/** «Сохранить версию» (кнопка появляется, если задано). */
|
|
273
|
-
save?: (label?: string) => Promise<void>;
|
|
274
|
-
/** Версию восстановили (уже после замены содержимого). */
|
|
275
|
-
onRestore?: (revision: Revision) => void;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Базовая схема документа NovaProse (P0 из PRD §4.1–4.2).
|
|
280
|
-
* Каждый узел и марка описывают и парсинг HTML (parseDOM), и сериализацию (toDOM),
|
|
281
|
-
* поэтому HTML на входе и выходе предсказуем.
|
|
282
|
-
*/
|
|
283
|
-
declare const ALIGNMENTS: readonly ["left", "center", "right", "justify"];
|
|
284
|
-
type TextAlign = (typeof ALIGNMENTS)[number];
|
|
285
|
-
declare const cssValue: {
|
|
286
|
-
color: (v: unknown) => string | null;
|
|
287
|
-
length: (v: unknown) => string | null;
|
|
288
|
-
lineHeight: (v: unknown) => string | null;
|
|
289
|
-
fontFamily: (v: unknown) => string | null;
|
|
290
|
-
};
|
|
291
|
-
type TextDirection = 'ltr' | 'rtl';
|
|
292
|
-
interface BlockStyle {
|
|
293
|
-
align: TextAlign | null;
|
|
294
|
-
lineHeight: string | null;
|
|
295
|
-
dir: TextDirection | null;
|
|
296
|
-
}
|
|
297
|
-
type ImageAlign = 'left' | 'center' | 'right';
|
|
298
|
-
/** Размер картинки в px: целое 1…10000, иначе null ('300', '300px', 300). */
|
|
299
|
-
declare function imageSize(value: unknown): number | null;
|
|
300
|
-
declare const nodes: {
|
|
301
|
-
table: NodeSpec;
|
|
302
|
-
table_row: NodeSpec;
|
|
303
|
-
table_cell: NodeSpec;
|
|
304
|
-
table_header: NodeSpec;
|
|
305
|
-
doc: {
|
|
306
|
-
content: string;
|
|
307
|
-
};
|
|
308
|
-
paragraph: {
|
|
309
|
-
group: string;
|
|
310
|
-
content: string;
|
|
311
|
-
attrs: {
|
|
312
|
-
align: {
|
|
313
|
-
default: null;
|
|
314
|
-
};
|
|
315
|
-
lineHeight: {
|
|
316
|
-
default: null;
|
|
317
|
-
};
|
|
318
|
-
dir: {
|
|
319
|
-
default: null;
|
|
320
|
-
};
|
|
321
|
-
};
|
|
322
|
-
parseDOM: {
|
|
323
|
-
tag: string;
|
|
324
|
-
getAttrs: (dom: HTMLElement) => BlockStyle;
|
|
325
|
-
}[];
|
|
326
|
-
toDOM: (node: prosemirror_model.Node) => DOMOutputSpec;
|
|
327
|
-
};
|
|
328
|
-
heading: {
|
|
329
|
-
group: string;
|
|
330
|
-
content: string;
|
|
331
|
-
defining: true;
|
|
332
|
-
attrs: {
|
|
333
|
-
align: {
|
|
334
|
-
default: null;
|
|
335
|
-
};
|
|
336
|
-
lineHeight: {
|
|
337
|
-
default: null;
|
|
338
|
-
};
|
|
339
|
-
dir: {
|
|
340
|
-
default: null;
|
|
341
|
-
};
|
|
342
|
-
level: {
|
|
343
|
-
default: number;
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
parseDOM: {
|
|
347
|
-
tag: string;
|
|
348
|
-
getAttrs: (dom: HTMLElement) => {
|
|
349
|
-
align: TextAlign | null;
|
|
350
|
-
lineHeight: string | null;
|
|
351
|
-
dir: TextDirection | null;
|
|
352
|
-
level: number;
|
|
353
|
-
};
|
|
354
|
-
}[];
|
|
355
|
-
toDOM: (node: prosemirror_model.Node) => DOMOutputSpec;
|
|
356
|
-
};
|
|
357
|
-
blockquote: {
|
|
358
|
-
group: string;
|
|
359
|
-
content: string;
|
|
360
|
-
defining: true;
|
|
361
|
-
parseDOM: {
|
|
362
|
-
tag: string;
|
|
363
|
-
}[];
|
|
364
|
-
toDOM: () => DOMOutputSpec;
|
|
365
|
-
};
|
|
366
|
-
horizontal_rule: {
|
|
367
|
-
group: string;
|
|
368
|
-
parseDOM: {
|
|
369
|
-
tag: string;
|
|
370
|
-
}[];
|
|
371
|
-
toDOM: () => DOMOutputSpec;
|
|
372
|
-
};
|
|
373
|
-
code_block: {
|
|
374
|
-
group: string;
|
|
375
|
-
content: string;
|
|
376
|
-
marks: string;
|
|
377
|
-
code: true;
|
|
378
|
-
defining: true;
|
|
379
|
-
attrs: {
|
|
380
|
-
language: {
|
|
381
|
-
default: null;
|
|
382
|
-
};
|
|
383
|
-
};
|
|
384
|
-
parseDOM: {
|
|
385
|
-
tag: string;
|
|
386
|
-
preserveWhitespace: "full";
|
|
387
|
-
getAttrs: (dom: HTMLElement) => {
|
|
388
|
-
language: string | null;
|
|
389
|
-
};
|
|
390
|
-
}[];
|
|
391
|
-
toDOM: (node: prosemirror_model.Node) => DOMOutputSpec;
|
|
392
|
-
};
|
|
393
|
-
bullet_list: {
|
|
394
|
-
group: string;
|
|
395
|
-
content: string;
|
|
396
|
-
attrs: {
|
|
397
|
-
listStyle: {
|
|
398
|
-
default: null;
|
|
399
|
-
};
|
|
400
|
-
};
|
|
401
|
-
parseDOM: {
|
|
402
|
-
tag: string;
|
|
403
|
-
getAttrs: (dom: HTMLElement) => {
|
|
404
|
-
listStyle: string | null;
|
|
405
|
-
};
|
|
406
|
-
}[];
|
|
407
|
-
toDOM: (node: prosemirror_model.Node) => DOMOutputSpec;
|
|
408
|
-
};
|
|
409
|
-
ordered_list: {
|
|
410
|
-
group: string;
|
|
411
|
-
content: string;
|
|
412
|
-
attrs: {
|
|
413
|
-
start: {
|
|
414
|
-
default: number;
|
|
415
|
-
};
|
|
416
|
-
listStyle: {
|
|
417
|
-
default: null;
|
|
418
|
-
};
|
|
419
|
-
};
|
|
420
|
-
parseDOM: {
|
|
421
|
-
tag: string;
|
|
422
|
-
getAttrs: (dom: HTMLElement) => {
|
|
423
|
-
start: number;
|
|
424
|
-
listStyle: string | null;
|
|
425
|
-
};
|
|
426
|
-
}[];
|
|
427
|
-
toDOM: (node: prosemirror_model.Node) => DOMOutputSpec;
|
|
428
|
-
};
|
|
429
|
-
list_item: {
|
|
430
|
-
content: string;
|
|
431
|
-
defining: true;
|
|
432
|
-
parseDOM: {
|
|
433
|
-
tag: string;
|
|
434
|
-
}[];
|
|
435
|
-
toDOM: () => DOMOutputSpec;
|
|
436
|
-
};
|
|
437
|
-
text: {
|
|
438
|
-
group: string;
|
|
439
|
-
};
|
|
440
|
-
image: {
|
|
441
|
-
group: string;
|
|
442
|
-
inline: true;
|
|
443
|
-
draggable: true;
|
|
444
|
-
attrs: {
|
|
445
|
-
src: {};
|
|
446
|
-
alt: {
|
|
447
|
-
default: null;
|
|
448
|
-
};
|
|
449
|
-
title: {
|
|
450
|
-
default: null;
|
|
451
|
-
};
|
|
452
|
-
width: {
|
|
453
|
-
default: null;
|
|
454
|
-
};
|
|
455
|
-
height: {
|
|
456
|
-
default: null;
|
|
457
|
-
};
|
|
458
|
-
align: {
|
|
459
|
-
default: null;
|
|
460
|
-
};
|
|
461
|
-
};
|
|
462
|
-
parseDOM: {
|
|
463
|
-
tag: string;
|
|
464
|
-
getAttrs: (dom: HTMLElement) => false | {
|
|
465
|
-
src: string | null;
|
|
466
|
-
alt: string | null;
|
|
467
|
-
title: string | null;
|
|
468
|
-
width: number | null;
|
|
469
|
-
height: number | null;
|
|
470
|
-
align: ImageAlign | null;
|
|
471
|
-
};
|
|
472
|
-
}[];
|
|
473
|
-
toDOM: (node: prosemirror_model.Node) => DOMOutputSpec;
|
|
474
|
-
};
|
|
475
|
-
hard_break: {
|
|
476
|
-
group: string;
|
|
477
|
-
inline: true;
|
|
478
|
-
selectable: false;
|
|
479
|
-
parseDOM: {
|
|
480
|
-
tag: string;
|
|
481
|
-
}[];
|
|
482
|
-
toDOM: () => DOMOutputSpec;
|
|
483
|
-
};
|
|
484
|
-
};
|
|
485
|
-
declare const marks: {
|
|
486
|
-
link: {
|
|
487
|
-
attrs: {
|
|
488
|
-
href: {};
|
|
489
|
-
title: {
|
|
490
|
-
default: null;
|
|
491
|
-
};
|
|
492
|
-
target: {
|
|
493
|
-
default: null;
|
|
494
|
-
};
|
|
495
|
-
};
|
|
496
|
-
inclusive: false;
|
|
497
|
-
parseDOM: {
|
|
498
|
-
tag: string;
|
|
499
|
-
getAttrs: (dom: HTMLElement) => false | {
|
|
500
|
-
href: string | null;
|
|
501
|
-
title: string | null;
|
|
502
|
-
target: string | null;
|
|
503
|
-
};
|
|
504
|
-
}[];
|
|
505
|
-
toDOM: (mark: prosemirror_model.Mark) => DOMOutputSpec;
|
|
506
|
-
};
|
|
507
|
-
bold: {
|
|
508
|
-
parseDOM: ({
|
|
509
|
-
tag: string;
|
|
510
|
-
getAttrs?: undefined;
|
|
511
|
-
style?: undefined;
|
|
512
|
-
} | {
|
|
513
|
-
tag: string;
|
|
514
|
-
getAttrs: (dom: HTMLElement) => false | null;
|
|
515
|
-
style?: undefined;
|
|
516
|
-
} | {
|
|
517
|
-
style: string;
|
|
518
|
-
getAttrs: (value: string) => false | null;
|
|
519
|
-
tag?: undefined;
|
|
520
|
-
})[];
|
|
521
|
-
toDOM: () => DOMOutputSpec;
|
|
522
|
-
};
|
|
523
|
-
italic: {
|
|
524
|
-
parseDOM: ({
|
|
525
|
-
tag: string;
|
|
526
|
-
style?: undefined;
|
|
527
|
-
} | {
|
|
528
|
-
style: string;
|
|
529
|
-
tag?: undefined;
|
|
530
|
-
})[];
|
|
531
|
-
toDOM: () => DOMOutputSpec;
|
|
532
|
-
};
|
|
533
|
-
underline: {
|
|
534
|
-
parseDOM: ({
|
|
535
|
-
tag: string;
|
|
536
|
-
style?: undefined;
|
|
537
|
-
} | {
|
|
538
|
-
style: string;
|
|
539
|
-
tag?: undefined;
|
|
540
|
-
})[];
|
|
541
|
-
toDOM: () => DOMOutputSpec;
|
|
542
|
-
};
|
|
543
|
-
strike: {
|
|
544
|
-
parseDOM: ({
|
|
545
|
-
tag: string;
|
|
546
|
-
style?: undefined;
|
|
547
|
-
} | {
|
|
548
|
-
style: string;
|
|
549
|
-
tag?: undefined;
|
|
550
|
-
})[];
|
|
551
|
-
toDOM: () => DOMOutputSpec;
|
|
552
|
-
};
|
|
553
|
-
code: {
|
|
554
|
-
parseDOM: {
|
|
555
|
-
tag: string;
|
|
556
|
-
}[];
|
|
557
|
-
toDOM: () => DOMOutputSpec;
|
|
558
|
-
};
|
|
559
|
-
subscript: {
|
|
560
|
-
excludes: string;
|
|
561
|
-
parseDOM: ({
|
|
562
|
-
tag: string;
|
|
563
|
-
style?: undefined;
|
|
564
|
-
} | {
|
|
565
|
-
style: string;
|
|
566
|
-
tag?: undefined;
|
|
567
|
-
})[];
|
|
568
|
-
toDOM: () => DOMOutputSpec;
|
|
569
|
-
};
|
|
570
|
-
superscript: {
|
|
571
|
-
excludes: string;
|
|
572
|
-
parseDOM: ({
|
|
573
|
-
tag: string;
|
|
574
|
-
style?: undefined;
|
|
575
|
-
} | {
|
|
576
|
-
style: string;
|
|
577
|
-
tag?: undefined;
|
|
578
|
-
})[];
|
|
579
|
-
toDOM: () => DOMOutputSpec;
|
|
580
|
-
};
|
|
581
|
-
color: {
|
|
582
|
-
attrs: {
|
|
583
|
-
value: {};
|
|
584
|
-
};
|
|
585
|
-
parseDOM: ({
|
|
586
|
-
style: string;
|
|
587
|
-
getAttrs: (v: string) => false | {
|
|
588
|
-
value: string;
|
|
589
|
-
};
|
|
590
|
-
tag?: undefined;
|
|
591
|
-
} | {
|
|
592
|
-
tag: string;
|
|
593
|
-
getAttrs: (dom: HTMLElement) => false | {
|
|
594
|
-
value: string;
|
|
595
|
-
};
|
|
596
|
-
style?: undefined;
|
|
597
|
-
})[];
|
|
598
|
-
toDOM: (mark: prosemirror_model.Mark) => DOMOutputSpec;
|
|
599
|
-
};
|
|
600
|
-
background: {
|
|
601
|
-
attrs: {
|
|
602
|
-
value: {};
|
|
603
|
-
};
|
|
604
|
-
parseDOM: ({
|
|
605
|
-
style: string;
|
|
606
|
-
getAttrs: (v: string) => false | {
|
|
607
|
-
value: string;
|
|
608
|
-
};
|
|
609
|
-
tag?: undefined;
|
|
610
|
-
} | {
|
|
611
|
-
tag: string;
|
|
612
|
-
getAttrs: () => {
|
|
613
|
-
value: string;
|
|
614
|
-
};
|
|
615
|
-
style?: undefined;
|
|
616
|
-
})[];
|
|
617
|
-
toDOM: (mark: prosemirror_model.Mark) => DOMOutputSpec;
|
|
618
|
-
};
|
|
619
|
-
font_family: {
|
|
620
|
-
attrs: {
|
|
621
|
-
value: {};
|
|
622
|
-
};
|
|
623
|
-
parseDOM: {
|
|
624
|
-
style: string;
|
|
625
|
-
getAttrs: (v: string) => false | {
|
|
626
|
-
value: string;
|
|
627
|
-
};
|
|
628
|
-
}[];
|
|
629
|
-
toDOM: (mark: prosemirror_model.Mark) => DOMOutputSpec;
|
|
630
|
-
};
|
|
631
|
-
font_size: {
|
|
632
|
-
attrs: {
|
|
633
|
-
value: {};
|
|
634
|
-
};
|
|
635
|
-
parseDOM: {
|
|
636
|
-
style: string;
|
|
637
|
-
getAttrs: (v: string) => false | {
|
|
638
|
-
value: string;
|
|
639
|
-
};
|
|
640
|
-
}[];
|
|
641
|
-
toDOM: (mark: prosemirror_model.Mark) => DOMOutputSpec;
|
|
642
|
-
};
|
|
643
|
-
};
|
|
644
|
-
type NodeName = keyof typeof nodes;
|
|
645
|
-
type MarkName = keyof typeof marks;
|
|
646
|
-
/**
|
|
647
|
-
* Схема редактора: базовые узлы и марки + расширения плагинов. Тип оставляем «базовым»: встроенный
|
|
648
|
-
* код обращается только к своим узлам (`schema.nodes.paragraph`), а узлы плагинов доступны по имени.
|
|
649
|
-
*/
|
|
650
|
-
type NovaSchema = Schema<NodeName, MarkName>;
|
|
651
|
-
/** Базовая схема без расширений — у редакторов без плагинов-узлов она общая. */
|
|
652
|
-
declare const schema: NovaSchema;
|
|
653
|
-
interface SchemaExtensions {
|
|
654
|
-
nodes?: Record<string, NodeSpec>;
|
|
655
|
-
marks?: Record<string, MarkSpec>;
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Схема с узлами и марками плагинов. Без расширений возвращает общую базовую схему.
|
|
659
|
-
* Новые узлы и марки добавляются в конец: базовые правила разбора HTML остаются в приоритете,
|
|
660
|
-
* если плагин не задал свой `priority` в parseDOM.
|
|
661
|
-
*/
|
|
662
|
-
declare function createSchema(extensions?: SchemaExtensions): NovaSchema;
|
|
663
|
-
|
|
664
|
-
/** Именованные команды редактора. Имена — часть публичного API (см. Editor.exec). */
|
|
665
|
-
type CommandName = 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'subscript' | 'superscript' | 'paragraph' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'blockquote' | 'codeBlock' | 'bulletList' | 'orderedList' | 'indent' | 'outdent' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'horizontalRule' | 'unlink' | 'clearFormatting' | 'undo' | 'redo';
|
|
666
|
-
/**
|
|
667
|
-
* Типы узлов и марок берём из схемы конкретного редактора (state.schema): у редакторов с плагинами
|
|
668
|
-
* она своя, и сравнение с типами общей базовой схемы дало бы ложь.
|
|
669
|
-
*/
|
|
670
|
-
declare const nodesOf: (state: EditorState) => {
|
|
671
|
-
readonly table: NodeType;
|
|
672
|
-
readonly table_row: NodeType;
|
|
673
|
-
readonly table_cell: NodeType;
|
|
674
|
-
readonly table_header: NodeType;
|
|
675
|
-
readonly doc: NodeType;
|
|
676
|
-
readonly paragraph: NodeType;
|
|
677
|
-
readonly heading: NodeType;
|
|
678
|
-
readonly blockquote: NodeType;
|
|
679
|
-
readonly horizontal_rule: NodeType;
|
|
680
|
-
readonly code_block: NodeType;
|
|
681
|
-
readonly bullet_list: NodeType;
|
|
682
|
-
readonly ordered_list: NodeType;
|
|
683
|
-
readonly list_item: NodeType;
|
|
684
|
-
readonly text: NodeType;
|
|
685
|
-
readonly image: NodeType;
|
|
686
|
-
readonly hard_break: NodeType;
|
|
687
|
-
} & {
|
|
688
|
-
readonly [key: string]: NodeType;
|
|
689
|
-
};
|
|
690
|
-
declare const marksOf: (state: EditorState) => {
|
|
691
|
-
readonly background: MarkType;
|
|
692
|
-
readonly code: MarkType;
|
|
693
|
-
readonly link: MarkType;
|
|
694
|
-
readonly bold: MarkType;
|
|
695
|
-
readonly italic: MarkType;
|
|
696
|
-
readonly underline: MarkType;
|
|
697
|
-
readonly strike: MarkType;
|
|
698
|
-
readonly subscript: MarkType;
|
|
699
|
-
readonly superscript: MarkType;
|
|
700
|
-
readonly color: MarkType;
|
|
701
|
-
readonly font_family: MarkType;
|
|
702
|
-
readonly font_size: MarkType;
|
|
703
|
-
} & {
|
|
704
|
-
readonly [key: string]: MarkType;
|
|
705
|
-
};
|
|
706
|
-
declare const commands: Record<CommandName, Command>;
|
|
707
|
-
/** Вставить или обновить ссылку на выделении. */
|
|
708
|
-
declare function setLink(href: string, attrs?: {
|
|
709
|
-
title?: string;
|
|
710
|
-
target?: string;
|
|
711
|
-
}): Command;
|
|
712
|
-
/** Вставить изображение на место выделения. */
|
|
713
|
-
declare function insertImage(src: string, alt?: string): Command;
|
|
714
|
-
declare function isMarkActive(state: EditorState, type: MarkType): boolean;
|
|
715
|
-
declare function isNodeActive(state: EditorState, type: NodeType, attrs?: Record<string, unknown>): boolean;
|
|
716
|
-
declare function getActiveAlign(state: EditorState): TextAlign;
|
|
717
|
-
/**
|
|
718
|
-
* Активна ли команда в текущем выделении: марка применена, блок нужного типа, выравнивание совпадает.
|
|
719
|
-
* Для команд-действий (undo, indent, horizontalRule…) всегда `false`.
|
|
720
|
-
*/
|
|
721
|
-
declare function isCommandActive(state: EditorState, command: CommandName): boolean;
|
|
722
|
-
declare function getLinkAt(state: EditorState): {
|
|
723
|
-
href: string;
|
|
724
|
-
title: string | null;
|
|
725
|
-
target: string | null;
|
|
726
|
-
} | null;
|
|
727
|
-
|
|
728
|
-
/** Английские строки UI — язык по умолчанию и эталон набора ключей для остальных языков. */
|
|
729
|
-
declare const en: {
|
|
730
|
-
readonly 'toolbar.label': "Formatting";
|
|
731
|
-
readonly 'toolbar.options': "options";
|
|
732
|
-
readonly 'editor.label': "Rich text editor";
|
|
733
|
-
readonly 'editor.required': "Please fill in this field.";
|
|
734
|
-
readonly undo: "Undo";
|
|
735
|
-
readonly redo: "Redo";
|
|
736
|
-
readonly bold: "Bold";
|
|
737
|
-
readonly italic: "Italic";
|
|
738
|
-
readonly underline: "Underline";
|
|
739
|
-
readonly strike: "Strikethrough";
|
|
740
|
-
readonly code: "Inline code";
|
|
741
|
-
readonly subscript: "Subscript";
|
|
742
|
-
readonly superscript: "Superscript";
|
|
743
|
-
readonly link: "Link";
|
|
744
|
-
readonly unlink: "Remove link";
|
|
745
|
-
readonly image: "Image";
|
|
746
|
-
readonly bulletList: "Bulleted list";
|
|
747
|
-
readonly orderedList: "Numbered list";
|
|
748
|
-
readonly indent: "Increase indent";
|
|
749
|
-
readonly outdent: "Decrease indent";
|
|
750
|
-
readonly align: "Alignment";
|
|
751
|
-
readonly alignLeft: "Align left";
|
|
752
|
-
readonly alignCenter: "Align center";
|
|
753
|
-
readonly alignRight: "Align right";
|
|
754
|
-
readonly alignJustify: "Justify";
|
|
755
|
-
readonly blockquote: "Quote";
|
|
756
|
-
readonly codeBlock: "Code block";
|
|
757
|
-
readonly horizontalRule: "Horizontal line";
|
|
758
|
-
readonly clearFormatting: "Clear formatting";
|
|
759
|
-
readonly more: "More";
|
|
760
|
-
readonly moreFormats: "More formatting";
|
|
761
|
-
readonly blocks: "Text style";
|
|
762
|
-
readonly paragraph: "Paragraph";
|
|
763
|
-
readonly h1: "Heading 1";
|
|
764
|
-
readonly h2: "Heading 2";
|
|
765
|
-
readonly h3: "Heading 3";
|
|
766
|
-
readonly h4: "Heading 4";
|
|
767
|
-
readonly h5: "Heading 5";
|
|
768
|
-
readonly h6: "Heading 6";
|
|
769
|
-
readonly fontFamily: "Font";
|
|
770
|
-
readonly fontSize: "Font size";
|
|
771
|
-
readonly lineHeight: "Line height";
|
|
772
|
-
readonly default: "Default";
|
|
773
|
-
readonly textColor: "Text color";
|
|
774
|
-
readonly backgroundColor: "Highlight color";
|
|
775
|
-
readonly removeColor: "Remove color";
|
|
776
|
-
readonly customColor: "Custom color";
|
|
777
|
-
readonly 'dialog.cancel': "Cancel";
|
|
778
|
-
readonly 'dialog.save': "Save";
|
|
779
|
-
readonly 'dialog.insert': "Insert";
|
|
780
|
-
readonly 'dialog.close': "Close";
|
|
781
|
-
readonly 'link.title': "Insert link";
|
|
782
|
-
readonly 'link.editTitle': "Edit link";
|
|
783
|
-
readonly 'link.url': "URL";
|
|
784
|
-
readonly 'link.text': "Text to display";
|
|
785
|
-
readonly 'link.tooltip': "Title (tooltip)";
|
|
786
|
-
readonly 'link.newTab': "Open in new tab";
|
|
787
|
-
readonly 'link.open': "Open link";
|
|
788
|
-
readonly 'link.edit': "Edit link";
|
|
789
|
-
readonly 'link.copy': "Copy link";
|
|
790
|
-
readonly 'link.copied': "Link copied";
|
|
791
|
-
readonly 'link.invalid': "This URL is not allowed";
|
|
792
|
-
readonly 'image.title': "Insert image";
|
|
793
|
-
readonly 'image.url': "Image URL";
|
|
794
|
-
readonly 'image.alt': "Alternative text";
|
|
795
|
-
readonly 'image.altHint': "Describe the image for people using screen readers";
|
|
796
|
-
readonly 'image.upload': "Upload";
|
|
797
|
-
readonly 'image.drop': "Drop an image here or click to choose";
|
|
798
|
-
readonly 'image.uploading': "Uploading image…";
|
|
799
|
-
readonly 'image.uploadFailed': "Image upload failed";
|
|
800
|
-
readonly 'image.invalid': "This image URL is not allowed";
|
|
801
|
-
readonly 'image.or': "or";
|
|
802
|
-
readonly 'image.toolbar': "Image options";
|
|
803
|
-
readonly 'image.alignLeft': "Float left";
|
|
804
|
-
readonly 'image.alignCenter': "Center";
|
|
805
|
-
readonly 'image.alignRight': "Float right";
|
|
806
|
-
readonly 'image.editAlt': "Alternative text";
|
|
807
|
-
readonly 'image.size': "Size";
|
|
808
|
-
readonly 'image.sizeSmall': "Small (25%)";
|
|
809
|
-
readonly 'image.sizeMedium': "Medium (50%)";
|
|
810
|
-
readonly 'image.sizeLarge': "Large (75%)";
|
|
811
|
-
readonly 'image.sizeFull': "Full width";
|
|
812
|
-
readonly 'image.sizeOriginal': "Original size";
|
|
813
|
-
readonly 'image.delete': "Remove image";
|
|
814
|
-
readonly 'status.words': "{count} words";
|
|
815
|
-
readonly pasteAsText: "Paste as text";
|
|
816
|
-
readonly 'menu.label': "Menu";
|
|
817
|
-
readonly 'menu.file': "File";
|
|
818
|
-
readonly 'menu.edit': "Edit";
|
|
819
|
-
readonly 'menu.view': "View";
|
|
820
|
-
readonly 'menu.insert': "Insert";
|
|
821
|
-
readonly 'menu.format': "Format";
|
|
822
|
-
readonly 'menu.table': "Table";
|
|
823
|
-
readonly 'menu.help': "Help";
|
|
824
|
-
readonly selectAll: "Select all";
|
|
825
|
-
readonly print: "Print";
|
|
826
|
-
readonly 'table.rows': "Rows";
|
|
827
|
-
readonly 'table.cols': "Columns";
|
|
828
|
-
readonly 'table.invalidSize': "Enter a number from 1 to 50";
|
|
829
|
-
readonly 'quickbars.selection': "Quick formatting";
|
|
830
|
-
readonly 'quickbars.insert': "Quick insert";
|
|
831
|
-
readonly 'search.title': "Find and replace";
|
|
832
|
-
readonly 'search.find': "Find";
|
|
833
|
-
readonly 'search.replace': "Replace with";
|
|
834
|
-
readonly 'search.next': "Next match";
|
|
835
|
-
readonly 'search.prev': "Previous match";
|
|
836
|
-
readonly 'search.replaceOne': "Replace";
|
|
837
|
-
readonly 'search.replaceAll': "Replace all";
|
|
838
|
-
readonly 'search.matchCase': "Match case";
|
|
839
|
-
readonly 'search.wholeWord': "Whole words only";
|
|
840
|
-
readonly 'search.count': "{current} of {total}";
|
|
841
|
-
readonly 'search.none': "No results";
|
|
842
|
-
readonly fullscreen: "Fullscreen";
|
|
843
|
-
readonly preview: "Preview";
|
|
844
|
-
readonly sourceCode: "Source code";
|
|
845
|
-
readonly help: "Keyboard shortcuts";
|
|
846
|
-
readonly 'help.formatting': "Text formatting";
|
|
847
|
-
readonly 'help.blocks': "Paragraphs and lists";
|
|
848
|
-
readonly 'help.editing': "Editing";
|
|
849
|
-
readonly 'help.navigation': "Navigation";
|
|
850
|
-
readonly 'help.slash': "Insert block (slash commands)";
|
|
851
|
-
readonly 'help.toMenubar': "Move to the menu bar";
|
|
852
|
-
readonly 'help.toToolbar': "Move to the toolbar";
|
|
853
|
-
readonly 'help.toContextToolbar': "Move to the image/table toolbar";
|
|
854
|
-
readonly 'help.toEditor': "Back to the text";
|
|
855
|
-
readonly 'help.nextCell': "Next table cell";
|
|
856
|
-
readonly table: "Table";
|
|
857
|
-
readonly 'table.insert': "Insert table";
|
|
858
|
-
readonly 'table.size': "{rows} × {cols}";
|
|
859
|
-
readonly 'table.toolbar': "Table options";
|
|
860
|
-
readonly 'table.rowBefore': "Insert row above";
|
|
861
|
-
readonly 'table.rowAfter': "Insert row below";
|
|
862
|
-
readonly 'table.rowDelete': "Delete row";
|
|
863
|
-
readonly 'table.colBefore': "Insert column left";
|
|
864
|
-
readonly 'table.colAfter': "Insert column right";
|
|
865
|
-
readonly 'table.colDelete': "Delete column";
|
|
866
|
-
readonly 'table.merge': "Merge cells";
|
|
867
|
-
readonly 'table.split': "Split cell";
|
|
868
|
-
readonly 'table.rowHeader': "Header row";
|
|
869
|
-
readonly 'table.colHeader': "Header column";
|
|
870
|
-
readonly 'table.cellBackground': "Cell background";
|
|
871
|
-
readonly 'table.delete': "Delete table";
|
|
872
|
-
readonly 'table.sort': "Sort";
|
|
873
|
-
readonly 'table.sortAsc': "Sort A → Z, 1 → 9";
|
|
874
|
-
readonly 'table.sortDesc': "Sort Z → A, 9 → 1";
|
|
875
|
-
readonly 'table.props': "Table properties";
|
|
876
|
-
readonly 'table.width': "Width";
|
|
877
|
-
readonly 'table.widthHint': "For example 100% or 600px. Leave empty to fit the content.";
|
|
878
|
-
readonly 'table.invalidWidth': "Enter a width such as 100% or 600px";
|
|
879
|
-
readonly 'table.align': "Alignment on the page";
|
|
880
|
-
readonly 'table.alignDefault': "Default";
|
|
881
|
-
readonly 'table.alignCenter': "Center";
|
|
882
|
-
readonly 'table.alignRight': "Right";
|
|
883
|
-
readonly 'table.cellProps': "Cell properties";
|
|
884
|
-
readonly 'table.valign': "Vertical alignment";
|
|
885
|
-
readonly 'table.valignTop': "Top";
|
|
886
|
-
readonly 'table.valignMiddle': "Middle";
|
|
887
|
-
readonly 'table.valignBottom': "Bottom";
|
|
888
|
-
readonly 'table.cellType': "Cell type";
|
|
889
|
-
readonly 'table.cellData': "Data cell";
|
|
890
|
-
readonly 'table.cellHeader': "Header cell";
|
|
891
|
-
readonly 'table.colWidth': "Column width, px";
|
|
892
|
-
readonly 'table.colWidthHint': "Leave empty to fit the content.";
|
|
893
|
-
readonly 'table.invalidColWidth': "Enter a number from 24 to 4000";
|
|
894
|
-
readonly 'slash.label': "Commands";
|
|
895
|
-
readonly 'slash.empty': "No matching commands";
|
|
896
|
-
};
|
|
897
|
-
type MessageKey = keyof typeof en;
|
|
898
|
-
type Messages = Record<MessageKey, string>;
|
|
899
|
-
|
|
900
|
-
declare const ru: Messages;
|
|
901
|
-
|
|
902
|
-
/** Зарегистрировать языковой пакет (BCP-47 код: 'de', 'pt-BR'). Недостающие ключи берутся из английского. */
|
|
903
|
-
declare function registerLanguage(code: string, messages: Partial<Messages>): void;
|
|
904
|
-
type Translator = (key: MessageKey, params?: Record<string, string | number>) => string;
|
|
905
|
-
/**
|
|
906
|
-
* Переводчик для экземпляра редактора. Ищет точный код ('pt-br'), затем базовый язык ('pt'),
|
|
907
|
-
* затем английский. overrides — точечная замена строк из конфига.
|
|
908
|
-
*/
|
|
909
|
-
declare function createTranslator(language?: string, overrides?: Partial<Messages>): Translator;
|
|
910
|
-
|
|
911
|
-
/**
|
|
912
|
-
* Загрузчик изображений (аналог images_upload_handler): получает файл, возвращает URL.
|
|
913
|
-
* progress(0..100) — необязательный индикатор.
|
|
914
|
-
*/
|
|
915
|
-
type UploadImageHandler = (file: File, progress: (percent: number) => void) => Promise<string>;
|
|
916
|
-
/**
|
|
917
|
-
* Вставить и загрузить файлы изображений. Пока файл грузится, показываем его локальную копию
|
|
918
|
-
* (blob:) полупрозрачной; после загрузки подменяем src, при ошибке — убираем и сообщаем.
|
|
919
|
-
* Без uploadImage картинка встраивается как data:URL (как делает TinyMCE без обработчика).
|
|
920
|
-
*/
|
|
921
|
-
declare function uploadImages(editor: Editor, files: File[], pos?: number): void;
|
|
922
|
-
/** Диалог вставки изображения: загрузка файла или URL + обязательный по смыслу alt. */
|
|
923
|
-
declare function openImageDialog(editor: Editor): void;
|
|
924
|
-
declare function getSelectedImage(state: EditorState): {
|
|
925
|
-
node: Node;
|
|
926
|
-
pos: number;
|
|
927
|
-
} | null;
|
|
928
|
-
/** Изменить атрибуты выделенной картинки (выделение узла сохраняется). */
|
|
929
|
-
declare function setImageAttrs(attrs: Partial<Record<'alt' | 'title' | 'width' | 'height' | 'align', unknown>>): Command;
|
|
930
|
-
/** Ширина картинки как доля ширины области текста (с сохранением пропорций); null — исходный размер. */
|
|
931
|
-
declare function setImageWidthFraction(editor: Editor, fraction: number | null): boolean;
|
|
932
|
-
/** Диалог альтернативного текста — главный пункт доступности картинки. */
|
|
933
|
-
declare function openImageAltDialog(editor: Editor): void;
|
|
934
|
-
|
|
935
|
-
/** 'clean' (по умолчанию) — без шрифтов, кегля, интервалов и цветов «по умолчанию»; 'keep' — как есть. */
|
|
936
|
-
type PasteStyles = 'clean' | 'keep';
|
|
937
|
-
|
|
938
|
-
/**
|
|
939
|
-
* Обработка вставки:
|
|
940
|
-
* - режим «Вставить как текст» (переключатель pastetext) — любое содержимое вставляется без форматирования;
|
|
941
|
-
* - Ctrl/Cmd+Shift+V — разовая вставка без форматирования (ProseMirror сам отдаёт text/plain
|
|
942
|
-
* при зажатом Shift; мы лишь гарантируем, что HTML-ветка не перехватит её);
|
|
943
|
-
* - хуки pastePreprocess (строка HTML до разбора) и pastePostprocess (DOM после разбора браузером).
|
|
944
|
-
*/
|
|
945
|
-
interface PasteOptions {
|
|
946
|
-
/** Изменить HTML до разбора: вернуть новую строку. */
|
|
947
|
-
pastePreprocess?: (html: string, editor: Editor) => string;
|
|
948
|
-
/** Изменить DOM после разбора: можно удалять/менять узлы на месте. */
|
|
949
|
-
pastePostprocess?: (fragment: HTMLElement, editor: Editor) => void;
|
|
950
|
-
/** Включить режим «вставить как текст» сразу. */
|
|
951
|
-
pasteAsText?: boolean;
|
|
952
|
-
/**
|
|
953
|
-
* Оформление при вставке из Word, Google Docs, Excel и веб-страниц.
|
|
954
|
-
* 'clean' (по умолчанию) — сохраняются жирный, курсив, цвета, списки, таблицы, ссылки, но не шрифт,
|
|
955
|
-
* кегль и интервалы документа-источника; 'keep' — переносить и их.
|
|
956
|
-
*/
|
|
957
|
-
pasteStyles?: PasteStyles;
|
|
958
|
-
}
|
|
959
|
-
/** Превращает HTML в простой текст с сохранением абзацев (для режима «как текст»). */
|
|
960
|
-
declare function htmlToPlainText(html: string): string;
|
|
961
|
-
|
|
962
|
-
interface MenuDefinition {
|
|
963
|
-
/** Заголовок меню (строка) или ключ перевода. */
|
|
964
|
-
title: string;
|
|
965
|
-
/** Пункты через пробел, '|' — разделитель: 'undo redo | searchreplace'. */
|
|
966
|
-
items: string;
|
|
967
|
-
}
|
|
968
|
-
/** Стандартные меню. Имена пунктов — из реестра пунктов меню или кнопок тулбара. */
|
|
969
|
-
declare const DEFAULT_MENUS: Record<string, MenuDefinition>;
|
|
970
|
-
declare const DEFAULT_MENUBAR = "file edit view insert format table help";
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* Ограничение контента (аналог valid_elements / invalid_elements / valid_styles).
|
|
974
|
-
*
|
|
975
|
-
* Схема NovaProse одна на процесс, поэтому ограничения — не другая схема, а нормализатор:
|
|
976
|
-
* всё запрещённое деградирует (жирный → текст, h1 → абзац, список → абзацы, таблица → содержимое)
|
|
977
|
-
* при любом изменении документа — вставке, перетаскивании, setContent, горячих клавишах.
|
|
978
|
-
*/
|
|
979
|
-
interface ContentRulesOptions {
|
|
980
|
-
/** Разрешены ТОЛЬКО эти элементы: 'p,strong/b,em/i,a[href],ul,ol'. Атрибуты в [...] пока не учитываются. */
|
|
981
|
-
validElements?: string;
|
|
982
|
-
/** Запрещённые элементы: 'img,table,h1'. */
|
|
983
|
-
invalidElements?: string;
|
|
984
|
-
/** Разрешённые CSS-свойства: 'color,text-align' или { '*': 'color', img: 'float' }. */
|
|
985
|
-
validStyles?: string | Record<string, string>;
|
|
986
|
-
}
|
|
987
|
-
/** Все теги, которыми оперирует NovaProse. p и текст разрешены всегда. */
|
|
988
|
-
declare const KNOWN_TAGS: readonly ["p", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote", "pre", "hr", "ul", "ol", "li", "img", "br", "table", "tr", "td", "th", "strong", "em", "u", "s", "code", "a", "sub", "sup", "span"];
|
|
989
|
-
/** Стили NovaProse и какой CSS-свойство каждый пишет. */
|
|
990
|
-
declare const KNOWN_STYLES: readonly ["color", "background-color", "font-family", "font-size", "text-align", "line-height", "float", "width"];
|
|
991
|
-
declare class ContentRules {
|
|
992
|
-
private readonly tags;
|
|
993
|
-
private readonly styles;
|
|
994
|
-
constructor(options: ContentRulesOptions);
|
|
995
|
-
isTagAllowed(tag: string): boolean;
|
|
996
|
-
isStyleAllowed(property: string): boolean;
|
|
997
|
-
/** Доступен ли контрол / пункт меню / слэш-команда (по имени). Неизвестные имена — разрешены. */
|
|
998
|
-
isAllowed(name: string): boolean;
|
|
999
|
-
private markAllowed;
|
|
1000
|
-
/** Атрибуты блока без запрещённых стилей. */
|
|
1001
|
-
private blockAttrs;
|
|
1002
|
-
/** Привести узел к правилам. Возвращает 0…n узлов (запрещённый блок может «раствориться»). */
|
|
1003
|
-
normalize(node: Node): Node[];
|
|
1004
|
-
normalizeChildren(fragment: Fragment): Fragment;
|
|
1005
|
-
/** Нормализовать документ целиком (начальное содержимое). */
|
|
1006
|
-
normalizeDoc(doc: Node): Node;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
/**
|
|
1010
|
-
* Плагин NovaProse. Встроенные и сторонние плагины используют один и тот же API.
|
|
1011
|
-
*
|
|
1012
|
-
* ```ts
|
|
1013
|
-
* export default definePlugin({
|
|
1014
|
-
* name: 'signature',
|
|
1015
|
-
* setup(editor) {
|
|
1016
|
-
* editor.ui.registry.addButton('signature', { text: 'Подпись', tooltip: '…', onAction: … });
|
|
1017
|
-
* },
|
|
1018
|
-
* });
|
|
1019
|
-
* ```
|
|
1020
|
-
*/
|
|
1021
|
-
interface NovaPlugin {
|
|
1022
|
-
/** Уникальное имя; по нему плагин указывается в конфиге и в requires других плагинов. */
|
|
1023
|
-
name: string;
|
|
1024
|
-
/** Плагины, которые должны быть подключены раньше. */
|
|
1025
|
-
requires?: string[];
|
|
1026
|
-
/** Регистрация кнопок, команд, автокомплитеров. Может вернуть функцию очистки (при destroy). */
|
|
1027
|
-
setup?: (editor: Editor) => void | (() => void);
|
|
1028
|
-
/**
|
|
1029
|
-
* Кнопки, которые добавляются в конец тулбара по умолчанию ('insertdatetime').
|
|
1030
|
-
* Если пользователь задал свой toolbar — не добавляются: его конфиг главнее.
|
|
1031
|
-
*/
|
|
1032
|
-
toolbar?: string;
|
|
1033
|
-
/** ProseMirror-плагины (ввод, декорации, клавиши). */
|
|
1034
|
-
prosemirrorPlugins?: (editor: Editor) => Plugin[];
|
|
1035
|
-
/**
|
|
1036
|
-
* Новые узлы документа (с parseDOM и toDOM). Расширяют схему конкретного редактора.
|
|
1037
|
-
* Плагин с узлами или марками передаётся объектом, не ленивым загрузчиком: схема создаётся сразу.
|
|
1038
|
-
*/
|
|
1039
|
-
nodes?: Record<string, NodeSpec>;
|
|
1040
|
-
/** Новые марки (инлайн-форматирование) с parseDOM и toDOM. */
|
|
1041
|
-
marks?: Record<string, MarkSpec>;
|
|
1042
|
-
/**
|
|
1043
|
-
* Переопределение именованных команд (кнопки, меню, горячие клавиши и editor.exec берут их отсюда).
|
|
1044
|
-
* Например, совместное редактирование заменяет undo/redo своими — «отменить только свои правки».
|
|
1045
|
-
*/
|
|
1046
|
-
commands?: Partial<Record<CommandName, Command>>;
|
|
1047
|
-
/** Плагин ведёт свою историю изменений — встроенная (prosemirror-history) не подключается. */
|
|
1048
|
-
replaceHistory?: boolean;
|
|
1049
|
-
/**
|
|
1050
|
-
* Переписать транзакцию до применения (режим правок превращает удаление в пометку «удалено»).
|
|
1051
|
-
* Вызывается для каждой транзакции редактора; вернуть ту же, если менять нечего.
|
|
1052
|
-
*/
|
|
1053
|
-
transformTransaction?: (tr: Transaction, state: EditorState, editor: Editor) => Transaction;
|
|
1054
|
-
}
|
|
1055
|
-
type Loader = () => Promise<NovaPlugin | {
|
|
1056
|
-
default: NovaPlugin;
|
|
1057
|
-
}>;
|
|
1058
|
-
/** Элемент конфига plugins: объект, имя из реестра или ленивый загрузчик. */
|
|
1059
|
-
type PluginEntry = NovaPlugin | string | Loader;
|
|
1060
|
-
/** Помощник для типизации определения плагина. */
|
|
1061
|
-
declare function definePlugin(plugin: NovaPlugin): NovaPlugin;
|
|
1062
|
-
/** Зарегистрировать плагин (или его ленивый загрузчик) под именем — для `plugins: ['имя']`. */
|
|
1063
|
-
declare function registerPlugin(name: string, plugin: NovaPlugin | Loader): void;
|
|
1064
|
-
declare function isPluginRegistered(name: string): boolean;
|
|
1065
|
-
|
|
1066
|
-
interface FontOption {
|
|
1067
|
-
label: string;
|
|
1068
|
-
value: string;
|
|
1069
|
-
}
|
|
1070
|
-
declare const defaultFontFamilies: FontOption[];
|
|
1071
|
-
declare const defaultFontSizes: string[];
|
|
1072
|
-
declare const defaultLineHeights: string[];
|
|
1073
|
-
|
|
1074
|
-
interface SlashCommand {
|
|
1075
|
-
name: string;
|
|
1076
|
-
/** Ключ перевода подписи. */
|
|
1077
|
-
label: MessageKey;
|
|
1078
|
-
icon: string;
|
|
1079
|
-
/** Доп. слова для поиска (английские — чтобы «/h1» и «/quote» работали в любом языке UI). */
|
|
1080
|
-
keywords: string[];
|
|
1081
|
-
shortcut?: string;
|
|
1082
|
-
run: (editor: Editor) => void;
|
|
1083
|
-
}
|
|
1084
|
-
declare const defaultSlashCommands: SlashCommand[];
|
|
1085
|
-
/**
|
|
1086
|
-
* Ранжирование: совпадение с начала подписи важнее совпадения с начала ключевого слова,
|
|
1087
|
-
* а то — важнее вхождения в середину. Пустой запрос — все команды по порядку.
|
|
1088
|
-
*/
|
|
1089
|
-
declare function rankSlashCommands(commands: SlashCommand[], query: string, t: (k: MessageKey) => string): SlashCommand[];
|
|
1090
|
-
|
|
1091
|
-
interface DialogOptions {
|
|
1092
|
-
host: HTMLElement;
|
|
1093
|
-
title: string;
|
|
1094
|
-
body: HTMLElement;
|
|
1095
|
-
/** Без submitLabel диалог информационный: в подвале только кнопка cancelLabel («Закрыть»). */
|
|
1096
|
-
submitLabel?: string;
|
|
1097
|
-
cancelLabel: string;
|
|
1098
|
-
closeLabel: string;
|
|
1099
|
-
/** Вернуть false (или строку ошибки), чтобы не закрывать диалог. */
|
|
1100
|
-
onSubmit?: () => boolean | string | void | Promise<boolean | string | void>;
|
|
1101
|
-
/** large — для предпросмотра и HTML-кода. */
|
|
1102
|
-
size?: 'normal' | 'large';
|
|
1103
|
-
onClose?: () => void;
|
|
1104
|
-
/** Куда вернуть фокус после закрытия. */
|
|
1105
|
-
returnFocus?: () => void;
|
|
1106
|
-
/** Элемент, получающий фокус при открытии (по умолчанию — первое поле). */
|
|
1107
|
-
initialFocus?: HTMLElement;
|
|
1108
|
-
}
|
|
1109
|
-
interface DialogHandle {
|
|
1110
|
-
el: HTMLElement;
|
|
1111
|
-
close(): void;
|
|
1112
|
-
setError(message: string | null): void;
|
|
1113
|
-
setBusy(busy: boolean): void;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
type NotificationType = 'info' | 'success' | 'warning' | 'error';
|
|
1117
|
-
interface NotificationOptions {
|
|
1118
|
-
text: string;
|
|
1119
|
-
type?: NotificationType;
|
|
1120
|
-
/** мс до автозакрытия; 0 — не закрывать автоматически. По умолчанию 4000 (ошибки — 0). */
|
|
1121
|
-
timeout?: number;
|
|
1122
|
-
}
|
|
1123
|
-
interface NotificationHandle {
|
|
1124
|
-
close(): void;
|
|
1125
|
-
setText(text: string): void;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
type Placement = 'bottom-start' | 'bottom-end' | 'top-start' | 'bottom';
|
|
1129
|
-
type Anchor = HTMLElement | (() => DOMRect);
|
|
1130
|
-
interface PopoverOptions {
|
|
1131
|
-
host: HTMLElement;
|
|
1132
|
-
anchor: Anchor;
|
|
1133
|
-
content: HTMLElement;
|
|
1134
|
-
placement?: Placement;
|
|
1135
|
-
className?: string;
|
|
1136
|
-
/** Закрывать по клику вне панели (по умолчанию да). */
|
|
1137
|
-
dismissOnOutside?: boolean;
|
|
1138
|
-
/** Элементы, клик по которым не считается «вне» (например, кнопка-якорь). */
|
|
1139
|
-
ignore?: HTMLElement[];
|
|
1140
|
-
onClose?: (reason: 'escape' | 'outside' | 'api') => void;
|
|
1141
|
-
}
|
|
1142
|
-
/** Всплывающая панель: меню, палитра цветов, панель ссылки, переполнение тулбара. */
|
|
1143
|
-
declare class Popover {
|
|
1144
|
-
readonly el: HTMLDivElement;
|
|
1145
|
-
private readonly options;
|
|
1146
|
-
private closed;
|
|
1147
|
-
constructor(options: PopoverOptions);
|
|
1148
|
-
get isOpen(): boolean;
|
|
1149
|
-
reposition: () => void;
|
|
1150
|
-
close(reason?: 'escape' | 'outside' | 'api'): void;
|
|
1151
|
-
/** Был ли фокус внутри панели в момент закрытия (тогда его надо вернуть на кнопку). */
|
|
1152
|
-
focusWasInside: boolean;
|
|
1153
|
-
private onKeyDown;
|
|
1154
|
-
private onPointerDown;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
interface AutocompleterItem {
|
|
1158
|
-
value: string;
|
|
1159
|
-
label: string;
|
|
1160
|
-
icon?: string;
|
|
1161
|
-
/** Подсказка справа — горячая клавиша в формате 'Mod-b'. */
|
|
1162
|
-
shortcut?: string;
|
|
1163
|
-
/** Подсказка справа обычным текстом (должность, e-mail). */
|
|
1164
|
-
detail?: string;
|
|
1165
|
-
}
|
|
1166
|
-
interface AutocompleterSpec {
|
|
1167
|
-
/** Символ-триггер: '/', '@', ':'. */
|
|
1168
|
-
trigger: string;
|
|
1169
|
-
/** Сколько символов после триггера нужно до показа списка (по умолчанию 0). */
|
|
1170
|
-
minChars?: number;
|
|
1171
|
-
/** Пункты для запроса; можно вернуть Promise (поиск на сервере). */
|
|
1172
|
-
fetch: (query: string, editor: Editor) => AutocompleterItem[] | Promise<AutocompleterItem[]>;
|
|
1173
|
-
/** Выбор пункта. range — позиции «триггер + запрос», их обычно удаляют. */
|
|
1174
|
-
onSelect: (item: AutocompleterItem, range: {
|
|
1175
|
-
from: number;
|
|
1176
|
-
to: number;
|
|
1177
|
-
}, editor: Editor) => void;
|
|
1178
|
-
/** Подпись списка для экранного диктора. */
|
|
1179
|
-
label: string;
|
|
1180
|
-
/** Текст, если ничего не найдено (иначе список скрывается). */
|
|
1181
|
-
emptyText?: string;
|
|
1182
|
-
maxResults?: number;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
interface MenuItem {
|
|
1186
|
-
type?: 'item';
|
|
1187
|
-
id: string;
|
|
1188
|
-
label: string;
|
|
1189
|
-
icon?: string;
|
|
1190
|
-
shortcut?: string;
|
|
1191
|
-
/** Отмечен (радио/чекбокс) — показывается галочка. */
|
|
1192
|
-
active?: boolean;
|
|
1193
|
-
/** Независимый переключатель (жирный, надстрочный) — menuitemcheckbox, а не radio. */
|
|
1194
|
-
checkbox?: boolean;
|
|
1195
|
-
disabled?: boolean;
|
|
1196
|
-
/** Стиль подписи — для превью шрифтов и заголовков прямо в меню. */
|
|
1197
|
-
labelStyle?: string;
|
|
1198
|
-
onSelect: () => void;
|
|
1199
|
-
}
|
|
1200
|
-
interface MenuSeparator {
|
|
1201
|
-
type: 'separator';
|
|
1202
|
-
}
|
|
1203
|
-
type MenuEntry = MenuItem | MenuSeparator;
|
|
1204
|
-
|
|
1205
|
-
interface ControlBase {
|
|
1206
|
-
/** Подпись для подсказки и aria-label. */
|
|
1207
|
-
tooltip: string;
|
|
1208
|
-
/** SVG-иконка (строка). Если нет — показывается text. */
|
|
1209
|
-
icon?: string;
|
|
1210
|
-
/** Текст на кнопке (для выпадающих списков: «Обычный текст ▾»). */
|
|
1211
|
-
text?: string;
|
|
1212
|
-
/** Горячая клавиша в формате ProseMirror ('Mod-b') — только для подсказки. */
|
|
1213
|
-
shortcut?: string;
|
|
1214
|
-
isEnabled?: (editor: Editor) => boolean;
|
|
1215
|
-
}
|
|
1216
|
-
interface ButtonSpec extends ControlBase {
|
|
1217
|
-
type: 'button';
|
|
1218
|
-
onAction: (editor: Editor) => void;
|
|
1219
|
-
/** Если задан — кнопка становится переключателем (aria-pressed). */
|
|
1220
|
-
isActive?: (editor: Editor) => boolean;
|
|
1221
|
-
}
|
|
1222
|
-
interface MenuButtonSpec extends ControlBase {
|
|
1223
|
-
type: 'menu';
|
|
1224
|
-
items: (editor: Editor) => MenuEntry[];
|
|
1225
|
-
/** Динамическая подпись (текущий стиль блока, шрифт и т.п.). */
|
|
1226
|
-
label?: (editor: Editor) => string;
|
|
1227
|
-
isActive?: (editor: Editor) => boolean;
|
|
1228
|
-
/** Минимальная ширина подписи в символах — чтобы тулбар не прыгал. */
|
|
1229
|
-
minChars?: number;
|
|
1230
|
-
}
|
|
1231
|
-
interface PanelButtonSpec extends ControlBase {
|
|
1232
|
-
type: 'panel';
|
|
1233
|
-
render: (editor: Editor, close: () => void) => HTMLElement;
|
|
1234
|
-
/** Цвет полоски под иконкой (текущий цвет текста/фона). */
|
|
1235
|
-
indicator?: (editor: Editor) => string | null;
|
|
1236
|
-
isActive?: (editor: Editor) => boolean;
|
|
1237
|
-
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Составная кнопка: основная часть выполняет действие (переключить список), стрелка открывает
|
|
1240
|
-
* меню вариантов (стиль маркеров). Как bullist/numlist с плагином advlist.
|
|
1241
|
-
*/
|
|
1242
|
-
interface SplitButtonSpec extends ControlBase {
|
|
1243
|
-
type: 'split';
|
|
1244
|
-
onAction: (editor: Editor) => void;
|
|
1245
|
-
items: (editor: Editor) => MenuEntry[];
|
|
1246
|
-
isActive?: (editor: Editor) => boolean;
|
|
1247
|
-
}
|
|
1248
|
-
type ControlSpec = ButtonSpec | MenuButtonSpec | PanelButtonSpec | SplitButtonSpec;
|
|
1249
|
-
/** Пункт меню менюбара. */
|
|
1250
|
-
interface MenuItemSpec {
|
|
1251
|
-
text: string;
|
|
1252
|
-
icon?: string;
|
|
1253
|
-
shortcut?: string;
|
|
1254
|
-
onAction: (editor: Editor) => void;
|
|
1255
|
-
/** Галочка (переключатель). */
|
|
1256
|
-
isActive?: (editor: Editor) => boolean;
|
|
1257
|
-
isEnabled?: (editor: Editor) => boolean;
|
|
1258
|
-
}
|
|
1259
|
-
/** Контекстный тулбар: появляется рядом с выделенным объектом (картинка, таблица, ссылка). */
|
|
1260
|
-
interface ContextToolbarSpec {
|
|
1261
|
-
/** Когда показывать. Проверяются по порядку регистрации — побеждает первый подходящий. */
|
|
1262
|
-
predicate: (editor: Editor) => boolean;
|
|
1263
|
-
/** Кнопки в формате тулбара ('a b | c'), из того же реестра. */
|
|
1264
|
-
items: string | string[];
|
|
1265
|
-
/** Подпись для экранного диктора. */
|
|
1266
|
-
label: string;
|
|
1267
|
-
/** Где показывать: над выделенным узлом (по умолчанию) или под выделением. */
|
|
1268
|
-
position?: 'node' | 'selection';
|
|
1269
|
-
/** Свой якорь (например, вся таблица). Перекрывает position. */
|
|
1270
|
-
anchor?: (editor: Editor) => DOMRect | null;
|
|
1271
|
-
/** Сторона относительно якоря; при нехватке места переворачивается. */
|
|
1272
|
-
placement?: 'top-start' | 'bottom-start';
|
|
1273
|
-
/** Порядок проверки: больше — раньше (по умолчанию 0). Выделение текста в таблице → quickbar важнее таблицы. */
|
|
1274
|
-
priority?: number;
|
|
1275
|
-
}
|
|
1276
|
-
type WithoutType<T> = Omit<T, 'type'>;
|
|
1277
|
-
/**
|
|
1278
|
-
* Реестр кнопок тулбара (аналог editor.ui.registry). Встроенные кнопки регистрируются так же,
|
|
1279
|
-
* как пользовательские, — плагины ничем не ограничены по сравнению с ядром.
|
|
1280
|
-
*/
|
|
1281
|
-
declare class Registry {
|
|
1282
|
-
private readonly controls;
|
|
1283
|
-
addButton(name: string, spec: WithoutType<ButtonSpec>): void;
|
|
1284
|
-
/** Синоним addButton с isActive — для совместимости с привычным API. */
|
|
1285
|
-
addToggleButton(name: string, spec: WithoutType<ButtonSpec>): void;
|
|
1286
|
-
addMenuButton(name: string, spec: WithoutType<MenuButtonSpec>): void;
|
|
1287
|
-
addPanelButton(name: string, spec: WithoutType<PanelButtonSpec>): void;
|
|
1288
|
-
addSplitButton(name: string, spec: WithoutType<SplitButtonSpec>): void;
|
|
1289
|
-
private readonly menuItems;
|
|
1290
|
-
/** Пункт меню менюбара (аналог addMenuItem). */
|
|
1291
|
-
addMenuItem(name: string, spec: MenuItemSpec): void;
|
|
1292
|
-
/** Пункт-переключатель (с галочкой). */
|
|
1293
|
-
addToggleMenuItem(name: string, spec: MenuItemSpec & {
|
|
1294
|
-
isActive: (editor: Editor) => boolean;
|
|
1295
|
-
}): void;
|
|
1296
|
-
/**
|
|
1297
|
-
* Пункт меню по имени. Если отдельного пункта нет — строится из одноимённой кнопки тулбара
|
|
1298
|
-
* (подпись = tooltip), чтобы не дублировать каждую функцию дважды.
|
|
1299
|
-
*/
|
|
1300
|
-
getMenuItem(name: string): MenuItemSpec | undefined;
|
|
1301
|
-
private readonly contextToolbars;
|
|
1302
|
-
private readonly autocompleters;
|
|
1303
|
-
/** Автокомплитер по символу-триггеру: '/' — команды, '@' — упоминания, ':' — эмодзи. */
|
|
1304
|
-
addAutocompleter(name: string, spec: AutocompleterSpec): void;
|
|
1305
|
-
getAutocompleters(): [string, AutocompleterSpec][];
|
|
1306
|
-
addContextToolbar(name: string, spec: ContextToolbarSpec): void;
|
|
1307
|
-
/** По убыванию priority; при равенстве — в порядке регистрации (sort стабильна). */
|
|
1308
|
-
getContextToolbars(): [string, ContextToolbarSpec][];
|
|
1309
|
-
get(name: string): ControlSpec | undefined;
|
|
1310
|
-
has(name: string): boolean;
|
|
1311
|
-
names(): string[];
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
/**
|
|
1315
|
-
* Одна общая подсказка на редактор: название кнопки + горячая клавиша.
|
|
1316
|
-
* Мышь — с задержкой, клавиатурный фокус — сразу. На тач-устройствах не показывается
|
|
1317
|
-
* (там подпись дублируется aria-label, а не скрывается в подсказке).
|
|
1318
|
-
*/
|
|
1319
|
-
declare class Tooltip {
|
|
1320
|
-
private readonly el;
|
|
1321
|
-
private timer;
|
|
1322
|
-
private target;
|
|
1323
|
-
constructor(host: HTMLElement);
|
|
1324
|
-
/** Подключить подсказку к элементу. Текст берётся из data-tooltip и data-shortcut. */
|
|
1325
|
-
attach(target: HTMLElement): void;
|
|
1326
|
-
private schedule;
|
|
1327
|
-
show(target: HTMLElement): void;
|
|
1328
|
-
hide(): void;
|
|
1329
|
-
get current(): HTMLElement | null;
|
|
1330
|
-
destroy(): void;
|
|
1331
|
-
private clearTimer;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
/**
|
|
1335
|
-
* UI-слой экземпляра редактора: реестр кнопок, оверлеи (поповеры, диалоги, подсказки),
|
|
1336
|
-
* уведомления и переводы. Доступен как editor.ui.
|
|
1337
|
-
*/
|
|
1338
|
-
declare class UiManager {
|
|
1339
|
-
private readonly focusEditor;
|
|
1340
|
-
readonly registry: Registry;
|
|
1341
|
-
readonly t: Translator;
|
|
1342
|
-
/** Слой для всех плавающих элементов. Лежит внутри .nova-editor, поэтому наследует тему. */
|
|
1343
|
-
readonly overlayHost: HTMLDivElement;
|
|
1344
|
-
readonly tooltip: Tooltip;
|
|
1345
|
-
private readonly notifications;
|
|
1346
|
-
private popover;
|
|
1347
|
-
private dialog;
|
|
1348
|
-
constructor(root: HTMLElement, t: Translator, focusEditor: () => void);
|
|
1349
|
-
/** Открыть поповер; одновременно открыт только один (кроме панели переполнения тулбара). */
|
|
1350
|
-
openPopover(options: Omit<PopoverOptions, 'host'>): Popover;
|
|
1351
|
-
closePopover(): void;
|
|
1352
|
-
get activePopover(): Popover | null;
|
|
1353
|
-
private readonly dialogListeners;
|
|
1354
|
-
/**
|
|
1355
|
-
* Подписаться на открытие диалога (вернёт отписку). Тулбар так закрывает панель «⋯»: иначе на узком
|
|
1356
|
-
* экране она оставалась открытой поверх текста после закрытия диалога, открытого из неё.
|
|
1357
|
-
*/
|
|
1358
|
-
onDialogOpen(listener: () => void): () => void;
|
|
1359
|
-
/**
|
|
1360
|
-
* Закрыть всплывающие панели и «⋯» тулбара — перед тем как плагин открывает свою панель или вид
|
|
1361
|
-
* (история версий, комментарии), чтобы они не остались поверх.
|
|
1362
|
-
*/
|
|
1363
|
-
closeOverlays(): void;
|
|
1364
|
-
openDialog(options: Omit<DialogOptions, 'host' | 'cancelLabel' | 'closeLabel' | 'returnFocus'> & {
|
|
1365
|
-
cancelLabel?: string;
|
|
1366
|
-
}): DialogHandle;
|
|
1367
|
-
get activeDialog(): DialogHandle | null;
|
|
1368
|
-
notify(options: NotificationOptions | string): NotificationHandle;
|
|
1369
|
-
destroy(): void;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* Конфиг тулбара: строка в привычном формате ('undo redo | bold italic') или массив имён,
|
|
1374
|
-
* где '|' разделяет группы.
|
|
1375
|
-
*/
|
|
1376
|
-
type ToolbarConfig = string | string[];
|
|
1377
|
-
/** Режим при нехватке ширины: перенос на новую строку или «⋯» с остальными группами. */
|
|
1378
|
-
type ToolbarMode = 'wrap' | 'sliding';
|
|
1379
|
-
declare const defaultToolbar: string;
|
|
1380
|
-
declare function parseToolbar(config: ToolbarConfig): string[][];
|
|
1381
|
-
|
|
1382
|
-
type EditorMode = 'classic' | 'inline' | 'distraction-free';
|
|
1383
|
-
type EditorEvent = 'change' | 'selectionChange' | 'focus' | 'blur' | 'editableChange' | 'destroy';
|
|
1384
|
-
/**
|
|
1385
|
-
* Настройки встроенных плагинов (типизированы — подсказки в редакторе кода) и любых сторонних по имени.
|
|
1386
|
-
* Только типы: модули плагинов не попадают в ядро.
|
|
1387
|
-
*/
|
|
1388
|
-
interface PluginOptions {
|
|
1389
|
-
comments?: CommentsOptions;
|
|
1390
|
-
mentions?: MentionsOptions;
|
|
1391
|
-
revisionhistory?: RevisionHistoryOptions;
|
|
1392
|
-
autosave?: AutosaveOptions;
|
|
1393
|
-
quickbars?: QuickbarsOptions;
|
|
1394
|
-
[plugin: string]: unknown;
|
|
1395
|
-
}
|
|
1396
|
-
interface EditorOptions extends PasteOptions, ContentRulesOptions {
|
|
1397
|
-
/** Элемент, внутрь которого монтируется редактор. */
|
|
1398
|
-
element: HTMLElement;
|
|
1399
|
-
/** Начальное содержимое: HTML-строка или JSON документа. */
|
|
1400
|
-
content?: string | Record<string, unknown>;
|
|
1401
|
-
/**
|
|
1402
|
-
* Тулбар: строка ('undo redo | bold italic'), массив имён или false (headless — UI рисует клиент).
|
|
1403
|
-
* По умолчанию — стандартный набор.
|
|
1404
|
-
*/
|
|
1405
|
-
toolbar?: false | ToolbarConfig;
|
|
1406
|
-
/** Поведение тулбара при нехватке ширины. По умолчанию 'sliding' (лишнее уходит в «⋯»). */
|
|
1407
|
-
toolbarMode?: ToolbarMode;
|
|
1408
|
-
/**
|
|
1409
|
-
* classic — рамка и панели (по умолчанию); inline — без рамки, панель появляется над текстом при фокусе;
|
|
1410
|
-
* distraction-free — без постоянных панелей, только quickbars над выделением и на пустой строке.
|
|
1411
|
-
*/
|
|
1412
|
-
mode?: EditorMode;
|
|
1413
|
-
/** Менюбар: true — стандартный ('file edit view insert format table help'), строка — свой набор. По умолчанию нет. */
|
|
1414
|
-
menubar?: boolean | string;
|
|
1415
|
-
/** Свои меню и переопределение стандартных: { insert: { title: 'Вставка', items: 'image link | hr' } }. */
|
|
1416
|
-
menu?: Record<string, MenuDefinition>;
|
|
1417
|
-
/** Статусбар с путём к элементу и счётчиком слов. По умолчанию включён. */
|
|
1418
|
-
statusbar?: boolean;
|
|
1419
|
-
/** Плейсхолдер для пустого документа. */
|
|
1420
|
-
placeholder?: string;
|
|
1421
|
-
editable?: boolean;
|
|
1422
|
-
/** Язык UI (BCP-47): 'en', 'ru'… По умолчанию 'en'. */
|
|
1423
|
-
language?: string;
|
|
1424
|
-
/** Точечная замена строк UI. */
|
|
1425
|
-
translations?: Partial<Messages>;
|
|
1426
|
-
/** Загрузка изображений на ваш сервер. Без неё картинки встраиваются как data:URL. */
|
|
1427
|
-
uploadImage?: UploadImageHandler;
|
|
1428
|
-
fontFamilies?: FontOption[];
|
|
1429
|
-
fontSizes?: string[];
|
|
1430
|
-
lineHeights?: string[];
|
|
1431
|
-
colors?: string[];
|
|
1432
|
-
/** Слэш-команды «/». false — выключить; массив — дополнительные команды к стандартным. */
|
|
1433
|
-
slashCommands?: false | SlashCommand[];
|
|
1434
|
-
/**
|
|
1435
|
-
* Плагины NovaProse: объект, имя из реестра ('insertdatetime') или ленивый загрузчик (() => import(...)).
|
|
1436
|
-
* Ленивые грузятся после создания редактора; дождаться — `await editor.ready`.
|
|
1437
|
-
*/
|
|
1438
|
-
plugins?: PluginEntry[];
|
|
1439
|
-
/** Настройки плагинов по имени: { comments: {...}, mentions: {...} }. Встроенные — с типами. */
|
|
1440
|
-
pluginOptions?: PluginOptions;
|
|
1441
|
-
/** Сырые ProseMirror-плагины (для низкоуровневых расширений). */
|
|
1442
|
-
prosemirrorPlugins?: Plugin[];
|
|
1443
|
-
/** Вызывается до отрисовки тулбара — место для editor.ui.registry.addButton(...). */
|
|
1444
|
-
setup?: (editor: Editor) => void;
|
|
1445
|
-
onChange?: (editor: Editor) => void;
|
|
1446
|
-
}
|
|
1447
|
-
type Listener = (editor: Editor) => void;
|
|
1448
|
-
/**
|
|
1449
|
-
* Публичный API редактора NovaProse.
|
|
1450
|
-
* Обёртки (React, Vue…) работают только через этот класс, а не через ProseMirror напрямую.
|
|
1451
|
-
*/
|
|
1452
|
-
declare class Editor {
|
|
1453
|
-
readonly view: EditorView;
|
|
1454
|
-
readonly root: HTMLElement;
|
|
1455
|
-
readonly ui: UiManager;
|
|
1456
|
-
readonly options: Readonly<EditorOptions>;
|
|
1457
|
-
private readonly listeners;
|
|
1458
|
-
/** Выполняется, когда загружены и подключены все ленивые плагины. */
|
|
1459
|
-
readonly ready: Promise<void>;
|
|
1460
|
-
private toolbar;
|
|
1461
|
-
private readonly toolbarHost;
|
|
1462
|
-
private readonly menubar;
|
|
1463
|
-
readonly mode: EditorMode;
|
|
1464
|
-
private readonly pluginsByName;
|
|
1465
|
-
private readonly commandOverrides;
|
|
1466
|
-
private readonly transactionTransforms;
|
|
1467
|
-
private readonly cleanups;
|
|
1468
|
-
/** Ограничения контента (validElements/invalidElements/validStyles) или null — без ограничений. */
|
|
1469
|
-
readonly contentRules: ContentRules | null;
|
|
1470
|
-
/** Схема документа этого редактора: базовая + узлы и марки синхронных плагинов. */
|
|
1471
|
-
readonly schema: NovaSchema;
|
|
1472
|
-
private readonly statusbar;
|
|
1473
|
-
private readonly searchBar;
|
|
1474
|
-
private destroyed;
|
|
1475
|
-
private editable;
|
|
1476
|
-
private pasteAsText;
|
|
1477
|
-
constructor(options: EditorOptions);
|
|
1478
|
-
/** Разрешён ли контрол/команда/тег по ограничениям контента (без ограничений — всегда да). */
|
|
1479
|
-
isAllowed(name: string): boolean;
|
|
1480
|
-
hasPlugin(name: string): boolean;
|
|
1481
|
-
/**
|
|
1482
|
-
* Схема с узлами и марками плагинов. Конфликт имён — ошибка конфигурации: сообщаем и работаем
|
|
1483
|
-
* на базовой схеме, чтобы редактор всё равно открылся.
|
|
1484
|
-
*/
|
|
1485
|
-
private buildSchema;
|
|
1486
|
-
private collectPmPlugins;
|
|
1487
|
-
/** setup с изоляцией ошибок: упавший плагин не ломает редактор. */
|
|
1488
|
-
private setupPlugin;
|
|
1489
|
-
private loadLazyPlugins;
|
|
1490
|
-
/**
|
|
1491
|
-
* Обновить состояние кнопок (нажата / доступна) без изменения документа — например, после того как
|
|
1492
|
-
* плагин переключил режим отображения. Изменения документа обновляют UI сами.
|
|
1493
|
-
*/
|
|
1494
|
-
updateUI(): void;
|
|
1495
|
-
/** Перестроить тулбар (после регистрации новых кнопок плагинами). */
|
|
1496
|
-
rebuildToolbar(): void;
|
|
1497
|
-
/** Конфиг тулбара: пользовательский как есть; по умолчанию — плюс кнопки подключённых плагинов. */
|
|
1498
|
-
private toolbarConfig;
|
|
1499
|
-
private handleTransaction;
|
|
1500
|
-
private updatePlaceholder;
|
|
1501
|
-
/** HTML документа. Детерминирован: одинаков во всех браузерах и в Node. */
|
|
1502
|
-
getHTML(): string;
|
|
1503
|
-
getJSON(): Record<string, unknown>;
|
|
1504
|
-
getText(): string;
|
|
1505
|
-
/** Заменить содержимое. По умолчанию попадает в историю undo. */
|
|
1506
|
-
setContent(content: string | Record<string, unknown>, { addToHistory }?: {
|
|
1507
|
-
addToHistory?: boolean | undefined;
|
|
1508
|
-
}): void;
|
|
1509
|
-
isEmpty(): boolean;
|
|
1510
|
-
/** Выполнить именованную команду или произвольную ProseMirror-команду. */
|
|
1511
|
-
/** Команда по имени: переопределение плагина или встроенная. */
|
|
1512
|
-
resolveCommand(name: CommandName): Command;
|
|
1513
|
-
private registerCommands;
|
|
1514
|
-
exec(command: CommandName | Command): boolean;
|
|
1515
|
-
/** Можно ли выполнить команду в текущем состоянии (для disabled-кнопок). */
|
|
1516
|
-
can(command: CommandName | Command): boolean;
|
|
1517
|
-
/** Активна ли именованная команда в текущем выделении (для своих кнопок тулбара). */
|
|
1518
|
-
isActive(command: CommandName): boolean;
|
|
1519
|
-
focus(): void;
|
|
1520
|
-
/** Режим «вставлять как текст» (переключатель pastetext). */
|
|
1521
|
-
isPasteAsText(): boolean;
|
|
1522
|
-
setPasteAsText(value: boolean): void;
|
|
1523
|
-
/** Открыть панель «Найти и заменить» (Ctrl/Cmd+F). */
|
|
1524
|
-
openSearch(): void;
|
|
1525
|
-
closeSearch(): void;
|
|
1526
|
-
isEditable(): boolean;
|
|
1527
|
-
setEditable(value: boolean): void;
|
|
1528
|
-
on(event: EditorEvent, listener: Listener): () => void;
|
|
1529
|
-
off(event: EditorEvent, listener: Listener): void;
|
|
1530
|
-
private emit;
|
|
1531
|
-
destroy(): void;
|
|
1532
|
-
}
|
|
1533
|
-
declare function createEditor(options: EditorOptions): Editor;
|
|
1
|
+
import { E as Editor, N as NovaSchema } from './editor-CXkltf1R.js';
|
|
2
|
+
export { A as API_CHANGE_META, a as AutocompleterItem, b as AutocompleterSpec, c as AutosaveOptions, B as BlockFormat, d as BlockTag, e as ButtonSpec, C as ClassFilter, f as ClassOption, g as CommandName, h as Comment, i as CommentAuthor, j as CommentStore, k as CommentThread, l as CommentsController, m as CommentsOptions, n as ContentRules, o as ContentRulesOptions, p as ContextToolbarSpec, q as ControlSpec, D as DEFAULT_MENUBAR, r as DEFAULT_MENUS, s as DialogApi, t as DialogData, u as DialogField, v as DialogFieldValue, w as DialogSpec, x as EditorEvent, y as EditorEventDetails, z as EditorListener, F as EditorMode, G as EditorOptions, H as FilePickResult, I as FilePickType, J as FilePicker, K as FontOption, L as FormatSpec, M as Formatter, O as ImageAlign, P as InlineTag, Q as KNOWN_STYLES, R as KNOWN_TAGS, S as MENTION_ID_RE, T as MarkName, U as MentionUser, V as MentionsOptions, W as MenuButtonSpec, X as MenuDefinition, Y as MenuEntry, Z as MenuItem, _ as MenuItemSpec, $ as MergeTag, a0 as MergeTagGroup, a1 as MergeTagsOptions, a2 as NodeName, a3 as NotificationAction, a4 as NotificationHandle, a5 as NotificationOptions, a6 as NovaPlugin, a7 as PanelButtonSpec, a8 as PasteOptions, a9 as PluginEntry, aa as PluginOptions, ab as QuickbarsOptions, ac as REMOTE_CHANGE_META, ad as Registry, ae as Revision, af as RevisionHistoryOptions, ag as SchemaExtensions, ah as SidebarSpec, ai as Sidebars, aj as SlashCommand, ak as StyleFormat, al as TextAlign, am as ToolbarConfig, an as ToolbarMode, ao as UiManager, ap as UploadImageHandler, aq as commands, ar as createCommentStore, as as createEditor, at as createSchema, au as cssValue, av as defaultFontFamilies, aw as defaultFontSizes, ax as defaultLineHeights, ay as defaultSlashCommands, az as defaultToolbar, aA as definePlugin, aB as getActiveAlign, aC as getComments, aD as getLinkAt, aE as getMentions, aF as getSelectedImage, aG as htmlToPlainText, aH as imageSize, aI as insertImage, aJ as isCommandActive, aK as isMarkActive, aL as isNodeActive, aM as isPluginRegistered, aN as marksOf, aO as newCommentId, aP as nodesOf, aQ as openImageAltDialog, aR as openImageDialog, aS as parseToolbar, aT as rankSlashCommands, aU as registerPlugin, aV as sanitizeThread, aW as schema, aX as setImageAttrs, aY as setImageWidthFraction, aZ as setLink, a_ as uploadImages } from './editor-CXkltf1R.js';
|
|
3
|
+
import { Schema, DOMParser, Node, Fragment } from 'prosemirror-model';
|
|
4
|
+
import { EditorState, Command, Transaction } from 'prosemirror-state';
|
|
5
|
+
export { L as LanguagePack, M as MessageKey, a as Messages, P as PluginMessageKey, T as Translator, c as createTranslator, e as en, g as getPluginMessages, r as registerLanguage } from './index-C603bU6r.js';
|
|
6
|
+
export { H as HtmlRulesInstance, b as HtmlRulesModule, a as HtmlRulesOptions, r as registerHtmlRules } from './html-rules-api-D3fKQi-R.js';
|
|
7
|
+
import 'prosemirror-view';
|
|
1534
8
|
|
|
1535
9
|
/** Печать содержимого через скрытый iframe (HTML уже очищен схемой). */
|
|
1536
10
|
declare function printContent(editor: Editor): void;
|
|
@@ -1574,7 +48,6 @@ declare function openLinkDialog(editor: Editor): void;
|
|
|
1574
48
|
/** Палитра по умолчанию: 8 оттенков × (тёмный, основной, светлый) + шкала серого. */
|
|
1575
49
|
declare const defaultColors: string[];
|
|
1576
50
|
|
|
1577
|
-
/** Считает слова так же, как пользователь: числа и слова с дефисом/апострофом — одно слово. */
|
|
1578
51
|
declare function countWords(text: string): number;
|
|
1579
52
|
|
|
1580
53
|
declare function isSafeLinkUrl(url: string): boolean;
|
|
@@ -1624,30 +97,39 @@ declare function formatHTML(html: string): string;
|
|
|
1624
97
|
declare function openSourceCode(editor: Editor): void;
|
|
1625
98
|
declare function openHelp(editor: Editor): void;
|
|
1626
99
|
|
|
1627
|
-
/**
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Узлы таблицы для схемы — без зависимости от prosemirror-tables: сама библиотека (выделение
|
|
102
|
+
* ячеек, ширина колонок, команды) грузится лениво, а схема нужна сразу. Спеки совместимы с ней
|
|
103
|
+
* (tableRole, атрибуты colspan/rowspan/colwidth, тот же HTML).
|
|
104
|
+
*
|
|
105
|
+
* Адаптировано из prosemirror-tables (MIT, © Marijn Haverbeke и др.): tableNodes, getCellAttrs,
|
|
106
|
+
* setCellAttrs.
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
/** Курсор внутри таблицы (как isInTable из prosemirror-tables). */
|
|
110
|
+
declare function isInTable(state: EditorState): boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Таблицы в первой загрузке — только лёгкая часть: создание и вставка таблицы, сетка выбора
|
|
114
|
+
* размера, положение таблицы на экране. Механика (выделение ячеек, ширина колонок, команды строк и
|
|
115
|
+
* столбцов, сортировка, свойства) — модуль ./table на prosemirror-tables: ~10 КБ gzip, грузится в
|
|
116
|
+
* фоне сразу после создания редактора и входит в `editor.ready`.
|
|
117
|
+
*
|
|
118
|
+
* Команды и помощники механики доступны здесь «заместителями» с тем же API: пока модуль не
|
|
119
|
+
* загружен (первые миллисекунды), команда «недоступна» (false), как любая неприменимая команда.
|
|
120
|
+
*/
|
|
1644
121
|
|
|
122
|
+
type TableCommandName = 'addRowBefore' | 'addRowAfter' | 'deleteRow' | 'addColumnBefore' | 'addColumnAfter' | 'deleteColumn' | 'mergeCells' | 'splitCell' | 'toggleHeaderRow' | 'toggleHeaderColumn' | 'deleteTable';
|
|
123
|
+
/** Команды строк, столбцов и ячеек (публичный API; до загрузки механики — недоступны). */
|
|
124
|
+
declare const tableCommands: Record<TableCommandName, Command>;
|
|
1645
125
|
/** Фон выделенных ячеек (null — убрать). */
|
|
1646
126
|
declare function setCellBackground(color: string | null): Command;
|
|
1647
|
-
/** Есть ли в текущей таблице строка-заголовок (первая строка из th). */
|
|
1648
127
|
declare function hasHeaderRow(state: EditorState): boolean;
|
|
1649
|
-
/** Есть ли столбец-заголовок (первая ячейка каждой строки — th). */
|
|
1650
128
|
declare function hasHeaderColumn(state: EditorState): boolean;
|
|
129
|
+
/** Создать таблицу rows×cols; первая строка — заголовки, если withHeader. */
|
|
130
|
+
declare function createTable(rows: number, cols: number, withHeader?: boolean, schema?: NovaSchema): Node;
|
|
131
|
+
/** Вставить таблицу на место выделения и поставить курсор в первую ячейку. */
|
|
132
|
+
declare function insertTable(rows: number, cols: number, withHeader?: boolean): Command;
|
|
1651
133
|
|
|
1652
134
|
/**
|
|
1653
135
|
* Плагин suggestions — режим правок (как «Предлагать изменения» в Google Docs).
|
|
@@ -1721,6 +203,7 @@ declare const icons: {
|
|
|
1721
203
|
imageRight: string;
|
|
1722
204
|
resize: string;
|
|
1723
205
|
altText: string;
|
|
206
|
+
imageCaption: string;
|
|
1724
207
|
trash: string;
|
|
1725
208
|
paragraph: string;
|
|
1726
209
|
h1: string;
|
|
@@ -1761,6 +244,10 @@ declare const icons: {
|
|
|
1761
244
|
externalLink: string;
|
|
1762
245
|
copy: string;
|
|
1763
246
|
edit: string;
|
|
247
|
+
resizeHandle: string;
|
|
248
|
+
browse: string;
|
|
249
|
+
mergeTags: string;
|
|
250
|
+
resizeHandleBoth: string;
|
|
1764
251
|
anchor: string;
|
|
1765
252
|
save: string;
|
|
1766
253
|
charmap: string;
|
|
@@ -1771,6 +258,8 @@ declare const icons: {
|
|
|
1771
258
|
media: string;
|
|
1772
259
|
nonBreaking: string;
|
|
1773
260
|
pageBreak: string;
|
|
261
|
+
/** Боковая панель (кнопка своих панелей плагинов по умолчанию). */
|
|
262
|
+
sidebar: string;
|
|
1774
263
|
history: string;
|
|
1775
264
|
suggest: string;
|
|
1776
265
|
review: string;
|
|
@@ -1780,10 +269,16 @@ declare const icons: {
|
|
|
1780
269
|
};
|
|
1781
270
|
|
|
1782
271
|
declare class HTMLSerializer {
|
|
272
|
+
/**
|
|
273
|
+
* Кэш отрисовки марок — свой у каждого типа марки: сериализатор общий для всех редакторов страницы,
|
|
274
|
+
* а вывод одноимённой марки зависит от схемы редактора (правила атрибутов, плагины).
|
|
275
|
+
*/
|
|
1783
276
|
private readonly cache;
|
|
1784
|
-
serializeFragment(fragment: Fragment
|
|
277
|
+
serializeFragment(fragment: Fragment, { pre }?: {
|
|
278
|
+
pre?: boolean;
|
|
279
|
+
}): string;
|
|
1785
280
|
serializeNode(node: Node): string;
|
|
1786
281
|
private renderMark;
|
|
1787
282
|
}
|
|
1788
283
|
|
|
1789
|
-
export {
|
|
284
|
+
export { Editor, HTMLSerializer, type LinkAttrs, NovaSchema, type SearchMatch, type SearchOptions, type SearchState, type StyleMark, type Suggestion, type SuggestionAuthor, type SuggestionsOptions, applyLink, clearSearch, countWords, createTable, defaultColors, findMatches, findNext, formatHTML, getLineHeight, getSearchState, getStyle, hasHeaderColumn, hasHeaderRow, icons, insertTable, isFullscreen, isInTable, isSafeImageUrl, isSafeLinkUrl, isSuggesting, listSuggestions, normalizeUrl, openHelp, openLinkDialog, openPreview, openSourceCode, parserFor, printContent, removeLink, replaceAll, replaceCurrent, resolveSuggestions, setCellBackground, setLineHeight, setSearch, setStyle, setSuggesting, suggestionsResult, tableCommands, toggleFullscreen };
|