ckeditor javascript 文档包装器

发布于 2024-11-26 19:17:56 字数 482 浏览 1 评论 0原文

在寻找用于导航编辑器文本区域元素的代码时,我找到了以下答案。该代码有效,唯一的问题是我不明白为什么。

var documentWrapper = editorname.document; //replace by your CKEDitor instance ID 
var documentNode = documentWrapper.$; // or documentWrapper['$'] ; 

答案是从以下 stackOverflow 链接中获得的:

/stackoverflow.com/questions/2178449/ckeditor-scrollintoview-to-a-div-element-within-the-editor">ckeditor rollIntoView 到编辑器中的 特别有人可以向我解释语法 documentWrapper.$;

我不知道这意味着什么??

谢谢

I found the following answer when looking for code to navigate the editors text area elements.. The code works, the onlyu problem is i dont understand why..

var documentWrapper = editorname.document; //replace by your CKEDitor instance ID 
var documentNode = documentWrapper.$; // or documentWrapper['

The answer was got from the folloing stackOverflow link :

ckeditor scrollIntoView to a div element within the editor

In particular could someone explain to me the syntax documentWrapper.$;

Ive no idea what this means??

Thanks

] ;

The answer was got from the folloing stackOverflow link :

ckeditor scrollIntoView to a div element within the editor

In particular could someone explain to me the syntax documentWrapper.$;

Ive no idea what this means??

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三月梨花 2024-12-03 19:17:56

@oggiemc

“$”代表 CKEDITOR 类对象指向的实际 DOM 对象。
在本例中,您正在使用“CKEDITOR.dom.document”类。在这里找到文档:
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom .document.html

名为“documentWrapper”的对象是一个 CKEDITOR 对象。它将具有 CKEDITOR API 文档中针对该类对象描述的任何属性。您还可以对其使用 CKEDITOR 方法。

当您使用“documentWrapper.$”时,您正在使用文档对象模型规范中描述的 DOM 对象。请参阅此处的规格:
http://www.w3.org/TR/ 2004/REC-DOM-Level-3-Core-20040407/

该对象将具有 DOM 规范中为此对象类型描述的属性。您不会对此对象使用 CKEDITOR 方法,您将使用该对象类型的 DOM 规范中描述的方法。

因此,“$”是 CKEDITOR 类对象所指向的 DOM 对象(文档、头、正文、div、span、p 等)的通用表示。

documentWrapper.someFunction();将在 CKEDITOR 类对象上使用 CKEDITOR 方法。
documentWrapper.$.someFunction();将在 DOM 对象上使用 DOM 方法。

@oggiemc

The "$" represents the actual DOM object that the CKEDITOR class object is pointing to.
In this case you're working with the "CKEDITOR.dom.document" class. Find the documentaion here:
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.dom.document.html

Your object named "documentWrapper" is a CKEDITOR object. It would have any properties described in the CKEDITOR API docs for that class object. You would also use CKEDITOR methods on it.

When you work with "documentWrapper.$", you're working with a DOM object that's described in the Document Object Model Specifications. See Specs here:
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/

This object will have the properties described for this object type in the DOM specs. You wouldn't use CKEDITOR methods on this object, you would use the methods described in the DOM specs for this object type.

So the "$" is a generic representaion of whichever DOM object (document, head, body, div, span, p, etc.) the CKEDITOR class object is pointing to.

documentWrapper.someFunction(); would use a CKEDITOR method on a CKEDITOR class object.
documentWrapper.$.someFunction(); would use a DOM method on a DOM object.

Joe

南烟 2024-12-03 19:17:56

作为参数传递给插件/对话框的编辑器与 getParentEditor() 返回的编辑器之间的区别。

它们通常是同一个对象。但是,如果一页上有多个编辑器实例,则需要使用 getParentEditor 来确保使用正确的编辑器实例。

特别是如果多个编辑器共享一个工具栏:How Do I Get Multiple CKEditor Instances to Share the Same Toolbar?
http://docs.cksource.com/CKEditor_3.x/Howto/Shared_Toolbar

您可以查看 CKEditor 目录中对话框单选按钮的代码:
ckeditor\_source\plugins\forms\dialogs\radio.js

或者在文档网站上:
http://docs.cksource.com/ckeditor_api/symbols/src/plugins_forms_dialogs_radio .js.html


当插件加载时,它使用活动编辑器实例加载标题和标签的文本,因为它们将是对于共享工具栏的所有实例都相同:

ckeditor_source\plugins\forms\dialogs\radio.js(5):
CKEDITOR.dialog.add( 'radio', function( editor )

(42) label : editor.lang.checkboxAndRadio.radioTitle,
(43) title : editor.lang.checkboxAndRadio.radioTitle,


但是对于对话框中使用的方法,它使用 getParentEditor(),以便操作将在正确的编辑器实例上执行:
ckeditor_source\plugins\forms\dialogs\radio.js(30):
编辑器 = this.getParentEditor();

(22) onOk : function() ........ editor = this.getParentEditor();

Difference between editor passed as argument to plugins/dialogs and editor returned by getParentEditor().

They would usually be the same object. But if you have multiple editor instances on one page, you need to use getParentEditor to make sure you're working with the correct editor instance.

Especially if multiple editors are sharing one toobar: How Do I Get Multiple CKEditor Instances to Share the Same Toolbar?
http://docs.cksource.com/CKEditor_3.x/Howto/Shared_Toolbar

You can take a look at the code for dialog radio buttons in the CKEditor directory:
ckeditor\_source\plugins\forms\dialogs\radio.js

Or on the docs site:
http://docs.cksource.com/ckeditor_api/symbols/src/plugins_forms_dialogs_radio.js.html


When the plugin is loaded it uses the active editor instance to load the text for the title and labels because they will be the same for all the instances sharing the toolbar:

ckeditor_source\plugins\forms\dialogs\radio.js(5):
CKEDITOR.dialog.add( 'radio', function( editor )

(42) label : editor.lang.checkboxAndRadio.radioTitle,
(43) title : editor.lang.checkboxAndRadio.radioTitle,


But for the methods used in the dialog, it uses getParentEditor(), so that the actions will be performed on the correct editor instance:
ckeditor_source\plugins\forms\dialogs\radio.js(30):
editor = this.getParentEditor();

(22) onOk : function() ........ editor = this.getParentEditor();

Joe

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文