本文整理汇总了TypeScript中@ephox/alloy.Attachment.attachSystem方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Attachment.attachSystem方法的具体用法?TypeScript Attachment.attachSystem怎么用?TypeScript Attachment.attachSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/alloy.Attachment
的用法示例。
在下文中一共展示了Attachment.attachSystem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: show
const render = () => {
if (floatContainer) {
show();
return;
}
floatContainer = uiComponents.outerContainer;
const uiContainer = getUiContainer(editor);
Attachment.attachSystem(uiContainer, uiComponents.mothership);
Attachment.attachSystem(uiContainer, uiComponents.uiMothership);
OuterContainer.setToolbar(
uiComponents.outerContainer,
identifyButtons(editor, rawUiConfig, {backstage}, Option.none())
);
OuterContainer.setMenubar(
uiComponents.outerContainer,
identifyMenus(editor, rawUiConfig)
);
if (!useFixedToolbarContainer) {
// Do not set position if using fixed_toolbar_container
Css.set(floatContainer.element(), 'position', 'absolute');
}
// Initialise the toolbar - set initial positioning then show
updateChromeUi();
show();
editor.on('NodeChange ResizeWindow', updateChromeUi);
editor.on('activate', show);
editor.on('deactivate', hide);
editor.nodeChanged();
};
示例2: 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
};
};
示例3: 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);
}
示例4: 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);
}
示例5: function
UnitTest.asynctest('Browser Test: ui.FontSizeSliderTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const detection = PlatformDetection.detect();
const realm = IosRealm(Fun.noop);
// Make toolbar appear
Class.add(realm.system().element(), 'tinymce-mobile-fullscreen-maximized');
const body = Body.body();
Attachment.attachSystem(body, realm.system());
TestStyles.addStyles();
const unload = function () {
TestStyles.removeStyles();
Attachment.detachSystem(realm.system());
};
const tEditor = TestFrameEditor();
realm.system().add(tEditor.component());
realm.setToolbarGroups([
{
label: 'group1',
items: [
FontSizeSlider.sketch(realm, tEditor.editor())
]
}
]);
Pipeline.async({}, detection.browser.isChrome() ? [
TestStyles.sWaitForToolstrip(realm),
tEditor.sWaitForEditorLoaded,
Step.sync(function () {
tEditor.editor().focus();
}),
Mouse.sClickOn(realm.system().element(), TestSelectors.fontsize()),
tEditor.sAssertEq('on first showing, the font size slider should not have fired execCommand', [ ])
// Think about how to do the slider events
] : [], function () {
unload(); success();
}, failure);
});
示例6: function
const onload = DomEvent.bind(iframe, 'load', function () {
const head = Element.fromDom(iframe.dom().contentWindow.document.head);
const body = Element.fromDom(iframe.dom().contentWindow.document.body);
Attachment.attachSystem(body, realm.system());
Css.set(body, 'margin', '0px');
const css = Element.fromTag('link');
Attr.setAll(css, {
href: '/project/tinymce/js/tinymce/skins/ui/oxide/skin.mobile.min.css',
rel: 'Stylesheet',
type: 'text/css'
});
Insert.append(head, css);
onload.unbind();
const editor = Element.fromTag('iframe');
Attr.set(editor, 'src', '/project/tinymce/src/themes/mobile/test/html/editor.html');
Replacing.append(
realm.system().getByDom(Element.fromDom(
realm.element().dom().querySelector('.tinymce-mobile-editor-socket'))
).getOrDie(),
GuiFactory.external({
element: editor
})
);
realm.init({
editor: {
getFrame () {
return editor;
},
onDomChanged () {
return { unbind: Fun.noop };
}
},
container: realm.element(),
socket: Element.fromDom(realm.element().dom().querySelector('.tinymce-mobile-editor-socket')),
toolstrip: Element.fromDom(realm.element().dom().querySelector('.tinymce-mobile-toolstrip')),
toolbar: Element.fromDom(realm.element().dom().querySelector('.tinymce-mobile-toolbar')),
alloy: realm.system(),
dropup: realm.dropup()
});
});
示例7: 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);
}
示例8: 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);
});
};
示例9: function
UnitTest.asynctest('Browser Test: ui.SerialisedLinkTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const detection = PlatformDetection.detect();
const realm = IosRealm();
// Make toolbar appear
Class.add(realm.system().element(), 'tinymce-mobile-fullscreen-maximized');
const body = Body.body();
Attachment.attachSystem(body, realm.system());
const doc = Traverse.owner(body);
TestStyles.addStyles();
const unload = function () {
TestStyles.removeStyles();
Attachment.detachSystem(realm.system());
};
const tEditor = TestEditor();
realm.setToolbarGroups([
{
label: 'group1',
items: [
LinkButton.sketch(realm, tEditor.editor())
]
}
]);
const sAssertNavigation = function (label, prevEnabled, nextEnabled) {
return Logger.t(
label,
Step.sync(function () {
const active = Focus.active().getOrDie();
// The buttons are next and previous siblings
const prev = Traverse.parent(active).bind(Traverse.prevSibling).getOrDie('Could not find button to left');
const next = Traverse.parent(active).bind(Traverse.nextSibling).getOrDie('Could not find button to right');
const assertNavButton = function (buttonLabel, expected, button) {
Assertions.assertStructure(
'Checking ' + buttonLabel + ' button should be enabled = ' + expected,
ApproxStructure.build(function (s, str, arr) {
return s.element('span', {
attr: {
role: str.is('button')
},
classes: [
(expected ? arr.not : arr.has)('tinymce-mobile-toolbar-navigation-disabled')
]
});
}),
button
);
};
assertNavButton('previous', prevEnabled, prev);
assertNavButton('next', nextEnabled, next);
})
);
};
const sClickNavigation = function (selector) {
return Chain.asStep({ }, [
TestUi.cGetFocused,
TestUi.cGetParent,
TestUi.cGetParent,
UiFinder.cFindIn(selector),
Mouse.cClick
]);
};
const sClickPrev = sClickNavigation('.tinymce-mobile-icon-previous');
const sClickNext = sClickNavigation('.tinymce-mobile-icon-next');
const sAssertUrlFocused = GeneralSteps.sequence([
FocusTools.sTryOnSelector('Focus should be on input with link URL', doc, 'input[placeholder="Type or paste URL"]'),
sAssertNavigation('Checking initial navigation on text node', false, true)
]);
const sAssertTextFocused = GeneralSteps.sequence([
FocusTools.sTryOnSelector('Focus should be on input with link text', doc, 'input[placeholder="Link text"]'),
sAssertNavigation('Checking navigation for link text', true, true)
]);
const sAssertTitleFocused = GeneralSteps.sequence([
FocusTools.sTryOnSelector('Focus should be on input with link title', doc, 'input[placeholder="Link title"]'),
sAssertNavigation('Checking navigation for link title', true, true)
]);
const sAssertTargetFocused = GeneralSteps.sequence([
FocusTools.sTryOnSelector('Focus should be on input with link target', doc, 'input[placeholder="Link target"]'),
sAssertNavigation('Checking navigation for link target', true, false)
]);
const sTestNavigation = GeneralSteps.sequence([
Keyboard.sKeydown(doc, Keys.tab(), { }),
sAssertTextFocused,
//.........这里部分代码省略.........
示例10: function
const renderUI = function (args) {
const cssUrls = CssUrls.derive(editor);
if (Settings.isSkinDisabled(editor) === false) {
editor.contentCSS.push(cssUrls.content);
DOMUtils.DOM.styleSheetLoader.load(cssUrls.ui, SkinLoaded.fireSkinLoaded(editor));
} else {
SkinLoaded.fireSkinLoaded(editor)();
}
const doScrollIntoView = function () {
editor.fire('scrollIntoView');
};
const wrapper = Element.fromTag('div');
const realm = PlatformDetection.detect().os.isAndroid() ? AndroidRealm(doScrollIntoView) : IosRealm(doScrollIntoView);
const original = Element.fromDom(args.targetNode);
Insert.after(original, wrapper);
Attachment.attachSystem(wrapper, realm.system());
const findFocusIn = function (elem) {
return Focus.search(elem).bind(function (focused) {
return realm.system().getByDom(focused).toOption();
});
};
const outerWindow = args.targetNode.ownerDocument.defaultView;
const orientation = Orientation.onChange(outerWindow, {
onChange () {
const alloy = realm.system();
alloy.broadcastOn([ TinyChannels.orientationChanged() ], { width: Orientation.getActualWidth(outerWindow) });
},
onReady: Fun.noop
});
const setReadOnly = function (readOnlyGroups, mainGroups, ro) {
if (ro === false) {
editor.selection.collapse();
}
realm.setToolbarGroups(ro ? readOnlyGroups.get() : mainGroups.get());
editor.setMode(ro === true ? 'readonly' : 'design');
editor.fire(ro === true ? READING() : EDITING());
realm.updateMode(ro);
};
const bindHandler = function (label, handler) {
editor.on(label, handler);
return {
unbind () {
editor.off(label);
}
};
};
editor.on('init', function () {
realm.init({
editor: {
getFrame () {
return Element.fromDom(editor.contentAreaContainer.querySelector('iframe'));
},
onDomChanged () {
return {
unbind: Fun.noop
};
},
onToReading (handler) {
return bindHandler(READING(), handler);
},
onToEditing (handler) {
return bindHandler(EDITING(), handler);
},
onScrollToCursor (handler) {
editor.on('scrollIntoView', function (tinyEvent) {
handler(tinyEvent);
});
const unbind = function () {
editor.off('scrollIntoView');
orientation.destroy();
};
return {
unbind
};
},
onTouchToolstrip () {
hideDropup();
},
onTouchContent () {
const toolbar = Element.fromDom(editor.editorContainer.querySelector('.' + Styles.resolve('toolbar')));
// If something in the toolbar had focus, fire an execute on it (execute on tap away)
// Perhaps it will be clearer later what is a better way of doing this.
findFocusIn(toolbar).each(AlloyTriggers.emitExecute);
realm.restoreToolbar();
hideDropup();
//.........这里部分代码省略.........