-
Notifications
You must be signed in to change notification settings - Fork 466
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
accept strings in Automerge.Text.insertAt #326
Comments
@josharian Sorry for the delay. I think this is a good idea, and we can make an API change for this in the 1.0 release. Suggestion: how about we get rid of The rationale for providing a character-wise insertion method is that if an application wants to use a different way of splitting a string into characters (e.g. by Unicode grapheme cluster rather than by code point), it can do so. |
If you do a PR for this, please make it relative to the performance branch, so that it goes in the 1.x release series. |
Is there a good reason to make these separate methods rather than doing something pseudo-polymorphic and checking the input for array / string? |
@pvh Good point, that would be better. So maybe we have a single |
I implemented a pseudo-polymorphic insertAt in #350. |
When multiple characters are inserted atomically (eg in a paste), Prosemirror generates a step with a single insertion string. But Automerge expects us to give it one character at a time, so we need to split the character up ourselves. See for more context: automerge/automerge#326
Add range and values queries
I sometimes have to do bulk inserts into an Automerge.Text, e.g. when importing a new document.
The current API accepts inserts one character at a time:
text.insertAt(0, 'h', 'e', 'l', 'l', 'o')
. Doing this with bulk inserts I've hit the javascript limit on the number of arguments allowed to a function call (65536).I'd like it if insertAt also accepted strings and treated them indistinguishably from individual characters:
text.insertAt(0, 'hello')
(and maybetext.insertAt(0, 'he', 'llo')
, not sure).Or alternatively, a new API that accepted only one single string:
text.insertStringAt(0, 'hello')
.I'm willing to attempt an implementation if you're open to it.
The text was updated successfully, but these errors were encountered: