@@ -4,6 +4,7 @@ import { refProp, watchUntilTrue } from '@stdlib/vue';
44import type { UnwrapRef } from 'vue' ;
55
66import type { Page } from '../page' ;
7+ import { roundTimeToMinutes } from './date' ;
78
89export interface IDraggingReact {
910 active : boolean ;
@@ -19,6 +20,9 @@ export class NoteDragging {
1920
2021 react : UnwrapRef < IDraggingReact > ;
2122
23+ initialRegionId ?: string ;
24+ finalRegionId ?: string ;
25+
2226 private _cancelPointerEvents ?: ( ) => void ;
2327
2428 constructor ( input : { page : Page } ) {
@@ -67,6 +71,9 @@ export class NoteDragging {
6771 private _dragStart = async ( event : PointerEvent ) => {
6872 this . react . active = true ;
6973
74+ this . initialRegionId = this . page . activeRegion . react . value . id ;
75+ this . finalRegionId = this . page . id ;
76+
7077 // Update note dragging states
7178
7279 for ( const selectedNote of this . page . selection . react . notes ) {
@@ -204,6 +211,18 @@ export class NoteDragging {
204211 }
205212
206213 private _dragFinish = ( ) => {
214+ if ( this . react . active && this . finalRegionId !== this . initialRegionId ) {
215+ const date = roundTimeToMinutes ( Date . now ( ) ) ;
216+
217+ this . page . collab . doc . transact ( ( ) => {
218+ for ( const selectedNote of this . page . selection . react . notes ) {
219+ if ( date !== this . page . collab . store . notes [ selectedNote . id ] ?. movedAt ) {
220+ this . page . collab . store . notes [ selectedNote . id ] . movedAt = date ;
221+ }
222+ }
223+ } ) ;
224+ }
225+
207226 this . react . active = false ;
208227
209228 for ( const selectedNote of this . page . selection . react . notes ) {
0 commit comments