update 0.11.7

This commit is contained in:
hufeixiong
2022-01-12 09:22:31 +08:00
parent 72ea563070
commit 07f5dc1bb4
7 changed files with 142 additions and 131 deletions

View File

@@ -1,5 +1,5 @@
{
"version": "0.11.6",
"version": "0.11.7",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/dooringx-lib.esm.js",

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili
* @LastEditTime: 2021-12-31 00:25:43
* @LastEditTime: 2022-01-12 09:15:44
* @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\calcRender.ts
*/
import { innerDragState } from '../innerDrag/state';
@@ -105,137 +105,140 @@ export function marklineCalRender(config: UserConfig, iframe: boolean): LinesTyp
// 只要cache里有东西说明有缓存
if (marklineState.cache) {
if (!marklineState.sortLeft) {
marklineState.sortLeft = Object.values(marklineState.cache).sort((a, b) => {
return a.left - b.left;
});
}
if (!marklineState.sortTop) {
marklineState.sortTop = Object.values(marklineState.cache).sort((a, b) => {
return a.top - b.top;
});
}
if (!marklineState.sortBottom) {
marklineState.sortBottom = Object.values(marklineState.cache).sort((a, b) => {
return a.bottom - b.bottom;
});
}
if (!marklineState.sortRight) {
marklineState.sortRight = Object.values(marklineState.cache).sort((a, b) => {
return a.right - b.right;
});
}
// 划线的元素不应该冲突
// 当横向或者纵向已经吸附过则后续不进行吸附差值为0则划线。
// 未吸附过时的第一次划线会带吸附,后续按上述走
const dirty = {
dirtyX: false,
dirtyY: false,
};
const indexLeft = binarySearchRemain<RealStyleType>(
realStyle.left,
marklineState.sortLeft,
'left',
marklineConfig.indent
);
if (indexLeft) {
marklineDisplay(realStyle, indexLeft[0], lines, focus, indexLeft[1], dirty, 'left');
}
const indexLeftRight = binarySearchRemain<RealStyleType>(
realStyle.left,
marklineState.sortRight,
'right',
marklineConfig.indent
);
if (indexLeftRight) {
marklineDisplay(
realStyle,
indexLeftRight[0],
lines,
focus,
indexLeftRight[1],
dirty,
'l-r'
const focusItem = config.getFocusState();
const isMulti = focusItem.blocks.length > 1;
if (!isMulti) {
if (!marklineState.sortLeft) {
marklineState.sortLeft = Object.values(marklineState.cache).sort((a, b) => {
return a.left - b.left;
});
}
if (!marklineState.sortTop) {
marklineState.sortTop = Object.values(marklineState.cache).sort((a, b) => {
return a.top - b.top;
});
}
if (!marklineState.sortBottom) {
marklineState.sortBottom = Object.values(marklineState.cache).sort((a, b) => {
return a.bottom - b.bottom;
});
}
if (!marklineState.sortRight) {
marklineState.sortRight = Object.values(marklineState.cache).sort((a, b) => {
return a.right - b.right;
});
}
// 划线的元素不应该冲突
// 当横向或者纵向已经吸附过则后续不进行吸附差值为0则划线。
// 未吸附过时的第一次划线会带吸附,后续按上述走
const dirty = {
dirtyX: false,
dirtyY: false,
};
const indexLeft = binarySearchRemain<RealStyleType>(
realStyle.left,
marklineState.sortLeft,
'left',
marklineConfig.indent
);
}
const indexRightLeft = binarySearchRemain<RealStyleType>(
realStyle.right,
marklineState.sortLeft,
'left',
marklineConfig.indent
);
if (indexRightLeft) {
marklineDisplay(
realStyle,
indexRightLeft[0],
lines,
focus,
indexRightLeft[1],
dirty,
'r-l'
if (indexLeft) {
marklineDisplay(realStyle, indexLeft[0], lines, focus, indexLeft[1], dirty, 'left');
}
const indexLeftRight = binarySearchRemain<RealStyleType>(
realStyle.left,
marklineState.sortRight,
'right',
marklineConfig.indent
);
}
const indexTopBottom = binarySearchRemain<RealStyleType>(
realStyle.top,
marklineState.sortBottom,
'bottom',
marklineConfig.indent
);
if (indexTopBottom) {
marklineDisplay(
realStyle,
indexTopBottom[0],
lines,
focus,
indexTopBottom[1],
dirty,
't-b'
if (indexLeftRight) {
marklineDisplay(
realStyle,
indexLeftRight[0],
lines,
focus,
indexLeftRight[1],
dirty,
'l-r'
);
}
const indexRightLeft = binarySearchRemain<RealStyleType>(
realStyle.right,
marklineState.sortLeft,
'left',
marklineConfig.indent
);
}
const indexBottomTop = binarySearchRemain<RealStyleType>(
realStyle.bottom,
marklineState.sortTop,
'top',
marklineConfig.indent
);
if (indexBottomTop) {
marklineDisplay(
realStyle,
indexBottomTop[0],
lines,
focus,
indexBottomTop[1],
dirty,
'b-t'
if (indexRightLeft) {
marklineDisplay(
realStyle,
indexRightLeft[0],
lines,
focus,
indexRightLeft[1],
dirty,
'r-l'
);
}
const indexTopBottom = binarySearchRemain<RealStyleType>(
realStyle.top,
marklineState.sortBottom,
'bottom',
marklineConfig.indent
);
}
const indexTop = binarySearchRemain<RealStyleType>(
realStyle.top,
marklineState.sortTop,
'top',
marklineConfig.indent
);
if (indexTop) {
marklineDisplay(realStyle, indexTop[0], lines, focus, indexTop[1], dirty, 'top');
}
const indexRight = binarySearchRemain<RealStyleType>(
realStyle.right,
marklineState.sortRight,
'right',
marklineConfig.indent
);
if (indexRight) {
marklineDisplay(realStyle, indexRight[0], lines, focus, indexRight[1], dirty, 'right');
}
const indexBottom = binarySearchRemain<RealStyleType>(
realStyle.bottom,
marklineState.sortBottom,
'bottom',
marklineConfig.indent
);
if (indexBottom) {
marklineDisplay(realStyle, indexBottom[0], lines, focus, indexBottom[1], dirty, 'bottom');
if (indexTopBottom) {
marklineDisplay(
realStyle,
indexTopBottom[0],
lines,
focus,
indexTopBottom[1],
dirty,
't-b'
);
}
const indexBottomTop = binarySearchRemain<RealStyleType>(
realStyle.bottom,
marklineState.sortTop,
'top',
marklineConfig.indent
);
if (indexBottomTop) {
marklineDisplay(
realStyle,
indexBottomTop[0],
lines,
focus,
indexBottomTop[1],
dirty,
'b-t'
);
}
const indexTop = binarySearchRemain<RealStyleType>(
realStyle.top,
marklineState.sortTop,
'top',
marklineConfig.indent
);
if (indexTop) {
marklineDisplay(realStyle, indexTop[0], lines, focus, indexTop[1], dirty, 'top');
}
const indexRight = binarySearchRemain<RealStyleType>(
realStyle.right,
marklineState.sortRight,
'right',
marklineConfig.indent
);
if (indexRight) {
marklineDisplay(realStyle, indexRight[0], lines, focus, indexRight[1], dirty, 'right');
}
const indexBottom = binarySearchRemain<RealStyleType>(
realStyle.bottom,
marklineState.sortBottom,
'bottom',
marklineConfig.indent
);
if (indexBottom) {
marklineDisplay(realStyle, indexBottom[0], lines, focus, indexBottom[1], dirty, 'bottom');
}
}
} else {
for (let i = 0; i < len; i++) {