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


TypeScript katamari.Options類代碼示例

本文整理匯總了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;未經允許,請勿轉載。