@nuasite/cms 0.7.0 → 0.7.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.
- package/dist/editor.js +1492 -1481
- package/package.json +1 -1
- package/src/editor/components/block-editor.tsx +19 -6
- package/src/editor/components/outline.tsx +1 -1
package/package.json
CHANGED
|
@@ -79,33 +79,46 @@ export function BlockEditor({
|
|
|
79
79
|
|
|
80
80
|
const updatePosition = () => {
|
|
81
81
|
const editorWidth = LAYOUT.BLOCK_EDITOR_WIDTH
|
|
82
|
+
const editorHeight = LAYOUT.BLOCK_EDITOR_HEIGHT
|
|
82
83
|
const padding = LAYOUT.VIEWPORT_PADDING
|
|
83
84
|
const viewportWidth = window.innerWidth
|
|
84
85
|
const viewportHeight = window.innerHeight
|
|
85
86
|
|
|
86
87
|
let top: number
|
|
87
88
|
let left: number
|
|
89
|
+
let maxHeight: number
|
|
88
90
|
|
|
89
91
|
if (cursor) {
|
|
90
|
-
top = cursor.y
|
|
91
92
|
left = cursor.x
|
|
92
93
|
|
|
93
|
-
// Keep within viewport bounds
|
|
94
|
+
// Keep within viewport bounds horizontally
|
|
94
95
|
if (left + editorWidth > viewportWidth - padding) {
|
|
95
96
|
left = viewportWidth - editorWidth - padding
|
|
96
97
|
}
|
|
97
98
|
if (left < padding) {
|
|
98
99
|
left = padding
|
|
99
100
|
}
|
|
101
|
+
|
|
102
|
+
const spaceBelow = viewportHeight - cursor.y - padding
|
|
103
|
+
const spaceAbove = cursor.y - padding
|
|
104
|
+
|
|
105
|
+
if (spaceBelow >= editorHeight || spaceBelow >= spaceAbove) {
|
|
106
|
+
// Open below cursor
|
|
107
|
+
top = Math.max(padding, Math.min(cursor.y, viewportHeight - padding - 100))
|
|
108
|
+
maxHeight = viewportHeight - top - padding
|
|
109
|
+
} else {
|
|
110
|
+
// Open above cursor — anchor bottom of panel to cursor position
|
|
111
|
+
const panelHeight = Math.min(spaceAbove, editorHeight)
|
|
112
|
+
top = cursor.y - panelHeight
|
|
113
|
+
top = Math.max(padding, top)
|
|
114
|
+
maxHeight = cursor.y - top
|
|
115
|
+
}
|
|
100
116
|
} else {
|
|
101
117
|
top = viewportHeight / 2
|
|
102
118
|
left = (viewportWidth - editorWidth) / 2
|
|
119
|
+
maxHeight = viewportHeight - top - padding
|
|
103
120
|
}
|
|
104
121
|
|
|
105
|
-
// Clamp top so the panel never extends past the viewport bottom
|
|
106
|
-
top = Math.max(padding, Math.min(top, viewportHeight - padding - 100))
|
|
107
|
-
const maxHeight = viewportHeight - top - padding
|
|
108
|
-
|
|
109
122
|
setEditorPosition({ top, left, maxHeight })
|
|
110
123
|
}
|
|
111
124
|
|