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


TypeScript Options.findMap方法代码示例

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


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

示例1: createAutocompleteItems

  const getCombinedItems = (triggerChar: string, matches: AutocompleteLookupData[]): ItemTypes.ItemSpec[] => {
    const columns = Options.findMap(matches, (m) => Option.from(m.columns)).getOr(1);

    return Arr.bind(matches, (match) => {
      const choices = match.items;

      return createAutocompleteItems(
        choices,
        (itemValue, itemMeta) => {
          const nr = editor.selection.getRng();
          const textNode = nr.startContainer as Text; // TODO: Investigate if this is safe
          getContext(nr, triggerChar, textNode.data, nr.startOffset).fold(
            () => console.error('Lost context. Cursor probably moved'),
            ({ rng }) => {
              const autocompleterApi: InlineContent.AutocompleterInstanceApi = {
                hide: closeIfNecessary
              };
              match.onAction(autocompleterApi, rng, itemValue, itemMeta);
            }
          );
        },
        columns,
        ItemResponse.BUBBLE_TO_SANDBOX,
        sharedBackstage
      );
    });
  };
开发者ID:tinymce,项目名称:tinymce,代码行数:27,代码来源:Autocompleter.ts

示例2: getContext

const getTriggerContext = (initRange: Range, initText: string, database: AutocompleterDatabase): Option<{ range: Range, text: string, triggerChar: string }> => {
  return Options.findMap(database.triggerChars, (ch) => {
    return getContext(initRange, ch, initText, initRange.startOffset).map(({ rng, text }) => {
      return { range: rng, text, triggerChar: ch };
    });
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:7,代码来源:AutocompleteLookup.ts

示例3:

const findTextByValue = (value: string, catalog: ListItem[]): Option<ListValue> => {
  return Options.findMap(catalog, (item) => {
    // TODO TINY-2236 re-enable this (support will need to be added to bridge)
    // return 'items' in item ? findTextByValue(value, item.items) :
     return Option.some(item).filter((i) => i.value === value);
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:7,代码来源:DialogChanges.ts

示例4:

 const findPrimary = (compInSystem: AlloyComponent): Option<AlloyComponent> => {
   return Options.findMap(buttons, (button, i) => {
     if (button.primary) {
       return Option.from(mementos[i]).bind((mem) => mem.getOpt(compInSystem)).filter(Fun.not(Disabling.isDisabled));
     } else {
       return Option.none();
     }
   });
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:9,代码来源:ContextFormButtons.ts

示例5: findEntryDelegate

const findEntryDelegate = (list: ListItem[], value: string): Option<ListValue> => {
  return Options.findMap(list, (item) => {
    if (isGroup(item)) {
      return findEntryDelegate(item.items, value);
    } else if (item.value === value) {
      return Option.some(item);
    } else {
      return Option.none();
    }
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:11,代码来源:ListUtils.ts

示例6: tryProtocolTransform

const preprocess = (editor: Editor, assumeExternalTargets: boolean, data: LinkDialogOutput): Future<LinkDialogOutput> => {
  return Options.findMap(
    [ tryEmailTransform, tryProtocolTransform(assumeExternalTargets) ],
    (f) => f(data)
  ).fold(
    () => Future.pure(data),
    (transform) => Future.nu((callback) => {
      delayedConfirm(editor, transform.message, (state) => {
        console.log('state', state);
        callback(state ? transform.preprocess(data) : data);
      });
    })
  );
};
开发者ID:tinymce,项目名称:tinymce,代码行数:14,代码来源:DialogConfirms.ts

示例7: getStyles

const findNearest = (editor: Editor, getStyles, nodeChangeEvent) => {
  const parents: Element[] = nodeChangeEvent.parents;

  const styles = getStyles();

  return Options.findMap(parents, (parent) => {
    return Arr.find(styles, (fmt) => {
      return editor.formatter.matchNode(parent, fmt.format);
    });
  }).orThunk(() => {
    if (editor.formatter.match('p')) { return Option.some({title: 'Paragraph', format: 'p' }); }
    return Option.none();
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:14,代码来源:FormatDetection.ts

示例8: function

const findDevice = function (deviceWidth, deviceHeight) {
  const devices = [
    // iPhone 4 class
    { width: 320, height: 480, keyboard: { portrait: 300, landscape: 240 } },
    // iPhone 5 class
    { width: 320, height: 568, keyboard: { portrait: 300, landscape: 240 } },
    // iPhone 6 class
    { width: 375, height: 667, keyboard: { portrait: 305, landscape: 240 } },
    // iPhone 6+ class
    { width: 414, height: 736, keyboard: { portrait: 320, landscape: 240 } },
    // iPad class
    { width: 768, height: 1024, keyboard: { portrait: 320, landscape: 400 } },
    // iPad pro class
    { width: 1024, height: 1366, keyboard: { portrait: 380, landscape: 460 } }
  ];

  return Options.findMap(devices, function (device) {
    return deviceWidth <= device.width && deviceHeight <= device.height ?
        Option.some(device.keyboard) :
        Option.none();
  }).getOr({ portrait: deviceHeight / 5, landscape: deviceWidth / 4 });
};
开发者ID:abstask,项目名称:tinymce,代码行数:22,代码来源:Devices.ts

示例9: getCombinedItems

        lookupInfo.lookupData.then((lookupData) => {
          const combinedItems = getCombinedItems(lookupInfo.triggerChar, lookupData);

          // Only open the autocompleter if there are items to show
          if (combinedItems.length > 0) {
            const columns: Types.ColumnTypes = Options.findMap(lookupData, (ld) => Option.from(ld.columns)).getOr(1);
            InlineView.showAt(
              autocompleter,
              {
                anchor: 'selection',
                root: Element.fromDom(editor.getBody()),
                getSelection: () => {
                  return Option.some({
                    start: () => Element.fromDom(lookupInfo.range.startContainer),
                    soffset: () => lookupInfo.range.startOffset,
                    finish: () => Element.fromDom(lookupInfo.range.endContainer),
                    foffset: () => lookupInfo.range.endOffset
                  });
                }
              },
              Menu.sketch(
                createMenuFrom(
                  createPartialMenuWithAlloyItems('autocompleter-value', true, combinedItems, columns, 'normal'),
                  columns,
                  FocusMode.ContentFocus,
                  // Use the constant.
                  'normal'
                )
              )
            );

            InlineView.getContent(autocompleter).each(Highlighting.highlightFirst);
          } else {
            closeIfNecessary();
          }
        });
开发者ID:tinymce,项目名称:tinymce,代码行数:36,代码来源:Autocompleter.ts

示例10: defaultIcon

const getFirst = (names: string[], icons: IconProvider): string => {
  return Options.findMap(names, (name) => Option.from(icons()[name])).getOrThunk(() => defaultIcon(icons));
};
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:Icons.ts


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