Skip to content

Commit

Permalink
fix: selection of inline-title and view-header when using editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Jun 7, 2024
1 parent 0b33526 commit 93c0407
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ function getAnchor(head: EditorPosition, anchor: EditorPosition) {
export function copySelectionRange(editor: Editor, plugin: EnhancedCopy): string {
let selectedText = "";
const selection = editor.listSelections();
const inlineTitle = activeWindow.document.querySelector(".inline-title:focus");
const viewHeader = activeWindow.document.querySelector(".view-header-title:focus");
if (inlineTitle?.textContent && inlineTitle.textContent !== "") return inlineTitle.textContent;
else if (viewHeader?.textContent && viewHeader.textContent !== "") {
return viewHeader.textContent;
}
for (const selected of selection) {
const head = getHead(selected.head, selected.anchor);
const anchor = getAnchor(selected.head, selected.anchor);
Expand Down

0 comments on commit 93c0407

Please sign in to comment.