const props = defineProps({
initialValue: String,
+ initialEditType: {
+ type: String,
+ default: "markdown",
+ },
});
const editorElement = ref();
...baseOptions,
el: editorElement.value,
initialValue: props.initialValue,
+ initialEditType: props.initialEditType,
});
});
return toastEditor.getMarkdown();
}
-defineExpose({ getMarkdown });
+function isWysiwygMode() {
+ return toastEditor.isWysiwygMode();
+}
+
+defineExpose({ getMarkdown, isWysiwygMode });
</script>
<style>
v-if="editMode"
ref="toastEditor"
:initialValue="note.content"
+ :initialEditType="loadDefaultEditorMode()"
/>
</div>
</LoadingIndicator>
}
}
+function saveDefaultEditorMode() {
+ const isWysiwygMode = toastEditor.value.isWysiwygMode();
+ localStorage.setItem(
+ "defaultEditorMode",
+ isWysiwygMode ? "wysiwyg" : "markdown",
+ );
+}
+
+function loadDefaultEditorMode() {
+ const defaultWysiwygMode = localStorage.getItem("defaultEditorMode");
+ return defaultWysiwygMode || "markdown";
+}
+
// Button Handlers
function editHandler() {
setBeforeUnloadConfirmation(true);
}
function saveHandler() {
+ // Save Default Editor Mode
+ saveDefaultEditorMode();
+
// Empty Title Validation
if (!newTitle.value) {
toast.add(
return;
}
+ // Save Note
let newContent = toastEditor.value.getMarkdown();
if (isNewNote.value) {
saveNew(newTitle.value, newContent);