问题描述
限时送ChatGPT账号..我正在尝试编写一个自动化(使用黄瓜/水豚/硒)测试,该测试将在 tinymce 框中选择一些文本,单击链接按钮,然后打开链接选择页面.
I'm trying to write an automated (using cucumber/capybara/selenium) test that will select some text in a tinymce box, click the link button, and open the link selection page.
但是链接按钮只有在选择了某些文本时才会变为活动状态...所以第一轮:
But the link button only becomes active when some text is selected...so round one:
tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.dom.select('p')[0]);
这会选择第一段的文本(对我来说已经足够了),但链接框仍处于禁用状态.然后我尝试手动激活它:
This selects the text of the first paragraph (good enough for my purposes) but the link box is still disabled. So then I tried to manually activate it:
tinyMCE.activeEditor.controlManager.setActive('link', true);
这仍然没有启用链接按钮.作为最后的努力,我尝试修改类:
This still didn't enable the link button. As a last ditch effort, I tried to modify the classes:
$("#mce_generic_html_link").removeClass("mceButtonDisabled");
$("#mce_generic_html_link").addClass("mceButtonEnabled");
但这也无济于事.
推荐答案
这解决了我的问题:
tinymce.activeEditor.nodeChanged();
这篇关于TinyMCE 选择文本并使用 javascript 激活链接对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论