当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Arr.head方法代码示例

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


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

示例1:

 (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

示例2: Uploader

const changeFileInput = (helpers: Helpers, info: ImageDialogInfo, state: ImageDialogState, api: API) => {
  const data = api.getData();
  api.block('Uploading image'); // What msg do we pass to the lock?
  Arr.head(data.fileinput)
    .fold(() => {
      api.unblock();
    }, (file) => {
      const blobUri: string = URL.createObjectURL(file);

      const uploader = Uploader({
        url: info.url,
        basePath: info.basePath,
        credentials: info.credentials,
        handler: info.handler
      });

      const finalize = () => {
        api.unblock();
        URL.revokeObjectURL(blobUri);
      };

      Utils.blobToDataUri(file).then((dataUrl) => {
        const blobInfo = helpers.createBlobCache(file, blobUri, dataUrl);
        uploader.upload(blobInfo).then((url: string) => {
          api.setData({ src: { value: url, meta: { } } });
          api.showTab('General');
          changeSrc(helpers, info, state, api);
          finalize();
        }).catch((err) => {
          finalize();
          helpers.alertErr(api, err);
        });
      });
    });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:35,代码来源:Dialog.ts

示例3: writeDeep

const composeList = (scope: Document, entries: Entry[]): Option<Element> => {
  const cast: Segment[] = Arr.foldl(entries, (cast, entry) => {
    return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
  }, []);

  return Arr.head(cast).map((segment) => segment.list);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:ComposeList.ts

示例4: createJoinedSections

const writeDeep = (scope: Document, outline: Section[], entry: Entry): Section[] => {
  const newSections = createJoinedSections(scope, entry.depth - outline.length, entry.listType);
  populateSections(newSections, entry);

  Options.liftN([
    Arr.last(outline),
    Arr.head(newSections)
  ], joinSections);
  return outline.concat(newSections);
};
开发者ID:mdgbayly,项目名称:tinymce,代码行数:10,代码来源:ComposeList.ts

示例5: getViewPortRect

const scrollRangeIntoView = (editor: Editor, rng: Range) => {
  Arr.head(CaretPosition.fromRangeStart(rng).getClientRects()).each((rngRect) => {
    const bodyRect = getViewPortRect(editor);
    const overflow = getOverflow(bodyRect, rngRect);
    const margin = 4;
    const dx = overflow.x > 0 ? overflow.x + margin : overflow.x - margin;
    const dy = overflow.y > 0 ? overflow.y + margin : overflow.y - margin;

    scrollBy(editor, overflow.x !== 0 ? dx : 0, overflow.y !== 0 ? dy : 0);
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:11,代码来源:ScrollIntoView.ts

示例6: if

const getMaxHeight = (heights: number[]) => {
  return Arr.head(Arr.sort(heights, (a, b) => {
    if (a > b) {
      return -1;
    } else if (a < b) {
      return +1;
    } else {
      return 0;
    }
  }));
};
开发者ID:tinymce,项目名称:tinymce,代码行数:11,代码来源:DialogTabHeight.ts

示例7: return

 return () => {
   const from = forward ? CaretPosition.fromRangeEnd(editor.selection.getRng()) : CaretPosition.fromRangeStart(editor.selection.getRng());
   const result = forward ? getPositionsUntilNextLine(editor.getBody(), from) : getPositionsUntilPreviousLine(editor.getBody(), from);
   const to = forward ? Arr.last(result.positions) : Arr.head(result.positions);
   return to.filter(isCefPosition(forward)).fold(
     Fun.constant(false),
     (pos) => {
       editor.selection.setRng(pos.toRange());
       return true;
     }
   );
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:12,代码来源:CefNavigation.ts

示例8: navigateIgnoreEmptyTextNodes

const isAtBlockBoundary = (forward: boolean, root: Element, pos: CaretPosition) => {
  const parentBlocks = Arr.filter(Parents.parentsAndSelf(Element.fromDom(pos.container()), root), ElementType.isBlock);
  return Arr.head(parentBlocks).fold(
    () => {
      return navigateIgnoreEmptyTextNodes(forward, root.dom(), pos).forall((newPos) => {
        return isInSameBlock(newPos, pos, root.dom()) === false;
      });
    },
    (parent) => {
      return navigateIgnoreEmptyTextNodes(forward, parent.dom(), pos).isNone();
    }
  );
};
开发者ID:tinymce,项目名称:tinymce,代码行数:13,代码来源:BlockBoundary.ts

示例9:

const open = (editor: Editor) => {
  const languages: LanguageSpec[] = Languages.getLanguages(editor);
  const defaultLanguage: string = Arr.head(languages).fold(() => '', (l) => l.value);
  const currentLanguage: string = Languages.getCurrentLanguage(editor, defaultLanguage);
  const currentCode: string = CodeSample.getCurrentCode(editor);

  editor.windowManager.open({
    title: 'Insert/Edit Code Sample',
    size: 'large',
    body: {
      type: 'panel',
      items: [
        {
          type: 'selectbox',
          name: 'language',
          label: 'Language',
          items: languages
        },
        {
          type: 'textarea',
          name: 'code',
          label: 'Code view',
        }
      ]
    },
    buttons: [
      {
        type: 'cancel',
        name: 'cancel',
        text: 'Cancel',
      },
      {
        type: 'submit',
        name: 'save',
        text: 'Save',
        primary: true
      }
    ],
    initialData: {
      language: currentLanguage,
      code: currentCode
    },
    onSubmit: (api) => {
      const data = api.getData();
      CodeSample.insertCodeSample(editor, data.language, data.code);
      api.close();
    }
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:49,代码来源:Dialog.ts

示例10:

 find: (comp: AlloyComponent) => {
   const children = Replacing.contents(comp);
   return Arr.head(children);
 }
开发者ID:tinymce,项目名称:tinymce,代码行数:4,代码来源:Sidebar.ts


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