@windoc/core 0.3.2 → 0.3.3
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/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -698,6 +698,7 @@ interface IDrawOption {
|
|
|
698
698
|
curIndex?: number;
|
|
699
699
|
isSetCursor?: boolean;
|
|
700
700
|
isSubmitHistory?: boolean;
|
|
701
|
+
isInputHistory?: boolean;
|
|
701
702
|
isCompute?: boolean;
|
|
702
703
|
isLazy?: boolean;
|
|
703
704
|
isInit?: boolean;
|
|
@@ -1490,10 +1491,15 @@ declare class HistoryManager {
|
|
|
1490
1491
|
private undoStack;
|
|
1491
1492
|
private redoStack;
|
|
1492
1493
|
private maxRecordCount;
|
|
1494
|
+
private lastInputTime;
|
|
1493
1495
|
constructor(draw: Draw);
|
|
1494
1496
|
undo(): void;
|
|
1495
1497
|
redo(): void;
|
|
1496
1498
|
execute(fn: Function): void;
|
|
1499
|
+
replaceLatest(fn: Function): void;
|
|
1500
|
+
isInputGroupable(): boolean;
|
|
1501
|
+
recordInputTime(): void;
|
|
1502
|
+
resetInputTime(): void;
|
|
1497
1503
|
isCanUndo(): boolean;
|
|
1498
1504
|
isCanRedo(): boolean;
|
|
1499
1505
|
isStackEmpty(): boolean;
|
|
@@ -2534,7 +2540,7 @@ declare class Draw {
|
|
|
2534
2540
|
private _immediateRender;
|
|
2535
2541
|
render(payload?: IDrawOption): void;
|
|
2536
2542
|
setCursor(curIndex: number | undefined): number | undefined;
|
|
2537
|
-
submitHistory(curIndex: number | undefined): void;
|
|
2543
|
+
submitHistory(curIndex: number | undefined, isInput?: boolean): void;
|
|
2538
2544
|
destroy(): void;
|
|
2539
2545
|
clearSideEffect(): void;
|
|
2540
2546
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -698,6 +698,7 @@ interface IDrawOption {
|
|
|
698
698
|
curIndex?: number;
|
|
699
699
|
isSetCursor?: boolean;
|
|
700
700
|
isSubmitHistory?: boolean;
|
|
701
|
+
isInputHistory?: boolean;
|
|
701
702
|
isCompute?: boolean;
|
|
702
703
|
isLazy?: boolean;
|
|
703
704
|
isInit?: boolean;
|
|
@@ -1490,10 +1491,15 @@ declare class HistoryManager {
|
|
|
1490
1491
|
private undoStack;
|
|
1491
1492
|
private redoStack;
|
|
1492
1493
|
private maxRecordCount;
|
|
1494
|
+
private lastInputTime;
|
|
1493
1495
|
constructor(draw: Draw);
|
|
1494
1496
|
undo(): void;
|
|
1495
1497
|
redo(): void;
|
|
1496
1498
|
execute(fn: Function): void;
|
|
1499
|
+
replaceLatest(fn: Function): void;
|
|
1500
|
+
isInputGroupable(): boolean;
|
|
1501
|
+
recordInputTime(): void;
|
|
1502
|
+
resetInputTime(): void;
|
|
1497
1503
|
isCanUndo(): boolean;
|
|
1498
1504
|
isCanRedo(): boolean;
|
|
1499
1505
|
isStackEmpty(): boolean;
|
|
@@ -2534,7 +2540,7 @@ declare class Draw {
|
|
|
2534
2540
|
private _immediateRender;
|
|
2535
2541
|
render(payload?: IDrawOption): void;
|
|
2536
2542
|
setCursor(curIndex: number | undefined): number | undefined;
|
|
2537
|
-
submitHistory(curIndex: number | undefined): void;
|
|
2543
|
+
submitHistory(curIndex: number | undefined, isInput?: boolean): void;
|
|
2538
2544
|
destroy(): void;
|
|
2539
2545
|
clearSideEffect(): void;
|
|
2540
2546
|
}
|
package/dist/index.js
CHANGED
|
@@ -8516,9 +8516,11 @@ function input(data2, host) {
|
|
|
8516
8516
|
}
|
|
8517
8517
|
if (~curIndex) {
|
|
8518
8518
|
rangeManager.setRange(curIndex, curIndex);
|
|
8519
|
+
const isWordBoundary = !isComposing && /[\s\p{P}]/u.test(data2);
|
|
8519
8520
|
draw.render({
|
|
8520
8521
|
curIndex,
|
|
8521
|
-
isSubmitHistory: !isComposing
|
|
8522
|
+
isSubmitHistory: !isComposing,
|
|
8523
|
+
isInputHistory: !isComposing && !isWordBoundary
|
|
8522
8524
|
});
|
|
8523
8525
|
}
|
|
8524
8526
|
if (isComposing && ~curIndex) {
|
|
@@ -9189,10 +9191,12 @@ var GlobalEvent = class {
|
|
|
9189
9191
|
};
|
|
9190
9192
|
|
|
9191
9193
|
// src/core/history/HistoryManager.ts
|
|
9194
|
+
var INPUT_GROUP_INTERVAL = 1e3;
|
|
9192
9195
|
var HistoryManager = class {
|
|
9193
9196
|
constructor(draw) {
|
|
9194
9197
|
this.undoStack = [];
|
|
9195
9198
|
this.redoStack = [];
|
|
9199
|
+
this.lastInputTime = 0;
|
|
9196
9200
|
this.maxRecordCount = draw.getOptions().historyMaxRecordCount + 1;
|
|
9197
9201
|
}
|
|
9198
9202
|
undo() {
|
|
@@ -9220,6 +9224,25 @@ var HistoryManager = class {
|
|
|
9220
9224
|
this.undoStack.shift();
|
|
9221
9225
|
}
|
|
9222
9226
|
}
|
|
9227
|
+
replaceLatest(fn) {
|
|
9228
|
+
if (this.undoStack.length > 0) {
|
|
9229
|
+
this.undoStack[this.undoStack.length - 1] = fn;
|
|
9230
|
+
} else {
|
|
9231
|
+
this.execute(fn);
|
|
9232
|
+
}
|
|
9233
|
+
if (this.redoStack.length) {
|
|
9234
|
+
this.redoStack = [];
|
|
9235
|
+
}
|
|
9236
|
+
}
|
|
9237
|
+
isInputGroupable() {
|
|
9238
|
+
return Date.now() - this.lastInputTime < INPUT_GROUP_INTERVAL;
|
|
9239
|
+
}
|
|
9240
|
+
recordInputTime() {
|
|
9241
|
+
this.lastInputTime = Date.now();
|
|
9242
|
+
}
|
|
9243
|
+
resetInputTime() {
|
|
9244
|
+
this.lastInputTime = 0;
|
|
9245
|
+
}
|
|
9223
9246
|
isCanUndo() {
|
|
9224
9247
|
return this.undoStack.length > 1;
|
|
9225
9248
|
}
|
|
@@ -22400,6 +22423,7 @@ var Draw = class {
|
|
|
22400
22423
|
const { header, footer } = this.options;
|
|
22401
22424
|
const {
|
|
22402
22425
|
isSubmitHistory = true,
|
|
22426
|
+
isInputHistory = false,
|
|
22403
22427
|
isSetCursor = true,
|
|
22404
22428
|
isCompute = true,
|
|
22405
22429
|
isLazy = true,
|
|
@@ -22479,7 +22503,7 @@ var Draw = class {
|
|
|
22479
22503
|
this.cursor.focus();
|
|
22480
22504
|
}
|
|
22481
22505
|
if (isSubmitHistory && !isFirstRender || curIndex !== void 0 && this.historyManager.isStackEmpty()) {
|
|
22482
|
-
this.submitHistory(curIndex);
|
|
22506
|
+
this.submitHistory(curIndex, isInputHistory);
|
|
22483
22507
|
}
|
|
22484
22508
|
nextTick(() => {
|
|
22485
22509
|
this.range.setRangeStyle();
|
|
@@ -22542,7 +22566,7 @@ var Draw = class {
|
|
|
22542
22566
|
});
|
|
22543
22567
|
return curIndex;
|
|
22544
22568
|
}
|
|
22545
|
-
submitHistory(curIndex) {
|
|
22569
|
+
submitHistory(curIndex, isInput = false) {
|
|
22546
22570
|
const positionContext = this.position.getPositionContext();
|
|
22547
22571
|
const oldElementList = getSlimCloneElementList(this.elementList);
|
|
22548
22572
|
const oldHeaderElementList = getSlimCloneElementList(
|
|
@@ -22555,7 +22579,7 @@ var Draw = class {
|
|
|
22555
22579
|
const pageNo = this.pageNo;
|
|
22556
22580
|
const oldPositionContext = deepClone(positionContext);
|
|
22557
22581
|
const zone = this.zone.getZone();
|
|
22558
|
-
|
|
22582
|
+
const fn = () => {
|
|
22559
22583
|
this.zone.setZone(zone);
|
|
22560
22584
|
this.setPageNo(pageNo);
|
|
22561
22585
|
this.position.setPositionContext(deepClone(oldPositionContext));
|
|
@@ -22568,7 +22592,17 @@ var Draw = class {
|
|
|
22568
22592
|
isSubmitHistory: false,
|
|
22569
22593
|
isSourceHistory: true
|
|
22570
22594
|
});
|
|
22571
|
-
}
|
|
22595
|
+
};
|
|
22596
|
+
if (isInput && this.historyManager.isInputGroupable()) {
|
|
22597
|
+
this.historyManager.replaceLatest(fn);
|
|
22598
|
+
} else {
|
|
22599
|
+
this.historyManager.execute(fn);
|
|
22600
|
+
}
|
|
22601
|
+
if (isInput) {
|
|
22602
|
+
this.historyManager.recordInputTime();
|
|
22603
|
+
} else {
|
|
22604
|
+
this.historyManager.resetInputTime();
|
|
22605
|
+
}
|
|
22572
22606
|
}
|
|
22573
22607
|
destroy() {
|
|
22574
22608
|
this.container.remove();
|