Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] fix(MarkdownContentEditor): Respect onLoaded callback passed via API #5525

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/components/Editor/MarkdownContentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,15 @@
extensions: this.extensions(),
onUpdate: ({ editor }) => {
const markdown = (createMarkdownSerializer(this.$editor.schema)).serialize(editor.state.doc)
this.$root.$emit('update:content', {
this.emit('update:content', {
json: editor.state.doc,
markdown,
})
},
onCreate: ({ editor }) => {
this.$emit('ready')
this.$parent.$emit('ready')
}

Check warning on line 166 in src/components/Editor/MarkdownContentEditor.vue

View workflow job for this annotation

GitHub Actions / eslint

Missing trailing comma
})
},

Expand All @@ -168,8 +172,24 @@
},

outlineToggled(visible) {
this.$emit('outline-toggled', visible)
this.$parent.$emit('outline-toggled', visible)
this.emit('outline-toggled', visible)
},

/**
* Wrapper to emit events on our own and the parent component
*
* The parent might be either the root component of src/editor.js or Viewer.vue which collectives currently uses
*
* Ideally this would be done in a generic way in the src/editor.js API abstraction, but it seems
* that there is no proper way to pass any received event along in vue, the only option I've found
* in https://github.com/vuejs/vue/issues/230 feels too hacky to me, so we just emit twice for now
*
* @param {string} event The event name
* @param {any} data The data to pass along
*/
emit(event, data) {
this.$emit(event, data)
this.$parent?.$emit(event, data)
},
},
}
Expand Down
Loading