contenteditable

Detect if browser supports contentEditable?

倾然丶 夕夏残阳落幕 提交于 2020-01-22 15:16:12
问题 There's this question, but the solution posted is browser sniffing, which I'm trying to avoid. I need to make my website compatible with the iPad and perhaps newer Androids. I've been using an old version of the FCKEditor (now CK Editor) for my WYSIWYG editors, but that doesn't work on mobile, so I want to swap it out for a simple textarea with something like markdown, if it's not supported. Supposedly it won't work because mobile devices tend not to support this contentEditable property,

contenteditable=false in contenteditable=true

牧云@^-^@ 提交于 2020-01-22 14:30:10
问题 Problem: I have observed an undesirable behaviour in Chrome and Opera that occurs when one joins two p tags by deleting the separation between them. Chrome and Opera delete contenteditable=false element(widget) and text after. Example: example on jsfiddle html: <div contenteditable="true" class="editor"> <p>This is the first paragraph.</p> <p>←Place your cursor here and press backspace. <span class="widget" contenteditable="false">widget</span> Text after widget</p> </div> css: .widget{

contenteditable=false in contenteditable=true

允我心安 提交于 2020-01-22 14:29:39
问题 Problem: I have observed an undesirable behaviour in Chrome and Opera that occurs when one joins two p tags by deleting the separation between them. Chrome and Opera delete contenteditable=false element(widget) and text after. Example: example on jsfiddle html: <div contenteditable="true" class="editor"> <p>This is the first paragraph.</p> <p>←Place your cursor here and press backspace. <span class="widget" contenteditable="false">widget</span> Text after widget</p> </div> css: .widget{

contentEditable on nodes in a XML/compound document?

杀马特。学长 韩版系。学妹 提交于 2020-01-22 02:24:46
问题 I have an XML document that I'm displaying in a web browser, with a stylesheet attached: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml-stylesheet type="text/css" href="abc.css"?> <myxml xmlns:xhtml="http://www.w3.org/1999/xhtml"> <para>I wish i was editable</para> <xhtml:script type="text/javascript" src="abc.js"/> </myxml> With the xhtml namespace declaration, and xhtml:script tag, I can execute javascript. What I'd like to do is to make arbitrary non-XHTML elements in this

internet explorer alternative to document.execCommand(“insertText”,…), for text insertion that can be undone/redone by the user

南笙酒味 提交于 2020-01-20 04:36:46
问题 When the user edits a contenteditable div , and press some keys, I would like to override the default behavior. For instance, I want to insert a normal line break when the user press ENTER. I do that using document.execCommand("insertText",...) This is the only way I have found so far to make this action undoable and redoable by the user. <div id="editor" contenteditable="true" style="white-space:pre-wrap"> Some text.... </div> <script> $("#editor").keydown(function(evt){ console.log(evt

Removing resize handlers on contentEditable div

本小妞迷上赌 提交于 2020-01-19 10:06:30
问题 I created a contentEditable div to use as a rich textarea. It has resize handlers around it that I'd like to get rid of. Any idea how I'd do this? Edit: This appears to be happening because I am absolutely positioning the div, so Firefox adds an infuriating _moz_resize attribute to the element which I cannot turn off. 回答1: Just as a side note, you can disable Firefox's automatic resize handle feature by sending the (somewhat poorly-documented) enableObjectResizing command to the document:

Removing resize handlers on contentEditable div

╄→гoц情女王★ 提交于 2020-01-19 10:06:26
问题 I created a contentEditable div to use as a rich textarea. It has resize handlers around it that I'd like to get rid of. Any idea how I'd do this? Edit: This appears to be happening because I am absolutely positioning the div, so Firefox adds an infuriating _moz_resize attribute to the element which I cannot turn off. 回答1: Just as a side note, you can disable Firefox's automatic resize handle feature by sending the (somewhat poorly-documented) enableObjectResizing command to the document:

How can I prevent a sticky footer + content editable div from having overlapping content

假如想象 提交于 2020-01-17 06:10:31
问题 So I have a jsfiddle describing a contenteditable div with a sticky footer area representing: https://jsfiddle.net/xd5p1h7u/ CSS .textarea { background: white; padding: 20px; min-height: 20px; width: 100%; } .footer { height: 20px; position: sticky; bottom: 0; background: blue; } HTML <div class="textarea" contenteditable="true"></div> <div class="footer"></div> If you type until you get to the bottom of the screen, you'll notice that the sticky footer covers up the bottom content. I've tried

Preserve at least one P element inside contenteditable

…衆ロ難τιáo~ 提交于 2020-01-17 06:05:00
问题 I have a contenteditable with a <p> element inside it like the following <div class="editable" contenteditable="true"> <p> dummy content here !!!!! </p> </div> When I click backspace on the keybord until it remove all the text, if I click the backspace again it removes also the <p> element ! In my case I would like to keep at least one <p> element there $(document).on('keydown', '[contenteditable=true]', function(e){ var contenteditable = $(this) if(e.keyCode == 8){ // if backspace var p =

Preserve at least one P element inside contenteditable

牧云@^-^@ 提交于 2020-01-17 06:04:32
问题 I have a contenteditable with a <p> element inside it like the following <div class="editable" contenteditable="true"> <p> dummy content here !!!!! </p> </div> When I click backspace on the keybord until it remove all the text, if I click the backspace again it removes also the <p> element ! In my case I would like to keep at least one <p> element there $(document).on('keydown', '[contenteditable=true]', function(e){ var contenteditable = $(this) if(e.keyCode == 8){ // if backspace var p =