How to use the @ephox/boulder.ValueSchema.objOfOnly function in @ephox/boulder

To help you get started, we’ve selected a few @ephox/boulder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / alloy / src / main / ts / ephox / alloy / api / behaviour / Behaviour.ts View on Github external
const create = (data: AlloyBehaviourConfig): AlloyBehaviour => {
  const value = ValueSchema.asRawOrDie('Creating behaviour: ' + data.name, simpleSchema, data);
  return CommonBehaviour.create(value.fields, value.name, value.active, value.apis, value.extra, value.state);
};

export interface BehaviourModeSpec {
  branchKey: string;
  branches: Record;
  name: string;
  active?: any;
  apis?: { };
  extra?: { };
  state?: { };
}

const modeSchema: Processor = ValueSchema.objOfOnly([
  FieldSchema.strict('branchKey'),
  FieldSchema.strict('branches'),
  FieldSchema.strict('name'),
  FieldSchema.defaulted('active', { }),
  FieldSchema.defaulted('apis', { }),
  FieldSchema.defaulted('state', NoState),
  FieldSchema.defaulted('extra', { })
]);

const createModes = (data: BehaviourModeSpec): AlloyBehaviour => {
  const value: BehaviourModeSpec = ValueSchema.asRawOrDie('Creating behaviour: ' + data.name, modeSchema, data);
  return CommonBehaviour.createModes(
    ValueSchema.choose(value.branchKey, value.branches),
    value.name, value.active, value.apis, value.extra, value.state
  );
};
github tinymce / tinymce / modules / alloy / src / main / ts / ephox / alloy / api / behaviour / Behaviour.ts View on Github external
export interface AlloyBehaviourConfig {
  fields: FieldProcessorAdt[];
  name: string;
  active?: {};
  apis?: {};
  extra?: {};
  state?: {};
}

const derive = (
  capabilities: Array>
): AlloyBehaviourRecord => {
  return Objects.wrapAll(capabilities);
};

const simpleSchema: Processor = ValueSchema.objOfOnly([
  FieldSchema.strict('fields'),
  FieldSchema.strict('name'),
  FieldSchema.defaulted('active', { }),
  FieldSchema.defaulted('apis', { }),
  FieldSchema.defaulted('state', NoState),
  FieldSchema.defaulted('extra', { })
]);

const create = (data: AlloyBehaviourConfig): AlloyBehaviour => {
  const value = ValueSchema.asRawOrDie('Creating behaviour: ' + data.name, simpleSchema, data);
  return CommonBehaviour.create(value.fields, value.name, value.active, value.apis, value.extra, value.state);
};

export interface BehaviourModeSpec {
  branchKey: string;
  branches: Record;