How to use the @ephox/sugar.Css.setAll function in @ephox/sugar

To help you get started, we’ve selected a few @ephox/sugar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / modes / Inline.ts View on Github external
const updateChromePosition = (toolbar: Option) => {
    // Calculate the toolbar offset when using a split toolbar drawer
    const offset = split ? toolbar.fold(() => 0, (tbar) => {
      // If we have an overflow toolbar, we need to offset the positioning by the height of the overflow toolbar
      return tbar.components().length > 1 ? Height.get(tbar.components()[1].element()) : 0;
    }) : 0;

    // The float container/editor may not have been rendered yet, which will cause it to have a non integer based positions
    // so we need to round this to account for that.
    const location = Location.absolute(targetElm);
    const top = location.top() - Height.get(floatContainer.element()) + offset;
    Css.setAll(uiComponents.outerContainer.element(), {
      position: 'absolute',
      top: Math.round(top) + 'px',
      left: Math.round(location.left()) + 'px'
    });

    // Update the max width of the inline toolbar
    const maxWidth = editorMaxWidthOpt.getOrThunk(() => {
      // No max width, so use the body width, minus the left pos as the maximum
      const bodyMargin = Utils.parseToInt(Css.get(Body.body(), 'margin-left')).getOr(0);
      return Width.get(Body.body()) - location.left() + bodyMargin;
    });
    Css.set(floatContainer.element(), 'max-width', maxWidth + 'px');
  };
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / modes / Iframe.ts View on Github external
identifyMenus(editor, rawUiConfig)
    );

    OuterContainer.setSidebar(
      uiComponents.outerContainer,
      rawUiConfig.sidebar
    );

    setupEvents(editor);
  });

  const socket = OuterContainer.getSocket(uiComponents.outerContainer).getOrDie('Could not find expected socket element');

  if (isTouch === true) {
    // TODO: move me, Setup mobile scrolling,
    Css.setAll(socket.element(), {
      'overflow': 'scroll',
      '-webkit-overflow-scrolling': 'touch' // required for ios < 13
    });
  }

  setupReadonlyModeSwitch(editor, uiComponents);

  editor.addCommand('ToggleSidebar', (ui: boolean, value: string) => {
    OuterContainer.toggleSidebar(uiComponents.outerContainer, value);
    editor.fire('ToggleSidebar');
  });

  editor.addQueryValueHandler('ToggleSidebar', () => {
    return OuterContainer.whichSidebar(uiComponents.outerContainer);
  });
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dialog / imagetools / ImagePanel.ts View on Github external
const panelW = Width.get(panel.element());
      const panelH = Height.get(panel.element());
      const width = img.dom().naturalWidth * zoom;
      const height = img.dom().naturalHeight * zoom;
      const left = Math.max(0, panelW / 2 - width / 2);
      const top = Math.max(0, panelH / 2 - height / 2);

      const css = {
        left: left.toString() + 'px',
        top: top.toString() + 'px',
        width: width.toString() + 'px',
        height: height.toString() + 'px',
        position: 'absolute'
      };

      Css.setAll(img, css);
      memBg.getOpt(panel).each((bg) => {
        Css.setAll(bg.element(), css);
      });

      cropRect.get().each((cRect) => {
        const rect = rectState.get();
        cRect.setRect({
          x: rect.x * zoom + left,
          y: rect.y * zoom + top,
          w: rect.w * zoom,
          h: rect.h * zoom
        });
        cRect.setClampRect({
          x: left,
          y: top,
          w: width,
github tinymce / tinymce / modules / tinymce / src / plugins / fullscreen / main / ts / core / Actions.ts View on Github external
      editorContainer.on((container) => Css.setAll(container, {
        top: visualViewport.offsetTop + 'px',
        left: visualViewport.offsetLeft + 'px',
        height: visualViewport.height + 'px',
        width: visualViewport.width + 'px'
      }));
    });
github tinymce / tinymce / modules / alloy / src / main / ts / ephox / alloy / behaviour / docking / DockingApis.ts View on Github external
const morphToCoord = (component: AlloyComponent, config: DockingConfig, scroll: SugarPosition, origin: SugarPosition, morph: DragCoord.CoordAdt): void => {
  const styles = DragCoord.toStyles(morph, scroll, origin);
  Css.setAll(component.element(), styles);
  const method = styles.position === 'fixed' ? config.onDocked : config.onUndocked;
  method(component);
};