feat: add element group
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { cloneProperty, deepClone, getUUID, splitText } from '.'
|
||||
import { cloneProperty, deepClone, getUUID, isArrayEqual, splitText } from '.'
|
||||
import {
|
||||
ElementType,
|
||||
IEditorOption,
|
||||
@@ -375,7 +375,17 @@ export function isSameElementExceptValue(
|
||||
if (sourceKeys.length !== targetKeys.length) return false
|
||||
for (let s = 0; s < sourceKeys.length; s++) {
|
||||
const key = sourceKeys[s] as never
|
||||
// 值不需要校验
|
||||
if (key === 'value') continue
|
||||
// groupIds数组需特殊校验数组是否相等
|
||||
if (
|
||||
key === 'groupIds' &&
|
||||
Array.isArray(source[key]) &&
|
||||
Array.isArray(target[key]) &&
|
||||
isArrayEqual(source[key], target[key])
|
||||
) {
|
||||
continue
|
||||
}
|
||||
if (source[key] !== target[key]) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -249,3 +249,10 @@ export function findScrollContainer(element: HTMLElement) {
|
||||
}
|
||||
return document.documentElement
|
||||
}
|
||||
|
||||
export function isArrayEqual(arr1: unknown[], arr2: unknown[]): boolean {
|
||||
if (arr1.length !== arr2.length) {
|
||||
return false
|
||||
}
|
||||
return !arr1.some(item => !arr2.includes(item))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user