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

EditContext.text should not extend by default #104

Open
mozesstumpf opened this issue Jul 23, 2024 · 1 comment
Open

EditContext.text should not extend by default #104

mozesstumpf opened this issue Jul 23, 2024 · 1 comment

Comments

@mozesstumpf
Copy link

mozesstumpf commented Jul 23, 2024

As far as I know, the EditContext.text is mainly designed for text editors that use the canvas element or choose the "hidden text area" solution. This may be a good fit for them, but that's not always the case.

There are text editors that rely on solutions like Virtual DOM or Custom Elements, and in that case, the text property is unused.

With the current implementation, the text property expands itself, assuming that we would use it. However, when we are not using it, we have to clear it to avoid using extra memory.

editContext.addEventListener("textupdate", () => {
    // Clear the text to avoid unnecessary memory usage
    editContext.updateText(0, editContext.text.length, "");
});

My suggestion is to change the behavior of the text somehow to not expand by default.

@marijnh
Copy link

marijnh commented Aug 22, 2024

I assume that this text is going to be used by the IME system (to provide context-aware virtual keyboard behavior, for example), and that keeping it empty is a bad idea. But it would be useful to get some more specifics on how much context should be kept in it and what the cost model of keeping a large document in the context is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants