smeditor 0.2.4 → 0.2.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3edf61aad6834f2726ef15563ef798a7d71ae7758868f016fcd82af1b3521e39
4
- data.tar.gz: 4ef021f5c72395a43f3f6dac47e5694c425bb4051691830f12ff83425f7e40e6
3
+ metadata.gz: b78483ba31701d6ff1da3c082c82396b6612812174f756d83312b13dc9f2a16d
4
+ data.tar.gz: d14fac8b9b6a172bf23fddf19eb0fa6b34b3eae978884ed7cc6b70b29a8c7e2e
5
5
  SHA512:
6
- metadata.gz: dbf99306fc6c0e519bc46f3de5910d7508f24d4016afde2aea1c713380db598e7145338b778d44c284f94902a1a5f31ca35e95e099355c8563e29a6f842930b3
7
- data.tar.gz: fda2e73e1c3df37b94c77911b0cf63c27d1d2d9bfa3488553a58b45f356601e3d7f015e524a847acc5878535ff5a5af33518310a4e52b3f583cc14fdb378c475
6
+ metadata.gz: f05b0e4d311cc29ab173c12b84d745fb8ef50c3a956d1983bf619a901fc738157cabcfe9784a197c28ff8991f88ccedc5b74af38a161aab1b63474b19c6c0841
7
+ data.tar.gz: c7ed0efe7cddecbde87182b620027ccfed65002948e14f4f68226e7ba3dc92bd1df095cd0445d3943e37193e2afd5a32159a34ff7ed19936aac5fad4104113a0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog — smeditor
2
2
 
3
+ ## 0.2.5 — 2026-09-09
4
+
5
+ - Fixed the Rails selected-text bubble toolbar being displaced to the right or vertically aligned with the text when the host application creates a CSS containing block (for example with `transform`, `filter`, `perspective`, or modal/animated wrappers).
6
+ - Bubble positioning now matches the playground: it is centered above the live selection, flips below near the top viewport edge, and clamps horizontally to the viewport.
7
+ - The Rails bubble is positioned in editor-local coordinates, so host layout transforms no longer corrupt its placement.
8
+
3
9
  ## 0.2.4 — 2026-09-09
4
10
 
5
11
  - Added the selected-text bubble formatting toolbar to the self-contained Rails adapter, matching the playground behavior.
@@ -463,13 +463,18 @@ function selectionForSurface(surface) {
463
463
  * This mirrors React's <BubbleMenu />: selecting non-empty text opens a small
464
464
  * formatting toolbar above the live DOM range.
465
465
  */
466
- function buildBubbleMenu(editor, surface) {
466
+ function buildBubbleMenu(editor, surface, container) {
467
467
  var _a;
468
468
  const menu = document.createElement("div");
469
469
  menu.className = "smeditor-floating smeditor-bubble-menu";
470
470
  menu.setAttribute("role", "toolbar");
471
471
  menu.setAttribute("aria-label", "Selected text formatting");
472
- menu.style.position = "fixed";
472
+ // Keep the popover in the editor's own coordinate space. `position: fixed`
473
+ // becomes relative to transformed/filtering ancestors in browsers, which can
474
+ // shove the menu to the right or down in host applications. Absolute local
475
+ // positioning is stable because both the selection and container are measured
476
+ // in viewport coordinates and then converted to editor-local coordinates.
477
+ menu.style.position = "absolute";
473
478
  menu.style.display = "none";
474
479
  menu.style.zIndex = "2147483000";
475
480
  const buttons = [
@@ -515,20 +520,27 @@ function buildBubbleMenu(editor, surface) {
515
520
  menu.style.left = "-9999px";
516
521
  menu.style.top = "-9999px";
517
522
  const rect = menu.getBoundingClientRect();
523
+ const containerRect = container.getBoundingClientRect();
518
524
  const margin = 8;
519
525
  const offset = 8;
520
526
  const viewportWidth = window.innerWidth;
521
527
  const viewportHeight = window.innerHeight;
522
- let left = anchor.left + anchor.width / 2 - rect.width / 2;
523
- left = Math.max(margin, Math.min(left, viewportWidth - rect.width - margin));
524
- let top = anchor.top - rect.height - offset;
525
- if (top < margin)
526
- top = anchor.bottom + offset;
527
- if (top + rect.height > viewportHeight - margin) {
528
- top = Math.max(margin, anchor.top - rect.height - offset);
529
- }
530
- menu.style.left = `${Math.round(left)}px`;
531
- menu.style.top = `${Math.round(top)}px`;
528
+ // Calculate the desired position in viewport coordinates first, exactly like
529
+ // the React playground's Floating primitive, including viewport clamping and
530
+ // top/bottom collision handling. Then translate that point into the local
531
+ // coordinate system of the editor shell. This survives transformed parents,
532
+ // zoomed panels, modals, sidebars and other containing-block creators.
533
+ let viewportLeft = anchor.left + anchor.width / 2 - rect.width / 2;
534
+ const maxViewportLeft = Math.max(margin, viewportWidth - rect.width - margin);
535
+ viewportLeft = Math.max(margin, Math.min(viewportLeft, maxViewportLeft));
536
+ let viewportTop = anchor.top - rect.height - offset;
537
+ if (viewportTop < margin)
538
+ viewportTop = anchor.bottom + offset;
539
+ if (viewportTop + rect.height > viewportHeight - margin) {
540
+ viewportTop = Math.max(margin, anchor.top - rect.height - offset);
541
+ }
542
+ menu.style.left = `${Math.round(viewportLeft - containerRect.left)}px`;
543
+ menu.style.top = `${Math.round(viewportTop - containerRect.top)}px`;
532
544
  menu.style.visibility = "visible";
533
545
  };
534
546
  const scheduleUpdate = () => {
@@ -618,8 +630,8 @@ function bootMount(mount) {
618
630
  });
619
631
  const toolbar = buildToolbar(editor, kit, uploadUrl);
620
632
  shell.insertBefore(toolbar, surface);
621
- const bubbleMenu = buildBubbleMenu(editor, surface);
622
- root.appendChild(bubbleMenu);
633
+ const bubbleMenu = buildBubbleMenu(editor, surface, shell);
634
+ shell.appendChild(bubbleMenu);
623
635
  input.smeditorInstance = editor;
624
636
  mount.smeditorInstance = editor;
625
637
  mount.dataset.smeditorBooted = "1";
@@ -143,6 +143,7 @@
143
143
  */
144
144
 
145
145
  .smeditor {
146
+ position: relative;
146
147
  font-family: var(--sme-font-sans);
147
148
  color: var(--sme-color-text);
148
149
  background: var(--sme-color-surface);
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SMEditor
4
4
  module Rails
5
- VERSION = "0.2.4"
5
+ VERSION = "0.2.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - SMEditor contributors
@@ -96,7 +96,7 @@ metadata:
96
96
  source_code_uri: https://github.com/sCruze/smeditor/tree/main/gems/smeditor
97
97
  changelog_uri: https://github.com/sCruze/smeditor/blob/main/gems/smeditor/CHANGELOG.md
98
98
  bug_tracker_uri: https://github.com/sCruze/smeditor/issues
99
- documentation_uri: https://rubydoc.info/gems/smeditor/0.2.4
99
+ documentation_uri: https://rubydoc.info/gems/smeditor/0.2.5
100
100
  rubygems_mfa_required: 'true'
101
101
  rdoc_options: []
102
102
  require_paths: