diff --git a/resources/js/Components/Editor/Editor.vue b/resources/js/Components/Editor/Editor.vue index 6938179..1f855a5 100644 --- a/resources/js/Components/Editor/Editor.vue +++ b/resources/js/Components/Editor/Editor.vue @@ -30,28 +30,11 @@ import HistoryTab from './Tabs/HistoryTab.vue' import BubbleMenu from './BubbleMenu.vue' import FloatingMenu from './FloatingMenu.vue' -const ImageAlign = Image.extend({ - addAttributes() { - return { - ...this.parent?.(), - alignment: { - default: 'left', - renderHTML: attributes => { - return { - class: `image-align-${attributes.alignment}`, - } - }, - }, - } - }, -}) - -// Props and emits const props = defineProps({ - initialContent: { - type: String, + content: { + type: Object || String, default: ` -
@@ -78,19 +61,45 @@ const props = defineProps({ N’hésitez pas à nous contacter si vous souhaitez avoir plus d’informations concernant notre groupe ou nos séances.
` + }, + editable: { + type: Boolean, + default: true, } }) const emit = defineEmits(['update']) - -// Editor instance const editor = ref(null) +const edit = ref(props.editable); const activeTab = ref('text') +defineExpose({ + editable: (flag) => { + edit.value = flag; + editor.value.setEditable(flag) + } +}); + +const ImageAlign = Image.extend({ + addAttributes() { + return { + ...this.parent?.(), + alignment: { + default: 'left', + renderHTML: attributes => { + return { + class: `image-align-${attributes.alignment}`, + } + }, + }, + } + }, +}) + // Initialize editor onMounted(() => { editor.value = new Editor({ - content: props.initialContent, + content: props.content, editorProps: { attributes: { class: 'tiptap-editor', @@ -154,7 +163,8 @@ onMounted(() => { json: editor.getJSON() }) } - }) + }); + editor.value.setEditable(edit); emit('update', { html: editor.value.getHTML(), json: editor.value.getJSON() @@ -169,9 +179,9 @@ onBeforeUnmount(() => { }) -