@hailin-zheng/editor-core 1.0.57 → 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 +43 -1
- package/index-cjs.js.map +1 -1
- package/index.js +43 -1
- package/index.js.map +1 -1
- package/med_editor/framework/document-context.d.ts +6 -0
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -12101,7 +12101,7 @@ class DocumentEvent {
|
|
12101
12101
|
//设置文档页中的相对位置
|
12102
12102
|
evt.pageX = hitPagePos.x;
|
12103
12103
|
evt.pageY = hitPagePos.y;
|
12104
|
-
const hitInfo = this.getHitLeafRender(docRender, { x:
|
12104
|
+
const hitInfo = this.getHitLeafRender(docRender, { x: -docRender.rect.x, y: -docRender.rect.y }, {
|
12105
12105
|
x: evt.pageX,
|
12106
12106
|
y: evt.pageY
|
12107
12107
|
});
|
@@ -15253,6 +15253,48 @@ class DocumentContext {
|
|
15253
15253
|
}
|
15254
15254
|
});
|
15255
15255
|
}
|
15256
|
+
/**
|
15257
|
+
* 查询字符
|
15258
|
+
* @param text
|
15259
|
+
*/
|
15260
|
+
searchText(text) {
|
15261
|
+
const docTextData = this.getElementTextData(this.ctx);
|
15262
|
+
const matchData = [];
|
15263
|
+
for (let i = 0; i < docTextData.length; i++) {
|
15264
|
+
if (docTextData[i].text.indexOf(text) >= 0) {
|
15265
|
+
matchData.push(docTextData[i]);
|
15266
|
+
}
|
15267
|
+
}
|
15268
|
+
console.log(matchData);
|
15269
|
+
}
|
15270
|
+
getElementTextData(ele) {
|
15271
|
+
const arr = [];
|
15272
|
+
if (ele instanceof BranchElement) {
|
15273
|
+
let prevText = null;
|
15274
|
+
for (let i = 0; i < ele.length; i++) {
|
15275
|
+
const child = ele.getChild(i);
|
15276
|
+
if (child instanceof TextGroupElement) {
|
15277
|
+
if (prevText) {
|
15278
|
+
const prevData = arr[arr.length - 1];
|
15279
|
+
prevData.eles.push(child);
|
15280
|
+
prevData.text += child.text;
|
15281
|
+
}
|
15282
|
+
else {
|
15283
|
+
arr.push({
|
15284
|
+
text: child.text,
|
15285
|
+
eles: [child]
|
15286
|
+
});
|
15287
|
+
}
|
15288
|
+
prevText = child;
|
15289
|
+
}
|
15290
|
+
else {
|
15291
|
+
arr.push(...this.getElementTextData(child));
|
15292
|
+
prevText = null;
|
15293
|
+
}
|
15294
|
+
}
|
15295
|
+
}
|
15296
|
+
return arr;
|
15297
|
+
}
|
15256
15298
|
}
|
15257
15299
|
|
15258
15300
|
/**
|