adtec-core-package 1.4.7 → 1.4.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adtec-core-package",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -70,7 +70,7 @@ const fontSizes = [
70
70
  { name: "小初", pt: 36, px: 42 },
71
71
  { name: "初号", pt: 42, px: 49 }
72
72
  ];
73
- function convertPxToPt(html: string) {
73
+ function convertPxToPt(html) {
74
74
  const regex = /font-size: (\d+)px/g;
75
75
  return html.replace(regex, (match, pxValue) => {
76
76
  const px = parseInt(pxValue, 10);
@@ -81,7 +81,7 @@ function convertPxToPt(html: string) {
81
81
  return match;
82
82
  });
83
83
  }
84
- function convertPtToPx(html: string) {
84
+ function convertPtToPx(html) {
85
85
  const regex = /font-size: (\d+)pt/g;
86
86
  return html.replace(regex, (match, ptValue) => {
87
87
  const pt = parseFloat(ptValue);
@@ -146,31 +146,30 @@ const defaultConfig = {
146
146
  * 修改样式
147
147
  */
148
148
  function setContent() {
149
- calcImagesHeight()
150
- model.value = convertPxToPt(model.value)
151
- // console.log('modelvalue', model.value)
149
+ let html = aiEditor!.getHtml()
150
+ html = calcImagesHeight(html)
151
+ model.value = convertPxToPt(html)
152
152
  }
153
153
 
154
154
  /**
155
155
  * 计算富文本框中图片的高度并赋值
156
156
  */
157
- function calcImagesHeight() {
157
+ function calcImagesHeight(html: string) {
158
158
  const map = new Map()
159
159
  const imageElements = divRef.value.querySelectorAll('img.resize-obj');
160
160
  if (imageElements.length > 0) {
161
- imageElements.forEach((imageElement: any) => {
161
+ imageElements.forEach((imageElement) => {
162
162
  const width = imageElement.offsetWidth;
163
163
  const height = imageElement.offsetHeight;
164
164
  if (width > 1 && height > 1) {
165
165
  map.set(imageElement.src.length > 100 ? imageElement.src.substring(0,100) : imageElement.src, height)
166
166
  }
167
167
  });
168
- let res = aiEditor!.getHtml()
169
168
  for (const [key, value] of map) {
170
- res = customStringReplacement(res, `${key}`, '>', `height="auto"`, `height="${value}"`)
169
+ html = customStringReplacement(html, `${key}`, '>', `height="auto"`, `height="${value}"`)
171
170
  }
172
- model.value = res
173
171
  }
172
+ return html
174
173
  }
175
174
 
176
175
 
@@ -212,7 +211,7 @@ function customStringReplacement(str: string, startMarker: string, endMarker: st
212
211
  // }
213
212
  // },
214
213
  // )
215
- function initHtml(html: string) {
214
+ function initHtml(html) {
216
215
  html = customStringReplacement(html, '<img', '>', 'height="[0-9]+"', 'height="auto"')
217
216
  return convertPtToPx(html)
218
217
  }