edytor 0.1.0-next.28 → 0.1.0-next.29
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/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
Edytor aims to be for Svelte what Slate.js is for React: a heavily customizable editor with an API to build any kind of collaborative rich text editor.
|
|
17
17
|
|
|
18
|
-
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.
|
|
18
|
+
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.29`, `edytor@next` on npm) and not ready for production; the API changes between releases without a compatibility layer. The untagged `edytor@0.0.11` on npm predates the current API. Issues and PRs are welcome: when you report a bug, include the document's JSON value.
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
@@ -120,7 +120,7 @@ const backdrop = (document) => {
|
|
|
120
120
|
node.setAttribute('aria-hidden', 'true');
|
|
121
121
|
return node;
|
|
122
122
|
};
|
|
123
|
-
/** How many blocks move: the badge
|
|
123
|
+
/** How many blocks move: the badge beside the drop indicator. */
|
|
124
124
|
const countBadge = (document, count) => {
|
|
125
125
|
const badge = document.createElement('span');
|
|
126
126
|
badge.dataset.edytorDragCount = 'true';
|
|
@@ -367,9 +367,7 @@ export class BlockHandleController {
|
|
|
367
367
|
const root = this.edytor.node;
|
|
368
368
|
const nodes = group.flatMap((moved) => (moved.node ? [moved.node] : []));
|
|
369
369
|
if (nativeSetDragImage && root && nodes.length) {
|
|
370
|
-
const
|
|
371
|
-
const badge = count > 1 ? countBadge(element.ownerDocument, count) : undefined;
|
|
372
|
-
const preview = dragPreview(root, nodes, location.current.input, badge);
|
|
370
|
+
const preview = dragPreview(root, nodes, location.current.input);
|
|
373
371
|
setCustomNativeDragPreview({
|
|
374
372
|
nativeSetDragImage,
|
|
375
373
|
getOffset: preview.offset,
|
|
@@ -21,13 +21,13 @@ export type DragPreview = {
|
|
|
21
21
|
/**
|
|
22
22
|
* The ghost of `nodes` (the dragged blocks' elements, in document order),
|
|
23
23
|
* grabbed at `pointer`: a copy of each block laid out at its own width (the
|
|
24
|
-
* widest of them; the editor's content width when none is laid out), scaled by `SCALE` from its top left, cut at `MAX_HEIGHT
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* widest of them; the editor's content width when none is laid out), scaled by `SCALE` from its top left, cut at `MAX_HEIGHT`.
|
|
25
|
+
* Nothing is added (no card, background, shadow, opacity, fade or count
|
|
26
|
+
* badge): the blocks' own look. The pointer
|
|
27
27
|
* keeps its place on the first block (a handle is left of it: a transparent
|
|
28
28
|
* gutter keeps the offset positive, which every browser supports).
|
|
29
29
|
*/
|
|
30
30
|
export declare const dragPreview: (root: HTMLElement, nodes: HTMLElement[], pointer: {
|
|
31
31
|
clientX: number;
|
|
32
32
|
clientY: number;
|
|
33
|
-
}
|
|
33
|
+
}) => DragPreview;
|
|
@@ -158,13 +158,13 @@ const contentWidth = (root) => {
|
|
|
158
158
|
/**
|
|
159
159
|
* The ghost of `nodes` (the dragged blocks' elements, in document order),
|
|
160
160
|
* grabbed at `pointer`: a copy of each block laid out at its own width (the
|
|
161
|
-
* widest of them; the editor's content width when none is laid out), scaled by `SCALE` from its top left, cut at `MAX_HEIGHT
|
|
162
|
-
*
|
|
163
|
-
*
|
|
161
|
+
* widest of them; the editor's content width when none is laid out), scaled by `SCALE` from its top left, cut at `MAX_HEIGHT`.
|
|
162
|
+
* Nothing is added (no card, background, shadow, opacity, fade or count
|
|
163
|
+
* badge): the blocks' own look. The pointer
|
|
164
164
|
* keeps its place on the first block (a handle is left of it: a transparent
|
|
165
165
|
* gutter keeps the offset positive, which every browser supports).
|
|
166
166
|
*/
|
|
167
|
-
export const dragPreview = (root, nodes, pointer
|
|
167
|
+
export const dragPreview = (root, nodes, pointer) => {
|
|
168
168
|
const { ownerDocument: document } = root;
|
|
169
169
|
const first = nodes[0]?.getBoundingClientRect();
|
|
170
170
|
const dx = first ? pointer.clientX - first.left : 0;
|
|
@@ -201,10 +201,6 @@ export const dragPreview = (root, nodes, pointer, badge) => {
|
|
|
201
201
|
overflow: 'hidden'
|
|
202
202
|
});
|
|
203
203
|
box.append(scaled);
|
|
204
|
-
if (badge) {
|
|
205
|
-
Object.assign(badge.style, { top: '4px', right: '4px' });
|
|
206
|
-
box.append(badge);
|
|
207
|
-
}
|
|
208
204
|
const element = document.createElement('div');
|
|
209
205
|
element.dataset.edytorDragPreview = 'true';
|
|
210
206
|
element.dataset.count = String(nodes.length);
|