@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.js CHANGED
@@ -12092,7 +12092,7 @@ class DocumentEvent {
12092
12092
  //设置文档页中的相对位置
12093
12093
  evt.pageX = hitPagePos.x;
12094
12094
  evt.pageY = hitPagePos.y;
12095
- const hitInfo = this.getHitLeafRender(docRender, { x: 0, y: -docRender.rect.y }, {
12095
+ const hitInfo = this.getHitLeafRender(docRender, { x: -docRender.rect.x, y: -docRender.rect.y }, {
12096
12096
  x: evt.pageX,
12097
12097
  y: evt.pageY
12098
12098
  });
@@ -15244,6 +15244,48 @@ class DocumentContext {
15244
15244
  }
15245
15245
  });
15246
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
+ }
15247
15289
  }
15248
15290
 
15249
15291
  /**