javascript 如何设置和锁定CKEditor窗口大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11504826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 13:26:41  来源:igfitidea点击:

How to set and lock the CKEditor window size?

javascripthtmlckeditor

提问by Suzan Cioc

CKEditor creates a resizable window of some default size. Is it possible to set the window to my desired size and prevent it from being resized?

CKEditor 创建一个默认大小的可调整大小的窗口。是否可以将窗口设置为我想要的大小并防止它被调整大小?

Styles do not work, including explicit style or rows attribute in the textarea tag.

样式不起作用,包括 textarea 标记中的显式样式或行属性。

jQuery also does not work (with it's height function).

jQuery 也不起作用(使用它的高度函数)。

回答by codewaggle

Use these config settings:

使用这些配置设置:

Starting height and width:

起始高度和宽度:

config.height = '111px'; 
config.width = 111;


Is the CkEditor window resizeable:

CkEditor 窗口是否可以调整大小:

config.resize_enabled = false; //false says not resizable


You can let it be resizable, but control the direction (vertical or horizontal) and the minimum and maximum values.

您可以让它调整大小,但要控制方向(垂直或水平)以及最小值和最大值。

config.resize_dir = 'vertical'; //Can use (both, vertical, and horizontal)

Height:

高度:

config.resize_maxHeight = 111;
config.resize_minHeight = 111;

Width:

宽度:

config.resize_maxWidth = 111;
config.resize_minWidth = 111;

The CkEditor API for config settings is here:
CKEDITOR.config API

用于配置设置的 CkEditor API 在这里:
CKEDITOR.config API

It tells you the allowed values and formatting for each setting.

它会告诉您每个设置的允许值和格式。

回答by Reinmar

You can set editor's height and width at start up (only) - there are config options heightand width.

您可以在启动时设置编辑器的高度和宽度(仅) - 有配置选项heightwidth.

See this: CKEditor & JavaScript - Adjust height and width in CKEditor

请参阅:CKEditor & JavaScript - 在 CKEditor 中调整高度和宽度

This one CKEditor 3.0 Heightmay be interesting to if you want to set height (and width maybe too) to a percentage.

如果您想将高度(也可能是宽度)设置为百分比,那么这个CKEditor 3.0 Height可能会很有趣。

UPDATE:

更新:

By coincidence I found today this:

巧合的是,我今天发现了这个:

/**
 * Resizes the editor interface.
 * @param {Number|String} width The new width. It can be an pixels integer or a
 *      CSS size value.
 * @param {Number|String} height The new height. It can be an pixels integer or
 *      a CSS size value.
 * @param {Boolean} [isContentHeight] Indicates that the provided height is to
 *      be applied to the editor contents space, not to the entire editor
 *      interface. Defaults to false.
 * @param {Boolean} [resizeInner] Indicates that the first inner interface
 *      element must receive the size, not the outer element. The default theme
 *      defines the interface inside a pair of span elements
 *      (<span><span>...</span></span>). By default the
 *      first span element receives the sizes. If this parameter is set to
 *      true, the second span is sized instead.
 * @example
 * editor.resize( 900, 300 );
 * @example
 * editor.resize( '100%', 450, true );
 */
CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner )

This means that I wasn't right that editor's size can be set only at start up, however it doesn't add anything to the question as well :).

这意味着我认为编辑器的大小只能在启动时设置是不对的,但是它也不会为问题添加任何内容:)。