Skip to content

Commit 75b87c4

Browse files
Clean up CrossReference
1 parent 7d11728 commit 75b87c4

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

webapp/src/components/TiptapInline.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,18 @@ export default {
374374
content: this.modelValue,
375375
onUpdate: () => this.$emit("update:modelValue", this.editor.getHTML()),
376376
onFocus: () => (this.showToolbar = true),
377-
onBlur: () =>
377+
onBlur: () => {
378378
setTimeout(() => {
379-
if (!this.$el.contains(document.activeElement)) {
379+
const suggestionEl = document.querySelector(".tiptap-suggestions");
380+
if (
381+
!this.$el.contains(document.activeElement) &&
382+
(!suggestionEl || !suggestionEl.contains(document.activeElement))
383+
) {
380384
this.showToolbar = false;
381385
this.showColorPicker = false;
382386
}
383-
}, 150),
387+
}, 150);
388+
},
384389
});
385390
386391
this.handleDocumentClick = (e) => this.handleClickOutside(e);

webapp/src/editor/extensions/CrossReferenceInputRule.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,6 @@ function createSuggestionPlugin(options, editor) {
7676
},
7777
},
7878

79-
props: {
80-
handleKeyDown(view, event) {
81-
const state = pluginKey.getState(view.state);
82-
if (!state?.active) return false;
83-
84-
if (event.key === "Backspace" && state.query === "" && state.range) {
85-
const tr = view.state.tr.deleteRange(state.range);
86-
view.dispatch(tr);
87-
hideSuggestions();
88-
return true;
89-
}
90-
91-
return false;
92-
},
93-
},
94-
9579
view() {
9680
return {
9781
update(view) {
@@ -142,8 +126,10 @@ function showSuggestions(view, state, options, editor) {
142126
suggestionEl.style.display = "block";
143127

144128
const input = suggestionEl.querySelector("input");
145-
if (input && document.activeElement !== input) {
146-
input.focus();
129+
if (input) {
130+
requestAnimationFrame(() => {
131+
input.focus({ preventScroll: true });
132+
});
147133
}
148134
}
149135

0 commit comments

Comments
 (0)