當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Option.from方法代碼示例

本文整理匯總了TypeScript中@ephox/katamari.Option.from方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Option.from方法的具體用法?TypeScript Option.from怎麽用?TypeScript Option.from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ephox/katamari.Option的用法示例。


在下文中一共展示了Option.from方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

const getToolbarIconButton = (clazz, editor) => {
  const icons = editor.ui.registry.getAll().icons;
  const optOxideIcon = Option.from(icons[clazz]);

  return optOxideIcon.fold(
    () => UiDomFactory.dom('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item ${prefix}-icon-' + clazz + ' ${prefix}-icon"></span>'),
    (icon) => UiDomFactory.dom('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item">' + icon + '</span>')
  );
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:9,代碼來源:Buttons.ts

示例2: function

 return function (rootElm, elm) {
   return Option.from(elm)
     .map(Element.fromDom)
     .filter(Node.isElement)
     .bind(function (element: any) {
       return getSpecifiedFontProp(propName, rootElm, element.dom())
         .or(getComputedFontProp(propName, element.dom()));
     })
     .getOr('');
 };
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例3:

            }, (rgbForm) => {
              Representing.setValue(rgbForm, {
                hex: Option.from(m[1]).getOr('')
              });

              // So not the way to do this.
              Form.getField(rgbForm, 'hex').each((hexField) => {
                AlloyTriggers.emit(hexField, NativeEvents.input());
              });
            });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:10,代碼來源:ColorPicker.ts

示例4: bodyElement

 const fixedToolbarAnchor = (): AnchorSpec => ({
   anchor: 'node',
   root: bodyElement(),
   node: Option.from(bodyElement()),
   bubble: Bubble.nu(-12, -12, bubbleAlignments),
   layouts: {
     onRtl: () => [ LayoutInside.northeast ],
     onLtr: () => [ LayoutInside.northwest ]
   }
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:10,代碼來源:Anchors.ts

示例5:

 select: (value) => {
   const optCurrentRgb = Option.from(getCurrentColor(editor, format));
   return optCurrentRgb.bind((currentRgb) => {
     return RgbaColour.fromString(currentRgb).map((rgba) => {
       const currentHex = HexColour.fromRgba(rgba).value();
       // note: value = '#FFFFFF', currentHex = 'ffffff'
       return Strings.contains(value.toLowerCase(), currentHex);
     });
   }).getOr(false);
 },
開發者ID:tinymce,項目名稱:tinymce,代碼行數:10,代碼來源:ColorSwatch.ts

示例6:

 }).orThunk(() => {
   if (isSystemFontStack(font)) {
     return Option.from({
       title: 'System Font',
       format: font
     });
   } else {
     return Option.none();
   }
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:10,代碼來源:FontSelect.ts

示例7: return

 return (rootElm: Element, elm: Node): string => {
   return Option.from(elm)
     .map(SugarElement.fromDom)
     .filter(SugarNode.isElement)
     .bind((element: any) => {
       return getSpecifiedFontProp(propName, rootElm, element.dom())
         .or(getComputedFontProp(propName, element.dom()));
     })
     .getOr('');
 };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:10,代碼來源:FontInfo.ts

示例8: function

 const scrollBounds = function () {
   const rects = Rectangles.getRectangles(cWin);
   return Option.from(rects[0]).bind(function (rect) {
     const viewTop = rect.top() - socket.dom().scrollTop;
     const outside = viewTop > outerWindow.innerHeight + VIEW_MARGIN || viewTop < -VIEW_MARGIN;
     return outside ? Option.some({
       top: Fun.constant(viewTop),
       bottom: Fun.constant(viewTop + rect.height())
     }) : Option.none();
   });
 };
開發者ID:abstask,項目名稱:tinymce,代碼行數:11,代碼來源:IosSetup.ts

示例9: function

 const focusInput = function (dialog) {
   const inputs = SelectorFilter.descendants(dialog.element(), 'input');
   const optInput = Option.from(inputs[spec.state.currentScreen.get()]);
   optInput.each(function (input) {
     dialog.getSystem().getByDom(input).each(function (inputComp) {
       AlloyTriggers.dispatchFocus(dialog, inputComp.element());
     });
   });
   const dotitems = memDots.get(dialog);
   Highlighting.highlightAt(dotitems, spec.state.currentScreen.get());
 };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:11,代碼來源:SerialisedDialog.ts

示例10:

const getTextContent = (editor: Editor): string => {
  return Option.from(editor.selection.getRng()).map((rng) => {
    const bin = editor.dom.add(editor.getBody(), 'div', {
      'data-mce-bogus': 'all',
      'style': 'overflow: hidden; opacity: 0;'
    }, rng.cloneContents());

    const text = Zwsp.trim(bin.innerText);
    editor.dom.remove(bin);
    return text;
  }).getOr('');
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:12,代碼來源:GetSelectionContent.ts


注:本文中的@ephox/katamari.Option.from方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。