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

feat: update editor data in source-editing mode #115

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
The **Nova Ckeditor** package combines the power of Laravel Nova with the advanced features of **CKEditor 5**, a modern and versatile text editor. It aims to bring CKEditor 5 integration to Laravel Nova, providing you with an enhanced content creation experience within your Laravel applications.\
With "Nova Ckeditor," you can seamlessly integrate CKEditor 5 into Laravel Nova and unlock advanced text editing capabilities within your Laravel applications. Whether you're building a blog, a content management system, or any other application that requires rich text editing, "Nova Ckeditor" provides the tools and features you need for a seamless content creation experience.

<div align="left">

<figure><img src="https://mostafaznv.github.io/donate/donate.svg" alt="" width="188"><figcaption></figcaption></figure>

</div>
[![Donate](https://mostafaznv.github.io/donate/donate.svg)](https://mostafaznv.github.io/donate)



Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/support-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ I believe in open source software and its power to change the world for the bett

Your contribution, no matter how small, is deeply appreciated.&#x20;

Thank you for your support!
Thank you for your support



Expand Down
22 changes: 22 additions & 0 deletions resources/js/fields/editor-field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default {
this.editorResizeFix(editor, writer)
});

this.syncDataOnSourceEditing()

if (this.currentField.readonly) {
editor.enableReadOnlyMode(this.$options[this.editorUUID]);
Expand Down Expand Up @@ -234,6 +235,27 @@ export default {
return string
},

syncDataOnSourceEditing() {
const editor = this.$options[this.editorName]
const sourceEditing = editor.plugins.get('SourceEditing')


sourceEditing.on('change:isSourceEditingMode', (_eventInfo, _name, value) => {
if (value) {
const sourceEditingTextarea = editor.editing.view.getDomRoot()?.nextSibling?.firstChild

if (!sourceEditingTextarea) {
throw new Error('This should not be possible')
}


sourceEditingTextarea.addEventListener('input', debounce(() => {
sourceEditing.updateEditorData()
}, 500))
}
})
},

fill(formData) {
if (this.currentlyIsVisible) {
formData.append(this.currentField.attribute, this.value || '')
Expand Down