• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript katamari.Options类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: prependData

const rngSetContent = (rng: Range, fragment: DocumentFragment): void => {
  const firstChild = Option.from(fragment.firstChild).map(Element.fromDom);
  const lastChild = Option.from(fragment.lastChild).map(Element.fromDom);

  rng.deleteContents();
  rng.insertNode(fragment);

  const prevText = firstChild.bind(Traverse.prevSibling).filter(Node.isText).bind(removeEmpty);
  const nextText = lastChild.bind(Traverse.nextSibling).filter(Node.isText).bind(removeEmpty);

  // Join start
  Options.liftN([prevText, firstChild.filter(Node.isText)], (prev: Element, start: Element) => {
    prependData(start.dom(), prev.dom().data);
    Remove.remove(prev);
  });

  // Join end
  Options.liftN([nextText, lastChild.filter(Node.isText)], (next: Element, end: Element) => {
    const oldLength = end.dom().length;
    end.dom().appendData(next.dom().data);
    rng.setEnd(end.dom(), oldLength);
    Remove.remove(next);
  });

  rng.collapse(false);
};
开发者ID:tinymce,项目名称:tinymce,代码行数:26,代码来源:SetSelectionContent.ts


示例2:

 (lastPos) => {
   return Options.liftN([Arr.head(lastPos.getClientRects()), Arr.head(newPos.getClientRects())], (lastRect, newRect) => {
     const lastDist = Math.abs(x - lastRect.left);
     const newDist = Math.abs(x - newRect.left);
     return newDist <= lastDist ? newPos : lastPos;
   }).or(acc);
 }
开发者ID:tinymce,项目名称:tinymce,代码行数:7,代码来源:LineReader.ts


示例3: function

const getCellRng = function (rng, isRoot) {
  return Options.liftN([ // get start and end cell
    getClosestCell(rng.startContainer, isRoot),
    getClosestCell(rng.endContainer, isRoot)
  ], tableCellRng)
    .filter(isExpandedCellRng);
};
开发者ID:enigmatic-user,项目名称:tinymce-1,代码行数:7,代码来源:TableDeleteAction.ts


示例4: 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


示例5: 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


示例6: function

const deleteNormalized = function (elm, afterDeletePosOpt) {
  return Options.liftN([Traverse.prevSibling(elm), Traverse.nextSibling(elm), afterDeletePosOpt], function (prev, next, afterDeletePos) {
    let offset;
    const prevNode = prev.dom();
    const nextNode = next.dom();

    if (NodeType.isText(prevNode) && NodeType.isText(nextNode)) {
      offset = prevNode.data.length;
      prevNode.appendData(nextNode.data);
      Remove.remove(next);
      Remove.remove(elm);
      if (afterDeletePos.container() === nextNode) {
        return new CaretPosition(prevNode, offset);
      } else {
        return afterDeletePos;
      }
    } else {
      Remove.remove(elm);
      return afterDeletePos;
    }
  }).orThunk(function () {
    Remove.remove(elm);
    return afterDeletePosOpt;
  });
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:25,代码来源:DeleteElement.ts


示例7: function

const hasAllContentsSelected = function (elm, rng) {
  return Options.liftN([getStartNode(rng), getEndNode(rng)], function (startNode, endNode) {
    const start = Arr.find(getFirstChildren(elm), Fun.curry(Compare.eq, startNode));
    const end = Arr.find(getLastChildren(elm), Fun.curry(Compare.eq, endNode));
    return start.isSome() && end.isSome();
  }).getOr(false);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:SelectionUtils.ts


示例8:

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


示例9: getCellIndex

const getSelectedCells = (tableSelection) => {
  return Options.liftN([
    getCellIndex(tableSelection.cells(), tableSelection.rng().start()),
    getCellIndex(tableSelection.cells(), tableSelection.rng().end())
  ], (startIndex, endIndex) => {
    return tableSelection.cells().slice(startIndex, endIndex + 1);
  });
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:TableDeleteAction.ts


示例10:

const getItemSelection = (editor: Editor): Option<ItemSelection> => {
  const selectedListItems = Arr.map(Selection.getSelectedListItems(editor), Element.fromDom);

  return Options.liftN([
    Arr.find(selectedListItems, Fun.not(hasFirstChildList)),
    Arr.find(Arr.reverse(selectedListItems), Fun.not(hasFirstChildList))
  ], (start, end) => ({ start, end }));
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:ListsIndendation.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript katamari.Result类代码示例发布时间:2022-05-28
下一篇:
TypeScript katamari.Option类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap