@sequent-org/moodboard 1.4.32 → 1.4.34
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 +5 -1
- package/src/assets/fonts/inter/inter-cyrillic-400-normal.woff2 +0 -0
- package/src/assets/fonts/inter/inter-cyrillic-500-normal.woff2 +0 -0
- package/src/assets/fonts/inter/inter-latin-400-normal.woff2 +0 -0
- package/src/assets/fonts/inter/inter-latin-500-normal.woff2 +0 -0
- package/src/assets/icons/attachments.svg +3 -1
- package/src/assets/icons/comments.svg +2 -2
- package/src/assets/icons/connector.svg +6 -0
- package/src/assets/icons/emoji.svg +6 -1
- package/src/assets/icons/frame.svg +4 -1
- package/src/assets/icons/image.svg +5 -1
- package/src/assets/icons/laser.svg +1 -0
- package/src/assets/icons/lasso.svg +5 -0
- package/src/assets/icons/mindmap.svg +10 -2
- package/src/assets/icons/note.svg +4 -1
- package/src/assets/icons/pan.svg +5 -2
- package/src/assets/icons/pencil.svg +4 -1
- package/src/assets/icons/reactions.svg +5 -0
- package/src/assets/icons/redo.svg +3 -2
- package/src/assets/icons/select.svg +2 -8
- package/src/assets/icons/shapes.svg +5 -1
- package/src/assets/icons/text-add.svg +15 -1
- package/src/assets/icons/undo.svg +3 -2
- package/src/assets/reactions/1f44d.svg +20 -0
- package/src/assets/reactions/1f44e.svg +20 -0
- package/src/assets/reactions/2705.svg +20 -0
- package/src/assets/reactions/274c.svg +19 -0
- package/src/assets/reactions/2753.svg +20 -0
- package/src/assets/reactions/2764.svg +22 -0
- package/src/assets/reactions/2b50.svg +19 -0
- package/src/assets/reactions/plus-one.svg +25 -0
- package/src/core/PixiEngine.js +23 -0
- package/src/core/bootstrap/CoreInitializer.js +43 -0
- package/src/core/commands/GroupDeleteCommand.js +13 -1
- package/src/core/commands/UpdateShapeStyleCommand.js +121 -0
- package/src/core/commands/UpdateTextStyleCommand.js +17 -6
- package/src/core/commands/index.js +3 -0
- package/src/core/events/Events.js +22 -0
- package/src/core/flows/LayerAndViewportFlow.js +1 -0
- package/src/core/flows/ObjectLifecycleFlow.js +155 -7
- package/src/core/index.js +28 -1
- package/src/grid/CrossGridZoomPhases.js +3 -3
- package/src/initNoBundler.js +1 -1
- package/src/moodboard/DataManager.js +28 -0
- package/src/moodboard/MoodBoard.js +27 -0
- package/src/moodboard/bootstrap/MoodBoardInitializer.js +69 -1
- package/src/moodboard/bootstrap/MoodBoardUiFactory.js +22 -4
- package/src/moodboard/integration/MoodBoardEventBindings.js +5 -1
- package/src/moodboard/integration/MoodBoardLoadApi.js +10 -1
- package/src/moodboard/lifecycle/MoodBoardDestroyer.js +9 -0
- package/src/objects/ConnectorObject.js +2 -2
- package/src/objects/FrameObject.js +119 -59
- package/src/objects/ShapeObject.js +49 -74
- package/src/objects/shape/ShapeDrawer.js +210 -0
- package/src/services/ConnectorBindingResolver.js +112 -0
- package/src/services/ConnectorRouter.js +210 -0
- package/src/services/ai/ChatSessionController.js +14 -8
- package/src/services/comments/CommentService.js +344 -0
- package/src/tools/object-tools/CommentTool.js +85 -0
- package/src/tools/object-tools/DrawingTool.js +110 -10
- package/src/tools/object-tools/LaserPointerTool.js +121 -0
- package/src/tools/object-tools/SelectTool.js +25 -1
- package/src/tools/object-tools/TextTool.js +6 -1
- package/src/tools/object-tools/connector/ConnectorDragController.js +50 -3
- package/src/tools/object-tools/connector/connectorGesture.js +33 -19
- package/src/tools/object-tools/placement/PlacementInputRouter.js +22 -1
- package/src/tools/object-tools/selection/BoxSelectController.js +24 -2
- package/src/tools/object-tools/selection/FrameTitleInlineEditorController.js +139 -0
- package/src/tools/object-tools/selection/InlineEditorController.js +12 -0
- package/src/tools/object-tools/selection/InlineEditorDomFactory.js +36 -0
- package/src/tools/object-tools/selection/LassoSelectController.js +125 -0
- package/src/tools/object-tools/selection/MindmapInlineEditorController.js +1 -0
- package/src/tools/object-tools/selection/SelectInputRouter.js +64 -5
- package/src/tools/object-tools/selection/SelectToolLifecycleController.js +11 -1
- package/src/tools/object-tools/selection/SelectToolSetup.js +13 -1
- package/src/tools/object-tools/selection/TextEditorInteractionController.js +46 -12
- package/src/tools/object-tools/selection/TextEditorSyncService.js +1 -0
- package/src/tools/object-tools/selection/TextInlineEditorController.js +65 -6
- package/src/ui/CommentPopover.js +6 -0
- package/src/ui/CommentsBar.js +91 -0
- package/src/ui/ConnectorPropertiesPanel.js +150 -0
- package/src/ui/ContextMenu.js +25 -0
- package/src/ui/DrawingPropertiesPanel.js +362 -0
- package/src/ui/FilePropertiesPanel.js +5 -0
- package/src/ui/FramePropertiesPanel.js +5 -0
- package/src/ui/HtmlTextLayer.js +246 -66
- package/src/ui/NotePropertiesPanel.js +6 -0
- package/src/ui/ShapePropertiesPanel.js +307 -0
- package/src/ui/TextPropertiesPanel.js +100 -1
- package/src/ui/Toolbar.js +25 -2
- package/src/ui/Topbar.js +2 -2
- package/src/ui/animation/HoverLiftController.js +6 -7
- package/src/ui/chat/ChatComposer.js +63 -9
- package/src/ui/chat/ChatWindow.js +329 -166
- package/src/ui/comments/CommentListPanel.js +213 -0
- package/src/ui/comments/CommentPinLayer.js +448 -0
- package/src/ui/comments/CommentThreadPopover.js +539 -0
- package/src/ui/comments/commentFormat.js +32 -0
- package/src/ui/connector-properties/ConnectorPropertiesPanelBindings.js +223 -0
- package/src/ui/connector-properties/ConnectorPropertiesPanelEventBridge.js +114 -0
- package/src/ui/connector-properties/ConnectorPropertiesPanelMapper.js +144 -0
- package/src/ui/connector-properties/ConnectorPropertiesPanelRenderer.js +447 -0
- package/src/ui/connector-properties/ConnectorPropertiesPanelState.js +61 -0
- package/src/ui/connectors/ConnectionAnchorsLayer.js +1 -0
- package/src/ui/connectors/ConnectorHandlesLayer.js +321 -0
- package/src/ui/connectors/ConnectorLabelLayer.js +334 -0
- package/src/ui/connectors/ConnectorLayer.js +264 -57
- package/src/ui/handles/HandlesDomRenderer.js +5 -13
- package/src/ui/handles/HandlesEventBridge.js +1 -0
- package/src/ui/handles/SingleSelectionHandlesController.js +4 -0
- package/src/ui/mindmap/MindmapCollapseLayer.js +1 -0
- package/src/ui/mindmap/MindmapConnectionLayer.js +1 -0
- package/src/ui/mindmap/MindmapHtmlTextLayer.js +6 -0
- package/src/ui/shape-properties/ShapePropertiesPanelDom.js +533 -0
- package/src/ui/shape-properties/ShapePropertiesPanelSync.js +132 -0
- package/src/ui/styles/chat.css +710 -18
- package/src/ui/styles/index.css +1 -0
- package/src/ui/styles/panels.css +112 -2
- package/src/ui/styles/shape-properties-panel.css +250 -0
- package/src/ui/styles/toolbar.css +7 -2
- package/src/ui/styles/topbar.css +1 -1
- package/src/ui/styles/workspace.css +257 -6
- package/src/ui/text-properties/TextFormatControls.js +88 -0
- package/src/ui/text-properties/TextListRenderer.js +137 -0
- package/src/ui/text-properties/TextPropertiesPanelBindings.js +27 -0
- package/src/ui/text-properties/TextPropertiesPanelEventBridge.js +3 -1
- package/src/ui/text-properties/TextPropertiesPanelMapper.js +56 -0
- package/src/ui/text-properties/TextPropertiesPanelRenderer.js +24 -0
- package/src/ui/text-properties/TextPropertiesPanelState.js +8 -0
- package/src/ui/toolbar/ReactionsPopupController.js +88 -0
- package/src/ui/toolbar/ToolbarActionRouter.js +71 -5
- package/src/ui/toolbar/ToolbarPopupsController.js +120 -118
- package/src/ui/toolbar/ToolbarRenderer.js +9 -1
- package/src/ui/toolbar/ToolbarStateController.js +4 -1
- package/src/utils/iconLoader.js +17 -16
- package/src/utils/markdown.js +14 -0
- package/src/utils/richText.js +125 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { Events } from '../../core/events/Events.js';
|
|
2
|
+
import { formatTime, pluralize, stripHtml } from './commentFormat.js';
|
|
3
|
+
|
|
4
|
+
const CLOSE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;
|
|
5
|
+
const CHECKMARK_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`;
|
|
6
|
+
const TRASH_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M6 6l1 14a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-14"/></svg>`;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Боковая панель со списком всех тредов доски.
|
|
10
|
+
* Открывается/закрывается по Events.Comment.ListOpened (toggle).
|
|
11
|
+
*/
|
|
12
|
+
export class CommentListPanel {
|
|
13
|
+
constructor(container, eventBus, core, commentService) {
|
|
14
|
+
this.container = container;
|
|
15
|
+
this.eventBus = eventBus;
|
|
16
|
+
this.core = core;
|
|
17
|
+
this.commentService = commentService;
|
|
18
|
+
|
|
19
|
+
this._panel = null;
|
|
20
|
+
this._body = null;
|
|
21
|
+
this._isOpen = false;
|
|
22
|
+
|
|
23
|
+
this._onListOpened = () => this.toggle();
|
|
24
|
+
this._onUpdate = () => { if (this._isOpen) this._renderList(); };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
attach() {
|
|
28
|
+
this._panel = document.createElement('div');
|
|
29
|
+
this._panel.className = 'moodboard-comments-list';
|
|
30
|
+
this._panel.style.display = 'none';
|
|
31
|
+
|
|
32
|
+
const header = document.createElement('div');
|
|
33
|
+
header.className = 'moodboard-comments-list__header';
|
|
34
|
+
|
|
35
|
+
const closeBtn = document.createElement('button');
|
|
36
|
+
closeBtn.type = 'button';
|
|
37
|
+
closeBtn.className = 'moodboard-comments-list__close';
|
|
38
|
+
closeBtn.setAttribute('aria-label', 'Закрыть');
|
|
39
|
+
closeBtn.innerHTML = CLOSE_SVG;
|
|
40
|
+
closeBtn.addEventListener('click', () => this.hide());
|
|
41
|
+
|
|
42
|
+
const title = document.createElement('span');
|
|
43
|
+
title.className = 'moodboard-comments-list__title';
|
|
44
|
+
title.textContent = 'Комментарии';
|
|
45
|
+
|
|
46
|
+
header.appendChild(title);
|
|
47
|
+
header.appendChild(closeBtn);
|
|
48
|
+
|
|
49
|
+
this._body = document.createElement('div');
|
|
50
|
+
this._body.className = 'moodboard-comments-list__body';
|
|
51
|
+
|
|
52
|
+
this._panel.appendChild(header);
|
|
53
|
+
this._panel.appendChild(this._body);
|
|
54
|
+
this.container.appendChild(this._panel);
|
|
55
|
+
|
|
56
|
+
this.eventBus.on(Events.Comment.ListOpened, this._onListOpened);
|
|
57
|
+
this.eventBus.on(Events.Comment.RemoteUpdated, this._onUpdate);
|
|
58
|
+
this.eventBus.on(Events.Comment.MessageAdded, this._onUpdate);
|
|
59
|
+
this.eventBus.on(Events.Comment.Resolved, this._onUpdate);
|
|
60
|
+
this.eventBus.on(Events.Comment.ThreadDeleted, this._onUpdate);
|
|
61
|
+
this.eventBus.on(Events.Comment.PinCreated, this._onUpdate);
|
|
62
|
+
this.eventBus.on(Events.Comment.ColorChanged, this._onUpdate);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
destroy() {
|
|
66
|
+
this.eventBus.off(Events.Comment.ListOpened, this._onListOpened);
|
|
67
|
+
this.eventBus.off(Events.Comment.RemoteUpdated, this._onUpdate);
|
|
68
|
+
this.eventBus.off(Events.Comment.MessageAdded, this._onUpdate);
|
|
69
|
+
this.eventBus.off(Events.Comment.Resolved, this._onUpdate);
|
|
70
|
+
this.eventBus.off(Events.Comment.ThreadDeleted, this._onUpdate);
|
|
71
|
+
this.eventBus.off(Events.Comment.PinCreated, this._onUpdate);
|
|
72
|
+
this.eventBus.off(Events.Comment.ColorChanged, this._onUpdate);
|
|
73
|
+
if (this._panel) {
|
|
74
|
+
this._panel.remove();
|
|
75
|
+
this._panel = null;
|
|
76
|
+
}
|
|
77
|
+
this._body = null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
toggle() {
|
|
81
|
+
if (this._isOpen) {
|
|
82
|
+
this.hide();
|
|
83
|
+
} else {
|
|
84
|
+
this.show();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
show() {
|
|
89
|
+
if (!this._panel) return;
|
|
90
|
+
this._isOpen = true;
|
|
91
|
+
this._panel.style.display = 'flex';
|
|
92
|
+
this._renderList();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
hide() {
|
|
96
|
+
if (!this._panel) return;
|
|
97
|
+
this._isOpen = false;
|
|
98
|
+
this._panel.style.display = 'none';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_renderList() {
|
|
102
|
+
if (!this._body) return;
|
|
103
|
+
const threads = this.commentService.getAllThreads();
|
|
104
|
+
this._body.replaceChildren();
|
|
105
|
+
|
|
106
|
+
if (!threads || threads.length === 0) {
|
|
107
|
+
const empty = document.createElement('div');
|
|
108
|
+
empty.className = 'moodboard-comments-list__empty';
|
|
109
|
+
empty.textContent = 'Пока нет комментариев';
|
|
110
|
+
this._body.appendChild(empty);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const fragment = document.createDocumentFragment();
|
|
115
|
+
for (const thread of threads) {
|
|
116
|
+
fragment.appendChild(this._buildCard(thread));
|
|
117
|
+
}
|
|
118
|
+
this._body.appendChild(fragment);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
_buildCard(thread) {
|
|
122
|
+
const root = document.createElement('div');
|
|
123
|
+
root.className = 'moodboard-comments-list__card' +
|
|
124
|
+
(thread.resolved ? ' moodboard-comments-list__card--resolved' : '');
|
|
125
|
+
root.addEventListener('click', (e) => this._onCardClick(e, thread));
|
|
126
|
+
|
|
127
|
+
const firstMsg = thread.messages?.items?.[0];
|
|
128
|
+
const currentUser = this.commentService.currentUser;
|
|
129
|
+
const isSelf = currentUser?.id != null && thread.created_by != null &&
|
|
130
|
+
String(thread.created_by) === String(currentUser.id);
|
|
131
|
+
const authorName = firstMsg?.author_name || (isSelf ? 'Вы' : 'Участник');
|
|
132
|
+
const timeStr = firstMsg?.created_at ? formatTime(firstMsg.created_at) : '';
|
|
133
|
+
const content = stripHtml(firstMsg?.content || '');
|
|
134
|
+
|
|
135
|
+
const colorDot = document.createElement('span');
|
|
136
|
+
colorDot.className = 'moodboard-comments-list__card-dot';
|
|
137
|
+
if (thread.color) colorDot.style.background = thread.color;
|
|
138
|
+
|
|
139
|
+
const meta = document.createElement('div');
|
|
140
|
+
meta.className = 'moodboard-comments-list__card-meta';
|
|
141
|
+
|
|
142
|
+
const author = document.createElement('span');
|
|
143
|
+
author.className = 'moodboard-comments-list__card-author';
|
|
144
|
+
author.textContent = authorName;
|
|
145
|
+
|
|
146
|
+
const time = document.createElement('span');
|
|
147
|
+
time.className = 'moodboard-comments-list__card-time';
|
|
148
|
+
time.textContent = timeStr;
|
|
149
|
+
|
|
150
|
+
meta.appendChild(author);
|
|
151
|
+
meta.appendChild(time);
|
|
152
|
+
|
|
153
|
+
const top = document.createElement('div');
|
|
154
|
+
top.className = 'moodboard-comments-list__card-top';
|
|
155
|
+
top.appendChild(colorDot);
|
|
156
|
+
top.appendChild(meta);
|
|
157
|
+
|
|
158
|
+
const body = document.createElement('div');
|
|
159
|
+
body.className = 'moodboard-comments-list__card-body';
|
|
160
|
+
body.textContent = content;
|
|
161
|
+
|
|
162
|
+
const replyCount = (thread.messages?.items?.length || 0) - 1;
|
|
163
|
+
let repliesEl = null;
|
|
164
|
+
if (replyCount > 0) {
|
|
165
|
+
repliesEl = document.createElement('div');
|
|
166
|
+
repliesEl.className = 'moodboard-comments-list__card-replies';
|
|
167
|
+
repliesEl.textContent = `${replyCount} ${pluralize(replyCount, 'ответ', 'ответа', 'ответов')}`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const actions = document.createElement('div');
|
|
171
|
+
actions.className = 'moodboard-comments-list__card-actions';
|
|
172
|
+
|
|
173
|
+
const resolveBtn = document.createElement('button');
|
|
174
|
+
resolveBtn.type = 'button';
|
|
175
|
+
resolveBtn.className = 'moodboard-comments-list__resolve-btn' +
|
|
176
|
+
(thread.resolved ? ' moodboard-comments-list__resolve-btn--resolved' : '');
|
|
177
|
+
resolveBtn.setAttribute('aria-label', thread.resolved ? 'Вернуть' : 'Решить');
|
|
178
|
+
resolveBtn.innerHTML = CHECKMARK_SVG + `<span>${thread.resolved ? 'Вернуть' : 'Решить'}</span>`;
|
|
179
|
+
resolveBtn.addEventListener('click', (e) => {
|
|
180
|
+
e.stopPropagation();
|
|
181
|
+
this.commentService.resolveThread(thread.id, !thread.resolved).catch(console.error);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const deleteBtn = document.createElement('button');
|
|
185
|
+
deleteBtn.type = 'button';
|
|
186
|
+
deleteBtn.className = 'moodboard-comments-list__delete-btn';
|
|
187
|
+
deleteBtn.setAttribute('aria-label', 'Удалить');
|
|
188
|
+
deleteBtn.innerHTML = TRASH_SVG;
|
|
189
|
+
deleteBtn.addEventListener('click', (e) => {
|
|
190
|
+
e.stopPropagation();
|
|
191
|
+
this.commentService.deleteThread(thread.id).catch(console.error);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
actions.appendChild(resolveBtn);
|
|
195
|
+
actions.appendChild(deleteBtn);
|
|
196
|
+
|
|
197
|
+
root.appendChild(top);
|
|
198
|
+
root.appendChild(body);
|
|
199
|
+
if (repliesEl) root.appendChild(repliesEl);
|
|
200
|
+
root.appendChild(actions);
|
|
201
|
+
|
|
202
|
+
return root;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
_onCardClick(e, thread) {
|
|
206
|
+
const pos = this.commentService.getThreadWorldPosition(thread, this.core);
|
|
207
|
+
if (pos) {
|
|
208
|
+
this.eventBus.emit(Events.UI.MinimapCenterOn, { worldX: pos.x, worldY: pos.y });
|
|
209
|
+
this.eventBus.emit(Events.Viewport.Changed);
|
|
210
|
+
}
|
|
211
|
+
this.commentService.openThread(thread.id);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import * as PIXI from 'pixi.js';
|
|
2
|
+
import { Events } from '../../core/events/Events.js';
|
|
3
|
+
|
|
4
|
+
const PIN_SIZE = 28;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* HTML-оверлей пинов комментариев. Перепроекция world→screen через toGlobal.
|
|
8
|
+
*
|
|
9
|
+
* Структура DOM каждого пина:
|
|
10
|
+
* <div.comment-pin-wrap> ← positioned absolute, 28×28, pointer-events:none
|
|
11
|
+
* <button.comment-pin> ← overflow:hidden (clip avatar), pointer-events:auto
|
|
12
|
+
* <img.comment-pin__avatar> | или
|
|
13
|
+
* <span.comment-pin__initials>
|
|
14
|
+
* </button>
|
|
15
|
+
* <span.comment-pin__badge> ← sibling кнопки, не клипируется её overflow
|
|
16
|
+
* </div>
|
|
17
|
+
*
|
|
18
|
+
* Такая структура позволяет добавить overflow:hidden на кнопку (для круглого аватара)
|
|
19
|
+
* без обрезания бейджа, который позиционируется за пределами кнопки.
|
|
20
|
+
*/
|
|
21
|
+
export class CommentPinLayer {
|
|
22
|
+
constructor(container, eventBus, core, commentService) {
|
|
23
|
+
this.container = container;
|
|
24
|
+
this.eventBus = eventBus;
|
|
25
|
+
this.core = core;
|
|
26
|
+
this.commentService = commentService;
|
|
27
|
+
this.layer = null;
|
|
28
|
+
/** @type {Map<number, HTMLElement>} кнопки пинов */
|
|
29
|
+
this.pinEls = new Map();
|
|
30
|
+
/** @type {Map<number, HTMLElement>} wrapper-divы (positioned), родители кнопки + бейджа */
|
|
31
|
+
this.pinWraps = new Map();
|
|
32
|
+
this._onReproject = () => this.reprojectAll();
|
|
33
|
+
this._onPinClick = this._onPinClick.bind(this);
|
|
34
|
+
this._onPinPointerDown = this._onPinPointerDown.bind(this);
|
|
35
|
+
this._onRemote = () => this.rebuild();
|
|
36
|
+
/** Показывать ли resolved-пины. По умолчанию true. Управляется CommentsBar. */
|
|
37
|
+
this.showResolved = true;
|
|
38
|
+
this._onResolvedFilterChanged = ({ showResolved }) => {
|
|
39
|
+
this.showResolved = !!showResolved;
|
|
40
|
+
this._applyResolvedFilter();
|
|
41
|
+
};
|
|
42
|
+
/** true — последний pointerup завершил drag; следующий click должен быть проигнорирован */
|
|
43
|
+
this._lastDragWasMoved = false;
|
|
44
|
+
/** Черновой пин (показывается до создания первого сообщения треда) */
|
|
45
|
+
this._draftWrap = null;
|
|
46
|
+
this._onDraftOpened = this._onDraftOpened.bind(this);
|
|
47
|
+
this._onDraftClosed = this._onDraftClosed.bind(this);
|
|
48
|
+
/** @type {{ threadId: number, startClientX: number, startClientY: number, startWorldX: number, startWorldY: number, moved: boolean } | null} */
|
|
49
|
+
this._activeDrag = null;
|
|
50
|
+
this._docMoveHandler = null;
|
|
51
|
+
this._docUpHandler = null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
attach() {
|
|
55
|
+
this.layer = document.createElement('div');
|
|
56
|
+
this.layer.className = 'comment-pin-layer';
|
|
57
|
+
Object.assign(this.layer.style, {
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
inset: '0',
|
|
60
|
+
pointerEvents: 'none',
|
|
61
|
+
zIndex: 22,
|
|
62
|
+
});
|
|
63
|
+
this.container.appendChild(this.layer);
|
|
64
|
+
|
|
65
|
+
const ev = [
|
|
66
|
+
[Events.Comment.ResolvedFilterChanged, this._onResolvedFilterChanged],
|
|
67
|
+
[Events.Viewport.Changed, this._onReproject],
|
|
68
|
+
[Events.Tool.PanUpdate, this._onReproject],
|
|
69
|
+
[Events.UI.ZoomPercent, this._onReproject],
|
|
70
|
+
[Events.Object.TransformUpdated, this._onReproject],
|
|
71
|
+
[Events.Comment.RemoteUpdated, this._onRemote],
|
|
72
|
+
[Events.Comment.PinCreated, this._onRemote],
|
|
73
|
+
[Events.Comment.ThreadDeleted, this._onRemote],
|
|
74
|
+
[Events.Comment.Resolved, this._onRemote],
|
|
75
|
+
[Events.Comment.ColorChanged, this._onRemote],
|
|
76
|
+
[Events.Comment.DraftOpened, this._onDraftOpened],
|
|
77
|
+
[Events.Comment.DraftClosed, this._onDraftClosed],
|
|
78
|
+
];
|
|
79
|
+
this._subs = ev;
|
|
80
|
+
for (const [name, fn] of ev) this.eventBus.on(name, fn);
|
|
81
|
+
|
|
82
|
+
if (typeof window !== 'undefined') {
|
|
83
|
+
this._onResize = () => this._onReproject();
|
|
84
|
+
window.addEventListener('resize', this._onResize);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.rebuild();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
destroy() {
|
|
91
|
+
this._removeDragListeners();
|
|
92
|
+
this._activeDrag = null;
|
|
93
|
+
if (this._subs) {
|
|
94
|
+
for (const [name, fn] of this._subs) this.eventBus.off(name, fn);
|
|
95
|
+
}
|
|
96
|
+
if (this._onResize) window.removeEventListener('resize', this._onResize);
|
|
97
|
+
this.pinEls.clear();
|
|
98
|
+
this.pinWraps.clear();
|
|
99
|
+
this._hideDraftPin();
|
|
100
|
+
if (this.layer) this.layer.remove();
|
|
101
|
+
this.layer = null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
rebuild() {
|
|
105
|
+
if (!this.layer) return;
|
|
106
|
+
const threads = this.commentService.getAllThreads();
|
|
107
|
+
const ids = new Set(threads.map((t) => Number(t.id)));
|
|
108
|
+
for (const id of [...this.pinWraps.keys()]) {
|
|
109
|
+
if (!ids.has(id)) {
|
|
110
|
+
this.pinWraps.get(id)?.remove();
|
|
111
|
+
this.pinWraps.delete(id);
|
|
112
|
+
this.pinEls.delete(id);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (const thread of threads) {
|
|
116
|
+
this._ensurePinEl(thread);
|
|
117
|
+
}
|
|
118
|
+
this.reprojectAll();
|
|
119
|
+
this._applyResolvedFilter();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_applyResolvedFilter() {
|
|
123
|
+
for (const [id, wrap] of this.pinWraps) {
|
|
124
|
+
const thread = this.commentService.getThread(id);
|
|
125
|
+
if (!thread) continue;
|
|
126
|
+
wrap.style.display = (!this.showResolved && thread.resolved) ? 'none' : '';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
reprojectAll() {
|
|
131
|
+
for (const thread of this.commentService.getAllThreads()) {
|
|
132
|
+
this._projectPin(thread);
|
|
133
|
+
}
|
|
134
|
+
this._projectDraftPin();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_ensurePinEl(thread) {
|
|
138
|
+
const id = Number(thread.id);
|
|
139
|
+
let wrap = this.pinWraps.get(id);
|
|
140
|
+
let el = this.pinEls.get(id);
|
|
141
|
+
|
|
142
|
+
if (!wrap) {
|
|
143
|
+
wrap = document.createElement('div');
|
|
144
|
+
wrap.className = 'comment-pin-wrap';
|
|
145
|
+
wrap.style.pointerEvents = 'none';
|
|
146
|
+
|
|
147
|
+
el = document.createElement('button');
|
|
148
|
+
el.type = 'button';
|
|
149
|
+
el.className = 'comment-pin';
|
|
150
|
+
el.dataset.threadId = String(id);
|
|
151
|
+
el.style.pointerEvents = 'auto';
|
|
152
|
+
el.addEventListener('click', this._onPinClick);
|
|
153
|
+
el.addEventListener('pointerdown', this._onPinPointerDown);
|
|
154
|
+
|
|
155
|
+
wrap.appendChild(el);
|
|
156
|
+
this.layer.appendChild(wrap);
|
|
157
|
+
this.pinEls.set(id, el);
|
|
158
|
+
this.pinWraps.set(id, wrap);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Аватар автора: thread.author_avatar → currentUser.avatar (если автор текущий) → инициалы
|
|
162
|
+
const cu = this.commentService.currentUser;
|
|
163
|
+
const avatarUrl = thread.author_avatar ||
|
|
164
|
+
(thread.created_by != null && cu?.id != null &&
|
|
165
|
+
String(thread.created_by) === String(cu.id)
|
|
166
|
+
? cu.avatar || null
|
|
167
|
+
: null);
|
|
168
|
+
|
|
169
|
+
let img = el.querySelector('.comment-pin__avatar');
|
|
170
|
+
let initials = el.querySelector('.comment-pin__initials');
|
|
171
|
+
|
|
172
|
+
if (avatarUrl) {
|
|
173
|
+
if (!img) {
|
|
174
|
+
img = document.createElement('img');
|
|
175
|
+
img.className = 'comment-pin__avatar';
|
|
176
|
+
img.alt = '';
|
|
177
|
+
el.insertBefore(img, el.firstChild);
|
|
178
|
+
}
|
|
179
|
+
img.src = avatarUrl;
|
|
180
|
+
img.style.display = '';
|
|
181
|
+
if (initials) initials.style.display = 'none';
|
|
182
|
+
} else {
|
|
183
|
+
if (img) img.style.display = 'none';
|
|
184
|
+
if (!initials) {
|
|
185
|
+
initials = document.createElement('span');
|
|
186
|
+
initials.className = 'comment-pin__initials';
|
|
187
|
+
el.insertBefore(initials, el.firstChild);
|
|
188
|
+
}
|
|
189
|
+
const name = thread.author_name || cu?.name || '';
|
|
190
|
+
initials.textContent = name.charAt(0).toUpperCase() || '?';
|
|
191
|
+
initials.style.display = '';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
el.classList.toggle('comment-pin--resolved', !!thread.resolved);
|
|
195
|
+
|
|
196
|
+
// Обводка цвета треда через CSS-переменную --pin-color.
|
|
197
|
+
// Resolved-пин всегда зелёный (border-color задан классом comment-pin--resolved),
|
|
198
|
+
// поэтому переменная применяется только к нерешённым пинам.
|
|
199
|
+
if (thread.color && !thread.resolved) {
|
|
200
|
+
el.style.setProperty('--pin-color', thread.color);
|
|
201
|
+
} else {
|
|
202
|
+
el.style.removeProperty('--pin-color');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Зелёный индикатор-галочка для решённых тредов
|
|
206
|
+
let resolvedBadge = wrap.querySelector('.comment-pin__resolved-badge');
|
|
207
|
+
if (thread.resolved) {
|
|
208
|
+
if (!resolvedBadge) {
|
|
209
|
+
resolvedBadge = document.createElement('span');
|
|
210
|
+
resolvedBadge.className = 'comment-pin__resolved-badge';
|
|
211
|
+
resolvedBadge.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="7" height="7" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>`;
|
|
212
|
+
wrap.appendChild(resolvedBadge);
|
|
213
|
+
}
|
|
214
|
+
resolvedBadge.style.display = '';
|
|
215
|
+
} else if (resolvedBadge) {
|
|
216
|
+
resolvedBadge.style.display = 'none';
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Бейдж — sibling кнопки внутри wrap; не клипируется overflow:hidden кнопки
|
|
220
|
+
const unread = thread.unread_count || 0;
|
|
221
|
+
let badge = wrap.querySelector('.comment-pin__badge');
|
|
222
|
+
if (unread > 0 && !thread.resolved) {
|
|
223
|
+
if (!badge) {
|
|
224
|
+
badge = document.createElement('span');
|
|
225
|
+
badge.className = 'comment-pin__badge';
|
|
226
|
+
wrap.appendChild(badge);
|
|
227
|
+
}
|
|
228
|
+
badge.textContent = unread > 99 ? '99+' : String(unread);
|
|
229
|
+
badge.style.display = '';
|
|
230
|
+
} else if (badge) {
|
|
231
|
+
badge.style.display = 'none';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
el.setAttribute('aria-label', thread.resolved ? 'Решённый комментарий' : 'Комментарий');
|
|
235
|
+
|
|
236
|
+
// Цвет пина через CSS-переменную; при null — дефолт из CSS
|
|
237
|
+
wrap.style.setProperty('--pin-color', thread.color || '');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
_onDraftOpened({ x, y }) {
|
|
241
|
+
this._showDraftPin(x, y);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
_onDraftClosed() {
|
|
245
|
+
this._hideDraftPin();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_showDraftPin(worldX, worldY) {
|
|
249
|
+
if (!this.layer) return;
|
|
250
|
+
this._hideDraftPin();
|
|
251
|
+
|
|
252
|
+
const wrap = document.createElement('div');
|
|
253
|
+
wrap.className = 'comment-pin-wrap comment-pin-wrap--draft';
|
|
254
|
+
wrap.style.pointerEvents = 'none';
|
|
255
|
+
wrap.style.position = 'absolute';
|
|
256
|
+
|
|
257
|
+
const btn = document.createElement('div');
|
|
258
|
+
btn.className = 'comment-pin comment-pin--draft';
|
|
259
|
+
|
|
260
|
+
const cu = this.commentService.currentUser;
|
|
261
|
+
const avatarUrl = cu?.avatar || null;
|
|
262
|
+
|
|
263
|
+
if (avatarUrl) {
|
|
264
|
+
const img = document.createElement('img');
|
|
265
|
+
img.className = 'comment-pin__avatar';
|
|
266
|
+
img.src = avatarUrl;
|
|
267
|
+
img.alt = '';
|
|
268
|
+
btn.appendChild(img);
|
|
269
|
+
} else {
|
|
270
|
+
const initials = document.createElement('span');
|
|
271
|
+
initials.className = 'comment-pin__initials';
|
|
272
|
+
const name = cu?.name || '';
|
|
273
|
+
initials.textContent = name.charAt(0).toUpperCase() || '?';
|
|
274
|
+
btn.appendChild(initials);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
wrap.appendChild(btn);
|
|
278
|
+
this.layer.appendChild(wrap);
|
|
279
|
+
this._draftWrap = wrap;
|
|
280
|
+
this._draftWorld = { x: worldX, y: worldY };
|
|
281
|
+
|
|
282
|
+
this._projectDraftPin();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
_hideDraftPin() {
|
|
286
|
+
if (this._draftWrap) {
|
|
287
|
+
this._draftWrap.remove();
|
|
288
|
+
this._draftWrap = null;
|
|
289
|
+
}
|
|
290
|
+
this._draftWorld = null;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
_projectDraftPin() {
|
|
294
|
+
if (!this._draftWrap || !this._draftWorld) return;
|
|
295
|
+
const screen = this._worldPointToCss(this._draftWorld.x, this._draftWorld.y);
|
|
296
|
+
if (!screen) return;
|
|
297
|
+
const left = Math.round(screen.left - PIN_SIZE / 2);
|
|
298
|
+
const top = Math.round(screen.top - PIN_SIZE / 2);
|
|
299
|
+
this._draftWrap.style.left = `${left}px`;
|
|
300
|
+
this._draftWrap.style.top = `${top}px`;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
_onPinClick(e) {
|
|
304
|
+
if (this._lastDragWasMoved) {
|
|
305
|
+
this._lastDragWasMoved = false;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const id = Number(e.currentTarget?.dataset?.threadId);
|
|
309
|
+
if (!Number.isFinite(id)) return;
|
|
310
|
+
e.stopPropagation();
|
|
311
|
+
this.eventBus.emit(Events.Comment.ThreadOpened, { threadId: id, pinEl: e.currentTarget });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
_onPinPointerDown(e) {
|
|
315
|
+
if (e.button !== 0) return;
|
|
316
|
+
e.stopPropagation();
|
|
317
|
+
const id = Number(e.currentTarget?.dataset?.threadId);
|
|
318
|
+
if (!Number.isFinite(id)) return;
|
|
319
|
+
const thread = this.commentService.getThread(id);
|
|
320
|
+
if (!thread) return;
|
|
321
|
+
const worldPos = this.commentService.getThreadWorldPosition(thread, this.core);
|
|
322
|
+
this._activeDrag = {
|
|
323
|
+
threadId: id,
|
|
324
|
+
startClientX: e.clientX,
|
|
325
|
+
startClientY: e.clientY,
|
|
326
|
+
startWorldX: worldPos?.x ?? thread.x,
|
|
327
|
+
startWorldY: worldPos?.y ?? thread.y,
|
|
328
|
+
moved: false,
|
|
329
|
+
};
|
|
330
|
+
this._docMoveHandler = (ev) => this._onDragMove(ev);
|
|
331
|
+
this._docUpHandler = (ev) => this._onDragUp(ev);
|
|
332
|
+
document.addEventListener('pointermove', this._docMoveHandler);
|
|
333
|
+
document.addEventListener('pointerup', this._docUpHandler);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
_onDragMove(e) {
|
|
337
|
+
const drag = this._activeDrag;
|
|
338
|
+
if (!drag) return;
|
|
339
|
+
const dx = e.clientX - drag.startClientX;
|
|
340
|
+
const dy = e.clientY - drag.startClientY;
|
|
341
|
+
if (!drag.moved && Math.hypot(dx, dy) < 4) return;
|
|
342
|
+
drag.moved = true;
|
|
343
|
+
|
|
344
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
345
|
+
const worldPos = this._cssPointToWorld(
|
|
346
|
+
e.clientX - containerRect.left,
|
|
347
|
+
e.clientY - containerRect.top,
|
|
348
|
+
);
|
|
349
|
+
if (!worldPos) return;
|
|
350
|
+
|
|
351
|
+
const thread = this.commentService.getThread(drag.threadId);
|
|
352
|
+
if (!thread) return;
|
|
353
|
+
// Мутируем напрямую (живой объект из Map) — только для визуального drag
|
|
354
|
+
thread.x = worldPos.x;
|
|
355
|
+
thread.y = worldPos.y;
|
|
356
|
+
this._projectPin(thread);
|
|
357
|
+
|
|
358
|
+
const el = this.pinEls.get(drag.threadId);
|
|
359
|
+
if (el) el.style.cursor = 'grabbing';
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
_onDragUp(e) {
|
|
363
|
+
const drag = this._activeDrag;
|
|
364
|
+
this._removeDragListeners();
|
|
365
|
+
this._activeDrag = null;
|
|
366
|
+
if (!drag) return;
|
|
367
|
+
|
|
368
|
+
const el = this.pinEls.get(drag.threadId);
|
|
369
|
+
if (el) el.style.cursor = '';
|
|
370
|
+
|
|
371
|
+
if (!drag.moved) return; // клик — click-событие обработает _onPinClick
|
|
372
|
+
this._lastDragWasMoved = true;
|
|
373
|
+
|
|
374
|
+
const thread = this.commentService.getThread(drag.threadId);
|
|
375
|
+
if (!thread) return;
|
|
376
|
+
|
|
377
|
+
let payload;
|
|
378
|
+
if (thread.anchor_object_id && !thread.detached) {
|
|
379
|
+
const pos = { objectId: thread.anchor_object_id, position: null };
|
|
380
|
+
this.eventBus.emit(Events.Tool.GetObjectPosition, pos);
|
|
381
|
+
if (pos.position) {
|
|
382
|
+
payload = {
|
|
383
|
+
x: thread.x,
|
|
384
|
+
y: thread.y,
|
|
385
|
+
anchor_object_id: thread.anchor_object_id,
|
|
386
|
+
anchor_dx: thread.x - pos.position.x,
|
|
387
|
+
anchor_dy: thread.y - pos.position.y,
|
|
388
|
+
};
|
|
389
|
+
} else {
|
|
390
|
+
payload = { x: thread.x, y: thread.y };
|
|
391
|
+
}
|
|
392
|
+
} else {
|
|
393
|
+
payload = { x: thread.x, y: thread.y };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
this.commentService.moveThread(drag.threadId, payload);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
_removeDragListeners() {
|
|
400
|
+
if (this._docMoveHandler) {
|
|
401
|
+
document.removeEventListener('pointermove', this._docMoveHandler);
|
|
402
|
+
this._docMoveHandler = null;
|
|
403
|
+
}
|
|
404
|
+
if (this._docUpHandler) {
|
|
405
|
+
document.removeEventListener('pointerup', this._docUpHandler);
|
|
406
|
+
this._docUpHandler = null;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
_projectPin(thread) {
|
|
411
|
+
const wrap = this.pinWraps.get(Number(thread.id));
|
|
412
|
+
if (!wrap) return;
|
|
413
|
+
const worldPos = this.commentService.getThreadWorldPosition(thread, this.core);
|
|
414
|
+
if (!worldPos) return;
|
|
415
|
+
const screen = this._worldPointToCss(worldPos.x, worldPos.y);
|
|
416
|
+
if (!screen) return;
|
|
417
|
+
const left = Math.round(screen.left - PIN_SIZE / 2);
|
|
418
|
+
const top = Math.round(screen.top - PIN_SIZE / 2);
|
|
419
|
+
wrap.style.left = `${left}px`;
|
|
420
|
+
wrap.style.top = `${top}px`;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
_worldPointToCss(worldX, worldY) {
|
|
424
|
+
const worldLayer = this.core?.pixi?.worldLayer || this.core?.pixi?.app?.stage;
|
|
425
|
+
const view = this.core?.pixi?.app?.view;
|
|
426
|
+
if (!worldLayer || !view?.parentElement) return null;
|
|
427
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
428
|
+
const viewRect = view.getBoundingClientRect();
|
|
429
|
+
const offsetLeft = viewRect.left - containerRect.left;
|
|
430
|
+
const offsetTop = viewRect.top - containerRect.top;
|
|
431
|
+
const g = worldLayer.toGlobal(new PIXI.Point(worldX, worldY));
|
|
432
|
+
return { left: offsetLeft + g.x, top: offsetTop + g.y };
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** Зеркало _worldPointToCss: CSS-координата (относительно container) → world. */
|
|
436
|
+
_cssPointToWorld(cssLeft, cssTop) {
|
|
437
|
+
const worldLayer = this.core?.pixi?.worldLayer || this.core?.pixi?.app?.stage;
|
|
438
|
+
const view = this.core?.pixi?.app?.view;
|
|
439
|
+
if (!worldLayer || !view?.parentElement) return null;
|
|
440
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
441
|
+
const viewRect = view.getBoundingClientRect();
|
|
442
|
+
const offsetLeft = viewRect.left - containerRect.left;
|
|
443
|
+
const offsetTop = viewRect.top - containerRect.top;
|
|
444
|
+
const gx = cssLeft - offsetLeft;
|
|
445
|
+
const gy = cssTop - offsetTop;
|
|
446
|
+
return worldLayer.toLocal(new PIXI.Point(gx, gy));
|
|
447
|
+
}
|
|
448
|
+
}
|