-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text inside editable span wrongly wrapped with <p> #865
Comments
Same behaviour with a plain
which also gets the text wrapped with
Also the layout does not keep position. Before: After: And worse for the spans: Ok, seems to be a browser specific issue. The above is for Chrome Version 46.0.2490.80 (64-bit). Here Safari Version 9.0 (9537.86.1.56.2): And Firefox 41.0.2 seams visually ok: But copies the parent element and leaves one of the copies empty: Before:
After:
So I will get two lines for each word in my final application, because I have
defined in the CSS. |
Using Chrome 46.0.2490.80. This line does it - what is the reason for it? if (MediumEditor.util.isMediumEditorElement(node) && node.children.length === 0) {
this.options.ownerDocument.execCommand('formatBlock', false, 'p');
} It fails to add a paragraph in Firefox though -- either a bug or Firefox feature? |
@forgandenny Commented it out but nothing changes on the wrong behaviour. Chrome version is the same as yours. Don't know what the reason is. I want to edit the text in a span and medium editor should not change the span, only the text in it should change. |
So the browser would be the one splitting/adding/removing these Would there be a problem with using |
Not sure about |
Yes, this is a problem, because the HTML is hOCR, a widespread format produced by OCR programs and many tools supporting it. So a possible work around would be converting to
and then convert back? Tried it, and it doesn't work. Same behaviour. @nmielnik are you sure the browser is the reason? I don't think so. |
The browser will attempt to insert Can you try starting with this html instead? If the class <p>
<span class='word'>The</span>
<span class='word'>quick</span>
</p> |
@nmielnik I tried now nearly every combination. Try yourself:
Then try this:
Without medium-editor it works like a charm. So it's not the browsers problem, it's a bug in medium-editor. The browser (Chrome) only inserts Without medium-editor I can also wrap the words with a span of display:block. Also the navigation with or from word to word works. Seems I should use the plain contenteditable and base my js on this. |
I use this code (in my React app) as a workaround for this bug (it allows for editing inside a non-block element, because in editing mode I don't want it to transform to block-level and take all the space): <span>
<div style={{margin: 0, padding: 0, display: 'inline-block'}} dangerouslySetInnerHTML={{__html: html}}/>
</span> Medium editor is attached to the <span data-medium-focused="true" class="" data-placeholder="Enter text here." medium-editor-index="0" aria-multiline="true" role="textbox" data-medium-editor-element="true" spellcheck="true" data-reactid=".1tjlu9nhreo.1.0.1.0.1.0.2.1.0" contenteditable="true">
test
<div style="margin:0;padding:0;display:inline-block;" data-reactid=".1tjlu9nhreo.1.0.1.0.1.0.2.1.0.0">
</div>
</span> Is it possible to somehow tell the editor to always put new data inside that inner |
Using a single if (inline) {
opts.disableReturn = true;
opts.disableDoubleReturn = true;
}
let props = {className};
if (html) {
props.dangerouslySetInnerHTML = {__html: html};
}
return (
<div style={{margin: 0, padding: 0, display: 'inline-block'}} {...props} />
); , and I don't mind having a |
For proofreading and corrections of OCR output I want to allow only editing on the lowest level of
<span>word</span>
.This is a (very simplified) example of the HTML structure:
Now when I click into one of the words, the text inside the
span
is wrapped with<p>
at the first key stroke and looks like this:Tried hard, but could not find a configuration option, work-around or the location in the source code causing this.
I would expect to keep the HTML elements as they are if valid HTML. Also wrapping with an element without some class like e.g. 'medium-created' does not give me the chance to overrule the CSS with
display: inline;
So the lines are split into paragraphs for each word, when I want to navigate from one editable word to the next with the TAB key. That destroys the WYSIWYG.The text was updated successfully, but these errors were encountered: