当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Objects.readOptFrom方法代码示例

本文整理汇总了TypeScript中@ephox/boulder.Objects.readOptFrom方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Objects.readOptFrom方法的具体用法?TypeScript Objects.readOptFrom怎么用?TypeScript Objects.readOptFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ephox/boulder.Objects的用法示例。


在下文中一共展示了Objects.readOptFrom方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: process

const buildBasicSettingsDataset = (editor: Editor, settingName, defaults, delimiter: Delimiter): BasicSelectDataset => {
  const rawFormats = Objects.readOptFrom<string>(editor.settings, settingName).getOr(defaults);
  const data = process(split(rawFormats, delimiter));
  return {
    type: 'basic',
    data
  };
};
开发者ID:tinymce,项目名称:tinymce,代码行数:8,代码来源:SelectDatasets.ts

示例2: getScopes

 editor.on(showContextToolbarEvent, (e) => {
   const scopes = getScopes();
   // TODO: Have this stored in a better structure
   Objects.readOptFrom<Toolbar.ContextToolbar | Toolbar.ContextForm>(scopes.lookupTable, e.toolbarKey).each((ctx) => {
     launchContext(ctx, e.target === editor ? Option.none() : Option.some(e as DomElement));
     // Forms launched via this way get immediate focus
     InlineView.getContent(contextbar).each(Keying.focusIn);
   });
 });
开发者ID:tinymce,项目名称:tinymce,代码行数:9,代码来源:ContextToolbar.ts

示例3:

const generateValueIfRequired = (item: SingleMenuItemApi): SingleMenuItemApi => {
  // Separators don't have a value, so just return the item
  if (isSeparator(item)) {
    return item;
  } else {
    // Use the value already in item if it has one.
    const itemValue = Objects.readOptFrom(item, 'value').getOrThunk(() => Id.generate('generated-menu-item'));
    return Merger.deepMerge({ value: itemValue }, item);
  }
};
开发者ID:tinymce,项目名称:tinymce,代码行数:10,代码来源:MenuConversion.ts

示例4: factory

const interpretParts: FormPartRenderer = (parts, spec, backstage) => {
  return Objects.readOptFrom(factories, spec.type).fold(
    () => {
      console.error(`Unknown factory type "${spec.type}", defaulting to container: `, spec);
      return spec as AlloySpec;
    },
    (factory: FormPartRenderer) => {
      return factory(parts, spec, backstage);
    }
  );
};
开发者ID:tinymce,项目名称:tinymce,代码行数:11,代码来源:UiFactory.ts

示例5: function

const derive = function (editor) {
  const base = Objects.readOptFrom(editor.settings, 'skin_url').fold(function () {
    return EditorManager.baseURL + '/skins/' + 'lightgray';
  }, function (url) {
    return url;
  });

  return {
    content: base + '/content.mobile.min.css',
    ui: base + '/skin.mobile.min.css'
  };
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:12,代码来源:CssUrls.ts

示例6: function

const register = function (editor, settings) {

  const isSelectedFor = function (format) {
    return function () {
      return editor.formatter.match(format);
    };
  };

  const getPreview = function (format) {
    return function () {
      const styles = editor.formatter.getCssText(format);
      return styles;
    };
  };

  const enrichSupported = function (item) {
    return Merger.deepMerge(item, {
      isSelected: isSelectedFor(item.format),
      getPreview: getPreview(item.format)
    });
  };

  // Item that triggers a submenu
  const enrichMenu = function (item) {
    return Merger.deepMerge(item, {
      isSelected: Fun.constant(false),
      getPreview: Fun.constant('')
    });
  };

  const enrichCustom = function (item) {
    const formatName = Id.generate(item.title);
    const newItem = Merger.deepMerge(item, {
      format: formatName,
      isSelected: isSelectedFor(formatName),
      getPreview: getPreview(formatName)
    });
    editor.formatter.register(formatName, newItem);
    return newItem;
  };

  const formats = Objects.readOptFrom(settings, 'style_formats').getOr(DefaultStyleFormats);

  const doEnrich = function (items) {
    return Arr.map(items, function (item) {
      if (Objects.hasKey(item, 'items')) {
        const newItems = doEnrich(item.items);
        return Merger.deepMerge(
          enrichMenu(item),
          {
            items: newItems
          }
        );
      } else if (Objects.hasKey(item, 'format')) {
        return enrichSupported(item);
      } else {
        return enrichCustom(item);
      }
    });
  };

  return doEnrich(formats);
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:63,代码来源:StyleFormats.ts

示例7: function

const getValue = function (item) {
  return Objects.readOptFrom(item, 'format').getOr(item.title);
};
开发者ID:abstask,项目名称:tinymce,代码行数:3,代码来源:StylesMenu.ts

示例8: return

 return (parts, spec, backstage) => {
   return Objects.readOptFrom<string>(spec, 'name').fold(
     () => render(spec, backstage),
     (fieldName) => parts.field(fieldName, render(spec, backstage) as SimpleOrSketchSpec)
   );
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:6,代码来源:UiFactory.ts

示例9:

const classForPreset = (presets: Types.PresetTypes): string => {
  return Objects.readOptFrom<string>(presetClasses, presets).getOr(navClass);
};
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:ItemClasses.ts


注:本文中的@ephox/boulder.Objects.readOptFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。