all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Musings on creating an HTML-based WYSIWYG mode
@ 2018-05-01 14:54 Lars Ingebrigtsen
  2018-05-01 19:00 ` Søren Pilgård
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2018-05-01 14:54 UTC (permalink / raw)
  To: emacs-devel

I'm not going to implement this any time soon, but I wondering how much
work it would be to create a WYSIWYG mode for Emacs based on
round-tripping through shr.

I think most people who have approached this subject before have said
"just use some text properties and store as enriched text and there you
go", but it's just not sufficient: If you're writing a <ol> list, then
you want this to be rendered as it should be, and it should be rendered
as the recipient is likely to read the text.  Otherwise it's not very
WYSIWYG, is it?

So: The serialisation format would be HTML.  Whenever a user types
something, Emacs generates HTML, asks shr to render it, and then present
the user with the results.  This would, of course, potentially be
horrifically slow, but we could envision strategies to only re-render
parts of the buffer/document.

Let's say the user is typing away at something resembling this
paragraph, and then decides to make "typing" bold, so the user would go
back to that work, mark it and issue whatever command there is for "make
this bold".  The mode would do the change to the HTML document, ask shr
to re-render it, and then display the results.

This is, of course, not like what Emacs does normally when editing text,
and would break a lot of invariants that people are used to.  We can
preserve basic things like point and mark easily enough (by inserting
special constructs into the HTML that allows us to find and restore them
after re-generating the buffer), but I'm sure there's oodles of stuff
that will stop working with such a radical approach.  But perhaps that's
OK?

Inserting images and the like into the buffer would be unproblematic --
just add a few new dired commands like "copy image to WYSIWYG clipboard"
and then yank from that "clipboard" into the buffer.  This presents
further interesting questions about the serialisation format...  but we
could, for instance, use MIME for that: multipart/related with the
images stashed as cid: links.

"External" images are simpler, of course.

The WYSIWYG clipboard would also be necessary for when cutting and
yanking text: If you're killing text starting from the middle of a link
and ending up in the middle of an <ol> link, you have to ensure that you
end up with something similar when you yank this mess somewhere else.
And you have to ensure that everything remains valid around where you
killed the region, too.

And then there's always the interesting subject of tables, or rather:
Side-by-side continuous regions.  Making editing commands work in those
circumstances may be, er, interesting...

So here's what I think: I think somebody (i.e., me) should try
implementing this.  I think there are so many unknowns here that it's
difficult to say whether this is a workable way of doing WYSIWYG in
Emacs before you have something semi-working and get a grip on how this
would feel in practice.  

But like I said, I don't have time at the moment.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-05-02 20:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-01 14:54 Musings on creating an HTML-based WYSIWYG mode Lars Ingebrigtsen
2018-05-01 19:00 ` Søren Pilgård
2018-05-01 20:11   ` Lars Ingebrigtsen
2018-05-02  8:16     ` Søren Pilgård
2018-05-02  9:22     ` Joost Kremers
2018-05-02  9:36       ` Van L
2018-05-02  1:45 ` Stefan Monnier
2018-05-02  9:50   ` Lars Ingebrigtsen
2018-05-02 10:36     ` Yuri Khan
2018-05-02 10:43       ` Lars Ingebrigtsen
2018-05-02 10:49         ` Yuri Khan
2018-05-02 20:32   ` Michael Heerdegen
2018-05-02  3:11 ` Richard Stallman
2018-05-02  3:50   ` Van L

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.