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


TypeScript sugar.WindowSelection類代碼示例

本文整理匯總了TypeScript中@ephox/sugar.WindowSelection的典型用法代碼示例。如果您正苦於以下問題:TypeScript WindowSelection類的具體用法?TypeScript WindowSelection怎麽用?TypeScript WindowSelection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WindowSelection類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

 return function () {
   return WindowSelection.get(win).bind(function (sel) {
     return WindowSelection.getFirstRect(win, sel).orThunk(function () {
       return tryFallbackBox(win);
     });
   });
 };
開發者ID:abstask,項目名稱:tinymce,代碼行數:7,代碼來源:PlatformEditor.ts

示例2:

    return Chain.op(function () {
      const sc = Hierarchy.follow(Element.fromDom(viewBlock.get()), startPath).getOrDie('invalid startPath');
      const fc = Hierarchy.follow(Element.fromDom(viewBlock.get()), finishPath).getOrDie('invalid finishPath');
      const win = Traverse.defaultView(sc);

      WindowSelection.setExact(
        win.dom(), sc, soffset, fc, foffset
      );
    });
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:9,代碼來源:SelectionBookmarkTest.ts

示例3: function

const setSelectionAtTouch = function (editorApi, touchEvent) {
  // shortTextFix, when text is short body height is short too, tapping at the bottom of the editor
  // should set a selection. We don't set body height to 100% because of side effects, so we resort
  // to a mousedown on the iDoc, it is a clean place, and very specific to this issue. On a vanilla
  // CE, with body height 100%, event sequence: touchstart, touchend, mousemove, mousedown, FOCUS,
  // mouseup, click. This is why we fire focus on mousedown, to match the natural sequence.
  Focus.focus(editorApi.body());

  // then set the selection to the end, last cursor position
  // Note: the reason why there is a flicker when we touch the bottom, is because of the native scroll
  // cursor into view, in this case it wants to scroll down so the text is centered on the screen,
  // we have to live with this until we control selection
  const touch = touchEvent.raw().changedTouches[0];
  WindowSelection.getAtPoint(editorApi.win(), touch.pageX, touch.pageY).each(function (raw) {
    editorApi.setSelection(raw.start(), raw.soffset(), raw.finish(), raw.foffset());
  });
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:17,代碼來源:IosHacks.ts

示例4: getCursorY

    return Step.stateful(function (value, next, die) {
      const pageBody = iframe.dom().contentWindow.document.body;
      const editorBody = pageBody.querySelector('iframe').contentWindow.document.body;
      const target = Option.from(editorBody.querySelectorAll(selector)[index]).map(Element.fromDom).getOrDie('no index ' + index + ' for selector: ' + selector);
      WindowSelection.setExact(editorBody.ownerDocument.defaultView, target, 0, target, 0);
      const socket = pageBody.querySelector('.tinymce-mobile-editor-socket');
      socket.scrollTop = target.dom().getBoundingClientRect().top - 100 - keyboardHeight;
      pageBody.style.setProperty('margin-bottom', '2000px');
      pageBody.ownerDocument.defaultView.scrollTo(0, keyboardHeight);

      //
      const cursorY = getCursorY(target);
      const newValue = Merger.deepMerge(
        value,
        {
          target,
          cursorY
        }
      );
      console.log('newValue', newValue);
      next(newValue);
    });
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:22,代碼來源:IosRealmTest.ts

示例5: function

const getCellFirstCursorPosition = function (editor, cell) {
  const selection = Selection.exact(cell, 0, cell, 0);
  return WindowSelection.toNative(selection);
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:4,代碼來源:TabContext.ts

示例6:

 return Traverse.parent(start).bind(function (parent) {
   const selection = Selection.exact(start, range.startOffset, parent, Awareness.getEnd(parent));
   const optRect = WindowSelection.getFirstRect(range.startContainer.ownerDocument.defaultView, selection);
   return optRect.map(collapsedRect).map(Arr.pure);
 }).getOr([ ]);
開發者ID:abstask,項目名稱:tinymce,代碼行數:5,代碼來源:Rectangles.ts

示例7: function

export default function () {
  const frame = Element.fromTag('iframe');
  Attr.set(frame, 'src', '/project/tinymce/src/themes/mobile/test/html/editor.html');

  const sWaitForEditorLoaded = Waiter.sTryUntil(
    'Waiting for iframe to load',
    Step.sync(() => {
      Assertions.assertEq('Check for a content editable body', 'true', frame.dom().contentWindow.document.body.contentEditable);
    }),
    100,
    8000
  );

  const config = {
    getFrame () {
      return frame;
    },
    onDomChanged () {
      return { unbind: Fun.noop };
    }
  };

  const delegate = TestEditor();
  const dEditor = delegate.editor();

  const editor = {
    selection: {
      getStart () {
        return WindowSelection.getExact(frame.dom().contentWindow).map(function (sel) {
          return sel.start().dom();
        }).getOr(null);
      },
      getContent () {
        return frame.dom().contentWindow.document.body.innerHTML;
      },
      select: Fun.noop
    },

    getBody () {
      return frame.dom().contentWindow.document.body;
    },

    insertContent: dEditor.insertContent,
    execCommand: dEditor.execCommand,
    dom: dEditor.dom,
    // Maybe this should be implemented
    focus () {
      Focus.focus(frame);
      const win = frame.dom().contentWindow;
      WindowSelection.getExact(win).orThunk(function () {
        const fbody = Element.fromDom(frame.dom().contentWindow.document.body);
        const elem = Cursors.calculateOne(fbody, [ 0 ]);
        WindowSelection.setExact(win, elem, 0, elem, 0);
        return Option.none();
      });
    },
    ui: {
      registry: {
        getAll: () => {
          return {
            icons: {}
          };
        }
      }
    }
  };

  const component = GuiFactory.build(
    GuiFactory.external({
      element: frame
    })
  );

  return {
    component: Fun.constant(component) as () => AlloyComponent,
    config: Fun.constant(config),
    editor: Fun.constant(editor),
    adder: delegate.adder,
    assertEq: delegate.assertEq,
    sAssertEq: delegate.sAssertEq,
    sWaitForEditorLoaded,
    sClear: delegate.sClear,
    sPrepareState: delegate.sPrepareState
  };
}
開發者ID:tinymce,項目名稱:tinymce,代碼行數:85,代碼來源:TestFrameEditor.ts


注:本文中的@ephox/sugar.WindowSelection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。