tuikit-atomicx-vue3 4.5.0 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-jPzZ5INK.js → MessageInput.vue_vue_type_script_setup_true_lang-3RVYOdkv.js} +38 -38
- package/dist/{PopoverTrigger-L8abAry7.js → PopoverPortal-DV6zFXcf.js} +91 -136
- package/dist/PopoverTrigger-DIjW4PKa.js +54 -0
- package/dist/{PopperContent-XdhqL8Y2.js → PopperContent-D__dbwpA.js} +6 -6
- package/dist/{Teleport-CSEuZbpM.js → Teleport-98QrIYDI.js} +280 -270
- package/dist/baseComp/Modal/Modal.js +3 -3
- package/dist/components/AudioSettingPanel/index.js +14 -14
- package/dist/components/BarrageInput/EmojiPicker/EmojiPicker.js +10 -9
- package/dist/components/BarrageInput/TextEditor/CharacterCountExtension.js +1 -1
- package/dist/components/BarrageInput/TextEditor/EditorCore.js +16 -15
- package/dist/components/ConversationList/ConversationActions/ConversationActions.js +53 -50
- package/dist/components/ConversationList/ConversationActions/ConversationActions.vue.d.ts +2 -0
- package/dist/components/ConversationList/ConversationCreate/ConversationCreate.js +25 -25
- package/dist/components/ConversationList/ConversationList.vue.d.ts +16 -0
- package/dist/components/ConversationList/ConversationPreview/ConversationPreview.vue.d.ts +16 -0
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewAbstract.js +62 -40
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewTimestamp.js +28 -26
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewTitle.js +27 -23
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewTitle.vue.d.ts +1 -1
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.js +81 -70
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue.d.ts +4 -0
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUnread.js +33 -31
- package/dist/components/ConversationList/ConversationPreview/utils.d.ts +2 -2
- package/dist/components/ConversationList/ConversationPreview/utils.js +81 -35
- package/dist/components/ConversationList/i18n/en-US.d.ts +11 -1
- package/dist/components/ConversationList/i18n/en-US.js +12 -2
- package/dist/components/ConversationList/i18n/zh-CN.d.ts +11 -1
- package/dist/components/ConversationList/i18n/zh-CN.js +12 -2
- package/dist/components/ConversationList/index.d.ts +48 -0
- package/dist/components/MessageInput/AttachmentPicker/index.js +10 -9
- package/dist/components/MessageInput/EmojiPicker/EmojiPicker.js +17 -16
- package/dist/components/MessageInput/MessageInput.js +1 -1
- package/dist/components/MessageInput/QuotedMessagePreview/index.js +35 -35
- package/dist/components/MessageInput/TextEditor/EditorCore.d.ts +13 -12
- package/dist/components/MessageInput/TextEditor/EditorCore.js +54 -89
- package/dist/components/MessageInput/TextEditor/extensions/MentionSuggestion.js +229 -0
- package/dist/components/MessageInput/TextEditor/extensions/MentionSuggestion.vue.d.ts +15 -0
- package/dist/components/MessageInput/TextEditor/extensions/characterCountExtension.js +1 -1
- package/dist/components/MessageInput/TextEditor/extensions/emojiExtension.d.ts +1 -0
- package/dist/components/MessageInput/TextEditor/extensions/emojiExtension.js +22 -0
- package/dist/components/MessageInput/TextEditor/extensions/enterKeyExtension.d.ts +3 -0
- package/dist/components/MessageInput/TextEditor/extensions/enterKeyExtension.js +15 -0
- package/dist/components/MessageInput/TextEditor/extensions/imageExtension.js +2 -2
- package/dist/components/MessageInput/TextEditor/extensions/index.d.ts +8 -0
- package/dist/components/MessageInput/TextEditor/extensions/index.js +12 -0
- package/dist/components/MessageInput/TextEditor/extensions/mentionExtension.d.ts +5 -0
- package/dist/components/MessageInput/TextEditor/extensions/mentionExtension.js +330 -0
- package/dist/components/MessageInput/TextEditor/index.js +62 -62
- package/dist/components/MessageInput/i18n/en-US.d.ts +3 -0
- package/dist/components/MessageInput/i18n/en-US.js +4 -1
- package/dist/components/MessageInput/i18n/index.d.ts +6 -0
- package/dist/components/MessageInput/i18n/zh-CN.d.ts +3 -0
- package/dist/components/MessageInput/i18n/zh-CN.js +4 -1
- package/dist/components/MessageInput/index.js +1 -1
- package/dist/components/MessageList/Message/ImageMessage/ImageMessage.js +119 -89
- package/dist/components/MessageList/Message/ImageMessage/ImagePreview.js +142 -0
- package/dist/components/MessageList/Message/ImageMessage/ImagePreview.vue.d.ts +20 -0
- package/dist/components/MessageList/Message/Message.vue.d.ts +8 -0
- package/dist/components/MessageList/Message/MessageLayout/MessageActionDropdown/MessageActionDropdown.js +3 -3
- package/dist/components/MessageList/Message/MessageLayout/MessageLayout.js +69 -58
- package/dist/components/MessageList/Message/MessageLayout/MessageLayout.vue.d.ts +8 -0
- package/dist/components/MessageList/Message/MessageLayout/MessageMeta/MessageMeta.js +37 -28
- package/dist/components/MessageList/Message/index.js +8 -4
- package/dist/components/MessageList/MessageList.js +109 -91
- package/dist/components/MessageList/MessageList.vue.d.ts +1 -1
- package/dist/components/MessageList/index.d.ts +21 -3
- package/dist/components/ScheduleRoomPanel/RoomDetail.js +22 -22
- package/dist/components/ScheduleRoomPanel/RoomEdit.js +1 -1
- package/dist/components/ScheduleRoomPanel/RoomShare.js +4 -4
- package/dist/components/ScheduleRoomPanel/ScheduleRoomPanel.js +1 -1
- package/dist/components/ScheduleRoomPanel/ScheduledRoomList.js +1 -1
- package/dist/components/Search/SearchResults/SearchResultsItem/Message/Message.js +6 -6
- package/dist/components/Search/SearchResults/SearchResultsItem/Message/Message.vue.d.ts +1 -1
- package/dist/components/UIKitModal/chatErrorModal/chatErrorModal.d.ts +72 -0
- package/dist/components/UIKitModal/chatErrorModal/chatErrorModal.js +95 -0
- package/dist/components/UIKitModal/chatErrorModal/i18n/en-US/index.d.ts +40 -0
- package/dist/components/UIKitModal/chatErrorModal/i18n/en-US/index.js +51 -0
- package/dist/components/UIKitModal/chatErrorModal/i18n/index.d.ts +4 -0
- package/dist/components/UIKitModal/chatErrorModal/i18n/index.js +6 -0
- package/dist/components/UIKitModal/chatErrorModal/i18n/zh-CN/index.d.ts +40 -0
- package/dist/components/UIKitModal/chatErrorModal/i18n/zh-CN/index.js +51 -0
- package/dist/components/UIKitModal/chatErrorModal/index.d.ts +3 -0
- package/dist/components/UIKitModal/chatErrorModal/index.js +11 -0
- package/dist/components/VideoSettingPanel/index.js +1 -1
- package/dist/hooks/useReadReceipt/useReadReceipt.js +44 -41
- package/dist/index-CTthrJb2.js +1461 -0
- package/dist/index-DXC5bPY4.js +2174 -0
- package/dist/{index-Do-2CngU.js → index-DuAffztD.js} +115 -142
- package/dist/{index-7vNB_Vx8.js → index-hHVD-MG2.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +150 -149
- package/dist/states/GroupSettingState/GroupSettingState.js +109 -102
- package/dist/states/LoginState.js +43 -43
- package/dist/states/MessageActionState/MessageActionState.js +83 -223
- package/dist/states/MessageInputState/MessageInputState.js +111 -82
- package/dist/states/MessageInputState/type.d.ts +36 -10
- package/dist/states/MessageInputState/utils.d.ts +1 -5
- package/dist/states/MessageListState/MessageListState.d.ts +1 -1
- package/dist/states/MessageListState/MessageListState.js +26 -23
- package/dist/states/RoomParticipantState/index.js +83 -24
- package/dist/states/RoomParticipantState/participantEventManager.d.ts +2 -2
- package/dist/states/RoomParticipantState/participantEventManager.js +217 -205
- package/dist/states/RoomParticipantState/participantManager.d.ts +4 -0
- package/dist/states/RoomParticipantState/participantManager.js +159 -127
- package/dist/states/RoomState/callManager.d.ts +3 -3
- package/dist/states/RoomState/callManager.js +20 -20
- package/dist/states/RoomState/common.d.ts +3 -2
- package/dist/states/RoomState/common.js +34 -24
- package/dist/states/RoomState/roomManager.d.ts +0 -1
- package/dist/states/RoomState/roomManager.js +21 -27
- package/dist/states/RoomState/scheduleManager.js +2 -2
- package/dist/styles/index.css +1 -1
- package/dist/{chat/index.d.ts → subEntry/chat/chat.d.ts} +2160 -2087
- package/dist/subEntry/chat/chat.js +89 -0
- package/dist/subEntry/chat/index.d.ts +11 -0
- package/dist/subEntry/chat/index.js +81 -0
- package/dist/{chat → subEntry/chat}/server.js +4 -4
- package/dist/subEntry/live/index.js +46 -45
- package/dist/subEntry/room/index.js +39 -38
- package/dist/types/beauty.d.ts +20 -0
- package/dist/types/index.js +37 -36
- package/dist/types/participant.d.ts +2 -0
- package/dist/types/room.d.ts +45 -1
- package/dist/types/room.js +4 -3
- package/dist/{useId-CtirfF0W.js → useId-B1VwPJLm.js} +1 -1
- package/dist/utils/call.js +77 -71
- package/dist/{utils-DaB7eSu5.js → utils-BU8IkP_V.js} +1 -1
- package/package.json +8 -7
- package/src/components/AudioSettingPanel/index.vue +4 -5
- package/src/components/ConversationList/ConversationActions/ConversationActions.vue +7 -1
- package/src/components/ConversationList/ConversationCreate/ConversationCreate.vue +5 -1
- package/src/components/ConversationList/ConversationList.vue +0 -1
- package/src/components/ConversationList/ConversationPreview/ConversationPreview.scss +10 -2
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewAbstract.vue +32 -1
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewTitle.vue +3 -2
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue +15 -0
- package/src/components/ConversationList/ConversationPreview/utils.ts +98 -28
- package/src/components/ConversationList/i18n/en-US.ts +11 -1
- package/src/components/ConversationList/i18n/zh-CN.ts +11 -1
- package/src/components/MessageInput/MessageInput.module.scss +1 -0
- package/src/components/MessageInput/QuotedMessagePreview/QuotedMessagePreview.vue +19 -22
- package/src/components/MessageInput/TextEditor/Editor.scss +25 -0
- package/src/components/MessageInput/TextEditor/EditorCore.ts +79 -99
- package/src/components/MessageInput/TextEditor/TextEditor.vue +64 -68
- package/src/components/MessageInput/TextEditor/extensions/MentionSuggestion.vue +449 -0
- package/src/components/MessageInput/TextEditor/extensions/emojiExtension.ts +22 -0
- package/src/components/MessageInput/TextEditor/extensions/enterKeyExtension.ts +22 -0
- package/src/components/MessageInput/TextEditor/extensions/index.ts +8 -0
- package/src/components/MessageInput/TextEditor/extensions/mentionExtension.ts +87 -0
- package/src/components/MessageInput/i18n/en-US.ts +3 -0
- package/src/components/MessageInput/i18n/zh-CN.ts +3 -0
- package/src/components/MessageList/Message/ImageMessage/ImageMessage.vue +49 -0
- package/src/components/MessageList/Message/ImageMessage/ImagePreview.vue +344 -0
- package/src/components/MessageList/Message/Message.vue +6 -0
- package/src/components/MessageList/Message/MessageLayout/MessageLayout.vue +8 -1
- package/src/components/MessageList/Message/MessageLayout/MessageMeta/MessageMeta.vue +12 -3
- package/src/components/MessageList/MessageList.vue +50 -14
- package/src/components/ScheduleRoomPanel/RoomDetail.vue +1 -0
- package/src/components/ScheduleRoomPanel/RoomEdit.vue +2 -1
- package/src/components/ScheduleRoomPanel/RoomShare.vue +1 -0
- package/src/components/ScheduleRoomPanel/ScheduleRoomPanel.vue +1 -0
- package/src/components/ScheduleRoomPanel/ScheduledRoomList.vue +1 -0
- package/src/components/Search/SearchResults/SearchResultsItem/Message/Message.vue +30 -31
- package/src/components/UIKitModal/chatErrorModal/chatErrorModal.ts +205 -0
- package/src/components/UIKitModal/chatErrorModal/i18n/en-US/index.ts +56 -0
- package/src/components/UIKitModal/chatErrorModal/i18n/index.ts +4 -0
- package/src/components/UIKitModal/chatErrorModal/i18n/zh-CN/index.ts +56 -0
- package/src/components/UIKitModal/chatErrorModal/index.ts +16 -0
- package/src/components/VideoSettingPanel/index.vue +1 -0
- package/src/hooks/useReadReceipt/useReadReceipt.ts +5 -4
- package/src/index.ts +1 -1
- package/src/{chat/index.ts → subEntry/chat/chat.ts} +25 -18
- package/src/subEntry/chat/index.ts +13 -0
- package/src/{chat → subEntry/chat}/server.ts +3 -3
- package/src/types/beauty.ts +20 -0
- package/src/types/participant.ts +3 -0
- package/src/types/room.ts +49 -1
- package/src/utils/call.ts +8 -0
- package/dist/chat/index.js +0 -59
- package/dist/index-ZILx4LYk.js +0 -4826
- package/dist/states/SearchState.d.ts +0 -314
- /package/dist/{chat → subEntry/chat}/server.d.ts +0 -0
|
@@ -0,0 +1,1461 @@
|
|
|
1
|
+
import { E, P, a as N, i as ie, b as U, D as Z, N as M, w as H, m as v, M as B, d as I, f as x, T as L, t as z, S, g as oe, k as ae, F, h as Q, j as K, l as le, o as de, p as ue, n as pe, q as ce, r as he } from "./index-DuAffztD.js";
|
|
2
|
+
const ft = E.create({
|
|
3
|
+
name: "placeholder",
|
|
4
|
+
addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
emptyEditorClass: "is-editor-empty",
|
|
7
|
+
emptyNodeClass: "is-empty",
|
|
8
|
+
placeholder: "Write something …",
|
|
9
|
+
showOnlyWhenEditable: !0,
|
|
10
|
+
showOnlyCurrent: !0,
|
|
11
|
+
includeChildren: !1
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
addProseMirrorPlugins() {
|
|
15
|
+
return [
|
|
16
|
+
new P({
|
|
17
|
+
key: new N("placeholder"),
|
|
18
|
+
props: {
|
|
19
|
+
decorations: ({ doc: t, selection: e }) => {
|
|
20
|
+
const n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: s } = e, r = [];
|
|
21
|
+
if (!n)
|
|
22
|
+
return null;
|
|
23
|
+
const i = this.editor.isEmpty;
|
|
24
|
+
return t.descendants((o, a) => {
|
|
25
|
+
const l = s >= a && s <= a + o.nodeSize, u = !o.isLeaf && ie(o);
|
|
26
|
+
if ((l || !this.options.showOnlyCurrent) && u) {
|
|
27
|
+
const c = [this.options.emptyNodeClass];
|
|
28
|
+
i && c.push(this.options.emptyEditorClass);
|
|
29
|
+
const d = U.node(a, a + o.nodeSize, {
|
|
30
|
+
class: c.join(" "),
|
|
31
|
+
"data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
|
|
32
|
+
editor: this.editor,
|
|
33
|
+
node: o,
|
|
34
|
+
pos: a,
|
|
35
|
+
hasAnchor: l
|
|
36
|
+
}) : this.options.placeholder
|
|
37
|
+
});
|
|
38
|
+
r.push(d);
|
|
39
|
+
}
|
|
40
|
+
return this.options.includeChildren;
|
|
41
|
+
}), Z.create(t, r);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
}), fe = /^\s*>\s$/, me = M.create({
|
|
48
|
+
name: "blockquote",
|
|
49
|
+
addOptions() {
|
|
50
|
+
return {
|
|
51
|
+
HTMLAttributes: {}
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
content: "block+",
|
|
55
|
+
group: "block",
|
|
56
|
+
defining: !0,
|
|
57
|
+
parseHTML() {
|
|
58
|
+
return [
|
|
59
|
+
{ tag: "blockquote" }
|
|
60
|
+
];
|
|
61
|
+
},
|
|
62
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
63
|
+
return ["blockquote", v(this.options.HTMLAttributes, t), 0];
|
|
64
|
+
},
|
|
65
|
+
addCommands() {
|
|
66
|
+
return {
|
|
67
|
+
setBlockquote: () => ({ commands: t }) => t.wrapIn(this.name),
|
|
68
|
+
toggleBlockquote: () => ({ commands: t }) => t.toggleWrap(this.name),
|
|
69
|
+
unsetBlockquote: () => ({ commands: t }) => t.lift(this.name)
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
addKeyboardShortcuts() {
|
|
73
|
+
return {
|
|
74
|
+
"Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
addInputRules() {
|
|
78
|
+
return [
|
|
79
|
+
H({
|
|
80
|
+
find: fe,
|
|
81
|
+
type: this.type
|
|
82
|
+
})
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
}), ge = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, ye = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, ve = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, be = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, Me = B.create({
|
|
86
|
+
name: "bold",
|
|
87
|
+
addOptions() {
|
|
88
|
+
return {
|
|
89
|
+
HTMLAttributes: {}
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
parseHTML() {
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
tag: "strong"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
tag: "b",
|
|
99
|
+
getAttrs: (t) => t.style.fontWeight !== "normal" && null
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
style: "font-weight=400",
|
|
103
|
+
clearMark: (t) => t.type.name === this.name
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
style: "font-weight",
|
|
107
|
+
getAttrs: (t) => /^(bold(er)?|[5-9]\d{2,})$/.test(t) && null
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
},
|
|
111
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
112
|
+
return ["strong", v(this.options.HTMLAttributes, t), 0];
|
|
113
|
+
},
|
|
114
|
+
addCommands() {
|
|
115
|
+
return {
|
|
116
|
+
setBold: () => ({ commands: t }) => t.setMark(this.name),
|
|
117
|
+
toggleBold: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
118
|
+
unsetBold: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
addKeyboardShortcuts() {
|
|
122
|
+
return {
|
|
123
|
+
"Mod-b": () => this.editor.commands.toggleBold(),
|
|
124
|
+
"Mod-B": () => this.editor.commands.toggleBold()
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
addInputRules() {
|
|
128
|
+
return [
|
|
129
|
+
x({
|
|
130
|
+
find: ge,
|
|
131
|
+
type: this.type
|
|
132
|
+
}),
|
|
133
|
+
x({
|
|
134
|
+
find: ve,
|
|
135
|
+
type: this.type
|
|
136
|
+
})
|
|
137
|
+
];
|
|
138
|
+
},
|
|
139
|
+
addPasteRules() {
|
|
140
|
+
return [
|
|
141
|
+
I({
|
|
142
|
+
find: ye,
|
|
143
|
+
type: this.type
|
|
144
|
+
}),
|
|
145
|
+
I({
|
|
146
|
+
find: be,
|
|
147
|
+
type: this.type
|
|
148
|
+
})
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
}), ke = "listItem", G = "textStyle", j = /^\s*([-+*])\s$/, we = M.create({
|
|
152
|
+
name: "bulletList",
|
|
153
|
+
addOptions() {
|
|
154
|
+
return {
|
|
155
|
+
itemTypeName: "listItem",
|
|
156
|
+
HTMLAttributes: {},
|
|
157
|
+
keepMarks: !1,
|
|
158
|
+
keepAttributes: !1
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
group: "block list",
|
|
162
|
+
content() {
|
|
163
|
+
return `${this.options.itemTypeName}+`;
|
|
164
|
+
},
|
|
165
|
+
parseHTML() {
|
|
166
|
+
return [
|
|
167
|
+
{ tag: "ul" }
|
|
168
|
+
];
|
|
169
|
+
},
|
|
170
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
171
|
+
return ["ul", v(this.options.HTMLAttributes, t), 0];
|
|
172
|
+
},
|
|
173
|
+
addCommands() {
|
|
174
|
+
return {
|
|
175
|
+
toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ke, this.editor.getAttributes(G)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
addKeyboardShortcuts() {
|
|
179
|
+
return {
|
|
180
|
+
"Mod-Shift-8": () => this.editor.commands.toggleBulletList()
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
addInputRules() {
|
|
184
|
+
let t = H({
|
|
185
|
+
find: j,
|
|
186
|
+
type: this.type
|
|
187
|
+
});
|
|
188
|
+
return (this.options.keepMarks || this.options.keepAttributes) && (t = H({
|
|
189
|
+
find: j,
|
|
190
|
+
type: this.type,
|
|
191
|
+
keepMarks: this.options.keepMarks,
|
|
192
|
+
keepAttributes: this.options.keepAttributes,
|
|
193
|
+
getAttributes: () => this.editor.getAttributes(G),
|
|
194
|
+
editor: this.editor
|
|
195
|
+
})), [
|
|
196
|
+
t
|
|
197
|
+
];
|
|
198
|
+
}
|
|
199
|
+
}), Ae = /(^|[^`])`([^`]+)`(?!`)/, Te = /(^|[^`])`([^`]+)`(?!`)/g, Ce = B.create({
|
|
200
|
+
name: "code",
|
|
201
|
+
addOptions() {
|
|
202
|
+
return {
|
|
203
|
+
HTMLAttributes: {}
|
|
204
|
+
};
|
|
205
|
+
},
|
|
206
|
+
excludes: "_",
|
|
207
|
+
code: !0,
|
|
208
|
+
exitable: !0,
|
|
209
|
+
parseHTML() {
|
|
210
|
+
return [
|
|
211
|
+
{ tag: "code" }
|
|
212
|
+
];
|
|
213
|
+
},
|
|
214
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
215
|
+
return ["code", v(this.options.HTMLAttributes, t), 0];
|
|
216
|
+
},
|
|
217
|
+
addCommands() {
|
|
218
|
+
return {
|
|
219
|
+
setCode: () => ({ commands: t }) => t.setMark(this.name),
|
|
220
|
+
toggleCode: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
221
|
+
unsetCode: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
addKeyboardShortcuts() {
|
|
225
|
+
return {
|
|
226
|
+
"Mod-e": () => this.editor.commands.toggleCode()
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
addInputRules() {
|
|
230
|
+
return [
|
|
231
|
+
x({
|
|
232
|
+
find: Ae,
|
|
233
|
+
type: this.type
|
|
234
|
+
})
|
|
235
|
+
];
|
|
236
|
+
},
|
|
237
|
+
addPasteRules() {
|
|
238
|
+
return [
|
|
239
|
+
I({
|
|
240
|
+
find: Te,
|
|
241
|
+
type: this.type
|
|
242
|
+
})
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
}), Le = /^```([a-z]+)?[\s\n]$/, Ie = /^~~~([a-z]+)?[\s\n]$/, xe = M.create({
|
|
246
|
+
name: "codeBlock",
|
|
247
|
+
addOptions() {
|
|
248
|
+
return {
|
|
249
|
+
languageClassPrefix: "language-",
|
|
250
|
+
exitOnTripleEnter: !0,
|
|
251
|
+
exitOnArrowDown: !0,
|
|
252
|
+
defaultLanguage: null,
|
|
253
|
+
HTMLAttributes: {}
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
content: "text*",
|
|
257
|
+
marks: "",
|
|
258
|
+
group: "block",
|
|
259
|
+
code: !0,
|
|
260
|
+
defining: !0,
|
|
261
|
+
addAttributes() {
|
|
262
|
+
return {
|
|
263
|
+
language: {
|
|
264
|
+
default: this.options.defaultLanguage,
|
|
265
|
+
parseHTML: (t) => {
|
|
266
|
+
var e;
|
|
267
|
+
const { languageClassPrefix: n } = this.options, i = [...((e = t.firstElementChild) === null || e === void 0 ? void 0 : e.classList) || []].filter((o) => o.startsWith(n)).map((o) => o.replace(n, ""))[0];
|
|
268
|
+
return i || null;
|
|
269
|
+
},
|
|
270
|
+
rendered: !1
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
},
|
|
274
|
+
parseHTML() {
|
|
275
|
+
return [
|
|
276
|
+
{
|
|
277
|
+
tag: "pre",
|
|
278
|
+
preserveWhitespace: "full"
|
|
279
|
+
}
|
|
280
|
+
];
|
|
281
|
+
},
|
|
282
|
+
renderHTML({ node: t, HTMLAttributes: e }) {
|
|
283
|
+
return [
|
|
284
|
+
"pre",
|
|
285
|
+
v(this.options.HTMLAttributes, e),
|
|
286
|
+
[
|
|
287
|
+
"code",
|
|
288
|
+
{
|
|
289
|
+
class: t.attrs.language ? this.options.languageClassPrefix + t.attrs.language : null
|
|
290
|
+
},
|
|
291
|
+
0
|
|
292
|
+
]
|
|
293
|
+
];
|
|
294
|
+
},
|
|
295
|
+
addCommands() {
|
|
296
|
+
return {
|
|
297
|
+
setCodeBlock: (t) => ({ commands: e }) => e.setNode(this.name, t),
|
|
298
|
+
toggleCodeBlock: (t) => ({ commands: e }) => e.toggleNode(this.name, "paragraph", t)
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
addKeyboardShortcuts() {
|
|
302
|
+
return {
|
|
303
|
+
"Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
|
|
304
|
+
// remove code block when at start of document or code block is empty
|
|
305
|
+
Backspace: () => {
|
|
306
|
+
const { empty: t, $anchor: e } = this.editor.state.selection, n = e.pos === 1;
|
|
307
|
+
return !t || e.parent.type.name !== this.name ? !1 : n || !e.parent.textContent.length ? this.editor.commands.clearNodes() : !1;
|
|
308
|
+
},
|
|
309
|
+
// exit node on triple enter
|
|
310
|
+
Enter: ({ editor: t }) => {
|
|
311
|
+
if (!this.options.exitOnTripleEnter)
|
|
312
|
+
return !1;
|
|
313
|
+
const { state: e } = t, { selection: n } = e, { $from: s, empty: r } = n;
|
|
314
|
+
if (!r || s.parent.type !== this.type)
|
|
315
|
+
return !1;
|
|
316
|
+
const i = s.parentOffset === s.parent.nodeSize - 2, o = s.parent.textContent.endsWith(`
|
|
317
|
+
|
|
318
|
+
`);
|
|
319
|
+
return !i || !o ? !1 : t.chain().command(({ tr: a }) => (a.delete(s.pos - 2, s.pos), !0)).exitCode().run();
|
|
320
|
+
},
|
|
321
|
+
// exit node on arrow down
|
|
322
|
+
ArrowDown: ({ editor: t }) => {
|
|
323
|
+
if (!this.options.exitOnArrowDown)
|
|
324
|
+
return !1;
|
|
325
|
+
const { state: e } = t, { selection: n, doc: s } = e, { $from: r, empty: i } = n;
|
|
326
|
+
if (!i || r.parent.type !== this.type || !(r.parentOffset === r.parent.nodeSize - 2))
|
|
327
|
+
return !1;
|
|
328
|
+
const a = r.after();
|
|
329
|
+
return a === void 0 ? !1 : s.nodeAt(a) ? t.commands.command(({ tr: u }) => (u.setSelection(S.near(s.resolve(a))), !0)) : t.commands.exitCode();
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
},
|
|
333
|
+
addInputRules() {
|
|
334
|
+
return [
|
|
335
|
+
z({
|
|
336
|
+
find: Le,
|
|
337
|
+
type: this.type,
|
|
338
|
+
getAttributes: (t) => ({
|
|
339
|
+
language: t[1]
|
|
340
|
+
})
|
|
341
|
+
}),
|
|
342
|
+
z({
|
|
343
|
+
find: Ie,
|
|
344
|
+
type: this.type,
|
|
345
|
+
getAttributes: (t) => ({
|
|
346
|
+
language: t[1]
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
];
|
|
350
|
+
},
|
|
351
|
+
addProseMirrorPlugins() {
|
|
352
|
+
return [
|
|
353
|
+
// this plugin creates a code block for pasted content from VS Code
|
|
354
|
+
// we can also detect the copied code language
|
|
355
|
+
new P({
|
|
356
|
+
key: new N("codeBlockVSCodeHandler"),
|
|
357
|
+
props: {
|
|
358
|
+
handlePaste: (t, e) => {
|
|
359
|
+
if (!e.clipboardData || this.editor.isActive(this.type.name))
|
|
360
|
+
return !1;
|
|
361
|
+
const n = e.clipboardData.getData("text/plain"), s = e.clipboardData.getData("vscode-editor-data"), r = s ? JSON.parse(s) : void 0, i = r == null ? void 0 : r.mode;
|
|
362
|
+
if (!n || !i)
|
|
363
|
+
return !1;
|
|
364
|
+
const { tr: o, schema: a } = t.state, l = a.text(n.replace(/\r\n?/g, `
|
|
365
|
+
`));
|
|
366
|
+
return o.replaceSelectionWith(this.type.create({ language: i }, l)), o.selection.$from.parent.type !== this.type && o.setSelection(L.near(o.doc.resolve(Math.max(0, o.selection.from - 2)))), o.setMeta("paste", !0), t.dispatch(o), !0;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
})
|
|
370
|
+
];
|
|
371
|
+
}
|
|
372
|
+
}), He = M.create({
|
|
373
|
+
name: "doc",
|
|
374
|
+
topNode: !0,
|
|
375
|
+
content: "block+"
|
|
376
|
+
});
|
|
377
|
+
function Se(t = {}) {
|
|
378
|
+
return new P({
|
|
379
|
+
view(e) {
|
|
380
|
+
return new Ee(e, t);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
class Ee {
|
|
385
|
+
constructor(e, n) {
|
|
386
|
+
var s;
|
|
387
|
+
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (s = n.width) !== null && s !== void 0 ? s : 1, this.color = n.color === !1 ? void 0 : n.color || "black", this.class = n.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((r) => {
|
|
388
|
+
let i = (o) => {
|
|
389
|
+
this[r](o);
|
|
390
|
+
};
|
|
391
|
+
return e.dom.addEventListener(r, i), { name: r, handler: i };
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
destroy() {
|
|
395
|
+
this.handlers.forEach(({ name: e, handler: n }) => this.editorView.dom.removeEventListener(e, n));
|
|
396
|
+
}
|
|
397
|
+
update(e, n) {
|
|
398
|
+
this.cursorPos != null && n.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
|
|
399
|
+
}
|
|
400
|
+
setCursor(e) {
|
|
401
|
+
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
402
|
+
}
|
|
403
|
+
updateOverlay() {
|
|
404
|
+
let e = this.editorView.state.doc.resolve(this.cursorPos), n = !e.parent.inlineContent, s, r = this.editorView.dom, i = r.getBoundingClientRect(), o = i.width / r.offsetWidth, a = i.height / r.offsetHeight;
|
|
405
|
+
if (n) {
|
|
406
|
+
let d = e.nodeBefore, p = e.nodeAfter;
|
|
407
|
+
if (d || p) {
|
|
408
|
+
let h = this.editorView.nodeDOM(this.cursorPos - (d ? d.nodeSize : 0));
|
|
409
|
+
if (h) {
|
|
410
|
+
let y = h.getBoundingClientRect(), k = d ? y.bottom : y.top;
|
|
411
|
+
d && p && (k = (k + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
412
|
+
let A = this.width / 2 * a;
|
|
413
|
+
s = { left: y.left, right: y.right, top: k - A, bottom: k + A };
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (!s) {
|
|
418
|
+
let d = this.editorView.coordsAtPos(this.cursorPos), p = this.width / 2 * o;
|
|
419
|
+
s = { left: d.left - p, right: d.left + p, top: d.top, bottom: d.bottom };
|
|
420
|
+
}
|
|
421
|
+
let l = this.editorView.dom.offsetParent;
|
|
422
|
+
this.element || (this.element = l.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", n), this.element.classList.toggle("prosemirror-dropcursor-inline", !n);
|
|
423
|
+
let u, c;
|
|
424
|
+
if (!l || l == document.body && getComputedStyle(l).position == "static")
|
|
425
|
+
u = -pageXOffset, c = -pageYOffset;
|
|
426
|
+
else {
|
|
427
|
+
let d = l.getBoundingClientRect(), p = d.width / l.offsetWidth, h = d.height / l.offsetHeight;
|
|
428
|
+
u = d.left - l.scrollLeft * p, c = d.top - l.scrollTop * h;
|
|
429
|
+
}
|
|
430
|
+
this.element.style.left = (s.left - u) / o + "px", this.element.style.top = (s.top - c) / a + "px", this.element.style.width = (s.right - s.left) / o + "px", this.element.style.height = (s.bottom - s.top) / a + "px";
|
|
431
|
+
}
|
|
432
|
+
scheduleRemoval(e) {
|
|
433
|
+
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
|
|
434
|
+
}
|
|
435
|
+
dragover(e) {
|
|
436
|
+
if (!this.editorView.editable)
|
|
437
|
+
return;
|
|
438
|
+
let n = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), s = n && n.inside >= 0 && this.editorView.state.doc.nodeAt(n.inside), r = s && s.type.spec.disableDropCursor, i = typeof r == "function" ? r(this.editorView, n, e) : r;
|
|
439
|
+
if (n && !i) {
|
|
440
|
+
let o = n.pos;
|
|
441
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
442
|
+
let a = oe(this.editorView.state.doc, o, this.editorView.dragging.slice);
|
|
443
|
+
a != null && (o = a);
|
|
444
|
+
}
|
|
445
|
+
this.setCursor(o), this.scheduleRemoval(5e3);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
dragend() {
|
|
449
|
+
this.scheduleRemoval(20);
|
|
450
|
+
}
|
|
451
|
+
drop() {
|
|
452
|
+
this.scheduleRemoval(20);
|
|
453
|
+
}
|
|
454
|
+
dragleave(e) {
|
|
455
|
+
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
const Pe = E.create({
|
|
459
|
+
name: "dropCursor",
|
|
460
|
+
addOptions() {
|
|
461
|
+
return {
|
|
462
|
+
color: "currentColor",
|
|
463
|
+
width: 1,
|
|
464
|
+
class: void 0
|
|
465
|
+
};
|
|
466
|
+
},
|
|
467
|
+
addProseMirrorPlugins() {
|
|
468
|
+
return [
|
|
469
|
+
Se(this.options)
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
class f extends S {
|
|
474
|
+
/**
|
|
475
|
+
Create a gap cursor.
|
|
476
|
+
*/
|
|
477
|
+
constructor(e) {
|
|
478
|
+
super(e, e);
|
|
479
|
+
}
|
|
480
|
+
map(e, n) {
|
|
481
|
+
let s = e.resolve(n.map(this.head));
|
|
482
|
+
return f.valid(s) ? new f(s) : S.near(s);
|
|
483
|
+
}
|
|
484
|
+
content() {
|
|
485
|
+
return Q.empty;
|
|
486
|
+
}
|
|
487
|
+
eq(e) {
|
|
488
|
+
return e instanceof f && e.head == this.head;
|
|
489
|
+
}
|
|
490
|
+
toJSON() {
|
|
491
|
+
return { type: "gapcursor", pos: this.head };
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
@internal
|
|
495
|
+
*/
|
|
496
|
+
static fromJSON(e, n) {
|
|
497
|
+
if (typeof n.pos != "number")
|
|
498
|
+
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
499
|
+
return new f(e.resolve(n.pos));
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
@internal
|
|
503
|
+
*/
|
|
504
|
+
getBookmark() {
|
|
505
|
+
return new W(this.anchor);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
@internal
|
|
509
|
+
*/
|
|
510
|
+
static valid(e) {
|
|
511
|
+
let n = e.parent;
|
|
512
|
+
if (n.isTextblock || !Oe(e) || !Re(e))
|
|
513
|
+
return !1;
|
|
514
|
+
let s = n.type.spec.allowGapCursor;
|
|
515
|
+
if (s != null)
|
|
516
|
+
return s;
|
|
517
|
+
let r = n.contentMatchAt(e.index()).defaultType;
|
|
518
|
+
return r && r.isTextblock;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
@internal
|
|
522
|
+
*/
|
|
523
|
+
static findGapCursorFrom(e, n, s = !1) {
|
|
524
|
+
e: for (; ; ) {
|
|
525
|
+
if (!s && f.valid(e))
|
|
526
|
+
return e;
|
|
527
|
+
let r = e.pos, i = null;
|
|
528
|
+
for (let o = e.depth; ; o--) {
|
|
529
|
+
let a = e.node(o);
|
|
530
|
+
if (n > 0 ? e.indexAfter(o) < a.childCount : e.index(o) > 0) {
|
|
531
|
+
i = a.child(n > 0 ? e.indexAfter(o) : e.index(o) - 1);
|
|
532
|
+
break;
|
|
533
|
+
} else if (o == 0)
|
|
534
|
+
return null;
|
|
535
|
+
r += n;
|
|
536
|
+
let l = e.doc.resolve(r);
|
|
537
|
+
if (f.valid(l))
|
|
538
|
+
return l;
|
|
539
|
+
}
|
|
540
|
+
for (; ; ) {
|
|
541
|
+
let o = n > 0 ? i.firstChild : i.lastChild;
|
|
542
|
+
if (!o) {
|
|
543
|
+
if (i.isAtom && !i.isText && !K.isSelectable(i)) {
|
|
544
|
+
e = e.doc.resolve(r + i.nodeSize * n), s = !1;
|
|
545
|
+
continue e;
|
|
546
|
+
}
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
i = o, r += n;
|
|
550
|
+
let a = e.doc.resolve(r);
|
|
551
|
+
if (f.valid(a))
|
|
552
|
+
return a;
|
|
553
|
+
}
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
f.prototype.visible = !1;
|
|
559
|
+
f.findFrom = f.findGapCursorFrom;
|
|
560
|
+
S.jsonID("gapcursor", f);
|
|
561
|
+
class W {
|
|
562
|
+
constructor(e) {
|
|
563
|
+
this.pos = e;
|
|
564
|
+
}
|
|
565
|
+
map(e) {
|
|
566
|
+
return new W(e.map(this.pos));
|
|
567
|
+
}
|
|
568
|
+
resolve(e) {
|
|
569
|
+
let n = e.resolve(this.pos);
|
|
570
|
+
return f.valid(n) ? new f(n) : S.near(n);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function ee(t) {
|
|
574
|
+
return t.isAtom || t.spec.isolating || t.spec.createGapCursor;
|
|
575
|
+
}
|
|
576
|
+
function Oe(t) {
|
|
577
|
+
for (let e = t.depth; e >= 0; e--) {
|
|
578
|
+
let n = t.index(e), s = t.node(e);
|
|
579
|
+
if (n == 0) {
|
|
580
|
+
if (s.type.spec.isolating)
|
|
581
|
+
return !0;
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
for (let r = s.child(n - 1); ; r = r.lastChild) {
|
|
585
|
+
if (r.childCount == 0 && !r.inlineContent || ee(r.type))
|
|
586
|
+
return !0;
|
|
587
|
+
if (r.inlineContent)
|
|
588
|
+
return !1;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return !0;
|
|
592
|
+
}
|
|
593
|
+
function Re(t) {
|
|
594
|
+
for (let e = t.depth; e >= 0; e--) {
|
|
595
|
+
let n = t.indexAfter(e), s = t.node(e);
|
|
596
|
+
if (n == s.childCount) {
|
|
597
|
+
if (s.type.spec.isolating)
|
|
598
|
+
return !0;
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
for (let r = s.child(n); ; r = r.firstChild) {
|
|
602
|
+
if (r.childCount == 0 && !r.inlineContent || ee(r.type))
|
|
603
|
+
return !0;
|
|
604
|
+
if (r.inlineContent)
|
|
605
|
+
return !1;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return !0;
|
|
609
|
+
}
|
|
610
|
+
function _e() {
|
|
611
|
+
return new P({
|
|
612
|
+
props: {
|
|
613
|
+
decorations: $e,
|
|
614
|
+
createSelectionBetween(t, e, n) {
|
|
615
|
+
return e.pos == n.pos && f.valid(n) ? new f(n) : null;
|
|
616
|
+
},
|
|
617
|
+
handleClick: Be,
|
|
618
|
+
handleKeyDown: Ne,
|
|
619
|
+
handleDOMEvents: { beforeinput: De }
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
const Ne = ae({
|
|
624
|
+
ArrowLeft: O("horiz", -1),
|
|
625
|
+
ArrowRight: O("horiz", 1),
|
|
626
|
+
ArrowUp: O("vert", -1),
|
|
627
|
+
ArrowDown: O("vert", 1)
|
|
628
|
+
});
|
|
629
|
+
function O(t, e) {
|
|
630
|
+
const n = t == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
|
|
631
|
+
return function(s, r, i) {
|
|
632
|
+
let o = s.selection, a = e > 0 ? o.$to : o.$from, l = o.empty;
|
|
633
|
+
if (o instanceof L) {
|
|
634
|
+
if (!i.endOfTextblock(n) || a.depth == 0)
|
|
635
|
+
return !1;
|
|
636
|
+
l = !1, a = s.doc.resolve(e > 0 ? a.after() : a.before());
|
|
637
|
+
}
|
|
638
|
+
let u = f.findGapCursorFrom(a, e, l);
|
|
639
|
+
return u ? (r && r(s.tr.setSelection(new f(u))), !0) : !1;
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function Be(t, e, n) {
|
|
643
|
+
if (!t || !t.editable)
|
|
644
|
+
return !1;
|
|
645
|
+
let s = t.state.doc.resolve(e);
|
|
646
|
+
if (!f.valid(s))
|
|
647
|
+
return !1;
|
|
648
|
+
let r = t.posAtCoords({ left: n.clientX, top: n.clientY });
|
|
649
|
+
return r && r.inside > -1 && K.isSelectable(t.state.doc.nodeAt(r.inside)) ? !1 : (t.dispatch(t.state.tr.setSelection(new f(s))), !0);
|
|
650
|
+
}
|
|
651
|
+
function De(t, e) {
|
|
652
|
+
if (e.inputType != "insertCompositionText" || !(t.state.selection instanceof f))
|
|
653
|
+
return !1;
|
|
654
|
+
let { $from: n } = t.state.selection, s = n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);
|
|
655
|
+
if (!s)
|
|
656
|
+
return !1;
|
|
657
|
+
let r = F.empty;
|
|
658
|
+
for (let o = s.length - 1; o >= 0; o--)
|
|
659
|
+
r = F.from(s[o].createAndFill(null, r));
|
|
660
|
+
let i = t.state.tr.replace(n.pos, n.pos, new Q(r, 0, 0));
|
|
661
|
+
return i.setSelection(L.near(i.doc.resolve(n.pos + 1))), t.dispatch(i), !1;
|
|
662
|
+
}
|
|
663
|
+
function $e(t) {
|
|
664
|
+
if (!(t.selection instanceof f))
|
|
665
|
+
return null;
|
|
666
|
+
let e = document.createElement("div");
|
|
667
|
+
return e.className = "ProseMirror-gapcursor", Z.create(t.doc, [U.widget(t.selection.head, e, { key: "gapcursor" })]);
|
|
668
|
+
}
|
|
669
|
+
const Ve = E.create({
|
|
670
|
+
name: "gapCursor",
|
|
671
|
+
addProseMirrorPlugins() {
|
|
672
|
+
return [
|
|
673
|
+
_e()
|
|
674
|
+
];
|
|
675
|
+
},
|
|
676
|
+
extendNodeSchema(t) {
|
|
677
|
+
var e;
|
|
678
|
+
const n = {
|
|
679
|
+
name: t.name,
|
|
680
|
+
options: t.options,
|
|
681
|
+
storage: t.storage
|
|
682
|
+
};
|
|
683
|
+
return {
|
|
684
|
+
allowGapCursor: (e = le(de(t, "allowGapCursor", n))) !== null && e !== void 0 ? e : null
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
}), ze = M.create({
|
|
688
|
+
name: "hardBreak",
|
|
689
|
+
addOptions() {
|
|
690
|
+
return {
|
|
691
|
+
keepMarks: !0,
|
|
692
|
+
HTMLAttributes: {}
|
|
693
|
+
};
|
|
694
|
+
},
|
|
695
|
+
inline: !0,
|
|
696
|
+
group: "inline",
|
|
697
|
+
selectable: !1,
|
|
698
|
+
linebreakReplacement: !0,
|
|
699
|
+
parseHTML() {
|
|
700
|
+
return [
|
|
701
|
+
{ tag: "br" }
|
|
702
|
+
];
|
|
703
|
+
},
|
|
704
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
705
|
+
return ["br", v(this.options.HTMLAttributes, t)];
|
|
706
|
+
},
|
|
707
|
+
renderText() {
|
|
708
|
+
return `
|
|
709
|
+
`;
|
|
710
|
+
},
|
|
711
|
+
addCommands() {
|
|
712
|
+
return {
|
|
713
|
+
setHardBreak: () => ({ commands: t, chain: e, state: n, editor: s }) => t.first([
|
|
714
|
+
() => t.exitCode(),
|
|
715
|
+
() => t.command(() => {
|
|
716
|
+
const { selection: r, storedMarks: i } = n;
|
|
717
|
+
if (r.$from.parent.type.spec.isolating)
|
|
718
|
+
return !1;
|
|
719
|
+
const { keepMarks: o } = this.options, { splittableMarks: a } = s.extensionManager, l = i || r.$to.parentOffset && r.$from.marks();
|
|
720
|
+
return e().insertContent({ type: this.name }).command(({ tr: u, dispatch: c }) => {
|
|
721
|
+
if (c && l && o) {
|
|
722
|
+
const d = l.filter((p) => a.includes(p.type.name));
|
|
723
|
+
u.ensureMarks(d);
|
|
724
|
+
}
|
|
725
|
+
return !0;
|
|
726
|
+
}).run();
|
|
727
|
+
})
|
|
728
|
+
])
|
|
729
|
+
};
|
|
730
|
+
},
|
|
731
|
+
addKeyboardShortcuts() {
|
|
732
|
+
return {
|
|
733
|
+
"Mod-Enter": () => this.editor.commands.setHardBreak(),
|
|
734
|
+
"Shift-Enter": () => this.editor.commands.setHardBreak()
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
}), Ke = M.create({
|
|
738
|
+
name: "heading",
|
|
739
|
+
addOptions() {
|
|
740
|
+
return {
|
|
741
|
+
levels: [1, 2, 3, 4, 5, 6],
|
|
742
|
+
HTMLAttributes: {}
|
|
743
|
+
};
|
|
744
|
+
},
|
|
745
|
+
content: "inline*",
|
|
746
|
+
group: "block",
|
|
747
|
+
defining: !0,
|
|
748
|
+
addAttributes() {
|
|
749
|
+
return {
|
|
750
|
+
level: {
|
|
751
|
+
default: 1,
|
|
752
|
+
rendered: !1
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
},
|
|
756
|
+
parseHTML() {
|
|
757
|
+
return this.options.levels.map((t) => ({
|
|
758
|
+
tag: `h${t}`,
|
|
759
|
+
attrs: { level: t }
|
|
760
|
+
}));
|
|
761
|
+
},
|
|
762
|
+
renderHTML({ node: t, HTMLAttributes: e }) {
|
|
763
|
+
return [`h${this.options.levels.includes(t.attrs.level) ? t.attrs.level : this.options.levels[0]}`, v(this.options.HTMLAttributes, e), 0];
|
|
764
|
+
},
|
|
765
|
+
addCommands() {
|
|
766
|
+
return {
|
|
767
|
+
setHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.setNode(this.name, t) : !1,
|
|
768
|
+
toggleHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.toggleNode(this.name, "paragraph", t) : !1
|
|
769
|
+
};
|
|
770
|
+
},
|
|
771
|
+
addKeyboardShortcuts() {
|
|
772
|
+
return this.options.levels.reduce((t, e) => ({
|
|
773
|
+
...t,
|
|
774
|
+
[`Mod-Alt-${e}`]: () => this.editor.commands.toggleHeading({ level: e })
|
|
775
|
+
}), {});
|
|
776
|
+
},
|
|
777
|
+
addInputRules() {
|
|
778
|
+
return this.options.levels.map((t) => z({
|
|
779
|
+
find: new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),
|
|
780
|
+
type: this.type,
|
|
781
|
+
getAttributes: {
|
|
782
|
+
level: t
|
|
783
|
+
}
|
|
784
|
+
}));
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
var _ = 200, g = function() {
|
|
788
|
+
};
|
|
789
|
+
g.prototype.append = function(e) {
|
|
790
|
+
return e.length ? (e = g.from(e), !this.length && e || e.length < _ && this.leafAppend(e) || this.length < _ && e.leafPrepend(this) || this.appendInner(e)) : this;
|
|
791
|
+
};
|
|
792
|
+
g.prototype.prepend = function(e) {
|
|
793
|
+
return e.length ? g.from(e).append(this) : this;
|
|
794
|
+
};
|
|
795
|
+
g.prototype.appendInner = function(e) {
|
|
796
|
+
return new We(this, e);
|
|
797
|
+
};
|
|
798
|
+
g.prototype.slice = function(e, n) {
|
|
799
|
+
return e === void 0 && (e = 0), n === void 0 && (n = this.length), e >= n ? g.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, n));
|
|
800
|
+
};
|
|
801
|
+
g.prototype.get = function(e) {
|
|
802
|
+
if (!(e < 0 || e >= this.length))
|
|
803
|
+
return this.getInner(e);
|
|
804
|
+
};
|
|
805
|
+
g.prototype.forEach = function(e, n, s) {
|
|
806
|
+
n === void 0 && (n = 0), s === void 0 && (s = this.length), n <= s ? this.forEachInner(e, n, s, 0) : this.forEachInvertedInner(e, n, s, 0);
|
|
807
|
+
};
|
|
808
|
+
g.prototype.map = function(e, n, s) {
|
|
809
|
+
n === void 0 && (n = 0), s === void 0 && (s = this.length);
|
|
810
|
+
var r = [];
|
|
811
|
+
return this.forEach(function(i, o) {
|
|
812
|
+
return r.push(e(i, o));
|
|
813
|
+
}, n, s), r;
|
|
814
|
+
};
|
|
815
|
+
g.from = function(e) {
|
|
816
|
+
return e instanceof g ? e : e && e.length ? new te(e) : g.empty;
|
|
817
|
+
};
|
|
818
|
+
var te = /* @__PURE__ */ function(t) {
|
|
819
|
+
function e(s) {
|
|
820
|
+
t.call(this), this.values = s;
|
|
821
|
+
}
|
|
822
|
+
t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e;
|
|
823
|
+
var n = { length: { configurable: !0 }, depth: { configurable: !0 } };
|
|
824
|
+
return e.prototype.flatten = function() {
|
|
825
|
+
return this.values;
|
|
826
|
+
}, e.prototype.sliceInner = function(r, i) {
|
|
827
|
+
return r == 0 && i == this.length ? this : new e(this.values.slice(r, i));
|
|
828
|
+
}, e.prototype.getInner = function(r) {
|
|
829
|
+
return this.values[r];
|
|
830
|
+
}, e.prototype.forEachInner = function(r, i, o, a) {
|
|
831
|
+
for (var l = i; l < o; l++)
|
|
832
|
+
if (r(this.values[l], a + l) === !1)
|
|
833
|
+
return !1;
|
|
834
|
+
}, e.prototype.forEachInvertedInner = function(r, i, o, a) {
|
|
835
|
+
for (var l = i - 1; l >= o; l--)
|
|
836
|
+
if (r(this.values[l], a + l) === !1)
|
|
837
|
+
return !1;
|
|
838
|
+
}, e.prototype.leafAppend = function(r) {
|
|
839
|
+
if (this.length + r.length <= _)
|
|
840
|
+
return new e(this.values.concat(r.flatten()));
|
|
841
|
+
}, e.prototype.leafPrepend = function(r) {
|
|
842
|
+
if (this.length + r.length <= _)
|
|
843
|
+
return new e(r.flatten().concat(this.values));
|
|
844
|
+
}, n.length.get = function() {
|
|
845
|
+
return this.values.length;
|
|
846
|
+
}, n.depth.get = function() {
|
|
847
|
+
return 0;
|
|
848
|
+
}, Object.defineProperties(e.prototype, n), e;
|
|
849
|
+
}(g);
|
|
850
|
+
g.empty = new te([]);
|
|
851
|
+
var We = /* @__PURE__ */ function(t) {
|
|
852
|
+
function e(n, s) {
|
|
853
|
+
t.call(this), this.left = n, this.right = s, this.length = n.length + s.length, this.depth = Math.max(n.depth, s.depth) + 1;
|
|
854
|
+
}
|
|
855
|
+
return t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
|
|
856
|
+
return this.left.flatten().concat(this.right.flatten());
|
|
857
|
+
}, e.prototype.getInner = function(s) {
|
|
858
|
+
return s < this.left.length ? this.left.get(s) : this.right.get(s - this.left.length);
|
|
859
|
+
}, e.prototype.forEachInner = function(s, r, i, o) {
|
|
860
|
+
var a = this.left.length;
|
|
861
|
+
if (r < a && this.left.forEachInner(s, r, Math.min(i, a), o) === !1 || i > a && this.right.forEachInner(s, Math.max(r - a, 0), Math.min(this.length, i) - a, o + a) === !1)
|
|
862
|
+
return !1;
|
|
863
|
+
}, e.prototype.forEachInvertedInner = function(s, r, i, o) {
|
|
864
|
+
var a = this.left.length;
|
|
865
|
+
if (r > a && this.right.forEachInvertedInner(s, r - a, Math.max(i, a) - a, o + a) === !1 || i < a && this.left.forEachInvertedInner(s, Math.min(r, a), i, o) === !1)
|
|
866
|
+
return !1;
|
|
867
|
+
}, e.prototype.sliceInner = function(s, r) {
|
|
868
|
+
if (s == 0 && r == this.length)
|
|
869
|
+
return this;
|
|
870
|
+
var i = this.left.length;
|
|
871
|
+
return r <= i ? this.left.slice(s, r) : s >= i ? this.right.slice(s - i, r - i) : this.left.slice(s, i).append(this.right.slice(0, r - i));
|
|
872
|
+
}, e.prototype.leafAppend = function(s) {
|
|
873
|
+
var r = this.right.leafAppend(s);
|
|
874
|
+
if (r)
|
|
875
|
+
return new e(this.left, r);
|
|
876
|
+
}, e.prototype.leafPrepend = function(s) {
|
|
877
|
+
var r = this.left.leafPrepend(s);
|
|
878
|
+
if (r)
|
|
879
|
+
return new e(r, this.right);
|
|
880
|
+
}, e.prototype.appendInner = function(s) {
|
|
881
|
+
return this.left.depth >= Math.max(this.right.depth, s.depth) + 1 ? new e(this.left, new e(this.right, s)) : new e(this, s);
|
|
882
|
+
}, e;
|
|
883
|
+
}(g);
|
|
884
|
+
const Fe = 500;
|
|
885
|
+
class b {
|
|
886
|
+
constructor(e, n) {
|
|
887
|
+
this.items = e, this.eventCount = n;
|
|
888
|
+
}
|
|
889
|
+
// Pop the latest event off the branch's history and apply it
|
|
890
|
+
// to a document transform.
|
|
891
|
+
popEvent(e, n) {
|
|
892
|
+
if (this.eventCount == 0)
|
|
893
|
+
return null;
|
|
894
|
+
let s = this.items.length;
|
|
895
|
+
for (; ; s--)
|
|
896
|
+
if (this.items.get(s - 1).selection) {
|
|
897
|
+
--s;
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
let r, i;
|
|
901
|
+
n && (r = this.remapping(s, this.items.length), i = r.maps.length);
|
|
902
|
+
let o = e.tr, a, l, u = [], c = [];
|
|
903
|
+
return this.items.forEach((d, p) => {
|
|
904
|
+
if (!d.step) {
|
|
905
|
+
r || (r = this.remapping(s, p + 1), i = r.maps.length), i--, c.push(d);
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
if (r) {
|
|
909
|
+
c.push(new w(d.map));
|
|
910
|
+
let h = d.step.map(r.slice(i)), y;
|
|
911
|
+
h && o.maybeStep(h).doc && (y = o.mapping.maps[o.mapping.maps.length - 1], u.push(new w(y, void 0, void 0, u.length + c.length))), i--, y && r.appendMap(y, i);
|
|
912
|
+
} else
|
|
913
|
+
o.maybeStep(d.step);
|
|
914
|
+
if (d.selection)
|
|
915
|
+
return a = r ? d.selection.map(r.slice(i)) : d.selection, l = new b(this.items.slice(0, s).append(c.reverse().concat(u)), this.eventCount - 1), !1;
|
|
916
|
+
}, this.items.length, 0), { remaining: l, transform: o, selection: a };
|
|
917
|
+
}
|
|
918
|
+
// Create a new branch with the given transform added.
|
|
919
|
+
addTransform(e, n, s, r) {
|
|
920
|
+
let i = [], o = this.eventCount, a = this.items, l = !r && a.length ? a.get(a.length - 1) : null;
|
|
921
|
+
for (let c = 0; c < e.steps.length; c++) {
|
|
922
|
+
let d = e.steps[c].invert(e.docs[c]), p = new w(e.mapping.maps[c], d, n), h;
|
|
923
|
+
(h = l && l.merge(p)) && (p = h, c ? i.pop() : a = a.slice(0, a.length - 1)), i.push(p), n && (o++, n = void 0), r || (l = p);
|
|
924
|
+
}
|
|
925
|
+
let u = o - s.depth;
|
|
926
|
+
return u > je && (a = Ge(a, u), o -= u), new b(a.append(i), o);
|
|
927
|
+
}
|
|
928
|
+
remapping(e, n) {
|
|
929
|
+
let s = new ue();
|
|
930
|
+
return this.items.forEach((r, i) => {
|
|
931
|
+
let o = r.mirrorOffset != null && i - r.mirrorOffset >= e ? s.maps.length - r.mirrorOffset : void 0;
|
|
932
|
+
s.appendMap(r.map, o);
|
|
933
|
+
}, e, n), s;
|
|
934
|
+
}
|
|
935
|
+
addMaps(e) {
|
|
936
|
+
return this.eventCount == 0 ? this : new b(this.items.append(e.map((n) => new w(n))), this.eventCount);
|
|
937
|
+
}
|
|
938
|
+
// When the collab module receives remote changes, the history has
|
|
939
|
+
// to know about those, so that it can adjust the steps that were
|
|
940
|
+
// rebased on top of the remote changes, and include the position
|
|
941
|
+
// maps for the remote changes in its array of items.
|
|
942
|
+
rebased(e, n) {
|
|
943
|
+
if (!this.eventCount)
|
|
944
|
+
return this;
|
|
945
|
+
let s = [], r = Math.max(0, this.items.length - n), i = e.mapping, o = e.steps.length, a = this.eventCount;
|
|
946
|
+
this.items.forEach((p) => {
|
|
947
|
+
p.selection && a--;
|
|
948
|
+
}, r);
|
|
949
|
+
let l = n;
|
|
950
|
+
this.items.forEach((p) => {
|
|
951
|
+
let h = i.getMirror(--l);
|
|
952
|
+
if (h == null)
|
|
953
|
+
return;
|
|
954
|
+
o = Math.min(o, h);
|
|
955
|
+
let y = i.maps[h];
|
|
956
|
+
if (p.step) {
|
|
957
|
+
let k = e.steps[h].invert(e.docs[h]), A = p.selection && p.selection.map(i.slice(l + 1, h));
|
|
958
|
+
A && a++, s.push(new w(y, k, A));
|
|
959
|
+
} else
|
|
960
|
+
s.push(new w(y));
|
|
961
|
+
}, r);
|
|
962
|
+
let u = [];
|
|
963
|
+
for (let p = n; p < o; p++)
|
|
964
|
+
u.push(new w(i.maps[p]));
|
|
965
|
+
let c = this.items.slice(0, r).append(u).append(s), d = new b(c, a);
|
|
966
|
+
return d.emptyItemCount() > Fe && (d = d.compress(this.items.length - s.length)), d;
|
|
967
|
+
}
|
|
968
|
+
emptyItemCount() {
|
|
969
|
+
let e = 0;
|
|
970
|
+
return this.items.forEach((n) => {
|
|
971
|
+
n.step || e++;
|
|
972
|
+
}), e;
|
|
973
|
+
}
|
|
974
|
+
// Compressing a branch means rewriting it to push the air (map-only
|
|
975
|
+
// items) out. During collaboration, these naturally accumulate
|
|
976
|
+
// because each remote change adds one. The `upto` argument is used
|
|
977
|
+
// to ensure that only the items below a given level are compressed,
|
|
978
|
+
// because `rebased` relies on a clean, untouched set of items in
|
|
979
|
+
// order to associate old items with rebased steps.
|
|
980
|
+
compress(e = this.items.length) {
|
|
981
|
+
let n = this.remapping(0, e), s = n.maps.length, r = [], i = 0;
|
|
982
|
+
return this.items.forEach((o, a) => {
|
|
983
|
+
if (a >= e)
|
|
984
|
+
r.push(o), o.selection && i++;
|
|
985
|
+
else if (o.step) {
|
|
986
|
+
let l = o.step.map(n.slice(s)), u = l && l.getMap();
|
|
987
|
+
if (s--, u && n.appendMap(u, s), l) {
|
|
988
|
+
let c = o.selection && o.selection.map(n.slice(s));
|
|
989
|
+
c && i++;
|
|
990
|
+
let d = new w(u.invert(), l, c), p, h = r.length - 1;
|
|
991
|
+
(p = r.length && r[h].merge(d)) ? r[h] = p : r.push(d);
|
|
992
|
+
}
|
|
993
|
+
} else o.map && s--;
|
|
994
|
+
}, this.items.length, 0), new b(g.from(r.reverse()), i);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
b.empty = new b(g.empty, 0);
|
|
998
|
+
function Ge(t, e) {
|
|
999
|
+
let n;
|
|
1000
|
+
return t.forEach((s, r) => {
|
|
1001
|
+
if (s.selection && e-- == 0)
|
|
1002
|
+
return n = r, !1;
|
|
1003
|
+
}), t.slice(n);
|
|
1004
|
+
}
|
|
1005
|
+
class w {
|
|
1006
|
+
constructor(e, n, s, r) {
|
|
1007
|
+
this.map = e, this.step = n, this.selection = s, this.mirrorOffset = r;
|
|
1008
|
+
}
|
|
1009
|
+
merge(e) {
|
|
1010
|
+
if (this.step && e.step && !e.selection) {
|
|
1011
|
+
let n = e.step.merge(this.step);
|
|
1012
|
+
if (n)
|
|
1013
|
+
return new w(n.getMap().invert(), n, this.selection);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
class T {
|
|
1018
|
+
constructor(e, n, s, r, i) {
|
|
1019
|
+
this.done = e, this.undone = n, this.prevRanges = s, this.prevTime = r, this.prevComposition = i;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
const je = 20;
|
|
1023
|
+
function qe(t, e, n, s) {
|
|
1024
|
+
let r = n.getMeta(C), i;
|
|
1025
|
+
if (r)
|
|
1026
|
+
return r.historyState;
|
|
1027
|
+
n.getMeta(Je) && (t = new T(t.done, t.undone, null, 0, -1));
|
|
1028
|
+
let o = n.getMeta("appendedTransaction");
|
|
1029
|
+
if (n.steps.length == 0)
|
|
1030
|
+
return t;
|
|
1031
|
+
if (o && o.getMeta(C))
|
|
1032
|
+
return o.getMeta(C).redo ? new T(t.done.addTransform(n, void 0, s, R(e)), t.undone, q(n.mapping.maps), t.prevTime, t.prevComposition) : new T(t.done, t.undone.addTransform(n, void 0, s, R(e)), null, t.prevTime, t.prevComposition);
|
|
1033
|
+
if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
|
|
1034
|
+
let a = n.getMeta("composition"), l = t.prevTime == 0 || !o && t.prevComposition != a && (t.prevTime < (n.time || 0) - s.newGroupDelay || !Xe(n, t.prevRanges)), u = o ? $(t.prevRanges, n.mapping) : q(n.mapping.maps);
|
|
1035
|
+
return new T(t.done.addTransform(n, l ? e.selection.getBookmark() : void 0, s, R(e)), b.empty, u, n.time, a ?? t.prevComposition);
|
|
1036
|
+
} else return (i = n.getMeta("rebased")) ? new T(t.done.rebased(n, i), t.undone.rebased(n, i), $(t.prevRanges, n.mapping), t.prevTime, t.prevComposition) : new T(t.done.addMaps(n.mapping.maps), t.undone.addMaps(n.mapping.maps), $(t.prevRanges, n.mapping), t.prevTime, t.prevComposition);
|
|
1037
|
+
}
|
|
1038
|
+
function Xe(t, e) {
|
|
1039
|
+
if (!e)
|
|
1040
|
+
return !1;
|
|
1041
|
+
if (!t.docChanged)
|
|
1042
|
+
return !0;
|
|
1043
|
+
let n = !1;
|
|
1044
|
+
return t.mapping.maps[0].forEach((s, r) => {
|
|
1045
|
+
for (let i = 0; i < e.length; i += 2)
|
|
1046
|
+
s <= e[i + 1] && r >= e[i] && (n = !0);
|
|
1047
|
+
}), n;
|
|
1048
|
+
}
|
|
1049
|
+
function q(t) {
|
|
1050
|
+
let e = [];
|
|
1051
|
+
for (let n = t.length - 1; n >= 0 && e.length == 0; n--)
|
|
1052
|
+
t[n].forEach((s, r, i, o) => e.push(i, o));
|
|
1053
|
+
return e;
|
|
1054
|
+
}
|
|
1055
|
+
function $(t, e) {
|
|
1056
|
+
if (!t)
|
|
1057
|
+
return null;
|
|
1058
|
+
let n = [];
|
|
1059
|
+
for (let s = 0; s < t.length; s += 2) {
|
|
1060
|
+
let r = e.map(t[s], 1), i = e.map(t[s + 1], -1);
|
|
1061
|
+
r <= i && n.push(r, i);
|
|
1062
|
+
}
|
|
1063
|
+
return n;
|
|
1064
|
+
}
|
|
1065
|
+
function Ye(t, e, n) {
|
|
1066
|
+
let s = R(e), r = C.get(e).spec.config, i = (n ? t.undone : t.done).popEvent(e, s);
|
|
1067
|
+
if (!i)
|
|
1068
|
+
return null;
|
|
1069
|
+
let o = i.selection.resolve(i.transform.doc), a = (n ? t.done : t.undone).addTransform(i.transform, e.selection.getBookmark(), r, s), l = new T(n ? a : i.remaining, n ? i.remaining : a, null, 0, -1);
|
|
1070
|
+
return i.transform.setSelection(o).setMeta(C, { redo: n, historyState: l });
|
|
1071
|
+
}
|
|
1072
|
+
let V = !1, X = null;
|
|
1073
|
+
function R(t) {
|
|
1074
|
+
let e = t.plugins;
|
|
1075
|
+
if (X != e) {
|
|
1076
|
+
V = !1, X = e;
|
|
1077
|
+
for (let n = 0; n < e.length; n++)
|
|
1078
|
+
if (e[n].spec.historyPreserveItems) {
|
|
1079
|
+
V = !0;
|
|
1080
|
+
break;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
return V;
|
|
1084
|
+
}
|
|
1085
|
+
const C = new N("history"), Je = new N("closeHistory");
|
|
1086
|
+
function Ue(t = {}) {
|
|
1087
|
+
return t = {
|
|
1088
|
+
depth: t.depth || 100,
|
|
1089
|
+
newGroupDelay: t.newGroupDelay || 500
|
|
1090
|
+
}, new P({
|
|
1091
|
+
key: C,
|
|
1092
|
+
state: {
|
|
1093
|
+
init() {
|
|
1094
|
+
return new T(b.empty, b.empty, null, 0, -1);
|
|
1095
|
+
},
|
|
1096
|
+
apply(e, n, s) {
|
|
1097
|
+
return qe(n, s, e, t);
|
|
1098
|
+
}
|
|
1099
|
+
},
|
|
1100
|
+
config: t,
|
|
1101
|
+
props: {
|
|
1102
|
+
handleDOMEvents: {
|
|
1103
|
+
beforeinput(e, n) {
|
|
1104
|
+
let s = n.inputType, r = s == "historyUndo" ? se : s == "historyRedo" ? re : null;
|
|
1105
|
+
return !r || !e.editable ? !1 : (n.preventDefault(), r(e.state, e.dispatch));
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
function ne(t, e) {
|
|
1112
|
+
return (n, s) => {
|
|
1113
|
+
let r = C.getState(n);
|
|
1114
|
+
if (!r || (t ? r.undone : r.done).eventCount == 0)
|
|
1115
|
+
return !1;
|
|
1116
|
+
if (s) {
|
|
1117
|
+
let i = Ye(r, n, t);
|
|
1118
|
+
i && s(e ? i.scrollIntoView() : i);
|
|
1119
|
+
}
|
|
1120
|
+
return !0;
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
const se = ne(!1, !0), re = ne(!0, !0), Ze = E.create({
|
|
1124
|
+
name: "history",
|
|
1125
|
+
addOptions() {
|
|
1126
|
+
return {
|
|
1127
|
+
depth: 100,
|
|
1128
|
+
newGroupDelay: 500
|
|
1129
|
+
};
|
|
1130
|
+
},
|
|
1131
|
+
addCommands() {
|
|
1132
|
+
return {
|
|
1133
|
+
undo: () => ({ state: t, dispatch: e }) => se(t, e),
|
|
1134
|
+
redo: () => ({ state: t, dispatch: e }) => re(t, e)
|
|
1135
|
+
};
|
|
1136
|
+
},
|
|
1137
|
+
addProseMirrorPlugins() {
|
|
1138
|
+
return [
|
|
1139
|
+
Ue(this.options)
|
|
1140
|
+
];
|
|
1141
|
+
},
|
|
1142
|
+
addKeyboardShortcuts() {
|
|
1143
|
+
return {
|
|
1144
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
1145
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
1146
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
1147
|
+
// Russian keyboard layouts
|
|
1148
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
1149
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
}), Qe = M.create({
|
|
1153
|
+
name: "horizontalRule",
|
|
1154
|
+
addOptions() {
|
|
1155
|
+
return {
|
|
1156
|
+
HTMLAttributes: {}
|
|
1157
|
+
};
|
|
1158
|
+
},
|
|
1159
|
+
group: "block",
|
|
1160
|
+
parseHTML() {
|
|
1161
|
+
return [{ tag: "hr" }];
|
|
1162
|
+
},
|
|
1163
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
1164
|
+
return ["hr", v(this.options.HTMLAttributes, t)];
|
|
1165
|
+
},
|
|
1166
|
+
addCommands() {
|
|
1167
|
+
return {
|
|
1168
|
+
setHorizontalRule: () => ({ chain: t, state: e }) => {
|
|
1169
|
+
if (!ce(e, e.schema.nodes[this.name]))
|
|
1170
|
+
return !1;
|
|
1171
|
+
const { selection: n } = e, { $from: s, $to: r } = n, i = t();
|
|
1172
|
+
return s.parentOffset === 0 ? i.insertContentAt({
|
|
1173
|
+
from: Math.max(s.pos - 1, 0),
|
|
1174
|
+
to: r.pos
|
|
1175
|
+
}, {
|
|
1176
|
+
type: this.name
|
|
1177
|
+
}) : he(n) ? i.insertContentAt(r.pos, {
|
|
1178
|
+
type: this.name
|
|
1179
|
+
}) : i.insertContent({ type: this.name }), i.command(({ tr: o, dispatch: a }) => {
|
|
1180
|
+
var l;
|
|
1181
|
+
if (a) {
|
|
1182
|
+
const { $to: u } = o.selection, c = u.end();
|
|
1183
|
+
if (u.nodeAfter)
|
|
1184
|
+
u.nodeAfter.isTextblock ? o.setSelection(L.create(o.doc, u.pos + 1)) : u.nodeAfter.isBlock ? o.setSelection(K.create(o.doc, u.pos)) : o.setSelection(L.create(o.doc, u.pos));
|
|
1185
|
+
else {
|
|
1186
|
+
const d = (l = u.parent.type.contentMatch.defaultType) === null || l === void 0 ? void 0 : l.create();
|
|
1187
|
+
d && (o.insert(c, d), o.setSelection(L.create(o.doc, c + 1)));
|
|
1188
|
+
}
|
|
1189
|
+
o.scrollIntoView();
|
|
1190
|
+
}
|
|
1191
|
+
return !0;
|
|
1192
|
+
}).run();
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
},
|
|
1196
|
+
addInputRules() {
|
|
1197
|
+
return [
|
|
1198
|
+
pe({
|
|
1199
|
+
find: /^(?:---|—-|___\s|\*\*\*\s)$/,
|
|
1200
|
+
type: this.type
|
|
1201
|
+
})
|
|
1202
|
+
];
|
|
1203
|
+
}
|
|
1204
|
+
}), et = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, tt = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, nt = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, st = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, rt = B.create({
|
|
1205
|
+
name: "italic",
|
|
1206
|
+
addOptions() {
|
|
1207
|
+
return {
|
|
1208
|
+
HTMLAttributes: {}
|
|
1209
|
+
};
|
|
1210
|
+
},
|
|
1211
|
+
parseHTML() {
|
|
1212
|
+
return [
|
|
1213
|
+
{
|
|
1214
|
+
tag: "em"
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
tag: "i",
|
|
1218
|
+
getAttrs: (t) => t.style.fontStyle !== "normal" && null
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
style: "font-style=normal",
|
|
1222
|
+
clearMark: (t) => t.type.name === this.name
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
style: "font-style=italic"
|
|
1226
|
+
}
|
|
1227
|
+
];
|
|
1228
|
+
},
|
|
1229
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
1230
|
+
return ["em", v(this.options.HTMLAttributes, t), 0];
|
|
1231
|
+
},
|
|
1232
|
+
addCommands() {
|
|
1233
|
+
return {
|
|
1234
|
+
setItalic: () => ({ commands: t }) => t.setMark(this.name),
|
|
1235
|
+
toggleItalic: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
1236
|
+
unsetItalic: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
1237
|
+
};
|
|
1238
|
+
},
|
|
1239
|
+
addKeyboardShortcuts() {
|
|
1240
|
+
return {
|
|
1241
|
+
"Mod-i": () => this.editor.commands.toggleItalic(),
|
|
1242
|
+
"Mod-I": () => this.editor.commands.toggleItalic()
|
|
1243
|
+
};
|
|
1244
|
+
},
|
|
1245
|
+
addInputRules() {
|
|
1246
|
+
return [
|
|
1247
|
+
x({
|
|
1248
|
+
find: et,
|
|
1249
|
+
type: this.type
|
|
1250
|
+
}),
|
|
1251
|
+
x({
|
|
1252
|
+
find: nt,
|
|
1253
|
+
type: this.type
|
|
1254
|
+
})
|
|
1255
|
+
];
|
|
1256
|
+
},
|
|
1257
|
+
addPasteRules() {
|
|
1258
|
+
return [
|
|
1259
|
+
I({
|
|
1260
|
+
find: tt,
|
|
1261
|
+
type: this.type
|
|
1262
|
+
}),
|
|
1263
|
+
I({
|
|
1264
|
+
find: st,
|
|
1265
|
+
type: this.type
|
|
1266
|
+
})
|
|
1267
|
+
];
|
|
1268
|
+
}
|
|
1269
|
+
}), it = M.create({
|
|
1270
|
+
name: "listItem",
|
|
1271
|
+
addOptions() {
|
|
1272
|
+
return {
|
|
1273
|
+
HTMLAttributes: {},
|
|
1274
|
+
bulletListTypeName: "bulletList",
|
|
1275
|
+
orderedListTypeName: "orderedList"
|
|
1276
|
+
};
|
|
1277
|
+
},
|
|
1278
|
+
content: "paragraph block*",
|
|
1279
|
+
defining: !0,
|
|
1280
|
+
parseHTML() {
|
|
1281
|
+
return [
|
|
1282
|
+
{
|
|
1283
|
+
tag: "li"
|
|
1284
|
+
}
|
|
1285
|
+
];
|
|
1286
|
+
},
|
|
1287
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
1288
|
+
return ["li", v(this.options.HTMLAttributes, t), 0];
|
|
1289
|
+
},
|
|
1290
|
+
addKeyboardShortcuts() {
|
|
1291
|
+
return {
|
|
1292
|
+
Enter: () => this.editor.commands.splitListItem(this.name),
|
|
1293
|
+
Tab: () => this.editor.commands.sinkListItem(this.name),
|
|
1294
|
+
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
}), ot = "listItem", Y = "textStyle", J = /^(\d+)\.\s$/, at = M.create({
|
|
1298
|
+
name: "orderedList",
|
|
1299
|
+
addOptions() {
|
|
1300
|
+
return {
|
|
1301
|
+
itemTypeName: "listItem",
|
|
1302
|
+
HTMLAttributes: {},
|
|
1303
|
+
keepMarks: !1,
|
|
1304
|
+
keepAttributes: !1
|
|
1305
|
+
};
|
|
1306
|
+
},
|
|
1307
|
+
group: "block list",
|
|
1308
|
+
content() {
|
|
1309
|
+
return `${this.options.itemTypeName}+`;
|
|
1310
|
+
},
|
|
1311
|
+
addAttributes() {
|
|
1312
|
+
return {
|
|
1313
|
+
start: {
|
|
1314
|
+
default: 1,
|
|
1315
|
+
parseHTML: (t) => t.hasAttribute("start") ? parseInt(t.getAttribute("start") || "", 10) : 1
|
|
1316
|
+
},
|
|
1317
|
+
type: {
|
|
1318
|
+
default: null,
|
|
1319
|
+
parseHTML: (t) => t.getAttribute("type")
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
},
|
|
1323
|
+
parseHTML() {
|
|
1324
|
+
return [
|
|
1325
|
+
{
|
|
1326
|
+
tag: "ol"
|
|
1327
|
+
}
|
|
1328
|
+
];
|
|
1329
|
+
},
|
|
1330
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
1331
|
+
const { start: e, ...n } = t;
|
|
1332
|
+
return e === 1 ? ["ol", v(this.options.HTMLAttributes, n), 0] : ["ol", v(this.options.HTMLAttributes, t), 0];
|
|
1333
|
+
},
|
|
1334
|
+
addCommands() {
|
|
1335
|
+
return {
|
|
1336
|
+
toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ot, this.editor.getAttributes(Y)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
1337
|
+
};
|
|
1338
|
+
},
|
|
1339
|
+
addKeyboardShortcuts() {
|
|
1340
|
+
return {
|
|
1341
|
+
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
|
|
1342
|
+
};
|
|
1343
|
+
},
|
|
1344
|
+
addInputRules() {
|
|
1345
|
+
let t = H({
|
|
1346
|
+
find: J,
|
|
1347
|
+
type: this.type,
|
|
1348
|
+
getAttributes: (e) => ({ start: +e[1] }),
|
|
1349
|
+
joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1]
|
|
1350
|
+
});
|
|
1351
|
+
return (this.options.keepMarks || this.options.keepAttributes) && (t = H({
|
|
1352
|
+
find: J,
|
|
1353
|
+
type: this.type,
|
|
1354
|
+
keepMarks: this.options.keepMarks,
|
|
1355
|
+
keepAttributes: this.options.keepAttributes,
|
|
1356
|
+
getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(Y) }),
|
|
1357
|
+
joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1],
|
|
1358
|
+
editor: this.editor
|
|
1359
|
+
})), [
|
|
1360
|
+
t
|
|
1361
|
+
];
|
|
1362
|
+
}
|
|
1363
|
+
}), lt = M.create({
|
|
1364
|
+
name: "paragraph",
|
|
1365
|
+
priority: 1e3,
|
|
1366
|
+
addOptions() {
|
|
1367
|
+
return {
|
|
1368
|
+
HTMLAttributes: {}
|
|
1369
|
+
};
|
|
1370
|
+
},
|
|
1371
|
+
group: "block",
|
|
1372
|
+
content: "inline*",
|
|
1373
|
+
parseHTML() {
|
|
1374
|
+
return [
|
|
1375
|
+
{ tag: "p" }
|
|
1376
|
+
];
|
|
1377
|
+
},
|
|
1378
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
1379
|
+
return ["p", v(this.options.HTMLAttributes, t), 0];
|
|
1380
|
+
},
|
|
1381
|
+
addCommands() {
|
|
1382
|
+
return {
|
|
1383
|
+
setParagraph: () => ({ commands: t }) => t.setNode(this.name)
|
|
1384
|
+
};
|
|
1385
|
+
},
|
|
1386
|
+
addKeyboardShortcuts() {
|
|
1387
|
+
return {
|
|
1388
|
+
"Mod-Alt-0": () => this.editor.commands.setParagraph()
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
}), dt = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, ut = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, pt = B.create({
|
|
1392
|
+
name: "strike",
|
|
1393
|
+
addOptions() {
|
|
1394
|
+
return {
|
|
1395
|
+
HTMLAttributes: {}
|
|
1396
|
+
};
|
|
1397
|
+
},
|
|
1398
|
+
parseHTML() {
|
|
1399
|
+
return [
|
|
1400
|
+
{
|
|
1401
|
+
tag: "s"
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
tag: "del"
|
|
1405
|
+
},
|
|
1406
|
+
{
|
|
1407
|
+
tag: "strike"
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
style: "text-decoration",
|
|
1411
|
+
consuming: !1,
|
|
1412
|
+
getAttrs: (t) => t.includes("line-through") ? {} : !1
|
|
1413
|
+
}
|
|
1414
|
+
];
|
|
1415
|
+
},
|
|
1416
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
1417
|
+
return ["s", v(this.options.HTMLAttributes, t), 0];
|
|
1418
|
+
},
|
|
1419
|
+
addCommands() {
|
|
1420
|
+
return {
|
|
1421
|
+
setStrike: () => ({ commands: t }) => t.setMark(this.name),
|
|
1422
|
+
toggleStrike: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
1423
|
+
unsetStrike: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
1424
|
+
};
|
|
1425
|
+
},
|
|
1426
|
+
addKeyboardShortcuts() {
|
|
1427
|
+
return {
|
|
1428
|
+
"Mod-Shift-s": () => this.editor.commands.toggleStrike()
|
|
1429
|
+
};
|
|
1430
|
+
},
|
|
1431
|
+
addInputRules() {
|
|
1432
|
+
return [
|
|
1433
|
+
x({
|
|
1434
|
+
find: dt,
|
|
1435
|
+
type: this.type
|
|
1436
|
+
})
|
|
1437
|
+
];
|
|
1438
|
+
},
|
|
1439
|
+
addPasteRules() {
|
|
1440
|
+
return [
|
|
1441
|
+
I({
|
|
1442
|
+
find: ut,
|
|
1443
|
+
type: this.type
|
|
1444
|
+
})
|
|
1445
|
+
];
|
|
1446
|
+
}
|
|
1447
|
+
}), ct = M.create({
|
|
1448
|
+
name: "text",
|
|
1449
|
+
group: "inline"
|
|
1450
|
+
}), mt = E.create({
|
|
1451
|
+
name: "starterKit",
|
|
1452
|
+
addExtensions() {
|
|
1453
|
+
var t, e, n, s, r, i, o, a, l, u, c, d, p, h, y, k, A, D;
|
|
1454
|
+
const m = [];
|
|
1455
|
+
return this.options.bold !== !1 && m.push(Me.configure((t = this.options) === null || t === void 0 ? void 0 : t.bold)), this.options.blockquote !== !1 && m.push(me.configure((e = this.options) === null || e === void 0 ? void 0 : e.blockquote)), this.options.bulletList !== !1 && m.push(we.configure((n = this.options) === null || n === void 0 ? void 0 : n.bulletList)), this.options.code !== !1 && m.push(Ce.configure((s = this.options) === null || s === void 0 ? void 0 : s.code)), this.options.codeBlock !== !1 && m.push(xe.configure((r = this.options) === null || r === void 0 ? void 0 : r.codeBlock)), this.options.document !== !1 && m.push(He.configure((i = this.options) === null || i === void 0 ? void 0 : i.document)), this.options.dropcursor !== !1 && m.push(Pe.configure((o = this.options) === null || o === void 0 ? void 0 : o.dropcursor)), this.options.gapcursor !== !1 && m.push(Ve.configure((a = this.options) === null || a === void 0 ? void 0 : a.gapcursor)), this.options.hardBreak !== !1 && m.push(ze.configure((l = this.options) === null || l === void 0 ? void 0 : l.hardBreak)), this.options.heading !== !1 && m.push(Ke.configure((u = this.options) === null || u === void 0 ? void 0 : u.heading)), this.options.history !== !1 && m.push(Ze.configure((c = this.options) === null || c === void 0 ? void 0 : c.history)), this.options.horizontalRule !== !1 && m.push(Qe.configure((d = this.options) === null || d === void 0 ? void 0 : d.horizontalRule)), this.options.italic !== !1 && m.push(rt.configure((p = this.options) === null || p === void 0 ? void 0 : p.italic)), this.options.listItem !== !1 && m.push(it.configure((h = this.options) === null || h === void 0 ? void 0 : h.listItem)), this.options.orderedList !== !1 && m.push(at.configure((y = this.options) === null || y === void 0 ? void 0 : y.orderedList)), this.options.paragraph !== !1 && m.push(lt.configure((k = this.options) === null || k === void 0 ? void 0 : k.paragraph)), this.options.strike !== !1 && m.push(pt.configure((A = this.options) === null || A === void 0 ? void 0 : A.strike)), this.options.text !== !1 && m.push(ct.configure((D = this.options) === null || D === void 0 ? void 0 : D.text)), m;
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
export {
|
|
1459
|
+
ft as P,
|
|
1460
|
+
mt as S
|
|
1461
|
+
};
|