@@ -896,10 +896,14 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
896896 window . siyuan . dragElement = target ;
897897 const selectIds : string [ ] = [ ] ;
898898 blockElement . querySelectorAll ( ".av__gallery-item--select" ) . forEach ( item => {
899- selectIds . push ( item . getAttribute ( "data-id" ) ) ;
899+ const bodyElement = hasClosestByClassName ( item , "av__body" ) as HTMLElement ;
900+ const groupId = bodyElement . getAttribute ( "data-group-id" ) ;
901+ selectIds . push ( item . getAttribute ( "data-id" ) + ( groupId ? `@${ groupId } ` : "" ) ) ;
900902 } ) ;
901903 if ( selectIds . length === 0 ) {
902- selectIds . push ( target . getAttribute ( "data-id" ) ) ;
904+ const bodyElement = hasClosestByClassName ( target , "av__body" ) as HTMLElement ;
905+ const groupId = bodyElement . getAttribute ( "data-group-id" ) ;
906+ selectIds . push ( target . getAttribute ( "data-id" ) + ( groupId ? `@${ groupId } ` : "" ) ) ;
903907 }
904908 event . dataTransfer . setData ( `${ Constants . SIYUAN_DROP_GUTTER } NodeAttributeView${ Constants . ZWSP } GalleryItem${ Constants . ZWSP } ${ selectIds } ` ,
905909 ghostElement . outerHTML ) ;
@@ -1172,18 +1176,20 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
11721176 // gallery item 内部拖拽
11731177 const doOperations : IOperation [ ] = [ ] ;
11741178 const undoOperations : IOperation [ ] = [ ] ;
1175- const undoPreviousId = blockElement . querySelector ( `.av__gallery-item[data-id="${ selectedIds [ 0 ] } "]` ) . previousElementSibling ?. getAttribute ( "data-id" ) || "" ;
11761179 const targetGroupID = targetElement . parentElement . parentElement . getAttribute ( "data-group-id" ) ;
11771180 selectedIds . reverse ( ) . forEach ( item => {
1178- const groupID = blockElement . querySelector ( `.av__gallery-item[data-id="${ item } "]` ) . parentElement . parentElement . getAttribute ( "data-group-id" ) ;
1181+ const items = item . split ( "@" ) ;
1182+ const id = items [ 0 ] ;
1183+ const groupID = items [ 1 ] || "" ;
1184+ const undoPreviousId = blockElement . querySelector ( `.av__body[data-group-id="${ groupID } "] .av__gallery-item[data-id="${ id } "]` ) . previousElementSibling . getAttribute ( "data-id" ) || "" ;
11791185 if ( previousID !== item && undoPreviousId !== previousID || (
11801186 ( undoPreviousId === "" && previousID === "" && targetGroupID !== groupID )
11811187 ) ) {
11821188 doOperations . push ( {
11831189 action : "sortAttrViewRow" ,
11841190 avID,
11851191 previousID,
1186- id : item ,
1192+ id,
11871193 blockID : blockElement . dataset . nodeId ,
11881194 groupID,
11891195 targetGroupID,
@@ -1192,7 +1198,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
11921198 action : "sortAttrViewRow" ,
11931199 avID,
11941200 previousID : undoPreviousId ,
1195- id : item ,
1201+ id,
11961202 blockID : blockElement . dataset . nodeId ,
11971203 groupID : targetGroupID ,
11981204 targetGroupID : groupID ,
@@ -1599,27 +1605,36 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
15991605 gutterTypes [ 2 ] . split ( "," ) . find ( item => {
16001606 if ( item && item . split ( "@" ) [ 1 ] !== groupID ) {
16011607 targetElement = false ;
1602- editorElement . querySelectorAll ( ".dragover__bottom, .dragover__top, .dragover" ) . forEach ( ( item : HTMLElement ) => {
1603- item . classList . remove ( "dragover__top" , "dragover__bottom" , "dragover" ) ;
1604- } ) ;
16051608 return true ;
16061609 }
16071610 } ) ;
16081611 }
16091612 }
16101613 } else if ( targetElement && gutterType && gutterType . startsWith ( `${ Constants . SIYUAN_DROP_GUTTER } NodeAttributeView${ Constants . ZWSP } GalleryItem${ Constants . ZWSP } ` . toLowerCase ( ) ) ) {
1611- // gallery item 只能拖拽当前 av 中
16121614 const containerElement = hasClosestByClassName ( event . target , "av__container" ) ;
16131615 if ( targetElement . classList . contains ( "av" ) || ! containerElement ||
16141616 ! containerElement . contains ( window . siyuan . dragElement ) || targetElement === window . siyuan . dragElement ) {
1617+ // gallery item 只能拖拽当前 av 中
16151618 targetElement = false ;
1616- editorElement . querySelectorAll ( ".dragover__left, .dragover__right" ) . forEach ( ( item : HTMLElement ) => {
1617- item . classList . remove ( "dragover__left" , "dragover__right" ) ;
1618- } ) ;
1619+ } else {
1620+ // 模板、创建时间、更新时间 字段作为分组方式时不允许跨分组拖拽 https://github.com/siyuan-note/siyuan/issues/15553
1621+ const bodyElement = hasClosestByClassName ( targetElement , "av__body" ) ;
1622+ if ( bodyElement && [ "template" , "created" , "updated" ] . includes ( bodyElement . getAttribute ( "data-dtype" ) ) ) {
1623+ const groupID = bodyElement . getAttribute ( "data-group-id" ) ;
1624+ gutterTypes [ 2 ] . split ( "," ) . find ( item => {
1625+ if ( item && item . split ( "@" ) [ 1 ] !== groupID ) {
1626+ targetElement = false ;
1627+ return true ;
1628+ }
1629+ } ) ;
1630+ }
16191631 }
16201632 }
16211633
16221634 if ( ! targetElement ) {
1635+ editorElement . querySelectorAll ( ".dragover__bottom, .dragover__top, .dragover, .dragover__left, .dragover__right" ) . forEach ( ( item : HTMLElement ) => {
1636+ item . classList . remove ( "dragover__top" , "dragover__bottom" , "dragover" , "dragover__left" , "dragover__right" ) ;
1637+ } ) ;
16231638 return ;
16241639 }
16251640 const isNotAvItem = ! targetElement . classList . contains ( "av__row" ) &&
0 commit comments