當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。