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


TypeScript SelectorFind.closest方法代码示例

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


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

示例1:

 predicate: (node) => {
   const sugarNode = Element.fromDom(node);
   const textBlockElementsMap = editor.schema.getTextBlockElements();
   const isRoot = (elem) => elem.dom() === editor.getBody();
   return SelectorFind.closest(sugarNode, 'table', isRoot).fold(
     () => PredicateFind.closest(sugarNode, (elem) => {
       return Node.name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom());
     }, isRoot).isSome(),
     () => false
   );
 },
开发者ID:tinymce,项目名称:tinymce,代码行数:11,代码来源:Toolbars.ts

示例2:

 SelectorFind.descendant(comp.element(), '.' + MenuButtonClasses.Active).each((activeButton) => {
   SelectorFind.closest(se.event().target(), '.' + MenuButtonClasses.Button).each((hoveredButton) => {
     if (! Compare.eq(activeButton, hoveredButton)) {
       // Now, find the components, and expand the hovered one, and close the active one
       comp.getSystem().getByDom(activeButton).each((activeComp) => {
         comp.getSystem().getByDom(hoveredButton).each((hoveredComp) => {
           Dropdown.expand(hoveredComp);
           Dropdown.close(activeComp);
           Focusing.focus(hoveredComp);
         });
       });
     }
   });
 });
开发者ID:tinymce,项目名称:tinymce,代码行数:14,代码来源:SilverMenubar.ts

示例3: renderTitle

const renderInlineHeader = (foo: WindowHeaderFoo, titleId: string, providersBackstage: UiFactoryBackstageProviders): AlloySpec => {
  return Container.sketch({
    dom: DomFactory.fromHtml('<div class="tox-dialog__header"></div>'),
    components: [
      renderTitle(foo, Option.some(titleId), providersBackstage),
      renderClose(providersBackstage)
    ],
    containerBehaviours: Behaviour.derive([
      Dragging.config({
        mode: 'mouse',
        blockerClass: 'blocker',
        getTarget (handle) {
          return SelectorFind.closest(handle, '[role="dialog"]').getOrDie();
        },
        snaps: {
          getSnapPoints: () => [ ],
          leftAttr: 'data-drag-left',
          topAttr: 'data-drag-top'
        }
      }),
    ])
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:23,代码来源:SilverDialogHeader.ts

示例4: getAttr

const identify = (editor: Editor, annotationName: Option<string>): Option<{uid: string, name: string, elements: any[]}> => {
  const rng = editor.selection.getRng();

  const start = Element.fromDom(rng.startContainer);
  const root = Element.fromDom(editor.getBody());

  const selector = annotationName.fold(
    () => '.' + Markings.annotation(),
    (an) => `[${Markings.dataAnnotation()}="${an}"]`
  );

  const newStart = Traverse.child(start, rng.startOffset).getOr(start);
  const closest = SelectorFind.closest(newStart, selector, (n) => {
    return Compare.eq(n, root);
  });

  const getAttr = (c, property: string): Option<any> => {
    if (Attr.has(c, property)) {
      return Option.some(Attr.get(c, property));
    } else {
      return Option.none();
    }
  };

  return closest.bind((c) => {
    return getAttr(c, `${Markings.dataAnnotationId()}`).bind((uid) =>
      getAttr(c, `${Markings.dataAnnotation()}`).map((name) => {
        const elements = findMarkers(editor, uid);
        return {
          uid,
          name,
          elements
        };
      })
    );
  });
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:37,代码来源:Identification.ts

示例5:

const getClosestCell = (container, isRoot) => {
  return SelectorFind.closest(Element.fromDom(container), 'td,th', isRoot);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:3,代码来源:TableDeleteAction.ts

示例6: function

 return DomEvent.bind(scope, 'touchmove', function (event) {
   SelectorFind.closest(event.target(), selector).filter(hasScroll).fold(function () {
     event.raw().preventDefault();
   }, Fun.noop);
 });
开发者ID:abstask,项目名称:tinymce,代码行数:5,代码来源:Scrollables.ts

示例7: function

const query = function (editor) {
  const start = Element.fromDom(editor.selection.getStart());
  return SelectorFind.closest(start, 'a');
};
开发者ID:abstask,项目名称:tinymce,代码行数:4,代码来源:LinkBridge.ts

示例8: f

 const runOnItem = (f: (c: AlloyComponent, tgt: Element, itemValue: string) => void) => <T extends EventFormat>(comp: AlloyComponent, se: SimulatedEvent<T>) => {
   SelectorFind.closest(se.event().target(), '[data-collection-item-value]').each((target) => {
     f(comp, target, Attr.get(target, 'data-collection-item-value'));
   });
 };
开发者ID:tinymce,项目名称:tinymce,代码行数:5,代码来源:Collection.ts


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