@hailin-zheng/editor-core 1.0.55 → 1.0.58
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/index-cjs.js +48 -5
- package/index-cjs.js.map +1 -1
- package/index.js +48 -5
- package/index.js.map +1 -1
- package/med_editor/framework/document-context.d.ts +6 -0
- package/package.json +1 -1
package/index.js
CHANGED
@@ -6660,6 +6660,7 @@ class DocumentSelection {
|
|
6660
6660
|
const range = this.selectionState.range;
|
6661
6661
|
//转换选区
|
6662
6662
|
this.transformRange();
|
6663
|
+
this.selectionState.clear();
|
6663
6664
|
if (!range) {
|
6664
6665
|
return false;
|
6665
6666
|
}
|
@@ -6781,7 +6782,7 @@ class SelectionState {
|
|
6781
6782
|
*/
|
6782
6783
|
rangeDirty = false;
|
6783
6784
|
addRange(range) {
|
6784
|
-
|
6785
|
+
this.clear();
|
6785
6786
|
this.range = range;
|
6786
6787
|
this.rangeDirty = true;
|
6787
6788
|
this.onChangedEvent.next();
|
@@ -12091,7 +12092,7 @@ class DocumentEvent {
|
|
12091
12092
|
//设置文档页中的相对位置
|
12092
12093
|
evt.pageX = hitPagePos.x;
|
12093
12094
|
evt.pageY = hitPagePos.y;
|
12094
|
-
const hitInfo = this.getHitLeafRender(docRender, { x:
|
12095
|
+
const hitInfo = this.getHitLeafRender(docRender, { x: -docRender.rect.x, y: -docRender.rect.y }, {
|
12095
12096
|
x: evt.pageX,
|
12096
12097
|
y: evt.pageY
|
12097
12098
|
});
|
@@ -15243,6 +15244,48 @@ class DocumentContext {
|
|
15243
15244
|
}
|
15244
15245
|
});
|
15245
15246
|
}
|
15247
|
+
/**
|
15248
|
+
* 查询字符
|
15249
|
+
* @param text
|
15250
|
+
*/
|
15251
|
+
searchText(text) {
|
15252
|
+
const docTextData = this.getElementTextData(this.ctx);
|
15253
|
+
const matchData = [];
|
15254
|
+
for (let i = 0; i < docTextData.length; i++) {
|
15255
|
+
if (docTextData[i].text.indexOf(text) >= 0) {
|
15256
|
+
matchData.push(docTextData[i]);
|
15257
|
+
}
|
15258
|
+
}
|
15259
|
+
console.log(matchData);
|
15260
|
+
}
|
15261
|
+
getElementTextData(ele) {
|
15262
|
+
const arr = [];
|
15263
|
+
if (ele instanceof BranchElement) {
|
15264
|
+
let prevText = null;
|
15265
|
+
for (let i = 0; i < ele.length; i++) {
|
15266
|
+
const child = ele.getChild(i);
|
15267
|
+
if (child instanceof TextGroupElement) {
|
15268
|
+
if (prevText) {
|
15269
|
+
const prevData = arr[arr.length - 1];
|
15270
|
+
prevData.eles.push(child);
|
15271
|
+
prevData.text += child.text;
|
15272
|
+
}
|
15273
|
+
else {
|
15274
|
+
arr.push({
|
15275
|
+
text: child.text,
|
15276
|
+
eles: [child]
|
15277
|
+
});
|
15278
|
+
}
|
15279
|
+
prevText = child;
|
15280
|
+
}
|
15281
|
+
else {
|
15282
|
+
arr.push(...this.getElementTextData(child));
|
15283
|
+
prevText = null;
|
15284
|
+
}
|
15285
|
+
}
|
15286
|
+
}
|
15287
|
+
return arr;
|
15288
|
+
}
|
15246
15289
|
}
|
15247
15290
|
|
15248
15291
|
/**
|
@@ -16034,17 +16077,17 @@ class CanvasTextEditor {
|
|
16034
16077
|
*/
|
16035
16078
|
refreshView(rePaint) {
|
16036
16079
|
const ssChanged = this.documentSelection.updateSelectionState();
|
16037
|
-
this.setCursor();
|
16038
16080
|
this.selectionOverlays.getSelectionTreeData();
|
16039
16081
|
this.documentPaint.refreshView(rePaint);
|
16040
16082
|
this.setScrollSize();
|
16041
|
-
|
16083
|
+
this.setCursor();
|
16084
|
+
(ssChanged || rePaint) && this.selectionChanged.next(this.documentSelection.selectionState);
|
16042
16085
|
this.docRule.refreshRule();
|
16043
16086
|
}
|
16044
16087
|
hitInfoChanged(hitInfo) {
|
16045
16088
|
this.documentSelection.setSelectionState(hitInfo);
|
16046
16089
|
this.refreshDocument();
|
16047
|
-
this.selectionChanged.next(this.documentSelection.selectionState);
|
16090
|
+
//this.selectionChanged.next(this.documentSelection.selectionState);
|
16048
16091
|
}
|
16049
16092
|
/**
|
16050
16093
|
* 设置光标
|