本文整理匯總了TypeScript中@ephox/alloy.Gui類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Gui類的具體用法?TypeScript Gui怎麽用?TypeScript Gui使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Gui類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: default
export default () => {
const oldSink = document.querySelectorAll('.mce-silver-sink');
if (oldSink.length > 0) {
throw Error('old sinks found, a previous test did not call helpers.destroy() leaving artifacts, found: ' + oldSink.length);
}
const sink = GuiFactory.build({
dom: DomFactory.fromHtml('<div class="mce-silver-sink"></div>'),
behaviours: Behaviour.derive([
Positioning.config({
useFixed: true
})
])
});
const uiMothership = Gui.create();
Class.add(uiMothership.element(), 'tox');
const backstage = TestBackstage(sink);
const mockEditor = {
setContent: (content) => {},
insertContent: (content: string, args?: any) => {},
execCommand: (cmd: string, ui?: boolean, value?: any) => {}
} as Editor;
const extras = {
editor: mockEditor,
backstage
};
uiMothership.add(sink);
Attachment.attachSystem(Body.body(), uiMothership);
const destroy = () => {
uiMothership.remove(sink);
uiMothership.destroy();
};
return {
backstage,
shared: backstage.shared,
extras,
destroy,
uiMothership,
mockEditor
};
};
示例2: function
export default function () {
const ephoxUi = SelectorFind.first('#ephox-ui').getOrDie();
const fontSlider = Container.sketch({
dom: UiDomFactory.dom('<div class="${prefix}-toolbar ${prefix}-context-toolbar"></div>'),
components: [
{
dom: UiDomFactory.dom('<div class="${prefix}-toolbar-group"></div>'),
components: FontSizeSlider.makeItems({
onChange: Fun.noop,
getInitialValue: Fun.constant(2)
})
}
]
});
const colorSlider = Container.sketch({
dom: UiDomFactory.dom('<div class="${prefix}-toolbar ${prefix}-context-toolbar"></div>'),
components: [
{
dom: UiDomFactory.dom('<div class="${prefix}-toolbar-group"></div>'),
components: ColorSlider.makeItems({
onChange: Fun.noop,
getInitialValue: Fun.constant(-1)
})
}
]
});
const gui = Gui.create();
Attachment.attachSystem(ephoxUi, gui);
const container = GuiFactory.build({
dom: UiDomFactory.dom('<div class="{prefix}-outer-container ${prefix}-fullscreen-maximized"></div>'),
components: [
{
dom: UiDomFactory.dom('<div class="${prefix}-toolstrip"></div>'),
components: [ fontSlider ]
},
{
dom: UiDomFactory.dom('<div class="${prefix}-toolstrip"></div>'),
components: [ colorSlider ]
}
]
});
gui.add(container);
}
示例3: function
export default function () {
const ephoxUi = SelectorFind.first('#ephox-ui').getOrDie();
const form = SerialisedDialog.sketch({
onExecute () { },
getInitialValue () {
return Option.some({
alpha: 'Alpha',
beta: '',
gamma: '',
delta: ''
});
},
fields: [
Inputs.field('alpha', 'placeholder-alpha'),
Inputs.field('beta', 'placeholder-beta'),
Inputs.field('gamma', 'placeholder-gamma'),
Inputs.field('delta', 'placeholder-delta')
]
});
const gui = Gui.create();
Attachment.attachSystem(ephoxUi, gui);
const container = GuiFactory.build({
dom: UiDomFactory.dom('<div class="${prefix}-outer-container ${prefix}-fullscreen-maximized"></div>'),
components: [
{
dom: UiDomFactory.dom('<div class="${prefix}-toolstrip"></div>'),
components: [
{
dom: UiDomFactory.dom('<div class="${prefix}-toolbar ${prefix}-context-toolbar"></div>'),
components: [
{
dom: UiDomFactory.dom('<div class="${prefix}-toolbar-group"></div>'),
components: [
form
]
}
]
}
]
}
]
});
gui.add(container);
}
示例4: function
export default function (spec) {
const root = GuiFactory.build(
Container.sketch({
dom: {
classes: [ Styles.resolve('outer-container') ].concat(spec.classes)
},
containerBehaviours: Behaviour.derive([
Swapping.config({
alpha: READ_ONLY_MODE_CLASS(),
omega: EDIT_MODE_CLASS()
})
])
})
);
return Gui.takeover(root);
}
示例5: function
export default function () {
const ephoxUi = SelectorFind.first('#ephox-ui').getOrDie();
const menu = StylesMenu.sketch({
formats: {
menus: {
Beta: [
{ title: 'Beta-1', isSelected: Fun.constant(false), getPreview: Fun.constant('') },
{ title: 'Beta-2', isSelected: Fun.constant(false), getPreview: Fun.constant('') },
{ title: 'Beta-3', isSelected: Fun.constant(false), getPreview: Fun.constant('') }
]
},
expansions: {
Beta: 'Beta'
},
items: [
{ title: 'Alpha', isSelected: Fun.constant(false), getPreview: Fun.constant('') },
{ title: 'Beta', isSelected: Fun.constant(false), getPreview: Fun.constant('') },
{ title: 'Gamma', isSelected: Fun.constant(true), getPreview: Fun.constant('') }
]
},
handle (format) {
// tslint:disable-next-line:no-console
console.log('firing', format);
}
});
const gui = Gui.create();
Attachment.attachSystem(ephoxUi, gui);
const container = GuiFactory.build({
dom: UiDomFactory.dom('<div class="${prefix}-outer-container ${prefix}-fullscreen-maximized"></div>'),
components: [
{
dom: UiDomFactory.dom('<div class="${prefix}-dropup" style="height: 500px;"></div>'),
components: [
menu
]
}
]
});
gui.add(container);
}
示例6: function
const setup = function (createComponent, f, success, failure) {
const store = TestStore();
const gui = Gui.create();
const doc = Element.fromDom(document);
const body = Element.fromDom(document.body);
Attachment.attachSystem(body, gui);
const component = createComponent(store, doc, body);
gui.add(component);
Pipeline.async({}, f(doc, body, gui, component, store), function () {
Attachment.detachSystem(gui);
success();
}, function (e) {
console.error(e);
failure(e);
});
};
示例7: onEscape
const setup = (editor: Editor): RenderInfo => {
const isInline = editor.getParam('inline', false, 'boolean');
const mode = isInline ? Inline : Iframe;
let lazyOuterContainer: Option<AlloyComponent> = Option.none();
const dirAttributes = I18n.isRtl() ? {
attributes: {
dir: 'rtl'
}
} : {};
const sink = GuiFactory.build({
dom: {
tag: 'div',
classes: ['tox', 'tox-silver-sink', 'tox-tinymce-aux'],
...dirAttributes
},
behaviours: Behaviour.derive([
Positioning.config({
useFixed: false // this allows menus to scroll with the outer page, we don't want position: fixed
})
])
});
const memAnchorBar = Memento.record({
dom: {
tag: 'div',
classes: [ 'tox-anchorbar']
}
});
const lazyAnchorBar = () => lazyOuterContainer.bind((container) => {
return memAnchorBar.getOpt(container);
}).getOrDie('Could not find a anchor bar element');
const lazyMoreButton = () => lazyOuterContainer.bind((container) => {
return OuterContainer.getMoreButton(container);
}).getOrDie('Could not find more button element');
const lazyToolbar = () => lazyOuterContainer.bind((container) => {
return OuterContainer.getToolbar(container);
}).getOrDie('Could not find more toolbar element');
const lazyThrobber = () => lazyOuterContainer.bind((container) => {
return OuterContainer.getThrobber(container);
}).getOrDie('Could not find throbber element');
const backstage: Backstage.UiFactoryBackstage = Backstage.init(sink, editor, lazyAnchorBar, lazyMoreButton);
const lazySink = () => Result.value<AlloyComponent, Error>(sink);
const partMenubar: AlloySpec = OuterContainer.parts().menubar({
dom: {
tag: 'div',
classes: [ 'tox-menubar' ]
},
backstage,
onEscape () {
editor.focus();
}
});
const partToolbar: AlloySpec = OuterContainer.parts().toolbar({
dom: {
tag: 'div',
classes: [ 'tox-toolbar' ]
},
getSink: lazySink,
backstage,
onEscape() {
editor.focus();
},
split: getToolbarDrawer(editor),
lazyToolbar,
lazyMoreButton
});
const partSocket: AlloySpec = OuterContainer.parts().socket({
dom: {
tag: 'div',
classes: [ 'tox-edit-area' ]
}
});
const partSidebar: AlloySpec = OuterContainer.parts().sidebar({
dom: {
tag: 'div',
classes: ['tox-sidebar']
}
});
const partThrobber: AlloySpec = OuterContainer.parts().throbber({
dom: {
tag: 'div',
classes: ['tox-throbber']
},
backstage
});
const statusbar = editor.getParam('statusbar', true, 'boolean') && !isInline ? Option.some(renderStatusbar(editor, backstage.shared.providers)) : Option.none();
//.........這裏部分代碼省略.........
示例8: function
const setup = function (info, onSuccess, onFailure) {
/* This test is going to create a toolbar with both list items on it */
const alloy = Gui.create();
Attachment.attachSystem(info.container, alloy);
const toolbar = GuiFactory.build({
dom: {
tag: 'div',
classes: [ 'test-toolbar' ]
},
behaviours: Behaviour.derive([
Replacing.config({ })
])
});
const socket = GuiFactory.build({
dom: {
tag: 'div',
classes: [ 'test-socket' ]
}
});
alloy.add(toolbar);
alloy.add(socket);
const realm = {
system: Fun.constant(alloy),
socket: Fun.constant(socket)
};
ThemeManager.add(name, function (editor) {
return {
renderUI (args) {
editor.fire('SkinLoaded');
return {
iframeContainer: socket.element().dom(),
editorContainer: alloy.element().dom()
};
}
};
});
return {
use (f) {
TinyLoader.setup(function (editor, onS, onF) {
const features = Features.setup(realm, editor);
FormatChangers.init(realm, editor);
const apis = TinyApis(editor);
const buttons = { };
Arr.each(info.items, function (item) {
// For each item in the toolbar, make a lookup
buttons[item] = Memento.record(features[item].sketch());
});
const toolbarItems = Arr.map(info.items, function (item) {
return buttons[item].asSpec();
});
Replacing.set(toolbar, toolbarItems);
f(realm, apis, toolbar, socket, buttons, onS, onF);
}, {
theme: name
}, onSuccess, onFailure);
}
};
};