u2ui 1.5.7 → 1.5.8
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.
|
@@ -2,7 +2,7 @@ import {elementAttributes, selectedElement} from '../command/element.js';
|
|
|
2
2
|
import {inlineUi} from '../config/config.js';
|
|
3
3
|
import {caretAfter} from '../ui/caret.js';
|
|
4
4
|
import {Handles} from '../ui/handles.js';
|
|
5
|
-
import {place} from '../ui/place.js';
|
|
5
|
+
import {panelGap, place} from '../ui/place.js';
|
|
6
6
|
|
|
7
7
|
const STYLE = `
|
|
8
8
|
#image {
|
|
@@ -193,7 +193,7 @@ function position(state, box = null) {
|
|
|
193
193
|
state.handles.place(handle.name, rect.left + rect.width * handle.x, rect.top + rect.height * handle.y);
|
|
194
194
|
}
|
|
195
195
|
// Below the image, clear of the handles sitting on its lower edge.
|
|
196
|
-
place(state.alt, state.active.view.surface, {align: 'start', prefer: 'below', gap:
|
|
196
|
+
place(state.alt, state.active.view.surface, {align: 'start', prefer: 'below', gap: panelGap, on: rect});
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
function build(state) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {inlineUi} from '../config/config.js';
|
|
2
2
|
import {linkHtml} from '../mark/standard.js';
|
|
3
3
|
import {caretAfter} from '../ui/caret.js';
|
|
4
|
-
import {place} from '../ui/place.js';
|
|
4
|
+
import {panelGap, place} from '../ui/place.js';
|
|
5
5
|
import {valueMark} from '../command/mark.js';
|
|
6
6
|
|
|
7
7
|
const STYLE = `
|
|
@@ -419,7 +419,7 @@ function position(state) {
|
|
|
419
419
|
return place(state.form, active.surface, {
|
|
420
420
|
align: 'start',
|
|
421
421
|
prefer: 'below',
|
|
422
|
-
gap:
|
|
422
|
+
gap: panelGap,
|
|
423
423
|
on: active.element?.getBoundingClientRect() || null,
|
|
424
424
|
});
|
|
425
425
|
}
|
package/js/rte/src/ui/README.md
CHANGED
|
@@ -243,6 +243,11 @@ keeps the element inside the viewport, and falls to the other side when the
|
|
|
243
243
|
preferred one does not fit. The roaming toolbar centres above the selection; the
|
|
244
244
|
link form aligns to its start and prefers below.
|
|
245
245
|
|
|
246
|
+
Two panels can answer for the same thing — an image that is also a link brings
|
|
247
|
+
its frame, its name and its address — so a panel goes under whatever is already
|
|
248
|
+
drawn where it wants to be, in the order the chrome holds them. `panelGap` is
|
|
249
|
+
the one distance they all keep from what they hang off, and from each other.
|
|
250
|
+
|
|
246
251
|
`caretAfter(surface, element)` is its counterpart at the end: the one way a
|
|
247
252
|
contextual UI hands the caret back, after the element it was about to change
|
|
248
253
|
rather than inside it. An element that is no longer there leaves the surface
|
package/js/rte/src/ui/place.js
CHANGED
|
@@ -6,6 +6,11 @@ import {rangeRect} from '../browser/range-rect.js';
|
|
|
6
6
|
//
|
|
7
7
|
// A UI that belongs to one element rather than to the selection passes that
|
|
8
8
|
// element's rect as `on`: what it points at should not shift with the caret.
|
|
9
|
+
// One distance for every panel that hangs off an element rather than off the
|
|
10
|
+
// selection: the handles on a frame's edge reach about this far, and two panels
|
|
11
|
+
// answering for the same element must not sit at two different heights.
|
|
12
|
+
export const panelGap = 16;
|
|
13
|
+
|
|
9
14
|
export function place(element, surface, {align = 'center', prefer = 'above', gap = 28, on = null} = {}) {
|
|
10
15
|
const range = on ? null : surface.selection?.range();
|
|
11
16
|
if (!on && !range) return false;
|
|
@@ -19,7 +24,24 @@ export function place(element, surface, {align = 'center', prefer = 'above', gap
|
|
|
19
24
|
const top = prefer === 'above'
|
|
20
25
|
? (fits ? above : Math.min(view.innerHeight - box.height - gap, below))
|
|
21
26
|
: (fits ? below : Math.max(gap, above));
|
|
22
|
-
|
|
23
|
-
element.style.
|
|
27
|
+
const left = Math.max(gap, Math.min(view.innerWidth - box.width - gap, start));
|
|
28
|
+
element.style.left = `${left}px`;
|
|
29
|
+
element.style.top = `${clear(element, {top, left, width: box.width, height: box.height}, gap)}px`;
|
|
24
30
|
return true;
|
|
25
31
|
}
|
|
32
|
+
|
|
33
|
+
// Two panels can answer for the same thing — an image that is also a link — and
|
|
34
|
+
// the second must not sit on the first. What is already drawn keeps its spot and
|
|
35
|
+
// the newcomer goes under it, in the order the chrome holds them, so the same
|
|
36
|
+
// two always stack the same way round.
|
|
37
|
+
function clear(element, box, gap) {
|
|
38
|
+
let top = box.top;
|
|
39
|
+
for (const panel of element.getRootNode().querySelectorAll?.('.panel') ?? []) {
|
|
40
|
+
if (panel === element || panel.hidden) continue;
|
|
41
|
+
const other = panel.getBoundingClientRect();
|
|
42
|
+
const misses = other.bottom <= top || other.top >= top + box.height
|
|
43
|
+
|| other.right <= box.left || other.left >= box.left + box.width;
|
|
44
|
+
if (!misses) top = other.bottom + gap;
|
|
45
|
+
}
|
|
46
|
+
return top;
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "u2ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "HTML Advanced: More Capabilities, Same Feel, Same Simplicity",
|
|
5
5
|
"keywords": ["web-components","pattern-library","component-library","ui-toolkit","design-system"],
|
|
6
6
|
"author": "Tobias Buschor",
|