Re: [w3c/editing] Should contenteditable=plaintext-only be standardized? (#162)

@samuelgozi We are now part of a new Working Group which no longer allows us to have documents here that do not yet have implementation insurances from browser makers in our main repository. We are now only allowed to have these sit in pull requests. For this reason, everything was removed in this pull request: https://github.com/w3c/contentEditable/commit/ae454fc84c784cd507a1e2f9a226d01f7ac519d4

The document before that PR still represents the current state of the discussion though, so if we can get implementation commitments, we may put them back some time in the future.

The existence of plaintext-only has been moved to the HTML spec. It does not specify anything about its behavior though.

@edgarascom What you describe sounds like something we wanted to enable with input events in combination with really any of the contenteditable states. Unfortunately also those were only half-implemented. As I said, I am not sure if we can get browser makers to agree on specific behavior for plaintext-only, because that would then mean that they would also need to change how their development tools work. But maybe it is possible. 

In the meantime, what you can do given the current state of things, if you need to write an editor right now, is to use a contenteditable element like this:

* Use a schema system and keep a copy of the document that is being edited in JavaScript.

* Translate that document to HTML and put that HTML as the innerHTML of the contenteditable element.

* With every user initated change to the contents of the contenteditable element, translate the current HTML of that element back to the format that you have the document stored in Javascript in.

* Diff the old and the new document, find out what has changed, store that change.

* Translate the new document back to HTML, see if there is any difference to the innerHTML of the contenteditable element, and if that is the case diff and patch the contenteditable element.

Very roughly described, that should get you around all the various bugs and inconsistencies in browsers and it should work even when browsers change. However, I hope you are not planning on writing such an editor as a one-person hobby project during a week or two, as it has proven it takes years to get it right. For most use-cases it is probably currently recommendable to use one of the existing JavaScript libraries and not try to write a contenteditable editor from scratch.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/162#issuecomment-616210379

Received on Sunday, 19 April 2020 19:20:51 UTC