autumnnote 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autumnnote",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "A modern, lightweight WYSIWYG editor — built with vanilla JavaScript, no jQuery required.",
5
5
  "main": "dist/autumnnote.umd.js",
6
6
  "module": "dist/autumnnote.es.js",
@@ -237,26 +237,29 @@ export class Toolbar {
237
237
 
238
238
  const openPopup = () => {
239
239
  isOpen = true;
240
- // Use fixed positioning to escape overflow-clipping ancestors
241
- // (toolbar scroll mode and mobile overflow-x:auto both clip position:absolute)
242
240
  const rect = btn.getBoundingClientRect();
241
+
242
+ // Measure popup dimensions while invisible so we can set the correct
243
+ // position before the browser paints (matches the color-picker pattern).
244
+ popup.style.visibility = 'hidden';
243
245
  popup.style.display = 'block';
244
246
  const pw = popup.offsetWidth;
245
247
  const ph = popup.offsetHeight;
248
+
246
249
  let left = rect.left;
247
250
  let top = rect.bottom + 4;
248
251
  if (left + pw > window.innerWidth - 8) left = Math.max(8, window.innerWidth - pw - 8);
249
- if (top + ph > window.innerHeight - 8) top = rect.top - ph - 4;
252
+ if (top + ph > window.innerHeight - 8) top = rect.top - ph - 4;
253
+
250
254
  popup.style.left = `${left}px`;
251
255
  popup.style.top = `${top}px`;
256
+ popup.style.visibility = '';
252
257
  btn.setAttribute('aria-expanded', 'true');
253
258
  };
254
259
 
255
260
  const closePopup = () => {
256
261
  isOpen = false;
257
262
  popup.style.display = 'none';
258
- popup.style.top = '';
259
- popup.style.left = '';
260
263
  btn.setAttribute('aria-expanded', 'false');
261
264
  setHighlight(0, 0);
262
265
  };
@@ -286,10 +289,14 @@ export class Toolbar {
286
289
 
287
290
  const d5 = on(document, 'click', () => { if (isOpen) closePopup(); });
288
291
 
289
- this._disposers.push(d1, d2, d3, d4, d5);
292
+ // Append popup to body so position:fixed is truly viewport-relative,
293
+ // unaffected by any ancestor transform / filter (same pattern as color picker).
294
+ this._disposers.push(d1, d2, d3, d4, d5, () => {
295
+ if (popup.parentNode) popup.parentNode.removeChild(popup);
296
+ });
290
297
 
291
298
  wrap.appendChild(btn);
292
- wrap.appendChild(popup);
299
+ document.body.appendChild(popup);
293
300
  return wrap;
294
301
  }
295
302