Skip to content

Commit

Permalink
Merge pull request #115 from mostafaznv/dev
Browse files Browse the repository at this point in the history
feat: update editor data in source-editing mode
  • Loading branch information
mostafaznv authored Feb 29, 2024
2 parents 6ed45d8 + fd77edb commit ddc3677
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
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

0 comments on commit ddc3677

Please sign in to comment.