How to use the @ephox/boulder.FieldSchema.strictArrayOf 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 / bridge / src / main / ts / ephox / bridge / components / dialog / FooterButton.ts View on Github external
export const dialogButtonFields = [
  ...baseButtonFields,
  FieldSchema.strictString('text')
];

const normalButtonFields = [
  FieldSchema.strictStringEnum('type', ['submit', 'cancel', 'custom']),
  ...dialogButtonFields
];

const menuButtonFields = [
  FieldSchema.strictStringEnum('type', ['menu']),
  FieldSchema.optionString('text'),
  FieldSchema.optionString('tooltip'),
  FieldSchema.optionString('icon'),
  FieldSchema.strictArrayOf('items', dialogToggleMenuItemSchema),
  FieldSchema.defaultedFunction('onSetup', () => Fun.noop),
  ...baseButtonFields
];

export const dialogButtonSchema = ValueSchema.choose(
  'type',
  {
    submit: normalButtonFields,
    cancel: normalButtonFields,
    custom: normalButtonFields,
    menu: menuButtonFields
  }
);
github tinymce / tinymce / modules / bridge / src / main / ts / ephox / bridge / components / toolbar / ContextToolbar.ts View on Github external
]));

const launchToggleButtonSchema = ValueSchema.objOf(baseToolbarToggleButtonFields.concat([
  FieldSchema.defaulted('type', 'contextformtogglebutton')
]));

const toggleOrNormal = ValueSchema.choose('type', {
  contextformbutton: contextButtonSchema,
  contextformtogglebutton: contextToggleButtonSchema
});

const contextFormSchema = ValueSchema.objOf([
  FieldSchema.defaulted('type', 'contextform'),
  FieldSchema.defaultedFunction('initValue', () => ''),
  FieldSchema.optionString('label'),
  FieldSchema.strictArrayOf('commands', toggleOrNormal),
  FieldSchema.optionOf('launch', ValueSchema.choose('type', {
    contextformbutton: launchButtonSchema,
    contextformtogglebutton: launchToggleButtonSchema
  }))
].concat(contextBarFields));

const contextToolbarSchema = ValueSchema.objOf([
  FieldSchema.defaulted('type', 'contexttoolbar'),
  FieldSchema.strictString('items')
].concat(contextBarFields));

export const createContextToolbar = (spec: ContextToolbarApi): Result> => {
  return ValueSchema.asRaw('ContextToolbar', contextToolbarSchema, spec);
};

export const createContextForm = (spec: ContextFormApi): Result> => {
github tinymce / tinymce / modules / bridge / src / main / ts / ephox / bridge / components / dialog / MenuButton.ts View on Github external
onSetup: (api: BaseDialogMenuButtonInstanceApi) => (api: BaseDialogMenuButtonInstanceApi) => void;
  storage: Cell;
}

export interface BaseDialogMenuButtonInstanceApi {
  isDisabled: () => boolean;
  setDisabled: (state: boolean) => void;
  isActive: () => boolean;
  setActive: (state: boolean) => void;
}

export const baseDialogMenuButtonFields = [
  FieldSchema.optionString('text'),
  FieldSchema.optionString('tooltip'),
  FieldSchema.optionString('icon'),
  FieldSchema.strictArrayOf('items', dialogToggleMenuItemSchema),
  FieldSchema.defaultedFunction('onSetup', () => Fun.noop),
  FieldSchema.defaulted('storage', Cell(false))
];