kzEditor
引用名:kzEditor
示例代码:
define(['kzEditor'],function(Editor){
console.log(Editor)
});
kzEditor 构造函数
参数:{$toolsPanel,$viewPanel,$configuratorPanel}
参数说明:
$toolsPanel: 工具窗口jquery dom 对象
$viewPanel: 预览窗口jquery dom 对象
$configuratorPanel: 配置窗口jquery dom 对象
示例代码:
define(['kzEditor','jquery'],function(Editor,$){
var editor = new Editor({
$toolsPanel:$("#toolsPanel"),
$viewPanel:$("#viewPanel"),
$configuratorPanel:$("#configuratorPanel")
});
console.log(editor);
});
kzEditor.prototype
function init(components)
参数说明:
components: 格式化的组件Array
返回:undefined
说明: 通过组件数据构建预览窗口组件。
function $getCurEl()
返回:object 当前选中的组件dom对象
说明:获取当前选中的组件dom
function setAsCurrentComponent($el)
参数说明:
$el:组件外层jquery dom 对象
返回:undefined
说明:设置一个包含了组件信息的jquery dom 为当前选中组件。
function blurAllComponent()
返回:undefined
说明:失焦所有组件
function clearComponents()
返回:undefined
说明:清除预览窗口内的数据
function addComponent(meta, data, placeholder, $parentComponentEl, opts)
参数说明:
meta:组件的配置数据,(即编写组件时的package.json文件以及editing.js文件数据)
data:组件数据,(即将组件拖入到预览窗口后产生的数据,这部分数据由用户产生)
targetEl:临时占位dom对象,在拖入预览窗口时,会有一个占位dom对象,如果没有,可传 null
$parentComponentEl:父组件dom对象,当组件添加至一个容器组件内部时使用
opts:添加的组件的控制项,具体如下:
{
configurable: true,/*是否可配置*/
deletable: true,/*是否可以删除*/
movable: true /*是否可移动*/
}
function insertComponent(meta, data, opts)
说明:在当前选中的组件后插入组件,注意 当没有选中组件时,执行将会返回错误信息,不会插入组件
参数说明:
meta:组件的配置数据,(即编写组件时的package.json文件以及editing.js文件数据)
data:组件数据,(即将组件拖入到预览窗口后产生的数据,这部分数据由用户产生)
opts:添加的组件的控制项,具体如下:
{
configurable: true,/*是否可配置*/
deletable: true,/*是否可以删除*/
movable: true /*是否可移动*/
}
function insertBeforeComponent(meta, data, opts)
说明:在当前选中的组件前插入组件,注意 当没有选中组件时,执行将会返回错误信息,不会插入组件
参数说明:
meta:组件的配置数据,(即编写组件时的package.json文件以及editing.js文件数据)
data:组件数据,(即将组件拖入到预览窗口后产生的数据,这部分数据由用户产生)
opts:添加的组件的控制项,具体如下:
{
configurable: true,/*是否可配置*/
deletable: true,/*是否可以删除*/
movable: true /*是否可移动*/
}
function eachComponent(fn)
参数说明:
fn:处理每一个组件数据的函数回调,回调函数的参数为 component
说明:使用回调函数处理当前页面内所有组件(不包括容器组件内的子组件)。
示例代码:
editor.eachComponent(function(component){
console.log(component)
})
function eachComponentIncludeSub(fn)
参数说明:
fn:处理每一个组件数据的函数回调,回调函数的参数为 component
说明:使用回调函数处理当前页面内所有组件(包括容器组件内的子组件)。
示例代码:
editor.eachComponentIncludeSub(function(component){
console.log(component)
})
function isValid()
返回:true|false|array()
说明:调用每个组件的 isValid 方法,验证组件数据是否正确,如果正确返回true,如果组件返回具体错误信息,就将错误信息push到数组中返回输入,如果有错但未返回具体错误,返回false
function getData()
返回:array()
说明:返回页面内组件的数据
--
function addPlugIn()
返回: undefined
说明:为编辑器添加插件.
