当前位置: 首页>>代码示例>>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;未经允许,请勿转载。