Skip to content

Commit adf6e4b

Browse files
committed
feat(pages): allow exporting multiple notes
1 parent f6eb1a8 commit adf6e4b

File tree

1 file changed

+20
-5
lines changed
  • apps/client/src/layouts/PagesLayout/RightSidebar/NoteProperties

1 file changed

+20
-5
lines changed

apps/client/src/layouts/PagesLayout/RightSidebar/NoteProperties/NoteExport.vue

+20-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
</q-item>
2828

2929
<q-item
30-
v-if="note.react.notes.length > 0"
3130
clickable
3231
@click="copyAsMarkdown({ includeDescendants: true })"
3332
>
@@ -56,7 +55,6 @@
5655
</q-item>
5756

5857
<q-item
59-
v-if="note.react.notes.length > 0"
6058
clickable
6159
@click="downloadAsMarkdown({ includeDescendants: true })"
6260
>
@@ -88,7 +86,24 @@ import type { Ref } from 'vue';
8886
8987
const page = inject<Ref<Page>>('page')!;
9088
91-
const note = computed(() => page.value.activeElem.react.value as PageNote);
89+
function notesToMarkdown(
90+
notes: PageNote[],
91+
params: {
92+
includeDescendants: boolean;
93+
},
94+
) {
95+
let markdown = '';
96+
97+
for (const [noteIndex, note] of notes.entries()) {
98+
if (noteIndex > 0) {
99+
markdown += '\n\n---\n\n';
100+
}
101+
102+
markdown += noteToMarkdown(note, params);
103+
}
104+
105+
return markdown;
106+
}
92107
93108
function noteToMarkdown(
94109
note: PageNote,
@@ -179,7 +194,7 @@ function editorToMarkdown(editor: Editor) {
179194
180195
async function copyAsMarkdown(params: { includeDescendants: boolean }) {
181196
await setClipboardText(
182-
noteToMarkdown(note.value, {
197+
notesToMarkdown(page.value.selection.react.notes, {
183198
includeDescendants: params.includeDescendants,
184199
}),
185200
);
@@ -194,7 +209,7 @@ async function downloadAsMarkdown(params: { includeDescendants: boolean }) {
194209
try {
195210
const blob = new Blob(
196211
[
197-
noteToMarkdown(note.value, {
212+
notesToMarkdown(page.value.selection.react.notes, {
198213
includeDescendants: params.includeDescendants,
199214
}),
200215
],

0 commit comments

Comments
 (0)