hrsass-components 2.2.8 → 2.3.0

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.
@@ -57,7 +57,7 @@ var _slicedToArray = _interopDefault(require('@babel/runtime/helpers/slicedToArr
57
57
  var resizeDetector = require('resize-detector');
58
58
  var moment = require('moment');
59
59
  var moment__default = _interopDefault(moment);
60
- var tinymce = _interopDefault(require('tinymce/tinymce'));
60
+ require('tinymce/tinymce');
61
61
  var Editor = _interopDefault(require('@tinymce/tinymce-vue'));
62
62
  require('tinymce/skins/ui/oxide/skin.css');
63
63
  var uiStyle = _interopDefault(require('!!raw-loader!tinymce/skins/ui/oxide/content.css'));
@@ -65,7 +65,7 @@ var contentStyle = _interopDefault(require('!!raw-loader!tinymce/skins/content/d
65
65
  var SvgPanZoom = _interopDefault(require('svg-pan-zoom'));
66
66
  var saveSvgAsPng = require('save-svg-as-png');
67
67
 
68
- var version = "2.2.8";
68
+ var version = "2.3.0";
69
69
 
70
70
  /**
71
71
  * 版本号
@@ -4080,6 +4080,9 @@ var browserVersion = {
4080
4080
 
4081
4081
  function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4082
4082
  function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4083
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
4084
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4085
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4083
4086
  console.log('navigator.userAgent', navigator.userAgent);
4084
4087
  if (!browserVersion.ltIe11) {
4085
4088
  // 主题
@@ -4093,11 +4096,72 @@ if (!browserVersion.ltIe11) {
4093
4096
  // import contentStyle from '!!raw-loader!tinymce/skins/content/dark/content.css';
4094
4097
 
4095
4098
  var myStyle = "\ntable tr.hiddenby0{\n display: none;\n}\ntable tr[class*=hiddenby0-]{\n background-color: #fcdcdb;\n}\n";
4099
+ /**
4100
+ *
4101
+ * rtf中提取图片信息
4102
+ * 利用正则从rtf内容中提取到图片的核心信息,得到数组。其中数组中保存的信息有
4103
+ {
4104
+ type: ‘’, //图片类型
4105
+ hex: ‘’ // hex字符串
4106
+ }
4107
+ * @param {*} rtfData
4108
+ */
4109
+ function extractImageDataFromRtf(rtfData) {
4110
+ if (!rtfData) {
4111
+ return [];
4112
+ }
4113
+ var regexPictureHeader = /{\\pict[\s\S]+?({\\\*\\blipuid\s?[\da-fA-F]+)[\s}]*/;
4114
+ var regexPicture = new RegExp('(?:(' + regexPictureHeader.source + '))([\\da-fA-F\\s]+)\\}', 'g');
4115
+ var images = rtfData.match(regexPicture);
4116
+ var result = [];
4117
+ if (images) {
4118
+ var _iterator = _createForOfIteratorHelper(images),
4119
+ _step;
4120
+ try {
4121
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4122
+ var image = _step.value;
4123
+ var imageType = false;
4124
+ if (image.includes('\\pngblip')) {
4125
+ imageType = 'image/png';
4126
+ } else if (image.includes('\\jpegblip')) {
4127
+ imageType = 'image/jpeg';
4128
+ }
4129
+ if (imageType) {
4130
+ result.push({
4131
+ hex: image.replace(regexPictureHeader, '').replace(/[^\da-fA-F]/g, ''),
4132
+ type: imageType
4133
+ });
4134
+ }
4135
+ }
4136
+ } catch (err) {
4137
+ _iterator.e(err);
4138
+ } finally {
4139
+ _iterator.f();
4140
+ }
4141
+ }
4142
+ return result;
4143
+ }
4144
+ function hexStringToBlob(hexString) {
4145
+ // 将十六进制字符串转换为字节数组
4146
+ var byteArray = new Uint8Array(hexString.match(/.{2}/g).map(function (hexVal) {
4147
+ return parseInt(hexVal, 16);
4148
+ }));
4149
+
4150
+ // 使用二进制数据创建Blob对象
4151
+ var blob = new Blob([byteArray], {
4152
+ type: 'application/octet-stream'
4153
+ });
4154
+ return blob;
4155
+ }
4096
4156
  var HrRichText = {
4097
4157
  props: _objectSpread$8(_objectSpread$8({}, Editor.props), {}, {
4098
4158
  readOnly: {
4099
4159
  type: Boolean,
4100
4160
  "default": false
4161
+ },
4162
+ loading: {
4163
+ type: Boolean,
4164
+ "default": false
4101
4165
  }
4102
4166
  }),
4103
4167
  watch: {
@@ -4125,6 +4189,7 @@ var HrRichText = {
4125
4189
  },
4126
4190
  computed: {
4127
4191
  initReset: function initReset() {
4192
+ var _this = this;
4128
4193
  return _objectSpread$8({
4129
4194
  // 样式内联填充进去
4130
4195
  content_style: uiStyle.toString() + '\n' + contentStyle.toString() + '\n' + myStyle,
@@ -4133,7 +4198,58 @@ var HrRichText = {
4133
4198
  // 多语言
4134
4199
  language: 'zh_CN',
4135
4200
  branding: false,
4136
- convert_urls: false
4201
+ convert_urls: false,
4202
+ paste_enable_default_filters: false,
4203
+ paste_data_images: true,
4204
+ font_formats: "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings",
4205
+ images_upload_handler: function images_upload_handler(blobInfo, success, failure) {
4206
+ console.log('images_upload_handler', blobInfo, success, failure);
4207
+ var formData = new FormData();
4208
+ formData.append('file', blobInfo.blob(), blobInfo.filename());
4209
+ _this.$axios({
4210
+ url: _this.init.upload_url || "/file.nolog?method=upload&temp=false&storageType=fileSystem",
4211
+ method: 'post',
4212
+ processData: false,
4213
+ headers: {
4214
+ token: _this.$pq.get('token')
4215
+ },
4216
+ data: formData
4217
+ }).then(function (res) {
4218
+ console.log('res', res);
4219
+ var url = _this.init.preview_url ? "".concat(_this.init.preview_url).concat(_this.init.preview_url.includes('?') ? '&' : '?', "fileId=").concat(res.fileId) : "/platform_web_portal_war_exploded/file.nolog?method=preview&fileId=".concat(res.fileId);
4220
+ success(url);
4221
+ })["catch"](function (err) {
4222
+ console.log('err', err);
4223
+ failure('上传失败');
4224
+ });
4225
+ },
4226
+ init_instance_callback: function init_instance_callback(editor) {
4227
+ var _that = _this;
4228
+ editor.on('paste', function (e) {
4229
+ console.log('paste', e);
4230
+ var data = e.clipboardData.getData('text/rtf');
4231
+ var imagesHex = extractImageDataFromRtf(data);
4232
+ if (imagesHex.length) {
4233
+ editor.dom.select('img').forEach(function (img, i) {
4234
+ var formData = new FormData();
4235
+ formData.append('file', hexStringToBlob(imagesHex[i].hex), "image".concat(i, ".png"));
4236
+ _that.$axios({
4237
+ url: _that.init.upload_url || "/file.nolog?method=upload&temp=false&storageType=fileSystem",
4238
+ method: 'post',
4239
+ processData: false,
4240
+ headers: {
4241
+ token: _that.$pq.get('token')
4242
+ },
4243
+ data: formData
4244
+ }).then(function (res) {
4245
+ editor.dom.setAttribs(img, {
4246
+ src: _that.init.preview_url ? "".concat(_that.init.preview_url).concat(_that.init.preview_url.includes('?') ? '&' : '?', "fileId=").concat(res.fileId) : "/platform_web_portal_war_exploded/file.nolog?method=preview&fileId=".concat(res.fileId)
4247
+ });
4248
+ });
4249
+ });
4250
+ }
4251
+ });
4252
+ }
4137
4253
  }, this.init);
4138
4254
  }
4139
4255
  },
@@ -4151,10 +4267,10 @@ var HrRichText = {
4151
4267
  });
4152
4268
  },
4153
4269
  reload: function reload() {
4154
- var _this = this;
4270
+ var _this2 = this;
4155
4271
  this.reloading = true;
4156
4272
  this.$nextTick(function () {
4157
- _this.reloading = false;
4273
+ _this2.reloading = false;
4158
4274
  });
4159
4275
  },
4160
4276
  getVmParentByName: function getVmParentByName(vm, name) {
@@ -4179,7 +4295,8 @@ var HrRichText = {
4179
4295
  }
4180
4296
  },
4181
4297
  mounted: function mounted() {
4182
- tinymce.init({});
4298
+ console.log('mounted--rich-text', this.$refs);
4299
+ // tinymce.init({});
4183
4300
  this.initATabsChangeAutoReload();
4184
4301
  },
4185
4302
  render: function render() {
@@ -4214,10 +4331,16 @@ var HrRichText = {
4214
4331
  if (!this.reloading) {
4215
4332
  widget = h("div", {
4216
4333
  "class": "hr-rich-text"
4334
+ }, [h(antDesignVue.Spin, {
4335
+ attrs: {
4336
+ spinning: this.loading,
4337
+ size: "small"
4338
+ }
4217
4339
  }, [h(Editor, {
4218
4340
  props: props,
4219
- on: this.$listeners
4220
- })]);
4341
+ on: this.$listeners,
4342
+ ref: 'editor'
4343
+ })])]);
4221
4344
  } else {
4222
4345
  widget = h("div", {
4223
4346
  "class": "hr-rich-text loading"
@@ -9206,6 +9329,11 @@ var index$2 = {
9206
9329
  if (res.expandedNodeIds) {
9207
9330
  opts.expandedKeyList = [].concat(_toConsumableArray(_this2.expandedKeyList), _toConsumableArray(res.expandedNodeIds));
9208
9331
  }
9332
+ _this2.$emit('expand', opts.expandedKeyList, {
9333
+ expanded: true,
9334
+ node: treeNode.dataRef,
9335
+ childNodes: treeNode.dataRef.children
9336
+ });
9209
9337
  _this2.setState(opts);
9210
9338
  if (res.checkedNodeIds) {
9211
9339
  var _getOptionProps4 = getOptionProps(_this2),
@@ -9412,11 +9540,11 @@ var index$2 = {
9412
9540
  }));
9413
9541
  _this5.$emit('check', checkedKeys, _objectSpread$f({}, e.node.dataRef), nodes);
9414
9542
  },
9415
- expand: function expand(keys) {
9543
+ expand: function expand(keys, params) {
9416
9544
  _this5.setState({
9417
9545
  expandedKeyList: keys
9418
9546
  });
9419
- _this5.$emit('expand', keys);
9547
+ _this5.$emit('expand', keys, params);
9420
9548
  },
9421
9549
  load: function load(loadedKeys) {
9422
9550
  _this5.setState({