本文整理汇总了TypeScript中@ephox/alloy.AlloyEvents.runOnAttached方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AlloyEvents.runOnAttached方法的具体用法?TypeScript AlloyEvents.runOnAttached怎么用?TypeScript AlloyEvents.runOnAttached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/alloy.AlloyEvents
的用法示例。
在下文中一共展示了AlloyEvents.runOnAttached方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: deriveMenuMovement
export const createMenuFrom = (partialMenu: Partial<MenuTypes.MenuSpec>, columns: number | 'auto', focusMode: FocusMode, presets: Types.PresetTypes): MenuTypes.MenuSpec => {
const focusManager = focusMode === FocusMode.ContentFocus ? FocusManagers.highlights() : FocusManagers.dom();
const movement = deriveMenuMovement(columns, presets);
const menuMarkers = getMenuMarkers(presets);
return {
dom: partialMenu.dom,
components: partialMenu.components,
items: partialMenu.items,
value: partialMenu.value,
markers: {
selectedItem: menuMarkers.selectedItem,
item: menuMarkers.item
},
movement,
fakeFocus: focusMode === FocusMode.ContentFocus,
focusManager,
menuBehaviours: SimpleBehaviours.unnamedEvents(columns !== 'auto' ? [ ] : [
AlloyEvents.runOnAttached((comp, se) => {
detectSize(comp, 4, menuMarkers.item).each(({ numColumns, numRows }) => {
Keying.setGridSize(comp, numRows, numColumns);
});
})
])
};
};
示例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
});
})
])
};
})();
示例3: createPartialChoiceMenu
}).map((items) => {
return Option.from(createTieredDataFrom(
Merger.deepMerge(
createPartialChoiceMenu(
Id.generate('menu-value'),
items,
(value) => {
spec.onItemAction(getApi(comp), value);
},
spec.columns,
spec.presets,
ItemResponse.CLOSE_ON_EXECUTE,
spec.select.getOr(() => false),
providersBackstage
),
{
movement: deriveMenuMovement(spec.columns, spec.presets),
menuBehaviours: SimpleBehaviours.unnamedEvents(spec.columns !== 'auto' ? [ ] : [
AlloyEvents.runOnAttached((comp, se) => {
detectSize(comp, 4, classForPreset(spec.presets)).each(({ numRows, numColumns }) => {
Keying.setGridSize(comp, numRows, numColumns);
});
})
])
} as TieredMenuTypes.PartialMenuSpec
)
));
});
示例4: runWithApi
const onControlAttached = <T>(info: OnControlAttachedType<T>, editorOffCell: Cell<OnDestroy<T>>) => {
return AlloyEvents.runOnAttached((comp) => {
const run = runWithApi(info, comp);
run((api) => {
const onDestroy = info.onSetup(api);
if (onDestroy !== null && onDestroy !== undefined) {
editorOffCell.set(onDestroy);
}
});
});
};
示例5: Cell
export const renderCustomEditor = (spec: CustomEditorFoo): SimpleSpec => {
const editorApi = Cell(Option.none());
const memReplaced = Memento.record({
dom: {
tag: spec.tag
}
});
const initialValue = Cell(Option.none());
return {
dom: {
tag: 'div',
classes: [ 'tox-custom-editor' ]
},
behaviours: Behaviour.derive([
AddEventsBehaviour.config('editor-foo-events', [
AlloyEvents.runOnAttached((component) => {
memReplaced.getOpt(component).each((ta) => {
spec.init(ta.element().dom()).then((ea) => {
initialValue.get().each((cvalue) => {
ea.setValue(cvalue);
});
initialValue.set(Option.none());
editorApi.set(Option.some(ea));
});
});
})
]),
Representing.config({
store: {
mode: 'manual',
getValue: () => editorApi.get().fold(
() => initialValue.get().getOr(''),
(ed) => ed.getValue()
),
setValue: (component, value) => {
editorApi.get().fold(
() => {
initialValue.set(Option.some(value));
},
(ed) => ed.setValue(value)
);
}
}
}),
ComposingConfigs.self()
]),
components: [memReplaced.asSpec()]
};
};
示例6: makePanels
const makeSidebar = (panelConfigs: SidebarConfig) => SlotContainer.sketch((parts) => {
return {
dom: {
tag: 'div',
classes: ['tox-sidebar__pane-container'],
},
components: makePanels(parts, panelConfigs),
slotBehaviours: SimpleBehaviours.unnamedEvents([
AlloyEvents.runOnAttached((slotContainer) => SlotContainer.hideAllSlots(slotContainer))
])
};
});
示例7: replaceCountText
export const renderWordCount = (editor: Editor, providersBackstage: UiFactoryBackstageProviders): SimpleSpec => {
const replaceCountText = (comp, count, mode) => Replacing.set(comp, [ GuiFactory.text(providersBackstage.translate(['{0} ' + mode, count[mode]])) ]);
return Button.sketch({
dom: {
// The tag for word count was changed to 'button' as Jaws does not read out spans.
// Word count is just a toggle and changes modes between words and characters.
tag: 'button',
classes: [ 'tox-statusbar__wordcount' ]
},
components: [ ],
buttonBehaviours: Behaviour.derive([
Tabstopping.config({ }),
Replacing.config({ }),
Representing.config({
store: {
mode: 'memory',
initialValue: {
mode: WordCountMode.Words,
count: { words: 0, characters: 0 }
}
}
}),
AddEventsBehaviour.config('wordcount-events', [
AlloyEvents.run(SystemEvents.tapOrClick(), (comp) => {
const currentVal = Representing.getValue(comp);
const newMode = currentVal.mode === WordCountMode.Words ? WordCountMode.Characters : WordCountMode.Words;
Representing.setValue(comp, { mode: newMode, count: currentVal.count });
replaceCountText(comp, currentVal.count, newMode);
}),
AlloyEvents.runOnAttached((comp) => {
editor.on('wordCountUpdate', (e) => {
const { mode } = Representing.getValue(comp);
Representing.setValue(comp, { mode, count: e.wordCount });
replaceCountText(comp, e.wordCount, mode);
});
})
])
]),
eventOrder: {
[SystemEvents.tapOrClick()]: [ 'wordcount-events', 'alloy.base.behaviour' ]
}
});
};
示例8:
const getToolbarbehaviours = (toolbarSpec, modeName, overflowOpt) => {
const onAttached = AlloyEvents.runOnAttached(function (component) {
const groups = Arr.map(toolbarSpec.initGroups, renderToolbarGroup);
AlloyToolbar.setGroups(component, groups);
});
const eventBehaviours = overflowOpt.fold(() => [
onAttached
],
(memOverflow) => [
onAttached,
AlloyEvents.run('alloy.toolbar.toggle', (toolbar, se) => {
toolbarSpec.getSink().toOption().each((sink) => {
memOverflow.getOpt(sink).fold(() => {
// overflow isn't there yet ... so add it, and return the built thing
const builtoverFlow = GuiFactory.build(memOverflow.asSpec());
Attachment.attach(sink, builtoverFlow);
Positioning.position(sink, toolbarSpec.backstage.shared.anchors.toolbarOverflow(), builtoverFlow);
SplitAlloyToolbar.refresh(toolbar);
SplitAlloyToolbar.getMoreButton(toolbar).each(Focusing.focus);
Keying.focusIn(builtoverFlow);
// return builtoverFlow;
}, (builtOverflow) => {
Attachment.detach(builtOverflow);
});
});
})
]
);
return Behaviour.derive([
Keying.config({
// Tabs between groups
mode: modeName,
onEscape: toolbarSpec.onEscape,
selector: '.tox-toolbar__group'
}),
AddEventsBehaviour.config('toolbar-events', eventBehaviours)
]);
};
示例9:
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');
})
])
])
};
};
示例10: interpretInForm
AlloyForm.sketch((parts) => {
return {
dom: {
tag: 'div',
classes: [ 'tox-form' ]
},
components: Arr.map(tab.items, (item) => interpretInForm(parts, item, backstage)),
formBehaviours: Behaviour.derive([
Keying.config({
mode: 'acyclic',
useTabstopAt: Fun.not(NavigableObject.isPseudoStop)
}),
AddEventsBehaviour.config('TabView.form.events', [
AlloyEvents.runOnAttached(setDataOnForm),
AlloyEvents.runOnDetached(updateDataWithForm)
]),
Receiving.config({
channels: Objects.wrapAll([
{
key: SendDataToSectionChannel,
value: {
onReceive: updateDataWithForm
}
},
{
key: SendDataToViewChannel,
value: {
onReceive: setDataOnForm
}
}
])
})
])
};
})