How to use the @ephox/katamari.Id.generate function in @ephox/katamari

To help you get started, we’ve selected a few @ephox/katamari 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 / tinymce / src / themes / silver / main / ts / ui / dialog / UrlInput.ts View on Github external
const history = filterByQuery(term, historyTargets(urlBackstage.getHistory(fileType)));
      return fileType === 'file' ? joinMenuLists([
        history,
        filterByQuery(term, headerTargets(linkInfo)),
        filterByQuery(term, Arr.flatten([
          anchorTargetTop(linkInfo),
          anchorTargets(linkInfo),
          anchorTargetBottom(linkInfo)
        ]))
      ])
        : history;
    }
  );
};

const errorId = Id.generate('aria-invalid');

export const renderUrlInput = (spec: UrlInputSpec, backstage: UiFactoryBackstage, urlBackstage: UiFactoryBackstageForUrlInput): SketchSpec => {
  const providersBackstage = backstage.shared.providers;

  const updateHistory = (component: AlloyComponent): void => {
    const urlEntry = Representing.getValue(component);
    urlBackstage.addToHistory(urlEntry.value, spec.filetype);
  };

  // TODO: Make alloy's typeahead only swallow enter and escape if menu is open
  const pField = AlloyFormField.parts().field({
    factory: AlloyTypeahead,
    dismissOnBlur: true,
    inputClasses: ['tox-textfield'],
    sandboxClasses: ['tox-dialog__popups'],
    inputAttributes: {
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / general / PanelButton.ts View on Github external
}).map((items) => {
        return Option.from(createTieredDataFrom(
          Merger.deepMerge(
            createPartialChoiceMenu(
              Id.generate('menu-value'),
              items,
              (value) => {
                spec.onItemAction(comp, value);
              },
              spec.columns,
              spec.presets,
              ItemResponse.CLOSE_ON_EXECUTE,
              // No colour is ever selected on opening
              () => false,
              sharedBackstage.providers
            ),
            {
              movement: deriveMenuMovement(spec.columns, spec.presets)
            }
          )
        ));
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dropdown / CommonDropdown.ts View on Github external
Unselecting,
} from '@ephox/alloy';
import { Types } from '@ephox/bridge';
import { Future, Id, Merger, Option, Arr, Cell, Fun } from '@ephox/katamari';
import { toolbarButtonEventOrder } from 'tinymce/themes/silver/ui/toolbar/button/ButtonEvents';

import { UiFactoryBackstageShared } from '../../backstage/Backstage';
import { renderLabel, renderReplacableIconFromPack } from '../button/ButtonSlices';
import * as Icons from '../icons/Icons';
import { componentRenderPipeline } from '../menus/item/build/CommonMenuItem';
import * as MenuParts from '../menus/menu/MenuParts';
import { DisablingConfigs } from '../alien/DisablingConfigs';
import { onControlAttached, onControlDetached, OnDestroy } from '../controls/Controls';

export const updateMenuText = Id.generate('update-menu-text');
export const updateMenuIcon = Id.generate('update-menu-icon');

export interface UpdateMenuTextEvent extends CustomEvent {
  text: () => string;
}

export interface UpdateMenuIconEvent extends CustomEvent {
  icon: () => string;
}

export interface CommonDropdownSpec {
  text: Option;
  icon: Option;
  disabled?: boolean;
  tooltip: Option;
  role: Option;
  fetch: (callback: (tdata: Option) => void) => void;
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dropdown / CommonDropdown.ts View on Github external
TieredData,
  Unselecting,
} from '@ephox/alloy';
import { Types } from '@ephox/bridge';
import { Future, Id, Merger, Option, Arr, Cell, Fun } from '@ephox/katamari';
import { toolbarButtonEventOrder } from 'tinymce/themes/silver/ui/toolbar/button/ButtonEvents';

import { UiFactoryBackstageShared } from '../../backstage/Backstage';
import { renderLabel, renderReplacableIconFromPack } from '../button/ButtonSlices';
import * as Icons from '../icons/Icons';
import { componentRenderPipeline } from '../menus/item/build/CommonMenuItem';
import * as MenuParts from '../menus/menu/MenuParts';
import { DisablingConfigs } from '../alien/DisablingConfigs';
import { onControlAttached, onControlDetached, OnDestroy } from '../controls/Controls';

export const updateMenuText = Id.generate('update-menu-text');
export const updateMenuIcon = Id.generate('update-menu-icon');

export interface UpdateMenuTextEvent extends CustomEvent {
  text: () => string;
}

export interface UpdateMenuIconEvent extends CustomEvent {
  icon: () => string;
}

export interface CommonDropdownSpec {
  text: Option;
  icon: Option;
  disabled?: boolean;
  tooltip: Option;
  role: Option;
github tinymce / tinymce / modules / tinymce / src / core / main / ts / annotate / Wrapping.ts View on Github external
const makeAnnotation = (eDoc: Document, { uid = Id.generate('mce-annotation'), ...data }, annotationName: string, decorate: Decorator): Element => {
  const master = Element.fromTag('span', eDoc);
  Class.add(master, Markings.annotation());
  Attr.set(master, `${Markings.dataAnnotationId()}`, uid);
  Attr.set(master, `${Markings.dataAnnotation()}`, annotationName);

  const { attributes = { }, classes = [ ] } = decorate(uid, data);
  Attr.setAll(master, attributes);
  Classes.add(master, classes);
  return master;
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / Channels.ts View on Github external
/**
 * 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 { Fun, Id } from '@ephox/katamari';

const toolbarHeightChange = Fun.constant(Id.generate('toolbar-height-change'));

export {
  toolbarHeightChange
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ContextToolbar.ts View on Github external
return ctx.type === 'contexttoolbar' ? (() => {
      const allButtons = Merger.merge(buttons, scopes.formNavigators);
      const initGroups = identifyButtons(editor, { buttons: allButtons, toolbar: ctx.items }, extras, Option.some([ 'form:' ]));
      return renderToolbar({
        uid: Id.generate('context-toolbar'),
        initGroups,
        onEscape: Option.none,
        cyclicKeying: true,
        backstage: extras.backstage,
        getSink: () => Result.error('')
      });
    })() : (() => {
      return ContextForm.renderContextForm(ctx, extras.backstage);
github tinymce / tinymce / modules / imagetools / src / main / ts / ephox / imagetools / assets / ImageExtract.ts View on Github external
BlobConversions.blobToDataUri(img).then((datauri) => {
      const ir = ResultConversions.fromBlobAndUrlSync(img, datauri);
      const id = Id.generate('image');
      const asset = ImageAsset.blob(id, ir, objurl);
      callback(asset);
    });
  });
github tinymce / tinymce / modules / bridge / src / main / ts / ephox / bridge / components / dialog / FooterButton.ts View on Github external
FieldPresence.defaultedThunk(() => {
      return Id.generate('button-name');
    }),
    ValueSchema.string
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dialog / ColorInput.ts View on Github external
} from '@ephox/alloy';
import { Types } from '@ephox/bridge';
import { Future, Id, Option, Result } from '@ephox/katamari';
import { Css, Element, Traverse } from '@ephox/sugar';

import { UiFactoryBackstageShared } from '../../backstage/Backstage';
import { UiFactoryBackstageForColorInput } from '../../backstage/ColorInputBackstage';
import { renderLabel } from '../alien/FieldLabeller';
import ColorSwatch from '../core/color/ColorSwatch';
import Settings from '../core/color/Settings';
import { renderPanelButton } from '../general/PanelButton';
import { formChangeEvent } from '../general/FormEvents';
import { Omit } from '../Omit';

const colorInputChangeEvent = Id.generate('color-input-change');
const colorSwatchChangeEvent = Id.generate('color-swatch-change');
const colorPickerCancelEvent = Id.generate('color-picker-cancel');

interface ColorInputChangeEvent extends CustomEvent {
  color: () => string;
}

interface ColorSwatchChangeEvent extends CustomEvent {
  value: () => string;
}

interface ColorPickerCancelEvent extends CustomEvent {
  value: () => string;
}

type ColorInputSpec = Omit;