prosekit 0.0.0-next-20230627094841
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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/basic/style.css +133 -0
- package/dist/chunk-23S3SZFA.js +46 -0
- package/dist/chunk-2MVHS73Q.js +709 -0
- package/dist/chunk-4GDRVRDP.js +0 -0
- package/dist/chunk-5PFF57NB.js +1546 -0
- package/dist/chunk-6A2XHVFY.js +46 -0
- package/dist/chunk-7OYIOTDD.js +16472 -0
- package/dist/chunk-ARJTWYPA.js +1321 -0
- package/dist/chunk-CDGN4JUS.js +1546 -0
- package/dist/chunk-CG5B6PMC.js +973 -0
- package/dist/chunk-DDN3TFRH.js +185 -0
- package/dist/chunk-EQV3CWHZ.js +2213 -0
- package/dist/chunk-ERNIDFFW.js +1711 -0
- package/dist/chunk-FAVXZAF7.js +3279 -0
- package/dist/chunk-HSPTUO6P.js +53 -0
- package/dist/chunk-JMNJUDT7.js +165 -0
- package/dist/chunk-LXCCO2LO.js +52 -0
- package/dist/chunk-MIPON3OH.js +922 -0
- package/dist/chunk-NAWSCY5F.js +166 -0
- package/dist/chunk-S64NFSV2.js +236 -0
- package/dist/chunk-S65R2BUY.js +15 -0
- package/dist/chunk-T2V5UU6H.js +204 -0
- package/dist/chunk-TWIMWRRZ.js +57 -0
- package/dist/chunk-US2P3K6I.js +185 -0
- package/dist/chunk-UTNVEPBA.js +950 -0
- package/dist/chunk-UWHQRU5N.js +4883 -0
- package/dist/chunk-VIKPJJET.js +662 -0
- package/dist/chunk-WAMZOD5I.js +67 -0
- package/dist/chunk-YUY5I2TY.js +236 -0
- package/dist/core/style.css +54 -0
- package/dist/extension-list/style.css +78 -0
- package/dist/pm/view/style/prosemirror.css +52 -0
- package/dist/prosekit-basic.js +2 -0
- package/dist/prosekit-core.js +2 -0
- package/dist/prosekit-extension-blockquote.js +2 -0
- package/dist/prosekit-extension-bold.js +2 -0
- package/dist/prosekit-extension-code-block.js +2 -0
- package/dist/prosekit-extension-code.js +2 -0
- package/dist/prosekit-extension-heading.js +2 -0
- package/dist/prosekit-extension-horizontal-rule.js +2 -0
- package/dist/prosekit-extension-italic.js +2 -0
- package/dist/prosekit-extension-list.js +2 -0
- package/dist/prosekit-extension-suggestion.js +2 -0
- package/dist/prosekit-lit-elements-menu-item.js +2 -0
- package/dist/prosekit-lit-elements-menu.js +2 -0
- package/dist/prosekit-lit-elements-popover.js +2 -0
- package/dist/prosekit-lit.js +2 -0
- package/dist/prosekit-pm-commands.js +2 -0
- package/dist/prosekit-pm-inputrules.js +2 -0
- package/dist/prosekit-pm-keymap.js +2 -0
- package/dist/prosekit-pm-model.js +2 -0
- package/dist/prosekit-pm-state.js +2 -0
- package/dist/prosekit-pm-transform.js +2 -0
- package/dist/prosekit-pm-view.js +2 -0
- package/dist/prosekit-pm.js +2 -0
- package/dist/prosekit-react-components-menu-item.js +2 -0
- package/dist/prosekit-react-components-menu.js +2 -0
- package/dist/prosekit-react-components-popover-suggestion.js +2 -0
- package/dist/prosekit-react-components-popover.js +2 -0
- package/dist/prosekit-react.js +2 -0
- package/dist/prosekit-vue-components-menu-item.js +2 -0
- package/dist/prosekit-vue-components-menu.js +2 -0
- package/dist/prosekit-vue-components-popover-suggestion.js +2 -0
- package/dist/prosekit-vue-components-popover.js +2 -0
- package/dist/prosekit-vue.js +2 -0
- package/dist/prosekit.js +0 -0
- package/package.json +262 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProseKitError,
|
|
3
|
+
addPlugin
|
|
4
|
+
} from "./chunk-2MVHS73Q.js";
|
|
5
|
+
import {
|
|
6
|
+
Decoration,
|
|
7
|
+
DecorationSet
|
|
8
|
+
} from "./chunk-UWHQRU5N.js";
|
|
9
|
+
import {
|
|
10
|
+
Plugin,
|
|
11
|
+
PluginKey
|
|
12
|
+
} from "./chunk-UTNVEPBA.js";
|
|
13
|
+
|
|
14
|
+
// ../extension-suggestion/src/is-valid.ts
|
|
15
|
+
function defaultIsValid({ state }) {
|
|
16
|
+
return state.selection.empty && !isInsideCode(state.selection.$from);
|
|
17
|
+
}
|
|
18
|
+
function isInsideCode($pos) {
|
|
19
|
+
for (let d = $pos.depth; d > 0; d--) {
|
|
20
|
+
if ($pos.node(d).type.spec.code) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return $pos.marks().some((mark) => mark.type.name === "code");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ../extension-suggestion/src/plugin.ts
|
|
28
|
+
var pluginKey = new PluginKey("prosemirror-prediction");
|
|
29
|
+
function getPluginState(state) {
|
|
30
|
+
return pluginKey.getState(state);
|
|
31
|
+
}
|
|
32
|
+
function getTrMeta(tr) {
|
|
33
|
+
return tr.getMeta(pluginKey);
|
|
34
|
+
}
|
|
35
|
+
function setTrMeta(tr, meta) {
|
|
36
|
+
return tr.setMeta(pluginKey, meta);
|
|
37
|
+
}
|
|
38
|
+
function createPredictionPlugin(options) {
|
|
39
|
+
if (options.rules.length === 0) {
|
|
40
|
+
throw new ProseKitError(
|
|
41
|
+
"You can't create a prediction plugin without rules"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const { onMatch, onDeactivate, isValid = defaultIsValid } = options;
|
|
45
|
+
return new Plugin({
|
|
46
|
+
key: pluginKey,
|
|
47
|
+
state: {
|
|
48
|
+
init: () => {
|
|
49
|
+
return { active: false, ignore: null, matching: null };
|
|
50
|
+
},
|
|
51
|
+
apply: (tr, prevValue, oldState, newState) => {
|
|
52
|
+
var _a;
|
|
53
|
+
const meta = getTrMeta(tr);
|
|
54
|
+
if (!tr.docChanged && oldState.selection.eq(newState.selection) && !meta) {
|
|
55
|
+
return prevValue;
|
|
56
|
+
}
|
|
57
|
+
if (meta) {
|
|
58
|
+
return meta;
|
|
59
|
+
}
|
|
60
|
+
if (!isValid({ state: newState })) {
|
|
61
|
+
return { active: false, ignore: null, matching: null };
|
|
62
|
+
}
|
|
63
|
+
const nextValue = calcPluginState(newState, options.rules);
|
|
64
|
+
if (nextValue.active && prevValue.ignore != null && ((_a = nextValue.matching) == null ? void 0 : _a.from) === prevValue.ignore) {
|
|
65
|
+
return prevValue;
|
|
66
|
+
}
|
|
67
|
+
return nextValue;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
view: () => ({
|
|
71
|
+
update: (view, prevState) => {
|
|
72
|
+
const prevPluginState = getPluginState(prevState);
|
|
73
|
+
const currPluginState = getPluginState(view.state);
|
|
74
|
+
if ((currPluginState == null ? void 0 : currPluginState.active) && currPluginState.matching && currPluginState.matching.from !== currPluginState.ignore) {
|
|
75
|
+
const { from, to } = currPluginState.matching;
|
|
76
|
+
const dismiss = () => {
|
|
77
|
+
view.dispatch(
|
|
78
|
+
setTrMeta(view.state.tr, {
|
|
79
|
+
active: false,
|
|
80
|
+
ignore: from,
|
|
81
|
+
matching: null
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
const textContent = view.state.doc.textBetween(from, to, "\uFFFC");
|
|
86
|
+
const deleteMatch = () => {
|
|
87
|
+
if (view.state.doc.textBetween(from, to, "\uFFFC") === textContent) {
|
|
88
|
+
view.dispatch(view.state.tr.delete(from, to));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
onMatch({
|
|
92
|
+
rule: currPluginState.matching.rule,
|
|
93
|
+
match: currPluginState.matching.match,
|
|
94
|
+
matchAfter: currPluginState.matching.matchAfter,
|
|
95
|
+
state: view.state,
|
|
96
|
+
dismiss,
|
|
97
|
+
deleteMatch
|
|
98
|
+
});
|
|
99
|
+
} else if (prevPluginState == null ? void 0 : prevPluginState.active) {
|
|
100
|
+
onDeactivate();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
props: {
|
|
105
|
+
decorations: (state) => {
|
|
106
|
+
const pluginState = getPluginState(state);
|
|
107
|
+
if ((pluginState == null ? void 0 : pluginState.active) && pluginState.matching) {
|
|
108
|
+
const { from, to } = pluginState.matching;
|
|
109
|
+
const deco = Decoration.inline(from, to, {
|
|
110
|
+
class: "prosemirror-prediction-match",
|
|
111
|
+
style: "background-color: lightblue"
|
|
112
|
+
});
|
|
113
|
+
return DecorationSet.create(state.doc, [deco]);
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function calcPluginState(state, rules) {
|
|
121
|
+
const { $anchor } = state.selection;
|
|
122
|
+
const matchAfter = rules.some((rule) => rule.matchAfter);
|
|
123
|
+
const parentOffset = $anchor.parentOffset;
|
|
124
|
+
const textBefore = $anchor.parent.textBetween(
|
|
125
|
+
Math.max(0, parentOffset - MAX_MATCH),
|
|
126
|
+
parentOffset,
|
|
127
|
+
null,
|
|
128
|
+
"\uFFFC"
|
|
129
|
+
);
|
|
130
|
+
const textAfter = matchAfter ? $anchor.parent.textBetween(
|
|
131
|
+
parentOffset,
|
|
132
|
+
Math.min(parentOffset + MAX_MATCH, $anchor.parent.content.size),
|
|
133
|
+
null
|
|
134
|
+
) : "";
|
|
135
|
+
for (const rule of rules) {
|
|
136
|
+
const match = textBefore.match(rule.match);
|
|
137
|
+
const matchAfter2 = rule.matchAfter ? textAfter.match(rule.matchAfter) : null;
|
|
138
|
+
if (match && match.index != null) {
|
|
139
|
+
const from = $anchor.pos - textBefore.length + match.index;
|
|
140
|
+
const to = $anchor.pos + (matchAfter2 ? matchAfter2[0].length : 0);
|
|
141
|
+
return {
|
|
142
|
+
active: true,
|
|
143
|
+
ignore: null,
|
|
144
|
+
matching: {
|
|
145
|
+
rule,
|
|
146
|
+
from,
|
|
147
|
+
to,
|
|
148
|
+
match,
|
|
149
|
+
matchAfter: matchAfter2
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { active: false };
|
|
155
|
+
}
|
|
156
|
+
var MAX_MATCH = 200;
|
|
157
|
+
|
|
158
|
+
// ../extension-suggestion/src/index.ts
|
|
159
|
+
function addSuggestion(options) {
|
|
160
|
+
const plugin = createPredictionPlugin(options);
|
|
161
|
+
return addPlugin({ plugins: [plugin] });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export {
|
|
165
|
+
addSuggestion
|
|
166
|
+
};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flip,
|
|
3
|
+
inline,
|
|
4
|
+
offset,
|
|
5
|
+
shift,
|
|
6
|
+
size
|
|
7
|
+
} from "./chunk-CDGN4JUS.js";
|
|
8
|
+
import {
|
|
9
|
+
b,
|
|
10
|
+
blockComponentStyles,
|
|
11
|
+
e,
|
|
12
|
+
n,
|
|
13
|
+
r,
|
|
14
|
+
s,
|
|
15
|
+
t
|
|
16
|
+
} from "./chunk-CG5B6PMC.js";
|
|
17
|
+
import {
|
|
18
|
+
addSuggestion
|
|
19
|
+
} from "./chunk-NAWSCY5F.js";
|
|
20
|
+
import {
|
|
21
|
+
ProseKitError
|
|
22
|
+
} from "./chunk-2MVHS73Q.js";
|
|
23
|
+
import {
|
|
24
|
+
__decorateClass
|
|
25
|
+
} from "./chunk-S65R2BUY.js";
|
|
26
|
+
|
|
27
|
+
// ../lit/src/utils/is-menu.ts
|
|
28
|
+
function isMenu(element) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === "prosekit-menu" || ["menu"].includes((_b = element == null ? void 0 : element.getAttribute("role")) != null ? _b : "");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ../lit/src/elements/popover-suggestion/controller.ts
|
|
34
|
+
var PopoverSuggestionController = class {
|
|
35
|
+
constructor(host, editor, rules, onContext) {
|
|
36
|
+
this.host = host;
|
|
37
|
+
this.editor = editor;
|
|
38
|
+
this.rules = rules;
|
|
39
|
+
this.onContext = onContext;
|
|
40
|
+
this.connected = false;
|
|
41
|
+
this.reference = null;
|
|
42
|
+
this.removeExtension = null;
|
|
43
|
+
if (!editor) {
|
|
44
|
+
throw new ProseKitError("Missing 'editor' property");
|
|
45
|
+
}
|
|
46
|
+
if (!rules) {
|
|
47
|
+
throw new ProseKitError("Missing 'rules' property");
|
|
48
|
+
}
|
|
49
|
+
this.host.addController(this);
|
|
50
|
+
}
|
|
51
|
+
hostUpdated() {
|
|
52
|
+
var _a;
|
|
53
|
+
if (this.connected)
|
|
54
|
+
return;
|
|
55
|
+
this.connected = true;
|
|
56
|
+
const editor = this.editor;
|
|
57
|
+
if (!editor) {
|
|
58
|
+
throw new ProseKitError("Missing 'editor' property");
|
|
59
|
+
}
|
|
60
|
+
if (!this.rules) {
|
|
61
|
+
throw new ProseKitError("Missing 'rules' property");
|
|
62
|
+
}
|
|
63
|
+
const extension = addSuggestion({
|
|
64
|
+
rules: this.rules,
|
|
65
|
+
onMatch: ({ dismiss, deleteMatch, match, matchAfter }) => {
|
|
66
|
+
var _a2, _b;
|
|
67
|
+
const span = editor.view.dom.querySelector(
|
|
68
|
+
".prosemirror-prediction-match"
|
|
69
|
+
);
|
|
70
|
+
if (span) {
|
|
71
|
+
this.reference = span;
|
|
72
|
+
}
|
|
73
|
+
const matchText = match[0] + ((_a2 = matchAfter == null ? void 0 : matchAfter[0]) != null ? _a2 : "");
|
|
74
|
+
(_b = this.onContext) == null ? void 0 : _b.call(this, {
|
|
75
|
+
active: true,
|
|
76
|
+
query: matchText,
|
|
77
|
+
onDismiss: () => {
|
|
78
|
+
dismiss();
|
|
79
|
+
},
|
|
80
|
+
onSubmit: () => {
|
|
81
|
+
deleteMatch();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
onDeactivate: () => {
|
|
86
|
+
this.reference = null;
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
var _a2;
|
|
89
|
+
(_a2 = this.onContext) == null ? void 0 : _a2.call(this, {
|
|
90
|
+
active: false
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
(_a = this.removeExtension) == null ? void 0 : _a.call(this);
|
|
96
|
+
this.removeExtension = editor.use(extension);
|
|
97
|
+
}
|
|
98
|
+
hostDisconnected() {
|
|
99
|
+
var _a;
|
|
100
|
+
this.connected = false;
|
|
101
|
+
(_a = this.removeExtension) == null ? void 0 : _a.call(this);
|
|
102
|
+
this.removeExtension = null;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// ../lit/src/elements/popover-suggestion/options.ts
|
|
107
|
+
var defaultDetectOverflowOptions = {
|
|
108
|
+
// Make sure the popover is always at least 8px away from the boundary
|
|
109
|
+
padding: 8
|
|
110
|
+
};
|
|
111
|
+
var defaultPopoverOptions = {
|
|
112
|
+
placement: "bottom-end",
|
|
113
|
+
middleware: [
|
|
114
|
+
offset(({ rects }) => ({
|
|
115
|
+
// Put the popover at the bottom right corner
|
|
116
|
+
alignmentAxis: -rects.floating.width,
|
|
117
|
+
// Move down the popover by 4px
|
|
118
|
+
mainAxis: 4
|
|
119
|
+
})),
|
|
120
|
+
size({
|
|
121
|
+
apply: ({ availableHeight, elements }) => {
|
|
122
|
+
const style = {
|
|
123
|
+
// Minimum acceptable height is 100px.
|
|
124
|
+
// `flip` will then take over.
|
|
125
|
+
maxHeight: `${Math.max(100, availableHeight)}px`,
|
|
126
|
+
overflowY: "auto"
|
|
127
|
+
};
|
|
128
|
+
Object.assign(elements.floating.style, style);
|
|
129
|
+
},
|
|
130
|
+
...defaultDetectOverflowOptions
|
|
131
|
+
}),
|
|
132
|
+
// Flip the popover to the top if it's overflowing the viewport
|
|
133
|
+
flip({
|
|
134
|
+
fallbackStrategy: "initialPlacement",
|
|
135
|
+
fallbackAxisSideDirection: "start",
|
|
136
|
+
crossAxis: false,
|
|
137
|
+
...defaultDetectOverflowOptions
|
|
138
|
+
}),
|
|
139
|
+
shift({
|
|
140
|
+
...defaultDetectOverflowOptions
|
|
141
|
+
}),
|
|
142
|
+
// Use the text caret as the reference point
|
|
143
|
+
inline()
|
|
144
|
+
]
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// ../lit/src/elements/popover-suggestion/popover-suggestion.ts
|
|
148
|
+
var PopoverSuggestion = class extends s {
|
|
149
|
+
/** @hidden */
|
|
150
|
+
constructor() {
|
|
151
|
+
super();
|
|
152
|
+
this.popoverOptions = defaultPopoverOptions;
|
|
153
|
+
this.context = { active: false };
|
|
154
|
+
}
|
|
155
|
+
/** @hidden */
|
|
156
|
+
firstUpdated() {
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
this.controller = new PopoverSuggestionController(
|
|
159
|
+
this,
|
|
160
|
+
this.editor,
|
|
161
|
+
this.rules,
|
|
162
|
+
(context) => {
|
|
163
|
+
var _a;
|
|
164
|
+
(_a = this.onContext) == null ? void 0 : _a.call(this, context);
|
|
165
|
+
this.context = context;
|
|
166
|
+
requestAnimationFrame(() => {
|
|
167
|
+
var _a2, _b;
|
|
168
|
+
(_b = (_a2 = this.queryMenu()) == null ? void 0 : _a2.ensureFocusedItem) == null ? void 0 : _b.call(_a2);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/** @hidden */
|
|
175
|
+
get active() {
|
|
176
|
+
var _a;
|
|
177
|
+
return !!((_a = this.controller) == null ? void 0 : _a.reference);
|
|
178
|
+
}
|
|
179
|
+
/** @hidden */
|
|
180
|
+
queryMenu() {
|
|
181
|
+
var _a, _b, _c;
|
|
182
|
+
return (_c = (_b = (_a = this.defaultSlot) == null ? void 0 : _a.assignedElements({ flatten: true })) == null ? void 0 : _b.find(isMenu)) != null ? _c : null;
|
|
183
|
+
}
|
|
184
|
+
/** @hidden */
|
|
185
|
+
render() {
|
|
186
|
+
var _a, _b;
|
|
187
|
+
return b`
|
|
188
|
+
<prosekit-popover
|
|
189
|
+
.active=${this.active}
|
|
190
|
+
.reference=${(_b = (_a = this.controller) == null ? void 0 : _a.reference) != null ? _b : void 0}
|
|
191
|
+
.options=${this.popoverOptions}
|
|
192
|
+
>
|
|
193
|
+
<slot
|
|
194
|
+
@menu-dismiss=${() => {
|
|
195
|
+
var _a2, _b2;
|
|
196
|
+
return (_b2 = (_a2 = this.context) == null ? void 0 : _a2.onDismiss) == null ? void 0 : _b2.call(_a2);
|
|
197
|
+
}}
|
|
198
|
+
@menu-select=${() => {
|
|
199
|
+
var _a2, _b2;
|
|
200
|
+
return (_b2 = (_a2 = this.context) == null ? void 0 : _a2.onSubmit) == null ? void 0 : _b2.call(_a2);
|
|
201
|
+
}}
|
|
202
|
+
></slot>
|
|
203
|
+
</prosekit-popover>
|
|
204
|
+
`;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
/** @hidden */
|
|
208
|
+
PopoverSuggestion.styles = blockComponentStyles;
|
|
209
|
+
__decorateClass([
|
|
210
|
+
n({ attribute: false })
|
|
211
|
+
], PopoverSuggestion.prototype, "editor", 2);
|
|
212
|
+
__decorateClass([
|
|
213
|
+
n({ attribute: false })
|
|
214
|
+
], PopoverSuggestion.prototype, "popoverOptions", 2);
|
|
215
|
+
__decorateClass([
|
|
216
|
+
n({ attribute: false })
|
|
217
|
+
], PopoverSuggestion.prototype, "rules", 2);
|
|
218
|
+
__decorateClass([
|
|
219
|
+
t()
|
|
220
|
+
], PopoverSuggestion.prototype, "context", 2);
|
|
221
|
+
__decorateClass([
|
|
222
|
+
n({ attribute: false })
|
|
223
|
+
], PopoverSuggestion.prototype, "onContext", 2);
|
|
224
|
+
__decorateClass([
|
|
225
|
+
t()
|
|
226
|
+
], PopoverSuggestion.prototype, "controller", 2);
|
|
227
|
+
__decorateClass([
|
|
228
|
+
r("slot")
|
|
229
|
+
], PopoverSuggestion.prototype, "defaultSlot", 2);
|
|
230
|
+
PopoverSuggestion = __decorateClass([
|
|
231
|
+
e("prosekit-popover-suggestion")
|
|
232
|
+
], PopoverSuggestion);
|
|
233
|
+
|
|
234
|
+
export {
|
|
235
|
+
PopoverSuggestion
|
|
236
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
__decorateClass
|
|
15
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Plugin
|
|
3
|
+
} from "./chunk-UTNVEPBA.js";
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/.pnpm/w3c-keyname@2.2.6/node_modules/w3c-keyname/index.es.js
|
|
6
|
+
var base = {
|
|
7
|
+
8: "Backspace",
|
|
8
|
+
9: "Tab",
|
|
9
|
+
10: "Enter",
|
|
10
|
+
12: "NumLock",
|
|
11
|
+
13: "Enter",
|
|
12
|
+
16: "Shift",
|
|
13
|
+
17: "Control",
|
|
14
|
+
18: "Alt",
|
|
15
|
+
20: "CapsLock",
|
|
16
|
+
27: "Escape",
|
|
17
|
+
32: " ",
|
|
18
|
+
33: "PageUp",
|
|
19
|
+
34: "PageDown",
|
|
20
|
+
35: "End",
|
|
21
|
+
36: "Home",
|
|
22
|
+
37: "ArrowLeft",
|
|
23
|
+
38: "ArrowUp",
|
|
24
|
+
39: "ArrowRight",
|
|
25
|
+
40: "ArrowDown",
|
|
26
|
+
44: "PrintScreen",
|
|
27
|
+
45: "Insert",
|
|
28
|
+
46: "Delete",
|
|
29
|
+
59: ";",
|
|
30
|
+
61: "=",
|
|
31
|
+
91: "Meta",
|
|
32
|
+
92: "Meta",
|
|
33
|
+
106: "*",
|
|
34
|
+
107: "+",
|
|
35
|
+
108: ",",
|
|
36
|
+
109: "-",
|
|
37
|
+
110: ".",
|
|
38
|
+
111: "/",
|
|
39
|
+
144: "NumLock",
|
|
40
|
+
145: "ScrollLock",
|
|
41
|
+
160: "Shift",
|
|
42
|
+
161: "Shift",
|
|
43
|
+
162: "Control",
|
|
44
|
+
163: "Control",
|
|
45
|
+
164: "Alt",
|
|
46
|
+
165: "Alt",
|
|
47
|
+
173: "-",
|
|
48
|
+
186: ";",
|
|
49
|
+
187: "=",
|
|
50
|
+
188: ",",
|
|
51
|
+
189: "-",
|
|
52
|
+
190: ".",
|
|
53
|
+
191: "/",
|
|
54
|
+
192: "`",
|
|
55
|
+
219: "[",
|
|
56
|
+
220: "\\",
|
|
57
|
+
221: "]",
|
|
58
|
+
222: "'"
|
|
59
|
+
};
|
|
60
|
+
var shift = {
|
|
61
|
+
48: ")",
|
|
62
|
+
49: "!",
|
|
63
|
+
50: "@",
|
|
64
|
+
51: "#",
|
|
65
|
+
52: "$",
|
|
66
|
+
53: "%",
|
|
67
|
+
54: "^",
|
|
68
|
+
55: "&",
|
|
69
|
+
56: "*",
|
|
70
|
+
57: "(",
|
|
71
|
+
59: ":",
|
|
72
|
+
61: "+",
|
|
73
|
+
173: "_",
|
|
74
|
+
186: ":",
|
|
75
|
+
187: "+",
|
|
76
|
+
188: "<",
|
|
77
|
+
189: "_",
|
|
78
|
+
190: ">",
|
|
79
|
+
191: "?",
|
|
80
|
+
192: "~",
|
|
81
|
+
219: "{",
|
|
82
|
+
220: "|",
|
|
83
|
+
221: "}",
|
|
84
|
+
222: '"'
|
|
85
|
+
};
|
|
86
|
+
var chrome = typeof navigator != "undefined" && /Chrome\/(\d+)/.exec(navigator.userAgent);
|
|
87
|
+
var gecko = typeof navigator != "undefined" && /Gecko\/\d+/.test(navigator.userAgent);
|
|
88
|
+
var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
|
|
89
|
+
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
|
|
90
|
+
var brokenModifierNames = mac || chrome && +chrome[1] < 57;
|
|
91
|
+
for (i = 0; i < 10; i++)
|
|
92
|
+
base[48 + i] = base[96 + i] = String(i);
|
|
93
|
+
var i;
|
|
94
|
+
for (i = 1; i <= 24; i++)
|
|
95
|
+
base[i + 111] = "F" + i;
|
|
96
|
+
var i;
|
|
97
|
+
for (i = 65; i <= 90; i++) {
|
|
98
|
+
base[i] = String.fromCharCode(i + 32);
|
|
99
|
+
shift[i] = String.fromCharCode(i);
|
|
100
|
+
}
|
|
101
|
+
var i;
|
|
102
|
+
for (code in base)
|
|
103
|
+
if (!shift.hasOwnProperty(code))
|
|
104
|
+
shift[code] = base[code];
|
|
105
|
+
var code;
|
|
106
|
+
function keyName(event) {
|
|
107
|
+
var ignoreKey = brokenModifierNames && (event.ctrlKey || event.altKey || event.metaKey) || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified";
|
|
108
|
+
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base)[event.keyCode] || event.key || "Unidentified";
|
|
109
|
+
if (name == "Esc")
|
|
110
|
+
name = "Escape";
|
|
111
|
+
if (name == "Del")
|
|
112
|
+
name = "Delete";
|
|
113
|
+
if (name == "Left")
|
|
114
|
+
name = "ArrowLeft";
|
|
115
|
+
if (name == "Up")
|
|
116
|
+
name = "ArrowUp";
|
|
117
|
+
if (name == "Right")
|
|
118
|
+
name = "ArrowRight";
|
|
119
|
+
if (name == "Down")
|
|
120
|
+
name = "ArrowDown";
|
|
121
|
+
return name;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ../../node_modules/.pnpm/prosemirror-keymap@1.2.2/node_modules/prosemirror-keymap/dist/index.js
|
|
125
|
+
var mac2 = typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : false;
|
|
126
|
+
function normalizeKeyName(name) {
|
|
127
|
+
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
128
|
+
if (result == "Space")
|
|
129
|
+
result = " ";
|
|
130
|
+
let alt, ctrl, shift2, meta;
|
|
131
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
132
|
+
let mod = parts[i];
|
|
133
|
+
if (/^(cmd|meta|m)$/i.test(mod))
|
|
134
|
+
meta = true;
|
|
135
|
+
else if (/^a(lt)?$/i.test(mod))
|
|
136
|
+
alt = true;
|
|
137
|
+
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
138
|
+
ctrl = true;
|
|
139
|
+
else if (/^s(hift)?$/i.test(mod))
|
|
140
|
+
shift2 = true;
|
|
141
|
+
else if (/^mod$/i.test(mod)) {
|
|
142
|
+
if (mac2)
|
|
143
|
+
meta = true;
|
|
144
|
+
else
|
|
145
|
+
ctrl = true;
|
|
146
|
+
} else
|
|
147
|
+
throw new Error("Unrecognized modifier name: " + mod);
|
|
148
|
+
}
|
|
149
|
+
if (alt)
|
|
150
|
+
result = "Alt-" + result;
|
|
151
|
+
if (ctrl)
|
|
152
|
+
result = "Ctrl-" + result;
|
|
153
|
+
if (meta)
|
|
154
|
+
result = "Meta-" + result;
|
|
155
|
+
if (shift2)
|
|
156
|
+
result = "Shift-" + result;
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
function normalize(map) {
|
|
160
|
+
let copy = /* @__PURE__ */ Object.create(null);
|
|
161
|
+
for (let prop in map)
|
|
162
|
+
copy[normalizeKeyName(prop)] = map[prop];
|
|
163
|
+
return copy;
|
|
164
|
+
}
|
|
165
|
+
function modifiers(name, event, shift2 = true) {
|
|
166
|
+
if (event.altKey)
|
|
167
|
+
name = "Alt-" + name;
|
|
168
|
+
if (event.ctrlKey)
|
|
169
|
+
name = "Ctrl-" + name;
|
|
170
|
+
if (event.metaKey)
|
|
171
|
+
name = "Meta-" + name;
|
|
172
|
+
if (shift2 && event.shiftKey)
|
|
173
|
+
name = "Shift-" + name;
|
|
174
|
+
return name;
|
|
175
|
+
}
|
|
176
|
+
function keymap(bindings) {
|
|
177
|
+
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
|
|
178
|
+
}
|
|
179
|
+
function keydownHandler(bindings) {
|
|
180
|
+
let map = normalize(bindings);
|
|
181
|
+
return function(view, event) {
|
|
182
|
+
let name = keyName(event), baseName, direct = map[modifiers(name, event)];
|
|
183
|
+
if (direct && direct(view.state, view.dispatch, view))
|
|
184
|
+
return true;
|
|
185
|
+
if (name.length == 1 && name != " ") {
|
|
186
|
+
if (event.shiftKey) {
|
|
187
|
+
let noShift = map[modifiers(name, event, false)];
|
|
188
|
+
if (noShift && noShift(view.state, view.dispatch, view))
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if ((event.shiftKey || event.altKey || event.metaKey || name.charCodeAt(0) > 127) && (baseName = base[event.keyCode]) && baseName != name) {
|
|
192
|
+
let fromCode = map[modifiers(baseName, event)];
|
|
193
|
+
if (fromCode && fromCode(view.state, view.dispatch, view))
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export {
|
|
202
|
+
keymap,
|
|
203
|
+
keydownHandler
|
|
204
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addInputRule,
|
|
3
|
+
addNodeSpec,
|
|
4
|
+
defineExtension,
|
|
5
|
+
getNodeType
|
|
6
|
+
} from "./chunk-2MVHS73Q.js";
|
|
7
|
+
import {
|
|
8
|
+
textblockTypeInputRule
|
|
9
|
+
} from "./chunk-JMNJUDT7.js";
|
|
10
|
+
|
|
11
|
+
// ../extension-heading/src/index.ts
|
|
12
|
+
function addHeadingSpec() {
|
|
13
|
+
return addNodeSpec({
|
|
14
|
+
name: "heading",
|
|
15
|
+
spec: {
|
|
16
|
+
attrs: { level: { default: 1 } },
|
|
17
|
+
content: "inline*",
|
|
18
|
+
group: "block",
|
|
19
|
+
defining: true,
|
|
20
|
+
parseDOM: [
|
|
21
|
+
{ tag: "h1", attrs: { level: 1 } },
|
|
22
|
+
{ tag: "h2", attrs: { level: 2 } },
|
|
23
|
+
{ tag: "h3", attrs: { level: 3 } },
|
|
24
|
+
{ tag: "h4", attrs: { level: 4 } },
|
|
25
|
+
{ tag: "h5", attrs: { level: 5 } },
|
|
26
|
+
{ tag: "h6", attrs: { level: 6 } }
|
|
27
|
+
],
|
|
28
|
+
toDOM(node) {
|
|
29
|
+
return [`h${node.attrs.level}`, 0];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function addHeadingInputRule() {
|
|
35
|
+
return addInputRule(({ schema }) => {
|
|
36
|
+
const nodeSpec = getNodeType(schema, "heading");
|
|
37
|
+
const inputRule = textblockTypeInputRule(
|
|
38
|
+
/^(#{1,6})\s/,
|
|
39
|
+
nodeSpec,
|
|
40
|
+
(match) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const level = (_b = (_a = match[1]) == null ? void 0 : _a.length) != null ? _b : 1;
|
|
43
|
+
return { level };
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
return [inputRule];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function addHeading() {
|
|
50
|
+
return defineExtension([addHeadingSpec(), addHeadingInputRule()]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
addHeadingSpec,
|
|
55
|
+
addHeadingInputRule,
|
|
56
|
+
addHeading
|
|
57
|
+
};
|