Open fregante opened 1 year ago
My suggestion?
Implement diff mode.
Browser sends editor the metadata (title, url, etc.) and the full text
Every time text changes in either browser or editor, it sends out a message that contains the line numbers from which the change starts, and the line number at which the change stops, and the whole text between those line numbers.
e.g.
Lorem Ipsum
Dolor Sit
Consectetur
Adipiscing Elit
Lorem Ipsum
Dolor Stand
Consectetur
Adipiscing Elit
start: 2
end: 2
Dolor Stand
sing with me, sing for the year,
sing for the laughter and sing for the tear.
sing with me, just for today,
maybe tomorrow the good lord will take you away
dream on, dream on, dream on,
dream until your dreams come true
Lorem Ipsum
Adipiscing Elit
start: 1
end: 3
sing with me, sing for the year,
sing for the laughter and sing for the tear.
sing with me, just for today
maybe tomorrow the good lord will take you away
dream on, dream on, dream on,
dream until your dreams come true
Lorem Ipsum
Lorem Ipsum
Adipiscing Elit
start: 1
end: 6
Lorem Ipsum
start: 2
end: 2
This way, GhostText can work on big files without needing to consume a ton of CPU.
Implement diff mode.
heh I was thinking about that earlier, but that complicates things a lot, because suddenly every message has to be delivered.
The other complication is that a diff algorithm, especially with multiple cursors, still doesn't come free (CPU), and has to be implemented by each editor plugin in different languages. One editor gets this wrong and people lose data and open issues here.
The only way I could do this would be with a standard, simple diffing algorithm available in multiple languages. This would avoid implementation errors and waste of dev time. I'd probably not implement this myself in any case due to the complexity, compared to just dynamic throttling (see the "updates" section in https://github.com/fregante/GhostText/issues/256)
Browser sends editor the metadata (title, url, etc.) and the full text
Totally agree, the current setup is awkward. PR welcome for that (including protocol.md). I suppose it would need to be sent via URL parameter though, which means it's limited in length (32k) and therefore it would need to be skipped when too long.
I'm happy to make changes that are backwards compatible, I already made a couple of improvements this week: https://github.com/fregante/GhostText/commits/main/PROTOCOL.md
Current
Future
EventSource
and HTTP/2 instead of WebSocketlabel
,[title]
,[aria-label]
, etc) to be used as tab title