markupeditor 0.9.7 → 0.9.8
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/custom-elements.json +29 -1
- package/dist/markup-editor.js +23 -4
- package/package.json +1 -1
|
@@ -2753,6 +2753,18 @@
|
|
|
2753
2753
|
"description": "Represents the search MenuItem in the toolbar, which hides/shows the search bar and maintains its state.",
|
|
2754
2754
|
"name": "SearchItem",
|
|
2755
2755
|
"members": [
|
|
2756
|
+
{
|
|
2757
|
+
"kind": "method",
|
|
2758
|
+
"name": "matchesKey",
|
|
2759
|
+
"parameters": [
|
|
2760
|
+
{
|
|
2761
|
+
"name": "event"
|
|
2762
|
+
},
|
|
2763
|
+
{
|
|
2764
|
+
"name": "keyStrings"
|
|
2765
|
+
}
|
|
2766
|
+
]
|
|
2767
|
+
},
|
|
2756
2768
|
{
|
|
2757
2769
|
"kind": "method",
|
|
2758
2770
|
"name": "showing"
|
|
@@ -2788,7 +2800,18 @@
|
|
|
2788
2800
|
},
|
|
2789
2801
|
{
|
|
2790
2802
|
"kind": "method",
|
|
2791
|
-
"name": "hideSearchbar"
|
|
2803
|
+
"name": "hideSearchbar",
|
|
2804
|
+
"parameters": [
|
|
2805
|
+
{
|
|
2806
|
+
"name": "state"
|
|
2807
|
+
},
|
|
2808
|
+
{
|
|
2809
|
+
"name": "dispatch"
|
|
2810
|
+
},
|
|
2811
|
+
{
|
|
2812
|
+
"name": "view"
|
|
2813
|
+
}
|
|
2814
|
+
]
|
|
2792
2815
|
},
|
|
2793
2816
|
{
|
|
2794
2817
|
"kind": "method",
|
|
@@ -2937,6 +2960,11 @@
|
|
|
2937
2960
|
"text": "boolean"
|
|
2938
2961
|
},
|
|
2939
2962
|
"default": "false"
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
"kind": "field",
|
|
2966
|
+
"name": "keymap",
|
|
2967
|
+
"default": "keymap"
|
|
2940
2968
|
}
|
|
2941
2969
|
]
|
|
2942
2970
|
},
|
package/dist/markup-editor.js
CHANGED
|
@@ -22130,6 +22130,22 @@ class SearchItem {
|
|
|
22130
22130
|
this.item = cmdItem(this.command, options);
|
|
22131
22131
|
this.text = '';
|
|
22132
22132
|
this.caseSensitive = false;
|
|
22133
|
+
this.keymap = keymap;
|
|
22134
|
+
}
|
|
22135
|
+
|
|
22136
|
+
matchesKey(event, keyStrings) {
|
|
22137
|
+
let keys = keyStrings instanceof Array ? keyStrings : (keyStrings ? [keyStrings] : []);
|
|
22138
|
+
return keys.some(ks => {
|
|
22139
|
+
let parts = ks.split('-');
|
|
22140
|
+
let key = parts[parts.length - 1];
|
|
22141
|
+
let modifiers = parts.slice(0, -1);
|
|
22142
|
+
if (event.key !== key) return false
|
|
22143
|
+
if (modifiers.includes('Ctrl') && !event.ctrlKey) return false
|
|
22144
|
+
if (modifiers.includes('Mod') && !(event.metaKey || event.ctrlKey)) return false
|
|
22145
|
+
if (modifiers.includes('Shift') && !event.shiftKey) return false
|
|
22146
|
+
if (modifiers.includes('Alt') && !event.altKey) return false
|
|
22147
|
+
return true
|
|
22148
|
+
})
|
|
22133
22149
|
}
|
|
22134
22150
|
|
|
22135
22151
|
showing() {
|
|
@@ -22150,15 +22166,14 @@ class SearchItem {
|
|
|
22150
22166
|
toggleSearch(state, dispatch, view) {
|
|
22151
22167
|
setActiveView(view);
|
|
22152
22168
|
if (this.showing()) {
|
|
22153
|
-
this.hideSearchbar();
|
|
22169
|
+
this.hideSearchbar(state, dispatch, view);
|
|
22154
22170
|
} else {
|
|
22155
22171
|
this.showSearchbar(state, dispatch, view);
|
|
22156
22172
|
}
|
|
22157
22173
|
this.update && this.update(state);
|
|
22158
22174
|
}
|
|
22159
22175
|
|
|
22160
|
-
hideSearchbar() {
|
|
22161
|
-
let view = activeView();
|
|
22176
|
+
hideSearchbar(state, dispatch, view) {
|
|
22162
22177
|
if (view) {
|
|
22163
22178
|
let searchbar = getSearchbar(view);
|
|
22164
22179
|
searchbar.parentElement.removeChild(searchbar);
|
|
@@ -22186,6 +22201,9 @@ class SearchItem {
|
|
|
22186
22201
|
} else {
|
|
22187
22202
|
this.searchBackwardCommand(view.state, view.dispatch, view);
|
|
22188
22203
|
}
|
|
22204
|
+
} else if (this.matchesKey(e, this.keymap.search)) {
|
|
22205
|
+
e.preventDefault();
|
|
22206
|
+
this.hideSearchbar(view.state, view.dispatch, view);
|
|
22189
22207
|
}
|
|
22190
22208
|
});
|
|
22191
22209
|
input.addEventListener('input', e => { // Use input so e.target.value contains what was typed
|
|
@@ -22197,6 +22215,7 @@ class SearchItem {
|
|
|
22197
22215
|
this.addSearchButtons(view, searchbar);
|
|
22198
22216
|
let beforeTarget = getToolbarMore(view) ? getToolbarMore(view).nextSibling : toolbar.nextSibling;
|
|
22199
22217
|
toolbar.parentElement.insertBefore(searchbar, beforeTarget);
|
|
22218
|
+
input.focus();
|
|
22200
22219
|
}
|
|
22201
22220
|
|
|
22202
22221
|
setStatus() {
|
|
@@ -22884,7 +22903,7 @@ function styleMenuItems(config, schema) {
|
|
|
22884
22903
|
if (h4) items.push(new ParagraphStyleItem(schema.nodes.heading, 'H4', { label: h4, keymap: baseKeyString('h4', keymap), attrs: { level: 4 }}));
|
|
22885
22904
|
if (h5) items.push(new ParagraphStyleItem(schema.nodes.heading, 'H5', { label: h5, keymap: baseKeyString('h5', keymap), attrs: { level: 5 }}));
|
|
22886
22905
|
if (h6) items.push(new ParagraphStyleItem(schema.nodes.heading, 'H6', { label: h6, keymap: baseKeyString('h6', keymap), attrs: { level: 6 }}));
|
|
22887
|
-
if (pre) items.push(new ParagraphStyleItem(schema.nodes.code_block, 'PRE', { label: pre }));
|
|
22906
|
+
if (pre) items.push(new ParagraphStyleItem(schema.nodes.code_block, 'PRE', { label: pre, keymap: baseKeyString('pre', keymap) }));
|
|
22888
22907
|
if (config.behavior.showStyle) {
|
|
22889
22908
|
let titleUpdate = (state) => {
|
|
22890
22909
|
let styleElement = paragraphStyle(state).toLowerCase();
|