|
1 | 1 | import dayjs from "dayjs"; |
2 | | -import { Modal } from "bootstrap"; |
3 | 2 | import type { ViewScope } from "./link.js"; |
4 | 3 |
|
5 | 4 | const SVG_MIME = "image/svg+xml"; |
@@ -275,69 +274,6 @@ function getMimeTypeClass(mime: string) { |
275 | 274 | return `mime-${mime.toLowerCase().replace(/[\W_]+/g, "-")}`; |
276 | 275 | } |
277 | 276 |
|
278 | | -function closeActiveDialog() { |
279 | | - if (glob.activeDialog) { |
280 | | - Modal.getOrCreateInstance(glob.activeDialog[0]).hide(); |
281 | | - glob.activeDialog = null; |
282 | | - } |
283 | | -} |
284 | | - |
285 | | -let $lastFocusedElement: JQuery<HTMLElement> | null; |
286 | | - |
287 | | -// perhaps there should be saved focused element per tab? |
288 | | -function saveFocusedElement() { |
289 | | - $lastFocusedElement = $(":focus"); |
290 | | -} |
291 | | - |
292 | | -function focusSavedElement() { |
293 | | - if (!$lastFocusedElement) { |
294 | | - return; |
295 | | - } |
296 | | - |
297 | | - if ($lastFocusedElement.hasClass("ck")) { |
298 | | - // must handle CKEditor separately because of this bug: https://github.com/ckeditor/ckeditor5/issues/607 |
299 | | - // the bug manifests itself in resetting the cursor position to the first character - jumping above |
300 | | - |
301 | | - const editor = $lastFocusedElement.closest(".ck-editor__editable").prop("ckeditorInstance"); |
302 | | - |
303 | | - if (editor) { |
304 | | - editor.editing.view.focus(); |
305 | | - } else { |
306 | | - console.log("Could not find CKEditor instance to focus last element"); |
307 | | - } |
308 | | - } else { |
309 | | - $lastFocusedElement.focus(); |
310 | | - } |
311 | | - |
312 | | - $lastFocusedElement = null; |
313 | | -} |
314 | | - |
315 | | -async function openDialog($dialog: JQuery<HTMLElement>, closeActDialog = true) { |
316 | | - if (closeActDialog) { |
317 | | - closeActiveDialog(); |
318 | | - glob.activeDialog = $dialog; |
319 | | - } |
320 | | - |
321 | | - saveFocusedElement(); |
322 | | - Modal.getOrCreateInstance($dialog[0]).show(); |
323 | | - |
324 | | - $dialog.on("hidden.bs.modal", () => { |
325 | | - const $autocompleteEl = $(".aa-input"); |
326 | | - if ("autocomplete" in $autocompleteEl) { |
327 | | - $autocompleteEl.autocomplete("close"); |
328 | | - } |
329 | | - |
330 | | - if (!glob.activeDialog || glob.activeDialog === $dialog) { |
331 | | - focusSavedElement(); |
332 | | - } |
333 | | - }); |
334 | | - |
335 | | - const keyboardActionsService = (await import("./keyboard_actions.js")).default; |
336 | | - keyboardActionsService.updateDisplayedShortcuts($dialog); |
337 | | - |
338 | | - return $dialog; |
339 | | -} |
340 | | - |
341 | 277 | function isHtmlEmpty(html: string) { |
342 | 278 | if (!html) { |
343 | 279 | return true; |
@@ -823,10 +759,6 @@ export default { |
823 | 759 | setCookie, |
824 | 760 | getNoteTypeClass, |
825 | 761 | getMimeTypeClass, |
826 | | - closeActiveDialog, |
827 | | - openDialog, |
828 | | - saveFocusedElement, |
829 | | - focusSavedElement, |
830 | 762 | isHtmlEmpty, |
831 | 763 | clearBrowserCache, |
832 | 764 | copySelectionToClipboard, |
|
0 commit comments