kre-form
Version:
本项目由 Angular8+ 编写的表单设计器和表单应用,所有的配置都是 JSON 结构体组成,PC 端是基于 ANT 组件库封装
56 lines (52 loc) • 1.91 kB
JavaScript
/**
* Copyright (c) 2014-2018, CKSource - Frederico Knabben. All rights reserved.
* Licensed under the terms of the MIT License (see LICENSE.md).
*
* Basic sample plugin inserting current date and time into the CKEditor editing area.
*
* Created out of the CKEditor Plugin SDK:
* http://docs.ckeditor.com/ckeditor4/docs/#!/guide/plugin_sdk_intro
*/
// Register the plugin within the editor.
CKEDITOR.plugins.add('i18n', {
// Register the icons. They must match command names.
icons: 'chinese,english',
// The plugin initialization logic goes inside this method.
init: function(editor) {
// Define the editor command that a chinese.
function updateState() {
const i18n = editor.element.getAttribute('data-i18n') || 1;
if (+i18n === 1) editor.getCommand('Chinese').setState(CKEDITOR.TRISTATE_ON);
else editor.getCommand('Chinese').setState(CKEDITOR.TRISTATE_OFF);
if (+i18n === 2) editor.getCommand('English').setState(CKEDITOR.TRISTATE_ON);
else editor.getCommand('English').setState(CKEDITOR.TRISTATE_OFF);
editor.fire('i18n',i18n)
}
editor.addCommand('Chinese', {
// Define the function that will be fired when the command is executed.
exec: function(editor) {
editor.element.setAttribute('data-i18n', 1);
updateState();
},
});
editor.addCommand('English', {
// Define the function that will be fired when the command is executed.
exec: function(editor) {
editor.element.setAttribute('data-i18n', 2);
updateState();
},
});
// Create the toolbar button that executes the above command.
editor.ui.addButton('Chinese', {
label: 'Chinese',
command: 'Chinese',
toolbar: 'insert',
});
editor.ui.addButton('English', {
label: 'English',
command: 'English',
toolbar: 'insert',
});
updateState();
},
});