本文整理汇总了TypeScript中@ephox/alloy.AlloyEvents.derive方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AlloyEvents.derive方法的具体用法?TypeScript AlloyEvents.derive怎么用?TypeScript AlloyEvents.derive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/alloy.AlloyEvents
的用法示例。
在下文中一共展示了AlloyEvents.derive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const sketch = function (editor): SketchSpec {
const pickerDom = {
tag: 'input',
attributes: { accept: 'image/*', type: 'file', title: '' },
// Visibility hidden so that it cannot be seen, and position absolute so that it doesn't
// disrupt the layout
styles: { visibility: 'hidden', position: 'absolute' }
};
const memPicker = Memento.record({
dom: pickerDom,
events: AlloyEvents.derive([
// Stop the event firing again at the button level
AlloyEvents.cutter(NativeEvents.click()),
AlloyEvents.run(NativeEvents.change(), function (picker, simulatedEvent) {
extractBlob(simulatedEvent).each(function (blob) {
addImage(editor, blob);
});
})
])
});
return Button.sketch({
dom: Buttons.getToolbarIconButton('image', editor),
components: [
memPicker.asSpec()
],
action (button) {
const picker = memPicker.get(button);
// Trigger a dom click for the file input
picker.element().dom().click();
}
});
};
示例2: renderBodyPanel
const checkboxSpec = (() => {
const memBodyPanel = Memento.record(
renderBodyPanel({
items: [
{ type: 'checkbox', name: 'checked', label: 'Checked' },
{ type: 'checkbox', name: 'unchecked', label: 'Unchecked' }
]
}, {
shared: sharedBackstage
})
);
return {
dom: {
tag: 'div'
},
components: [
memBodyPanel.asSpec(),
],
events: AlloyEvents.derive([
AlloyEvents.runOnAttached((component) => {
const body = memBodyPanel.get(component);
Representing.setValue(body, {
checked: true,
unchecked: false
});
})
])
};
})();