本文整理汇总了TypeScript中tinymce/ui/Api.registerToFactory函数的典型用法代码示例。如果您正苦于以下问题:TypeScript registerToFactory函数的具体用法?TypeScript registerToFactory怎么用?TypeScript registerToFactory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了registerToFactory函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
UnitTest.asynctest('browser.tinymce.ui.ListBoxtest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
// Registers ui widgets to factory
Api.registerToFactory();
const createListBox = function (settings) {
EventUtils.Event.clean(viewBlock.get());
viewBlock.update('');
return Factory.create(Tools.extend({
type: 'listbox'
}, settings)).renderTo(viewBlock.get()).reflow();
};
suite.test('listbox, size 100x100', function () {
const listBox = createListBox({ values: {title: 'Home', value: '/'}, width: 100, height: 100 });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, listBox), [0, 0, 100, 100], 4);
});
suite.test('listbox, select nested item', function () {
const listBox = createListBox({
values: [
{text: 'Home', value: '/'},
{text: 'Category Level 1', menu: [
{text: 'C1 Page 1', value: '/c1/foo'},
{text: 'C1 Page 2', value: '/c1/bar'},
{text: 'Category Level 2', menu: [
{text: 'C2 Page 1', value: '/c1/c2/foo'},
{text: 'C2 Page 2', value: '/c1/c2/bar'}
]}
]}
]
});
Assertions.assertEq('Should equal the first value', '/', listBox.value());
// Simulate selecting an item by setting a value
listBox.value('/c1/foo');
Assertions.assertEq('Should equal the selected items value', '/c1/foo', listBox.value());
Assertions.assertEq('Should equal the selected items text', 'C1 Page 1', listBox.text());
});
UiUtils.loadSkinAndOverride(viewBlock, function () {
Pipeline.async({}, suite.toSteps({}), function () {
EventUtils.Event.clean(viewBlock.get());
viewBlock.detach();
success();
}, failure);
});
});
示例2: function
UnitTest.asynctest('browser.tinymce.ui.PanelTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
// Registers ui widgets to factory
Api.registerToFactory();
const createPanel = function (settings) {
EventUtils.Event.clean(viewBlock.get());
viewBlock.update('');
return Factory.create(Tools.extend({
type: 'panel'
}, settings)).renderTo(viewBlock.get()).reflow();
};
suite.test('panel width: 100, height: 100', function () {
const panel = createPanel({
width: 100,
height: 100
});
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel), [0, 0, 100, 100], 4);
});
suite.test('panel border: 1, width: 100, height: 100', function () {
const panel = createPanel({
width: 100,
height: 100,
border: 1
});
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel), [0, 0, 100, 100], 4);
});
UiUtils.loadSkinAndOverride(viewBlock, function () {
Pipeline.async({}, suite.toSteps({}), function () {
EventUtils.Event.clean(viewBlock.get());
viewBlock.detach();
success();
}, failure);
});
});
示例3: function
UnitTest.asynctest('browser.tinymce.ui.TextBoxTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
// Registers ui widgets to factory
Api.registerToFactory();
const createTextBox = function (settings) {
return Factory.create(Tools.extend({
type: 'textbox'
}, settings)).renderTo(viewBlock.get()).reflow();
};
const teardown = function () {
EventUtils.Event.clean(viewBlock.get());
viewBlock.update('');
};
suite.test('textbox text, size chars: 5', function () {
const textBox1 = createTextBox({ text: 'X', size: 5 });
const textBox2 = createTextBox({ text: 'X', size: 6 });
LegacyUnit.equal(UiUtils.size(textBox1)[0] < UiUtils.size(textBox2)[0], true);
teardown();
});
suite.test('textbox text, size 100x100', function () {
const textBox = createTextBox({ text: 'X', width: 100, height: 100 });
LegacyUnit.equal(UiUtils.size(textBox), [100, 100]);
teardown();
});
UiUtils.loadSkinAndOverride(viewBlock, function () {
Pipeline.async({}, suite.toSteps({}), function () {
teardown();
viewBlock.detach();
success();
}, failure);
});
});
示例4: function
UnitTest.asynctest('browser.tinymce.ui.AbsoluteLayoutTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
// Registers ui widgets to factory
Api.registerToFactory();
const createPanel = function (settings) {
return Factory.create(Tools.extend({
type: 'panel',
layout: 'absolute',
width: 200,
height: 200
}, settings)).renderTo(viewBlock.get()).reflow();
};
suite.test('spacer x:10, y:20, minWidth: 100, minHeight: 100', function () {
const panel = createPanel({
items: [
{ type: 'spacer', x: 10, y: 20, w: 100, h: 120, classes: 'red' }
]
});
LegacyUnit.deepEqual(UiUtils.rect(viewBlock, panel), [0, 0, 200, 200]);
LegacyUnit.deepEqual(UiUtils.rect(viewBlock, panel.find('spacer')[0]), [10, 20, 100, 120]);
});
UiUtils.loadSkinAndOverride(viewBlock, function () {
Pipeline.async({}, suite.toSteps({}), function () {
EventUtils.Event.clean(viewBlock.get());
viewBlock.detach();
success();
}, failure);
});
});
示例5: function
UnitTest.asynctest('browser.tinymce.ui.ButtonTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
// Registers ui widgets to factory
Api.registerToFactory();
const createButton = function (settings) {
EventUtils.Event.clean(viewBlock.get());
viewBlock.update('');
return Factory.create(Tools.extend({
type: 'button'
}, settings)).renderTo(viewBlock.get());
};
suite.test('button text, size default', function () {
const button = createButton({ text: 'X' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 27, 30], 4);
});
suite.test('button text, size large', function () {
const button = createButton({ text: 'X', size: 'large' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 40, 38], 5);
});
suite.test('button text, size small', function () {
const button = createButton({ text: 'X', size: 'small' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 19, 23], 4);
});
suite.test('button text, width 100, height 100', function () {
const button = createButton({ text: 'X', width: 100, height: 100 });
LegacyUnit.equal(UiUtils.rect(viewBlock, button), [0, 0, 100, 100]);
LegacyUnit.equal(UiUtils.rect(viewBlock, button.getEl().firstChild), [1, 1, 98, 98]);
});
suite.test('button icon, size default', function () {
const button = createButton({ icon: 'test' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 34, 30], 4);
});
suite.test('button icon, size small', function () {
const button = createButton({ icon: 'test', size: 'small' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 28, 24], 4);
});
suite.test('button icon, size large', function () {
const button = createButton({ icon: 'test', size: 'large' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 44, 40], 4);
});
suite.test('button icon, width 100, height 100', function () {
const button = createButton({ icon: 'test', width: 100, height: 100 });
LegacyUnit.equal(UiUtils.rect(viewBlock, button), [0, 0, 100, 100]);
LegacyUnit.equal(UiUtils.rect(viewBlock, button.getEl().firstChild), [1, 1, 98, 98]);
});
suite.test('button text & icon, size default', function () {
const button = createButton({ text: 'X', icon: 'test' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 47, 30], 4);
});
suite.test('button text & icon, size large', function () {
const button = createButton({ text: 'X', icon: 'test', size: 'large' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 59, 40], 4);
});
suite.test('button text & icon, size small', function () {
const button = createButton({ text: 'X', icon: 'test', size: 'small' });
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, button), [0, 0, 43, 24], 5);
});
suite.test('button text & icon, width 100, height 100', function () {
const button = createButton({ text: 'X', icon: 'test', width: 100, height: 100 });
LegacyUnit.equal(UiUtils.rect(viewBlock, button), [0, 0, 100, 100]);
LegacyUnit.equal(UiUtils.rect(viewBlock, button.getEl().firstChild), [1, 1, 98, 98]);
});
suite.test('button click event', function () {
let button;
const clicks: any = {};
button = createButton({
text: 'X',
onclick () {
//.........这里部分代码省略.........
示例6: function
/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*/
import ThemeManager from 'tinymce/core/api/ThemeManager';
import ThemeApi from './api/ThemeApi';
import Buttons from './ui/Buttons';
import * as Panel from './ui/Panel';
import Api from 'tinymce/ui/Api';
import FormatControls from 'tinymce/ui/FormatControls';
declare let window: any;
Api.registerToFactory();
Api.appendTo(window.tinymce ? window.tinymce : {});
ThemeManager.add('inlite', function (editor) {
const panel = Panel.create();
FormatControls.setup(editor);
Buttons.addToEditor(editor, panel);
return ThemeApi.get(editor, panel);
});
export default function () { }
示例7: function
UnitTest.asynctest('browser.tinymce.ui.TabPanelTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
// Registers ui widgets to factory
Api.registerToFactory();
const createTabPanel = function (settings) {
EventUtils.Event.clean(viewBlock.get());
viewBlock.update('');
return Factory.create(Tools.extend({
type: 'tabpanel',
items: [
{ title: 'a', type: 'spacer', classes: 'red' },
{ title: 'b', type: 'spacer', classes: 'green' },
{ title: 'c', type: 'spacer', classes: 'blue' }
]
}, settings)).renderTo(viewBlock.get()).reflow();
};
suite.test('panel width: 100, height: 100', function () {
const panel = createTabPanel({
width: 100,
height: 100,
layout: 'fit'
});
LegacyUnit.equal(UiUtils.rect(viewBlock, panel), [0, 0, 100, 100]);
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel.items()[0]), [0, 31, 100, 69], 4);
});
suite.test('panel width: 100, height: 100, border: 1', function () {
const panel = createTabPanel({
width: 100,
height: 100,
border: 1,
layout: 'fit'
});
LegacyUnit.equal(UiUtils.rect(viewBlock, panel), [0, 0, 100, 100]);
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel.items()[0]), [0, 31, 100, 69], 4);
});
suite.test('panel width: 100, height: 100, activeTab: 1', function () {
const panel = createTabPanel({
width: 100,
height: 100,
activeTab: 1,
layout: 'fit'
});
LegacyUnit.equal(UiUtils.rect(viewBlock, panel), [0, 0, 100, 100]);
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel.items()[1]), [0, 31, 100, 69], 4);
});
suite.test('panel width: auto, height: auto, mixed sized widgets', function () {
const panel = createTabPanel({
items: [
{ title: 'a', type: 'spacer', classes: 'red', style: 'width: 100px; height: 100px' },
{ title: 'b', type: 'spacer', classes: 'green', style: 'width: 70px; height: 70px' },
{ title: 'c', type: 'spacer', classes: 'blue', style: 'width: 120px; height: 120px' }
]
});
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel), [0, 0, 120, 151], 4);
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel.items()[0]), [0, 31, 120, 120], 4);
panel.activateTab(1);
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel.items()[1]), [0, 31, 120, 120], 4);
panel.activateTab(2);
UiUtils.nearlyEqualRects(UiUtils.rect(viewBlock, panel.items()[2]), [0, 31, 120, 120], 4);
});
suite.test('panel width: auto, height: auto, mixed sized containers', function () {
const panel = createTabPanel({
items: [
{
title: 'a',
type: 'panel',
layout: 'flex',
align: 'stretch',
items: {
type: 'spacer',
classes: 'red',
flex: 1,
minWidth: 100,
minHeight: 100
}
},
{
title: 'b',
type: 'panel',
layout: 'flex',
align: 'stretch',
items: {
//.........这里部分代码省略.........
示例8: function
UnitTest.asynctest('browser.tinymce.ui.ControlTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
Control.translate = function (text) {
return EditorManager.translate(text);
};
// Registers ui widgets to factory
Api.registerToFactory();
suite.test('Initial states', function () {
let ctrl;
ctrl = new Control({});
// Check initial states
LegacyUnit.equal(ctrl.disabled(), false);
LegacyUnit.equal(ctrl.active(), false);
LegacyUnit.equal(ctrl.visible(), true);
LegacyUnit.equal(ctrl.text(), undefined);
LegacyUnit.equal(ctrl.name(), undefined);
LegacyUnit.equal(ctrl.title(), undefined);
LegacyUnit.equal(ctrl.parent(), undefined);
LegacyUnit.equal(ctrl.settings, {});
});
suite.test('Settings', function () {
const ctrl = new Control({
disabled: true,
active: true,
visible: true,
text: 'Text',
title: 'Title',
name: 'Name'
});
// Check settings states
LegacyUnit.equal(ctrl.disabled(), true);
LegacyUnit.equal(ctrl.active(), true);
LegacyUnit.equal(ctrl.visible(), true);
LegacyUnit.equal(ctrl.text(), 'Text');
LegacyUnit.equal(ctrl.name(), 'Name');
LegacyUnit.equal(ctrl.title(), 'Title');
LegacyUnit.equal(ctrl.parent(), undefined);
LegacyUnit.equal(ctrl.settings, {
disabled: true,
active: true,
visible: true,
text: 'Text',
title: 'Title',
name: 'Name'
});
});
suite.test('Properties', function () {
let ctrl, cont;
cont = new Container({});
ctrl = new Control({});
// Set all states
ctrl = ctrl.
disabled(true).
active(true).
visible(true).
text('Text').
title('Title').
name('Name').parent(cont);
// Check states
LegacyUnit.equal(ctrl.disabled(), true);
LegacyUnit.equal(ctrl.active(), true);
LegacyUnit.equal(ctrl.visible(), true);
LegacyUnit.equal(ctrl.text(), 'Text');
LegacyUnit.equal(ctrl.name(), 'Name');
LegacyUnit.equal(ctrl.title(), 'Title');
LegacyUnit.equal(ctrl.parent(), cont);
LegacyUnit.equal(ctrl.settings, {});
});
suite.test('Chained methods', function () {
let ctrl = new Control({});
// Set all states
ctrl = ctrl.
on('click', function () { }).
off().
renderTo(viewBlock.get()).
remove();
// Check so that the chain worked
LegacyUnit.equal(ctrl instanceof Control, true);
});
suite.test('Events', function () {
let ctrl, count;
//.........这里部分代码省略.........
示例9: function
UnitTest.asynctest('browser.tinymce.ui.ButtonTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
let panel;
// Registers ui widgets to factory
Api.registerToFactory();
const createPanel = function () {
panel = Factory.create({
type: 'panel',
items: [
{ type: 'button', name: 'button1', text: 'button1', classes: 'class1', disabled: true },
{ type: 'button', name: 'button2', classes: 'class1 class2' },
{ type: 'button', name: 'button3', classes: 'class2 class1 class3' },
{
type: 'buttongroup', name: 'buttongroup1', items: [
{ type: 'button', name: 'button4' },
{ type: 'button', name: 'button5' },
{ type: 'button', name: 'button6' }
]
},
{
type: 'buttongroup', name: 'buttongroup2', items: [
{ type: 'button', name: 'button7' },
{ type: 'button', name: 'button8' },
{ type: 'button', name: 'button9' }
]
},
{
type: 'toolbar', name: 'toolbar1', items: [
{
type: 'buttongroup', name: 'buttongroup3', items: [
{ type: 'button', name: 'button10', disabled: true },
{ type: 'button', name: 'button11' },
{ type: 'button', name: 'button12', classes: 'class4' }
]
}
]
}
]
}).renderTo(viewBlock.get());
};
suite.test('Constructor', function () {
LegacyUnit.equal(new Collection().length, 0);
LegacyUnit.equal(new Collection(panel.find('button').toArray()).length, 12);
LegacyUnit.equal(new Collection(panel.find('button')).length, 12);
LegacyUnit.equal(new Collection(panel.find('button:first')[0]).length, 1);
LegacyUnit.equal(new Collection(panel.find('button:first')[0])[0].type, 'button');
});
suite.test('add', function () {
const collection = new Collection([panel, panel]);
LegacyUnit.equal(collection.add(panel).length, 3);
LegacyUnit.equal(collection.add([panel, panel]).length, 5);
});
suite.test('set', function () {
const collection = new Collection([panel, panel]);
LegacyUnit.equal(collection.set(panel).length, 1);
LegacyUnit.equal(collection.set([panel, panel]).length, 2);
});
suite.test('filter', function () {
LegacyUnit.equal(panel.find('button').filter('*:first').length, 4);
LegacyUnit.equal(panel.find('button').filter('buttongroup button').length, 9);
LegacyUnit.equal(panel.find('button').filter('*').length, 12);
LegacyUnit.equal(panel.find('button').filter('nomatch').length, 0);
LegacyUnit.equal(panel.find('button').filter(function (ctrl) {
return ctrl.settings.name === 'button7';
}).length, 1);
});
suite.test('slice', function () {
LegacyUnit.equal(panel.find('button').slice(1).length, 11);
LegacyUnit.equal(panel.find('button').slice(1)[0].name(), 'button2');
LegacyUnit.equal(panel.find('button').slice(0, 1).length, 1);
LegacyUnit.equal(panel.find('button').slice(0, 1)[0].name(), 'button1');
LegacyUnit.equal(panel.find('button').slice(-1).length, 1);
LegacyUnit.equal(panel.find('button').slice(-1)[0].name(), 'button12');
LegacyUnit.equal(panel.find('button').slice(-2).length, 2);
LegacyUnit.equal(panel.find('button').slice(-2)[0].name(), 'button11');
LegacyUnit.equal(panel.find('button').slice(-2, -1).length, 1);
LegacyUnit.equal(panel.find('button').slice(-2, -1)[0].name(), 'button11');
LegacyUnit.equal(panel.find('button').slice(1000).length, 0);
LegacyUnit.equal(panel.find('button').slice(-1000).length, 12);
});
//.........这里部分代码省略.........
示例10: function
UnitTest.asynctest('browser.tinymce.ui.FitLayoutTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const viewBlock = ViewBlock();
// Registers ui widgets to factory
Api.registerToFactory();
const createFitPanel = function (settings) {
EventUtils.Event.clean(viewBlock.get());
viewBlock.update('');
return Factory.create(Tools.extend({
type: 'panel',
layout: 'fit',
width: 200,
height: 200,
border: 1
}, settings)).renderTo(viewBlock.get()).reflow();
};
suite.test('fit with spacer inside', function () {
const panel = createFitPanel({
items: [
{ type: 'spacer', classes: 'red' }
]
});
LegacyUnit.equal(UiUtils.rect(viewBlock, panel), [0, 0, 200, 200]);
LegacyUnit.equal(UiUtils.rect(viewBlock, panel.find('spacer')[0]), [1, 1, 198, 198]);
});
suite.test('fit with padding and spacer inside', function () {
const panel = createFitPanel({
padding: 3,
items: [
{ type: 'spacer', classes: 'red' }
]
});
LegacyUnit.equal(UiUtils.rect(viewBlock, panel), [0, 0, 200, 200]);
LegacyUnit.equal(UiUtils.rect(viewBlock, panel.find('spacer')[0]), [4, 4, 192, 192]);
});
suite.test('fit with panel inside', function () {
const panel = createFitPanel({
items: [
{ type: 'panel', border: 1 }
]
});
LegacyUnit.equal(UiUtils.rect(viewBlock, panel), [0, 0, 200, 200]);
LegacyUnit.equal(UiUtils.rect(viewBlock, panel.find('panel')[0]), [1, 1, 198, 198]);
});
UiUtils.loadSkinAndOverride(viewBlock, function () {
Pipeline.async({}, suite.toSteps({}), function () {
EventUtils.Event.clean(viewBlock.get());
viewBlock.detach();
success();
}, failure);
});
});