更新: 在 TinyMCE 论坛上发帖之后< /a> (在提供赏金之前我应该做的事情)主要问题可能会得到解决,但我仍然对有关如何禁用可调整大小的行为的其他问题持非常开放的态度(数字2 和 3 位于帖子末尾)。
我在 IE8(不是其他版本)中使用 TinyMCE 保存内容时遇到问题。在 IE 中,编辑器中的某些元素在每个角都有手柄和可拖动的“边框”,当您聚焦开始编辑时,可能会出现条纹边框:
问题:
如果我在粗边框仍然可见时提交表单(图像中的状态 3),则表单将不会保存内容。我必须单击编辑器的另一个区域以使所有边框消失,然后提交表单。
我正在使用 TinyMCE 3.4.6 jQuery 包,在其他浏览器中没有出现此行为。
更新:
我已经缩小了问题的原因,并发现了一些事情:
我创建了一个实时 简单的演示,其内容如下:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">
$(function() {
$('textarea.tinymce').tinymce({
script_url : 'tiny_mce/tiny_mce.js',
content_css : 'test.css'
});
});
</script>
<form action="" method="post">
<textarea class="tinymce" name="content"><p>Testing</p></textarea>
<button type="submit">Submit</button>
</form>
/* Content of test.css */
p {
min-height: 24px; /* this line makes the handles appear */
background-color: #f00;
color: #fff;
}
如何重现:
- 打开IE8 中的演示
- 单击现有段落,应该会出现一个 1px 的小边框,并且您应该无法编辑文本。
- 再次单击该元素,现在会出现粗边框并且可以编辑文本。
- 输入几个字符,然后单击提交按钮。更新不会与
$_POST
数据一起发送。如果您单击编辑器内的另一个区域,删除粗边框,数据将正常发送。
疑问/问题:
-
重要:如何让表单发布编辑后的文本而不需要用户采取解决方法?
更新:这似乎在最近提交中得到解决< /a> 来自 TinyMCE 首席开发人员。我仍然无法在真正的 IE8 安装上进行测试,但这有效并消除了 IETester 中的错误。
-
不太重要:有什么方法可以完全防止或删除手柄和可拖动边缘吗?我猜这是 IE 的 contentEditable
实现的问题,而不是 TinyMCE,甚至可能不是问题的原因。
- 额外:如何防止这些句柄延伸到编辑器之外?
Update: After posting on the TinyMCE forum (something I should have done before offering the bounty) the primary issue may be solved, but I'm still very much open to anything regarding the other issues of how to disable the resizable behavior (number 2 and 3 at the end of the post).
I am having trouble saving content with TinyMCE in IE8 (not other versions). In IE, certain elements in the editor have handles in each corner and draggable "borders", and when you focus in to start editing, a striped border may appear:
Problem:
If I submit the form while the thick border is still visible (state 3 in the image), the form will not save the content. I have to click into another area of the editor to make all the borders disappear, and then submit the form.
I'm Using the TinyMCE 3.4.6 jQuery package, I don't get this behavior in other browsers.
Update:
I've narrowed down the cause of the issue quite a bit and found a few things:
- The problem occurs with or without the jQuery build, and does not depend on which tinymce plugins are in use.
- The thicker "border" only seems to appear when there is a (min-)height/width applied to the element, either declared inline or from external CSS.
-
Using IETester, I was getting errors that claim 'length' is null or not an object
when focus from the active element is lost; i.e. when you click anywhere outside the TinyMCE editor.
I did not see this error in a true IE8 install (something I currently can not access), however: this makes sense somewhat, considering the problem and workaround stated above. I had to hit submit twice and dismiss the warnings to get the form to post in IETester.
- These borders and handles will actually extend outside of the editor/iframe:
I created a live bare-bones demo, here is the content of it:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">
$(function() {
$('textarea.tinymce').tinymce({
script_url : 'tiny_mce/tiny_mce.js',
content_css : 'test.css'
});
});
</script>
<form action="" method="post">
<textarea class="tinymce" name="content"><p>Testing</p></textarea>
<button type="submit">Submit</button>
</form>
/* Content of test.css */
p {
min-height: 24px; /* this line makes the handles appear */
background-color: #f00;
color: #fff;
}
How to reproduce:
- Open the demo in IE8
- Click on the existing paragraph, a small 1px border should appear, and you should be unable to edit the text.
- Click on the element again, now the thick border appears and text can be edited.
- Type a few characters, then click the submit button. The update will not be sent with the
$_POST
data. If you were to click another area inside the editor, removing the thick border, the data would be sent normally.
Questions/Issues:
-
Important: How can I get the form to post the edited text without requiring a workaround from the user?
Update: This seems to be resolved in a recent commit from the TinyMCE lead developer. I still have been unable to test on a real IE8 install, but this worked and silenced the errors in IETester.
-
Less important: Is there any way to prevent or remove the handles and draggable edges completely? I'm guessing this is a concern with IE's implementation of contentEditable
and not so much TinyMCE, and may not even be the cause of the problem.
- Extra: How can I prevent these handles from extending outside the editor?
发布评论
评论(4)
问题 2 是由于 IE 实现了 contentEditable,这是他们连接站点上的一张票,请求修复它 https://connect.microsoft.com/IE/feedback/details/576043/paragraphs-with-haslayout-behave-like-a-block-inside-contenteditable(需要登录)
我不知道问题3有什么解决办法,除了等待新的IE。在 windows8 下的最新 IE10 中,他们声称已修复 https://connect.microsoft.com/IE/feedback/details/576040/resizing-handles-in-contenteditable-elements-are-placed-over-any-other-element (需要登录),但他们的解决方案是始终隐藏调整大小手柄。好吧,有一个解决方案,它是避免在编辑时使用任何强制 IE 的内部 hasLayout 标志的样式
Question 2 is due to the IE implementation of contentEditable, This is a ticket at their connect site requesting to fix it https://connect.microsoft.com/IE/feedback/details/576043/paragraphs-with-haslayout-behave-like-a-block-inside-contenteditable (login required)
I don't know of any solution for Question 3, except to wait for a new IE. In the latest IE10 under windows8 they claim that it's fixed https://connect.microsoft.com/IE/feedback/details/576040/resizing-handles-in-contenteditable-elements-are-placed-over-any-other-element (login required), but their solution is to hide the resizing handles always. Well, there's a solution and it's to avoid using any style while you're editing that forces the internal hasLayout flag for IE
好吧,这是一个奇怪的 IE8 错误。我已经找到了解决方法,但 tinymce 团队仍然应该解决这个问题。
我发现在提交表单之前,您可以将文本区域的内容设置为文本区域的内容...听起来很奇怪,但调用
.html()
会触发一个tinymce 事件,该事件返回正确的html。alright this is a weird IE8 bug. I've found a workaround but still the tinymce team should fix this.
I've found out that before submitting the form you could set the content of the textarea to the content of the textarea... Sounds weird but calling the
.html()
triggers a tinymce event that returns the correct html.显然没有办法解决第二个问题。
这里有一篇文章对此进行了很好的解释:除非删除使它们出现的属性,否则您无法删除它们。
http://www.satzansatz.de/cssd/onhavinglayout.html
(搜索单词“remove”)
您仍然可以通过在容器(具有 contenteditable 的元素)上使用它来改进一点:(
您的元素不必是 div)
onmousedown 只允许您单击一次即可进入可以书写的状态。
onresizestart 将阻止调整大小。
There is apparently no way you can fix the second issue.
Here is an articles that explains it quite well: You can't remove those unless you remove the property that made them appear.
http://www.satzansatz.de/cssd/onhavinglayout.html
(search for the word "remove")
You can still improve a bit by using this on the container (the element with contenteditable):
(Your element doesn't have to be a div)
The onmousedown will allow you to click only once to get to the state where you can write.
The onresizestart will prevent resizing.
如果你给它 hasLayout ,它应该可以工作。尝试缩放:1;
if you give it hasLayout, it should work. try zoom:1;