當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。