From 62ee0e08111a6a496a71d24b9bf5d46f28ffa6dc Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Fri, 6 Dec 2024 14:42:47 +0100 Subject: [PATCH] Change terminology Note -> Buffer --- src/components/App.vue | 62 +++++------ .../{NoteSelector.vue => BufferSelector.vue} | 38 +++---- .../{EditNote.vue => EditBuffer.vue} | 28 ++--- src/components/Editor.vue | 18 +-- src/components/{NewNote.vue => NewBuffer.vue} | 46 ++++---- src/components/StatusBar.vue | 10 +- src/editor/block/block.js | 6 +- src/editor/editor.js | 24 ++-- src/editor/keymap.js | 6 +- src/main.js | 4 +- .../{notes-store.js => heynote-store.js} | 105 +++++++++--------- 11 files changed, 172 insertions(+), 175 deletions(-) rename src/components/{NoteSelector.vue => BufferSelector.vue} (94%) rename src/components/{EditNote.vue => EditBuffer.vue} (91%) rename src/components/{NewNote.vue => NewBuffer.vue} (87%) rename src/stores/{notes-store.js => heynote-store.js} (60%) diff --git a/src/components/App.vue b/src/components/App.vue index b9683b03..d546834d 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -2,17 +2,17 @@ import { mapState, mapActions } from 'pinia' import { mapWritableState } from 'pinia' - import { useNotesStore } from "../stores/notes-store" + import { useHeynoteStore } from "../stores/heynote-store" import { useErrorStore } from "../stores/error-store" import StatusBar from './StatusBar.vue' import Editor from './Editor.vue' import LanguageSelector from './LanguageSelector.vue' - import NoteSelector from './NoteSelector.vue' + import BufferSelector from './BufferSelector.vue' import Settings from './settings/Settings.vue' import ErrorMessages from './ErrorMessages.vue' - import NewNote from './NewNote.vue' - import EditNote from './EditNote.vue' + import NewBuffer from './NewBuffer.vue' + import EditBuffer from './EditBuffer.vue' export default { components: { @@ -20,10 +20,10 @@ StatusBar, LanguageSelector, Settings, - NoteSelector, + BufferSelector, ErrorMessages, - NewNote, - EditNote, + NewBuffer, + EditBuffer, }, data() { @@ -67,37 +67,37 @@ watch: { // when a dialog is closed, we want to focus the editor showLanguageSelector(value) { this.dialogWatcher(value) }, - showNoteSelector(value) { this.dialogWatcher(value) }, - showCreateNote(value) { this.dialogWatcher(value) }, - showEditNote(value) { this.dialogWatcher(value) }, + showBufferSelector(value) { this.dialogWatcher(value) }, + showCreateBuffer(value) { this.dialogWatcher(value) }, + showEditBuffer(value) { this.dialogWatcher(value) }, - currentNotePath() { + currentBufferPath() { this.focusEditor() }, }, computed: { - ...mapState(useNotesStore, [ - "currentNotePath", + ...mapState(useHeynoteStore, [ + "currentBufferPath", "showLanguageSelector", - "showNoteSelector", - "showCreateNote", - "showEditNote", + "showBufferSelector", + "showCreateBuffer", + "showEditBuffer", ]), editorInert() { - return this.showCreateNote || this.showSettings || this.showEditNote + return this.showCreateBuffer || this.showSettings || this.showEditBuffer }, }, methods: { - ...mapActions(useNotesStore, [ + ...mapActions(useHeynoteStore, [ "openLanguageSelector", - "openNoteSelector", - "openCreateNote", + "openBufferSelector", + "openCreateBuffer", "closeDialog", - "closeNoteSelector", - "openNote", + "closeBufferSelector", + "openBuffer", ]), // Used as a watcher for the booleans that control the visibility of editor dialogs. @@ -177,7 +177,7 @@ - - - diff --git a/src/components/NoteSelector.vue b/src/components/BufferSelector.vue similarity index 94% rename from src/components/NoteSelector.vue rename to src/components/BufferSelector.vue index 9004ca1a..cc4eed6e 100644 --- a/src/components/NoteSelector.vue +++ b/src/components/BufferSelector.vue @@ -4,7 +4,7 @@ import { mapState, mapActions } from 'pinia' import { toRaw } from 'vue'; import { SCRATCH_FILE_NAME } from "../common/constants" - import { useNotesStore } from "../stores/notes-store" + import { useHeynoteStore } from "../stores/heynote-store" export default { data() { @@ -19,7 +19,7 @@ }, async mounted() { - await this.updateNotes() + await this.updateBuffers() this.$refs.container.focus() this.$refs.input.focus() this.buildItems() @@ -29,13 +29,13 @@ }, computed: { - ...mapState(useNotesStore, [ - "notes", - "recentNotePaths", + ...mapState(useHeynoteStore, [ + "buffers", + "recentBufferPaths", ]), orderedItems() { - const sortKeys = Object.fromEntries(this.recentNotePaths.map((item, idx) => [item, idx])) + const sortKeys = Object.fromEntries(this.recentBufferPaths.map((item, idx) => [item, idx])) const getSortScore = (item) => sortKeys[item.path] !== undefined ? sortKeys[item.path] : 1000 const compareFunc = (a, b) => { const sortScore = getSortScore(a) - getSortScore(b) @@ -90,16 +90,16 @@ }, methods: { - ...mapActions(useNotesStore, [ - "updateNotes", - "editNote", - "deleteNote", - "openCreateNote", + ...mapActions(useHeynoteStore, [ + "updateBuffers", + "editBufferMetadata", + "deleteBuffer", + "openCreateBuffer", ]), buildItems() { - //console.log("buildItems", Object.entries(this.notes)) - this.items = Object.entries(this.notes).map(([path, metadata]) => { + //console.log("buildItems", Object.entries(this.buffers)) + this.items = Object.entries(this.buffers).map(([path, metadata]) => { return { "path": path, "name": metadata?.name || path, @@ -158,7 +158,7 @@ event.preventDefault() if (this.actionButton === 1) { //console.log("edit file:", path) - this.editNote(item.path) + this.editBufferMetadata(item.path) } else if (this.actionButton === 2) { this.deleteConfirmNote(item.path) } else { @@ -170,12 +170,12 @@ selectItem(item) { if (item.createNew) { if (this.filteredItems.length === 1) { - this.openCreateNote("new", this.filter) + this.openCreateBuffer("new", this.filter) } else { - this.openCreateNote("new", "") + this.openCreateBuffer("new", "") } } else { - this.$emit("openNote", item.path) + this.$emit("openBuffer", item.path) } }, @@ -220,7 +220,7 @@ async deleteConfirmNote(path) { if (this.deleteConfirm) { //console.log("delete file:", path) - await this.deleteNote(path) + await this.deleteBuffer(path) this.hideActionButtons() this.buildItems() this.selected = Math.min(this.selected, this.items.length - 1) @@ -264,7 +264,7 @@