@vtx/components 4.0.0-beta.26 → 4.0.0-beta.28

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.
@@ -7,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import { useStyle as useAntdStyle } from "../../vtx-provider";
8
8
  var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
9
9
  var componentCls = token.componentCls;
10
+ console.log('token.controlHeight', token.controlHeight);
10
11
  return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '&-popover', {
11
12
  minWidth: '200px',
12
13
  height: '300px',
@@ -59,6 +60,7 @@ var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
59
60
  color: token.colorTextDescription,
60
61
  display: 'inline-flex',
61
62
  alignItems: 'center',
63
+ width: token.controlHeight,
62
64
  '&:hover': {
63
65
  color: token.colorPrimary
64
66
  }
@@ -17,14 +17,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
17
17
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  /*eslint-disable*/
20
- import React, { forwardRef, useState, useEffect, useContext, useCallback } from 'react';
20
+ import React, { forwardRef, useState, useEffect, useContext, useCallback, useRef } from 'react';
21
21
  import PropTypes from 'prop-types';
22
22
  import { Editor, Toolbar } from '@wangeditor/editor-for-react';
23
23
  import attachmentModule from '@wangeditor/plugin-upload-attachment';
24
24
  import { Boot } from '@wangeditor/editor';
25
25
  import getToken from "../utils/getToken";
26
26
  import { withEmptyHtml, findAllImgSrcsFromHtml, extractImageDataFromRtf, replaceImagesFileSourceWithInlineRepresentation, replaceAllSpanFontSize, sanitizeHtml } from "./wangEditorUtil";
27
- import { ConfigProvider } from 'antd';
28
27
  import cls from 'classnames';
29
28
  import { useStyle } from "./style/index";
30
29
  import { FormItemInputContext } from 'antd/es/form/context';
@@ -62,6 +61,7 @@ var VtxWangEditor = function VtxWangEditor(props) {
62
61
  setError(error.message);
63
62
  // 可以在这里添加错误上报逻辑
64
63
  }, []);
64
+ var valueRef = useRef();
65
65
  var _React$useContext = React.useContext(FormItemInputContext),
66
66
  contextStatus = _React$useContext.status,
67
67
  hasFeedback = _React$useContext.hasFeedback,
@@ -108,6 +108,9 @@ var VtxWangEditor = function VtxWangEditor(props) {
108
108
  }
109
109
  };
110
110
  }, []);
111
+ useEffect(function () {
112
+ valueRef.current = value;
113
+ }, [value]);
111
114
 
112
115
  // 修改安全的粘贴处理函数
113
116
  var handleSafePaste = useCallback( /*#__PURE__*/function () {
@@ -230,10 +233,14 @@ var VtxWangEditor = function VtxWangEditor(props) {
230
233
  var newValue = editor.getHtml() || undefined;
231
234
  // 对输出内容也进行安全过滤
232
235
  var processedValue = enableSanitization && newValue !== undefined ? sanitizeHtml(newValue) : newValue;
233
- console.log('编辑器内容变化,处理前内容:', newValue);
234
- console.log('编辑器内容变化,处理后内容:', processedValue);
235
- if (processedValue !== value) {
236
- onChange(processedValue);
236
+ // console.log('编辑器内容变化,处理前内容:', newValue);
237
+ // console.log('编辑器内容变化,处理后内容:', processedValue);
238
+ if (processedValue !== valueRef.current) {
239
+ if (processedValue === undefined) {
240
+ onChange('');
241
+ } else {
242
+ onChange(processedValue);
243
+ }
237
244
  }
238
245
  } catch (error) {
239
246
  handleError(new Error('编辑器内容处理失败: ' + error.message));
@@ -268,7 +275,6 @@ var VtxWangEditor = function VtxWangEditor(props) {
268
275
  },
269
276
  customInsert: function customInsert(res, insertFn) {
270
277
  try {
271
- console.log(res, insertFn);
272
278
  // res 即服务端的返回结果
273
279
  // 从 res 中找到 url alt href ,然后插入图片
274
280
  if (res.result == 0) {
@@ -13,6 +13,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
13
13
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
14
  var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
15
15
  var componentCls = token.componentCls;
16
+ console.log('token.controlHeight', token.controlHeight);
16
17
  return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, componentCls, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, '&-popover', {
17
18
  minWidth: '200px',
18
19
  height: '300px',
@@ -65,6 +66,7 @@ var genVtxTreeSelectStyle = function genVtxTreeSelectStyle(token) {
65
66
  color: token.colorTextDescription,
66
67
  display: 'inline-flex',
67
68
  alignItems: 'center',
69
+ width: token.controlHeight,
68
70
  '&:hover': {
69
71
  color: token.colorPrimary
70
72
  }
@@ -12,7 +12,6 @@ var _pluginUploadAttachment = _interopRequireDefault(require("@wangeditor/plugin
12
12
  var _editor = require("@wangeditor/editor");
13
13
  var _getToken = _interopRequireDefault(require("../utils/getToken"));
14
14
  var _wangEditorUtil = require("./wangEditorUtil");
15
- var _antd = require("antd");
16
15
  var _classnames = _interopRequireDefault(require("classnames"));
17
16
  var _index = require("./style/index");
18
17
  var _context2 = require("antd/es/form/context");
@@ -67,6 +66,7 @@ var VtxWangEditor = exports.VtxWangEditor = function VtxWangEditor(props) {
67
66
  setError(error.message);
68
67
  // 可以在这里添加错误上报逻辑
69
68
  }, []);
69
+ var valueRef = (0, _react.useRef)();
70
70
  var _React$useContext = _react.default.useContext(_context2.FormItemInputContext),
71
71
  contextStatus = _React$useContext.status,
72
72
  hasFeedback = _React$useContext.hasFeedback,
@@ -113,6 +113,9 @@ var VtxWangEditor = exports.VtxWangEditor = function VtxWangEditor(props) {
113
113
  }
114
114
  };
115
115
  }, []);
116
+ (0, _react.useEffect)(function () {
117
+ valueRef.current = value;
118
+ }, [value]);
116
119
 
117
120
  // 修改安全的粘贴处理函数
118
121
  var handleSafePaste = (0, _react.useCallback)( /*#__PURE__*/function () {
@@ -235,10 +238,14 @@ var VtxWangEditor = exports.VtxWangEditor = function VtxWangEditor(props) {
235
238
  var newValue = editor.getHtml() || undefined;
236
239
  // 对输出内容也进行安全过滤
237
240
  var processedValue = enableSanitization && newValue !== undefined ? (0, _wangEditorUtil.sanitizeHtml)(newValue) : newValue;
238
- console.log('编辑器内容变化,处理前内容:', newValue);
239
- console.log('编辑器内容变化,处理后内容:', processedValue);
240
- if (processedValue !== value) {
241
- onChange(processedValue);
241
+ // console.log('编辑器内容变化,处理前内容:', newValue);
242
+ // console.log('编辑器内容变化,处理后内容:', processedValue);
243
+ if (processedValue !== valueRef.current) {
244
+ if (processedValue === undefined) {
245
+ onChange('');
246
+ } else {
247
+ onChange(processedValue);
248
+ }
242
249
  }
243
250
  } catch (error) {
244
251
  handleError(new Error('编辑器内容处理失败: ' + error.message));
@@ -273,7 +280,6 @@ var VtxWangEditor = exports.VtxWangEditor = function VtxWangEditor(props) {
273
280
  },
274
281
  customInsert: function customInsert(res, insertFn) {
275
282
  try {
276
- console.log(res, insertFn);
277
283
  // res 即服务端的返回结果
278
284
  // 从 res 中找到 url alt href ,然后插入图片
279
285
  if (res.result == 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtx/components",
3
- "version": "4.0.0-beta.26",
3
+ "version": "4.0.0-beta.28",
4
4
  "description": "React components for Vortex",
5
5
  "keywords": [
6
6
  "react",