本文整理汇总了TypeScript中@ephox/boulder.FieldSchema类的典型用法代码示例。如果您正苦于以下问题:TypeScript FieldSchema类的具体用法?TypeScript FieldSchema怎么用?TypeScript FieldSchema使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FieldSchema类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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());
});
};
示例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 navigateEvent = 'navigateEvent';
const wrapperAdhocEvents = 'serializer-wrapper-events';
const formAdhocEvents = 'form-events';
const schema = ValueSchema.objOf([
FieldSchema.strict('fields'),
// Used for when datafields are present.
FieldSchema.defaulted('maxFieldIndex', rawSpec.fields.length - 1),
FieldSchema.strict('onExecute'),
FieldSchema.strict('getInitialValue'),
FieldSchema.state('state', function () {
return {
dialogSwipeState: Singleton.value(),
currentScreen: Cell(0)
};
})
]);
const spec = ValueSchema.asRawOrDie('SerialisedDialog', schema, rawSpec);
const navigationButton = function (direction, directionName, enabled) {
return Button.sketch({
dom: UiDomFactory.dom('<span class="${prefix}-icon-' + directionName + ' ${prefix}-icon"></span>'),
action (button) {
AlloyTriggers.emitWith(button, navigateEvent, { direction });
},
buttonBehaviours: Behaviour.derive([
Disabling.config({
disableClass: Styles.resolve('toolbar-navigation-disabled'),
disabled: !enabled
})
])
});
};
const reposition = function (dialog, message) {
SelectorFind.descendant(dialog.element(), '.' + Styles.resolve('serialised-dialog-chain')).each(function (parent) {
Css.set(parent, 'left', (-spec.state.currentScreen.get() * message.width) + 'px');
});
};
const navigate = function (dialog, direction) {
const screens = SelectorFilter.descendants(dialog.element(), '.' + Styles.resolve('serialised-dialog-screen'));
SelectorFind.descendant(dialog.element(), '.' + Styles.resolve('serialised-dialog-chain')).each(function (parent) {
if ((spec.state.currentScreen.get() + direction) >= 0 && (spec.state.currentScreen.get() + direction) < screens.length) {
Css.getRaw(parent, 'left').each(function (left) {
const currentLeft = parseInt(left, 10);
const w = Width.get(screens[0]);
Css.set(parent, 'left', (currentLeft - (direction * w)) + 'px');
});
spec.state.currentScreen.set(spec.state.currentScreen.get() + direction);
}
});
};
// Unfortunately we need to inspect the DOM to find the input that is currently on screen
const focusInput = function (dialog) {
const inputs = SelectorFilter.descendants(dialog.element(), 'input');
const optInput = Option.from(inputs[spec.state.currentScreen.get()]);
optInput.each(function (input) {
dialog.getSystem().getByDom(input).each(function (inputComp) {
AlloyTriggers.dispatchFocus(dialog, inputComp.element());
});
});
const dotitems = memDots.get(dialog);
Highlighting.highlightAt(dotitems, spec.state.currentScreen.get());
};
const resetState = function () {
spec.state.currentScreen.set(0);
spec.state.dialogSwipeState.clear();
};
const memForm = Memento.record(
Form.sketch(function (parts) {
return {
dom: UiDomFactory.dom('<div class="${prefix}-serialised-dialog"></div>'),
components: [
Container.sketch({
dom: UiDomFactory.dom('<div class="${prefix}-serialised-dialog-chain" style="left: 0px; position: absolute;"></div>'),
components: Arr.map(spec.fields, function (field, i) {
return i <= spec.maxFieldIndex ? Container.sketch({
dom: UiDomFactory.dom('<div class="${prefix}-serialised-dialog-screen"></div>'),
components: [
navigationButton(-1, 'previous', (i > 0)),
parts.field(field.name, field.spec),
navigationButton(+1, 'next', (i < spec.maxFieldIndex))
]
}) : parts.field(field.name, field.spec);
})
})
],
formBehaviours: Behaviour.derive([
Receivers.orientation(function (dialog, message) {
reposition(dialog, message);
}),
Keying.config({
//.........这里部分代码省略.........
示例4: focus
}),
Tabstopping.config({ })
]),
apis,
domModification: {
attributes: {
role: 'menubar'
}
}
};
};
export default Sketcher.single({
factory,
name: 'silver.Menubar',
configFields: [
FieldSchema.strict('dom'),
FieldSchema.strict('uid'),
FieldSchema.strict('onEscape'),
FieldSchema.strict('backstage'),
FieldSchema.defaulted('onSetup', Fun.noop)
],
apis: {
focus (apis, comp) {
apis.focus(comp);
},
setMenus (apis, comp, menus) {
apis.setMenus(comp, menus);
}
}
}) as SilverMenubarSketch;
示例5: function
import { Behaviour, Slider, Toggling } from '@ephox/alloy';
import { FieldSchema, ValueSchema } from '@ephox/boulder';
import Receivers from '../channels/Receivers';
import Styles from '../style/Styles';
import UiDomFactory from '../util/UiDomFactory';
const schema = ValueSchema.objOfOnly([
FieldSchema.strict('getInitialValue'),
FieldSchema.strict('onChange'),
FieldSchema.strict('category'),
FieldSchema.strict('sizes')
]);
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: [
示例6:
}
}],
action: (comp) => {
detail.onAction(comp);
}
})
),
apis
};
};
export const Notification = Sketcher.single<NotificationSketchSpec, NotificationSketchDetail>({
name: 'Notification',
factory,
configFields: [
FieldSchema.option('level'),
FieldSchema.strict('progress'),
FieldSchema.strict('icon'),
FieldSchema.strict('onAction'),
FieldSchema.strict('text'),
FieldSchema.strict('iconProvider'),
FieldSchema.strict('translationProvider'),
],
apis: {
updateProgress: (apis: NotificationSketchApis, comp: AlloyComponent, percent: number) => {
apis.updateProgress(comp, percent);
},
updateText: (apis: NotificationSketchApis, comp: AlloyComponent, text: string) => {
apis.updateText(comp, text);
}
}
示例7:
/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*/
import { MementoRecord, Representing, AlloyComponent } from '@ephox/alloy';
import { FieldSchema, ValueSchema } from '@ephox/boulder';
import { Fun, Merger, Option } from '@ephox/katamari';
import { Element, Html, Value } from '@ephox/sugar';
const processors = ValueSchema.objOf([
FieldSchema.defaulted('preprocess', Fun.identity),
FieldSchema.defaulted('postprocess', Fun.identity)
]);
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:
export default ValueSchema.objOf([
FieldSchema.strictObjOf('editor', [
// Maybe have frame as a method, but I doubt it ... I think we pretty much need a frame
FieldSchema.strict('getFrame'),
FieldSchema.option('getBody'),
FieldSchema.option('getDoc'),
FieldSchema.option('getWin'),
FieldSchema.option('getSelection'),
FieldSchema.option('setSelection'),
FieldSchema.option('clearSelection'),
FieldSchema.option('cursorSaver'),
FieldSchema.option('onKeyup'),
FieldSchema.option('onNodeChanged'),
FieldSchema.option('getCursorBox'),
FieldSchema.strict('onDomChanged'),
FieldSchema.defaulted('onTouchContent', Fun.noop),
FieldSchema.defaulted('onTapContent', Fun.noop),
FieldSchema.defaulted('onTouchToolstrip', Fun.noop),
FieldSchema.defaulted('onScrollToCursor', Fun.constant({ unbind: Fun.noop })),
FieldSchema.defaulted('onScrollToElement', Fun.constant({ unbind: Fun.noop })),
FieldSchema.defaulted('onToEditing', Fun.constant({ unbind: Fun.noop })),
FieldSchema.defaulted('onToReading', Fun.constant({ unbind: Fun.noop })),
FieldSchema.defaulted('onToolbarScrollStart', Fun.identity)
]),
FieldSchema.strict('socket'),