Giter Site home page Giter Site logo

Realtime editing about rich-markdown-editor HOT 8 CLOSED

outline avatar outline commented on May 22, 2024
Realtime editing

from rich-markdown-editor.

Comments (8)

tommoor avatar tommoor commented on May 22, 2024 2

Wouldn't it be easier to do realtime editing on the underlying markdown value as it's just plain text

I think that would likely come undone once you got into the details - doing OT on the Slate structure would allow keeping selection and cursor positions for example. Considering there is a wider effort in the Slate ecosystem to enable realtime it would be good to participate in that…

from rich-markdown-editor.

tommoor avatar tommoor commented on May 22, 2024 1

@ShiroYacha If you put in a pr that exposes value and updates the editorValue internally when the prop changes I'd be happy to accept.

from rich-markdown-editor.

tommoor avatar tommoor commented on May 22, 2024

The editor isn't designed for this usecase yet, you'd probably need to be able to show other users cursors too at a minimum. As it stands it would be relatively easy to allow though and a welcome improvement πŸ˜„

from rich-markdown-editor.

ShiroYacha avatar ShiroYacha commented on May 22, 2024

In my use-case, there are multiple editors in one screen (actually there might be another issue with the toolbar...) and the user should be able to get realtime update when the value of an editor is changed by another person. Further, if possible I would like to enable collaboration when an editor is in edit mode.

Now I'm doing it using the ref which is a extremly ugly hack... Something like:

    render() {

        if (this.editorRef.current && checkRemoteContent()) {
            const value = MarkdownSerializer.deserialize(this.state.remoteContent);
            this.editorRef.current.setState({ editorValue: value });
        }
        return (<Editor
            ...
            ref={this.editorRef}
            ... />);
    }

In this way, at least the updates will be in real-time, however, I haven't find a way to effectively merge the content of each user so you won't lose the cursor when an update arrives...

Ideally, if the editor exposes the value prop of the editor it would be pretty easy to inject the incoming content. To be more inline with the current structure, we can probably wrap a valueOverride prop that gets deserialized and overrides the editorValue state inside componentWillReceiveProps?

from rich-markdown-editor.

jfrolich avatar jfrolich commented on May 22, 2024

Wouldn't it be easier to do realtime editing on the underlying markdown value as it's just plain text? To me that seems way easier to implement server and client-side than mutations on the complex json document especially when merging different states. Additionally you can use well-known algorithms for this (https://en.wikipedia.org/wiki/Operational_transformation).

from rich-markdown-editor.

jfrolich avatar jfrolich commented on May 22, 2024

BTW if you are interested to contribute this back (or fork), I am really interested in this as well.

from rich-markdown-editor.

ShiroYacha avatar ShiroYacha commented on May 22, 2024

Hey, actually originally I just wanted a way to feed the editor value back from remote. I am not really doing real collaboration editing...The slate editor already has an issue open on this subject and has supported to some level OT check ianstormtaylor/slate#259. I am not sure if it will be easier to operate on markdown text as opposed to the slate objects..

from rich-markdown-editor.

tommoor avatar tommoor commented on May 22, 2024

I'm closing this issue – the editor has been rebuilt to be based on Prosemirror, which makes adding realtime editing much easier through their plugins architecture. However the work to do so will not be included as part of this project.

from rich-markdown-editor.

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.