Giter Site home page Giter Site logo

Comments (4)

bernesto avatar bernesto commented on July 24, 2024 1

Hi @artf,

The root issue is that we are trying to place a popover palette absolutely positioned over another element at an arbitrary location on the page. And we need to do this even when the origin element is outside of the editor container node.

To meet this requirement, the popover palette can not be contained anywhere within an offsetParent, and further it must be at the highest z-index. Otherwise it will be subject to the visible area of it's offsetParent and ordered by the parent's z-index.

In my prior patch, it appeared to work because the example editor took up the full window, and thus, left: 0 and top: 0 inside the editor element were left: 0 and top: 0 inside the body as well, and the parent for spectrum was rooted right under the top most editor node placing it at the same coordinates.

At the time, I didn't consider that the StyleManager may not be within the editor element; and that we'd never find the root element as we climbed the tree. This resulted in the coordinates of the palette relative to the origin input being inaccurately calculated in getOffset.

In InputColor.ts we append the container for spectrum to the editor node. Which will work in instances where the editor contains the InputColor element and the palette, but not outside of it.

To resolve this, we need to move the Spectrum palette container all the way to the body instead.

      var colorEl = $(`<div class="${this.ppfx}field-color-picker"></div>`);
      var cpStyle = colorEl.get(0)!.style;
      //var elToAppend = em && em.config ? em.config.el : '';
      var elToAppend = $('body');
      var colorPickerConfig = (em && em.getConfig && em.getConfig().colorPicker) || {};

That said, and as expected... appending Spectrum's parent container at the body has the cascading effect of not inheriting the editor styles either. As shown below:

image

vs.

image

We'd need to remove all of the .gjs-editor-cont parent classes in the style sheet, or replace them with something like .gjs-editor-sp and add that to the container.

Do you have any issues with these changes?

from grapesjs.

artf avatar artf commented on July 24, 2024

@bernesto can you check this one as it seems to be related to your changes

from grapesjs.

bernesto avatar bernesto commented on July 24, 2024

Yes, I see the issue. The logic needs to account for when the parent is outside of the container. Let me see what I can do there.

from grapesjs.

artf avatar artf commented on July 24, 2024

Fixed by @bernesto here

from grapesjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.