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 +4 -4
- data/CHANGELOG.md +6 -0
- data/app/assets/javascripts/smeditor.js +26 -14
- data/app/assets/stylesheets/smeditor.css +1 -0
- data/lib/smeditor/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b78483ba31701d6ff1da3c082c82396b6612812174f756d83312b13dc9f2a16d
|
|
4
|
+
data.tar.gz: d14fac8b9b6a172bf23fddf19eb0fa6b34b3eae978884ed7cc6b70b29a8c7e2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
-
|
|
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";
|
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
|
+
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.
|
|
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:
|