GithubHelp home page GithubHelp logo

Very slow with large text about ckeditor5-vue HOT 14 CLOSED

ropel avatar ropel commented on June 24, 2024
Very slow with large text

from ckeditor5-vue.

Comments (14)

awmartin avatar awmartin commented on June 24, 2024 2

I just encountered this issue today in Vue.js. I get a half- to full-second delay while typing, making for a frustrating staccato, stop-and-go experience. Is there a mitigation for this, perhaps not using CKEditor as a Vue component and just loading it as a pure native build?

from ckeditor5-vue.

Reinmar avatar Reinmar commented on June 24, 2024 1

Something like – isBusy? :D If it solves some issues, then it sounds fine to me.

from ckeditor5-vue.

Mgsy avatar Mgsy commented on June 24, 2024

I can confirm it. I've just loaded 800 paragraphs as initial editor content and the editor became incredibly slow. It doesn't happen in CKEditor 5 without Vue integration.

@oleq, could you take a look at this one?

from ckeditor5-vue.

oleq avatar oleq commented on June 24, 2024

I confirm the issue. The culprit is this listener

editor.model.document.on( 'change:data', evt => {
const data = editor.getData();
// The compatibility with the v-model and general Vue.js concept of input–like components.
this.$emit( 'input', data, evt, editor );
} );
. When there's a lot of data, it takes a lot of time to emit the event. It's getData that makes it slow. We should probably debounce it.

image

from ckeditor5-vue.

Reinmar avatar Reinmar commented on June 24, 2024

Dunno how it works in Vue, so sorry for a potentially stupid question – can the content be retrieved only on demand? Or does Vue implement a sort of two-way-binding so it can't?

BTW, I'd consider something like:

this.$emit( 'input', () => editor.getData(), evt, editor ); 

So, instead of passing data directly in the input event, we'd allow someone to retrieve it if needed. Although, if the consumer would actually read it on every input that would change nothing.

Sorry again if I'm missing the point :D For two-way data binding debouncing seems reasonable.

from ckeditor5-vue.

oleq avatar oleq commented on June 24, 2024

@Reinmar I'm afraid it is impossible. 2-way data binding depends on actual data and there's no way to do things on demand. However, in the PR I managed to reduce the number of setData() and getData() calls with some caching, which significantly improved the performance.

In the second step, I'm gonna investigate a possibility of debouncing. Stay tuned.

from ckeditor5-vue.

oleq avatar oleq commented on June 24, 2024

I updated the PR with a debounced #input event. Any feedback appreciated.

from ckeditor5-vue.

AndrewMast avatar AndrewMast commented on June 24, 2024

It would be nice to know if the editor is currently being "debounced" so a form submission can be delayed. Maybe setting a variable "typing" to true? Or at least setting a "maxWait"...

from ckeditor5-vue.

Reinmar avatar Reinmar commented on June 24, 2024

BTW, perhaps we could use the PendingActions plugin? It's mentioned in https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/saving-data.html#autosave-feature and could help here too.

from ckeditor5-vue.

Reinmar avatar Reinmar commented on June 24, 2024

@awmartin could you open a new ticket (and cc me there)? I suppose that there must be an option to disable the two-way data binding or a smarter debounce mechanism (e.g. similar to the one used by autosave).

Also, a related ticket in CKEditor 5 itself: ckeditor/ckeditor5#5812.

from ckeditor5-vue.

szohaib avatar szohaib commented on June 24, 2024

Can anyone share some update on this please?

from ckeditor5-vue.

danefondo avatar danefondo commented on June 24, 2024

What about @ready="onReady" --> onReady(editor) { const data = editor.getData() } and skip the v-model? Possibly tying it to various events through editor.editing.view.document.on("event", (evt, data) => {})

from ckeditor5-vue.

awmartin avatar awmartin commented on June 24, 2024

I forgot to open another ticket. :-(

For context, I use a doc with about 6000 words and a lot of paragraphs and list items to test. The delay is typically 600-700ms when it appears. I think the performance of getData is largely correlated to the number of top-level elements.

To bypass the v-model pattern and remove the hesitation, I had to remove the change:data event here and remove the modelValue watcher. The performance returned, and I just handled saving documents manually. You don't get any Vue.js data binding though.

The other approach I tried was just increasing the debounce interval to 3000ms. It seemed to be okay except for a couple of hiccups, which I couldn't quite track down.

from ckeditor5-vue.

rolexta avatar rolexta commented on June 24, 2024

still very slow on document editor

from ckeditor5-vue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.