Closed laurencedorman closed 9 years ago
Hard to tell without stepping through but best guess would be that you're trying to put a block level element - in this case a <figure>
- inside a <p>
which is not allowed.
Hadn't thought of that - so basically I need to make sure the cursor is actually at the end of a <p>
and not inside it? Does Scribe have any helper functions for that sort of thing?
You should be able to check the position of the scribe markers and that will show you where the selection begins and ends.
In the end I got around it in the following way:
new scribe.api.Selection();
selection.placeMarkers();
scribe.getHTML();
<p>
or </p>
, whichever is closer.figure
HTML.em
.scribe.setHTML();
I'm guessing it's not really what would be recommended, but I can't think of a better way for now. The execCommand
does too much stuff on its own; which leads me to think that I think my problem is with the native API, not Scribe.
Ok, took the time to learn a bit more about how Scribe works and made a much better solution inspired by the Coursera table plugin. Will try and find the time to open source the plugin. Thanks for your help.
@ld0rman I hope you find the time, I would be interesting in seeing your plugin.
Hello, I'm trying to implement a way to insert images into a
contenteditable="true"
div
using Scribe.I place the cursor at what I assume to be the end of a line:
Call the function with the
figure
markup:Result I would expect:
Result I obtain:
I'm not entirely familiar with everything Scribe does at the moment; is this some automatic formatter that's pulling apart the markup?