@vibe-tiptap/editor-ui 1.1.0 → 1.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-tiptap/editor-ui",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "description": "Vibe Tiptap UI 实现共享的工具栏、主题和文件辅助模块",
5
5
  "license": "ISC",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@excalidraw/excalidraw": "0.18.0-dabd83c",
21
- "@vibe-tiptap/core": "1.1.0"
21
+ "@vibe-tiptap/core": "1.1.3"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^18.0.0 || ^19.0.0",
@@ -1,7 +0,0 @@
1
- import type { Editor } from '@vibe-tiptap/core';
2
- export declare function trackTextBubbleAnchor(editor: Editor): {
3
- getReference(): {
4
- getBoundingClientRect: () => DOMRect;
5
- } | null;
6
- destroy(): void;
7
- };
@@ -1,60 +0,0 @@
1
- const DRAG_THRESHOLD = 4;
2
- export function trackTextBubbleAnchor(editor) {
3
- const { view } = editor;
4
- const { dom } = view;
5
- let anchor;
6
- function onMouseDown(event) {
7
- anchor = undefined;
8
- if (event.button !== 0 ||
9
- event.shiftKey ||
10
- event.ctrlKey ||
11
- event.metaKey ||
12
- event.altKey) {
13
- return;
14
- }
15
- const { clientX: x, clientY: y } = event;
16
- const hit = view.posAtCoords({ left: x, top: y });
17
- if (hit)
18
- anchor = { pos: hit.pos, x, y };
19
- }
20
- function onMouseMove(event) {
21
- if (anchor &&
22
- (event.buttons & 1) &&
23
- Math.hypot(event.clientX - anchor.x, event.clientY - anchor.y) > DRAG_THRESHOLD) {
24
- anchor = undefined;
25
- }
26
- }
27
- const onBeforeTransaction = ({ transaction, nextState, }) => {
28
- if (!anchor)
29
- return;
30
- if (!transaction.getMeta('pointer') &&
31
- (transaction.selectionSet || !nextState.selection.eq(editor.state.selection))) {
32
- anchor = undefined;
33
- }
34
- else if (transaction.docChanged) {
35
- const mapped = transaction.mapping.mapResult(anchor.pos);
36
- anchor = mapped.deleted ? undefined : { ...anchor, pos: mapped.pos };
37
- }
38
- };
39
- dom.addEventListener('mousedown', onMouseDown, true);
40
- dom.ownerDocument.addEventListener('mousemove', onMouseMove, true);
41
- editor.on('beforeTransaction', onBeforeTransaction);
42
- return {
43
- getReference() {
44
- const { selection } = editor.state;
45
- if (!anchor || selection.empty || anchor.pos < selection.from || anchor.pos > selection.to) {
46
- return null;
47
- }
48
- const { left, top, bottom } = view.coordsAtPos(anchor.pos);
49
- const rect = new DOMRect(left, top, 0, bottom - top);
50
- return {
51
- getBoundingClientRect: () => rect,
52
- };
53
- },
54
- destroy() {
55
- dom.removeEventListener('mousedown', onMouseDown, true);
56
- dom.ownerDocument.removeEventListener('mousemove', onMouseMove, true);
57
- editor.off('beforeTransaction', onBeforeTransaction);
58
- },
59
- };
60
- }