medium-editor icon indicating copy to clipboard operation
medium-editor copied to clipboard

The toolbar appear on the hcenter of the OL/UL instead of the selection in case of autolist

Open orbanbotond opened this issue 7 years ago • 2 comments

Description

I am using the autolist plugin https://github.com/varun-raj/medium-editor-autolist

When I select at least 3 lines and mark them as ordered list or unordered list then then toolbar appear at the horizontal centre of the ol/ul not at the horizontal centre of the selection.

Steps to reproduce

  1. write 3 lines
  2. select those 3 lines
  3. mark them as ordered list (use the above plugin)

Expected behavior: [What you expected to happen] The toolbar should appear at the horizontal centre of the selection Actual behavior: [What actually happened] Itappear at the horizontal centre of the ul/ol.

See these screenshots.

screen shot 2016-11-22 at 12 43 23 screen shot 2016-11-22 at 12 43 24

Versions

  • medium-editor:
  • browser:
  • OS:

orbanbotond avatar Nov 22 '16 11:11 orbanbotond

I've noticed this myself but am yet to come up with a way to figure out how to center the toolbar in respect to this. The few times I've tried to think about this, I've struggled to figure out how to find the exact coordinates of the rectangle created while selecting the text, which I'm assuming you'd need to do to properly align the toolbar.

Just for reference, there are some other cases where the toolbar alignment is a bit wonky, so just wanted to call them out in one place, in case someone comes up with some clever toolbar alignment fixes:

See also #1214 and #857

nmielnik avatar Feb 08 '17 06:02 nmielnik

let ecp=$(elementsContainer).offset(); positions.left=selection.getRangeAt(0).getBoundingClientRect().right-ecp.left; positions.top=selection.getRangeAt(0).getBoundingClientRect().top-ecp.top-$(toolbarElement).height()-6; positions.right='initial';

whxleemdddd avatar Jan 17 '21 15:01 whxleemdddd