Closed mcottret closed 3 years ago
Yes, I guess you're right. It doesn't actually make sense activating RTE without selecting the component (it probably makes sense with all other "activatable" blocks).
Hello, just updated the file from commit bb4a661, and i think it's so close, i'm using the grapesjs-ckeditor code and the first open of RTE, i'ts placed right:
But at the second time the rte is open, it's misplaced again... :/
I'll keep checking for it :/
I have the same issue. Did anyone find a solution?
Hi. Me and @ronaldohoch have found a workaround for this problem.
We trigger the scroll event when the RTE is enabled. Here's the code:
// Trigger scroll event from canvas so that grapesjs
// fix CKEditor position correctly
editor.on("rte:enable", () => {
editor.trigger('canvasScroll');
});
Thank you for your answer, i tried your code after
const editor = grapesjs.init({...})
But it didn't change anything, i thought it's about my grapesjs version and, i upgraded my version but still missplaced when i open the text block for the first time
Can you provide some code in jsfiddle? https://jsfiddle.net/szLp8h4n
Version: 0.17.4
Are you able to reproduce the bug from the demo?
Steps to reproduce:
What is the expected behavior?
The opened RTE should be positioned correctly
What is the current behavior?
The RTE is misplaced, it hides the "Text" component's content & can prevent editing properly (especially when using bigger custom RTE like CKEditor).
This only happens when the RTE is first opened & only if the dropped block is a "Text" component with
activeOnRender
option set totrue
.This is caused by a miscalculation of the toolbar's position when its
offsetHeight
equals 0. Itself due to its parent (CanvasView.toolsEl
) being set todisplay: none
at this time (becauserte.enable
is called on drop whenactiveOnRender
istrue
, which happens while the component is unselected as opposed to normal, hence itstoolsEl
still being set todisplay: none
)Proposed solution:
Selecting the component before triggering
activeOnRender
'sactive
event seems to fix the issue.Concretely, adding
em.setSelected(result);
beforeresult.trigger('active');
here should do it, unless I'm missing something.I could take care of the PR if this looks good to you :)
Are you able to attach screenshots, screencasts or a live demo?