本文整理汇总了TypeScript中@ephox/boulder.ValueSchema类的典型用法代码示例。如果您正苦于以下问题:TypeScript ValueSchema类的具体用法?TypeScript ValueSchema怎么用?TypeScript ValueSchema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ValueSchema类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
memCollection.getOpt(everything).each((collection) => {
Representing.setValue(collection,
ValueSchema.asRawOrDie('dialogComponentsDemo.collection', Types.Collection.collectionDataProcessor, [
{
value: 'a',
text: 'A',
icon: 'a'
},
{
value: 'b',
text: 'B',
icon: 'b'
},
{
value: 'c',
text: 'C',
icon: 'c'
},
{
value: 'd',
text: 'D',
icon: 'd'
}
])
);
});
示例2: function
const sTestScenario = function (rawScenario) {
const scenario = ValueSchema.asRawOrDie('Checking scenario', ValueSchema.objOf([
FieldSchema.strict('label'),
FieldSchema.defaulted('content', ''),
FieldSchema.defaulted('node', Element.fromText('')),
FieldSchema.strictObjOf('fields', [
FieldSchema.option('url'),
FieldSchema.option('text'),
FieldSchema.option('title'),
FieldSchema.option('target')
]),
FieldSchema.strict('expected'),
FieldSchema.defaulted('beforeExecute', Step.pass),
FieldSchema.defaulted('mutations', Fun.constant(Step.pass))
]), rawScenario);
return Logger.t(
scenario.label,
GeneralSteps.sequence([
tEditor.sPrepareState(scenario.node.dom(), scenario.content),
sClickLink,
TestUi.sSetFieldOptValue(scenario.fields.url),
sClickNext,
sAssertTextFocused,
TestUi.sSetFieldOptValue(scenario.fields.text),
sClickNext,
sAssertTitleFocused,
TestUi.sSetFieldOptValue(scenario.fields.title),
sClickNext,
sAssertTargetFocused,
TestUi.sSetFieldOptValue(scenario.fields.target),
sClickPrev,
sAssertTitleFocused,
sClickPrev,
sAssertTextFocused,
sClickPrev,
sAssertUrlFocused,
scenario.beforeExecute,
Keyboard.sKeydown(doc, Keys.enter(), { }),
tEditor.sAssertEq('Checking insert content', scenario.expected),
scenario.mutations(scenario.node),
tEditor.sClear
])
);
};
示例3: function
const sketch = function (rawSpec) {
const spec = ValueSchema.asRawOrDie('SizeSlider', schema, rawSpec);
const isValidValue = function (valueIndex) {
return valueIndex >= 0 && valueIndex < spec.sizes.length;
};
const onChange = function (slider, thumb, valueIndex) {
if (isValidValue(valueIndex)) {
spec.onChange(valueIndex);
}
};
return Slider.sketch({
dom: {
tag: 'div',
classes: [
Styles.resolve('slider-' + spec.category + '-size-container'),
Styles.resolve('slider'),
Styles.resolve('slider-size-container') ]
},
onChange,
onDragStart (slider, thumb) {
Toggling.on(thumb);
},
onDragEnd (slider, thumb) {
Toggling.off(thumb);
},
min: 0,
max: spec.sizes.length - 1,
stepSize: 1,
getInitialValue: spec.getInitialValue,
snapToGrid: true,
sliderBehaviours: Behaviour.derive([
Receivers.orientation(Slider.refresh)
]),
components: [
Slider.parts().spectrum({
dom: UiDomFactory.dom('<div class="${prefix}-slider-size-container"></div>'),
components: [
UiDomFactory.spec('<div class="${prefix}-slider-size-line"></div>')
]
}),
Slider.parts().thumb({
dom: UiDomFactory.dom('<div class="${prefix}-slider-thumb"></div>'),
behaviours: Behaviour.derive([
Toggling.config({
toggleClass: Styles.resolve('thumb-active')
})
])
})
]
});
};
示例4: function
const checkGetALink = function (rawScenario) {
const schema = ValueSchema.objOfOnly([
FieldSchema.strict('label'),
FieldSchema.defaulted('linkHtml', ''),
FieldSchema.defaulted('selection', ''),
FieldSchema.strict('expected')
]);
const scenario = ValueSchema.asRawOrDie(rawScenario.label, schema, rawScenario);
Logger.sync('getInfo ... ' + scenario.label + ', link: ' + scenario.linkHtml, function () {
editorState.start.set(Element.fromHtml(scenario.linkHtml).dom());
editorState.content.set(scenario.selection);
const info = LinkBridge.getInfo(editor);
RawAssertions.assertEq('Checking getInfo (link)', scenario.expected, Objects.narrow(info, [ 'url', 'text', 'target', 'title' ]));
RawAssertions.assertEq('Checking link is set', true, info.link.isSome());
});
};
示例5:
const specs = Arr.map(Obj.keys(panelConfigs), (name) => {
const spec = panelConfigs[name];
const bridged = ValueSchema.getOrDie(BridgeSidebar.createSidebar(spec));
return {
name,
getApi,
onSetup: bridged.onSetup,
onShow: bridged.onShow,
onHide: bridged.onHide
};
});
示例6: renderToolbarToggleButtonWith
const renderContextToggleButton = (memInput: MementoRecord, button: Toolbar.ContextToggleButton, extras) => {
const { primary, ...rest } = button.original;
const bridged = ValueSchema.getOrDie(
Toolbar.createToggleButton({
...rest,
type: 'togglebutton',
onAction: () => { }
})
);
return renderToolbarToggleButtonWith(bridged, extras.backstage.shared.providers, [
runOnExecute<Toolbar.ToolbarButtonInstanceApi>(memInput, button)
]);
};
示例7:
const memento = (mem: MementoRecord, rawProcessors) => {
const ps = ValueSchema.asRawOrDie('RepresentingConfigs.memento processors', processors, rawProcessors);
return Representing.config({
store: {
mode: 'manual',
getValue: (comp) => {
const other = mem.get(comp);
const rawValue = Representing.getValue(other);
return ps.postprocess(rawValue);
},
setValue: (comp, rawValue) => {
const newValue = ps.preprocess(rawValue);
const other = mem.get(comp);
Representing.setValue(other, newValue);
}
}
});
};
示例8: function
const produce = function (raw) {
const mobile = ValueSchema.asRawOrDie(
'Getting AndroidWebapp schema',
MobileSchema,
raw
);
/* Make the toolbar */
Css.set(mobile.toolstrip, 'width', '100%');
// We do not make the Android container relative, because we aren't positioning the toolbar absolutely.
const onTap = function () {
mobile.setReadOnly(true);
mode.enter();
};
const mask = GuiFactory.build(
TapToEditMask.sketch(onTap, mobile.translate)
);
mobile.alloy.add(mask);
const maskApi = {
show () {
mobile.alloy.add(mask);
},
hide () {
mobile.alloy.remove(mask);
}
};
Insert.append(mobile.container, mask.element());
const mode = AndroidMode.create(mobile, maskApi);
return {
setReadOnly: mobile.setReadOnly,
// Not used.
refreshStructure: Fun.noop,
enter: mode.enter,
exit: mode.exit,
destroy: Fun.noop
};
};