本文整理汇总了TypeScript中@ephox/alloy.AlloySpec类的典型用法代码示例。如果您正苦于以下问题:TypeScript AlloySpec类的具体用法?TypeScript AlloySpec怎么用?TypeScript AlloySpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AlloySpec类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: renderTitle
const renderModalHeader = (foo: WindowHeaderFoo, providersBackstage: UiFactoryBackstageProviders): AlloySpec => {
const pTitle = ModalDialog.parts().title(
renderTitle(foo, Option.none(), providersBackstage)
);
const pHandle = ModalDialog.parts().draghandle({
dom: DomFactory.fromHtml('<div class="tox-dialog__draghandle"></div>')
});
const pClose = ModalDialog.parts().close(
renderClose(providersBackstage)
);
const components = [ pTitle ].concat(foo.draggable ? [ pHandle ] : []).concat([ pClose ]);
return Container.sketch({
dom: DomFactory.fromHtml('<div class="tox-dialog__header"></div>'),
components
});
};
开发者ID:tinymce,项目名称:tinymce,代码行数:19,代码来源:SilverDialogHeader.ts
示例2: renderContextToolbar
const register = (editor: Editor, registryContextToolbars, sink, extras) => {
const contextbar = GuiFactory.build(
renderContextToolbar({
sink,
onEscape: () => {
editor.focus();
return Option.some(true);
}
})
);
const getBoxElement = () => Option.some(Element.fromDom(editor.contentAreaContainer));
editor.on('init', () => {
const scroller = editor.getBody().ownerDocument.defaultView;
// FIX: make a lot nicer.
const onScroll = DomEvent.bind(Element.fromDom(scroller), 'scroll', () => {
lastAnchor.get().each((anchor) => {
const elem = lastElement.get().getOr(editor.selection.getNode());
const nodeBounds = elem.getBoundingClientRect();
const contentAreaBounds = editor.contentAreaContainer.getBoundingClientRect();
const aboveEditor = nodeBounds.bottom < 0;
const belowEditor = nodeBounds.top > contentAreaBounds.height;
if (aboveEditor || belowEditor) {
Css.set(contextbar.element(), 'display', 'none');
} else {
Css.remove(contextbar.element(), 'display');
Positioning.positionWithin(sink, anchor, contextbar, getBoxElement());
}
});
});
editor.on('remove', () => {
onScroll.unbind();
});
});
const lastAnchor = Cell(Option.none());
const lastElement = Cell<Option<DomElement>>(Option.none<DomElement>());
const timer = Cell(null);
const wrapInPopDialog = (toolbarSpec: AlloySpec) => {
return {
dom: {
tag: 'div',
classes: ['tox-pop__dialog'],
},
components: [toolbarSpec],
behaviours: Behaviour.derive([
Keying.config({
mode: 'acyclic'
}),
AddEventsBehaviour.config('pop-dialog-wrap-events', [
AlloyEvents.runOnAttached((comp) => {
editor.shortcuts.add('ctrl+F9', 'focus statusbar', () => Keying.focusIn(comp));
}),
AlloyEvents.runOnDetached((comp) => {
editor.shortcuts.remove('ctrl+F9');
})
])
])
};
};
const getScopes: () => ScopedToolbars = Thunk.cached(() => {
return ToolbarScopes.categorise(registryContextToolbars, (toolbarApi) => {
const alloySpec = buildToolbar(toolbarApi);
AlloyTriggers.emitWith(contextbar, forwardSlideEvent, {
forwardContents: wrapInPopDialog(alloySpec)
});
});
});
const buildToolbar = (ctx): AlloySpec => {
const { buttons } = editor.ui.registry.getAll();
const scopes = getScopes();
return ctx.type === 'contexttoolbar' ? (() => {
const allButtons = Merger.merge(buttons, scopes.formNavigators);
const initGroups = identifyButtons(editor, { buttons: allButtons, toolbar: ctx.items }, extras, Option.some([ 'form:' ]));
return renderToolbar({
uid: Id.generate('context-toolbar'),
initGroups,
onEscape: Option.none,
cyclicKeying: true,
backstage: extras.backstage,
getSink: () => Result.error('')
});
})() : (() => {
return ContextForm.renderContextForm(ctx, extras.backstage);
})();
};
editor.on(showContextToolbarEvent, (e) => {
const scopes = getScopes();
// TODO: Have this stored in a better structure
Objects.readOptFrom<Toolbar.ContextToolbar | Toolbar.ContextForm>(scopes.lookupTable, e.toolbarKey).each((ctx) => {
launchContext(ctx, e.target === editor ? Option.none() : Option.some(e as DomElement));
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:ContextToolbar.ts
示例3: getItems
//.........这里部分代码省略.........
])),
eventOrder: {
[NativeEvents.input()]: [ 'streaming', 'urlinput-events', 'invalidating' ]
},
model: {
getDisplayText: (itemData) => {
return itemData.value;
},
selectsOver: false,
populateFromBrowse: false
},
markers: {
// FIX:
openClass: 'dog'
},
lazySink: backstage.shared.getSink,
parts: {
menu: MenuParts.part(false, 1, 'normal')
},
onExecute: (_menu, component, _entry) => {
AlloyTriggers.emitWith(component, formSubmitEvent, {});
},
onItemExecute: (typeahead, _sandbox, _item, _value) => {
updateHistory(typeahead);
AlloyTriggers.emitWith(typeahead, formChangeEvent, { name: spec.name });
}
});
const pLabel = spec.label.map((label) => renderLabel(label, providersBackstage)) as Option<AlloySpec>;
// TODO: Consider a way of merging with Checkbox.
const makeIcon = (name, errId: Option<string>, icon = name, label = name) => {
return ({
dom: {
tag: 'div',
classes: ['tox-icon', 'tox-control-wrap__status-icon-' + name],
innerHtml: Icons.get(icon, providersBackstage.icons),
attributes: {
'title': providersBackstage.translate(label),
'aria-live': 'polite',
...errId.fold(() => ({ }), (id) => ({ id }))
}
}
});
};
const memInvalidIcon = Memento.record(
makeIcon('invalid', Option.some(errorId), 'warning')
);
const memStatus = Memento.record({
dom: {
tag: 'div',
classes: ['tox-control-wrap__status-icon-wrap']
},
components: [
// Include the 'valid' and 'unknown' icons here only if they are to be displayed
memInvalidIcon.asSpec()
]
});
开发者ID:tinymce,项目名称:tinymce,代码行数:66,代码来源:UrlInput.ts
示例4: clearTimer
const launchContext = (toolbarApi: Toolbar.ContextToolbar | Toolbar.ContextForm, elem: Option<DomElement>) => {
clearTimer();
const toolbarSpec = buildToolbar(toolbarApi);
const sElem = elem.map(Element.fromDom);
const anchor = getAnchor(toolbarApi.position, sElem);
lastAnchor.set(Option.some((anchor)));
lastElement.set(elem);
InlineView.showWithin(contextbar, anchor, wrapInPopDialog(toolbarSpec), getBoxElement());
Css.remove(contextbar.element(), 'display');
};
开发者ID:tinymce,项目名称:tinymce,代码行数:10,代码来源:ContextToolbar.ts
示例5: renderSpinner
const toggleThrobber = (comp: AlloyComponent, state: boolean, providerBackstage: UiFactoryBackstageProviders) => {
const element = comp.element();
if (state === true) {
Replacing.set(comp, [ renderSpinner(providerBackstage) ]);
Css.remove(element, 'display');
Attr.remove(element, 'aria-hidden');
} else {
Replacing.set(comp, [ ]);
Css.set(element, 'display', 'none');
Attr.set(element, 'aria-hidden', 'true');
}
};
开发者ID:tinymce,项目名称:tinymce,代码行数:12,代码来源:Throbber.ts
示例6: renderBody
const renderModalBody = (foo: WindowBodyFoo, backstage: UiFactoryBackstage) => {
const bodySpec = renderBody(foo, Option.none(), backstage, false);
return ModalDialog.parts().body(
bodySpec
);
};
开发者ID:tinymce,项目名称:tinymce,代码行数:6,代码来源:SilverDialogBody.ts
注:本文中的@ephox/alloy.AlloySpec类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论