@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.13 → 1.0.0-alpha.15
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/es/LcdpUeditor.d.ts.map +1 -1
- package/es/LcdpUeditor.js +10 -5
- package/es/tools/filterHtmlNode.d.ts +5 -1
- package/es/tools/filterHtmlNode.d.ts.map +1 -1
- package/es/tools/filterHtmlNode.js +7 -1
- package/lib/LcdpUeditor.js +7 -5
- package/lib/tools/filterHtmlNode.d.ts +5 -1
- package/lib/tools/filterHtmlNode.js +7 -1
- package/package.json +1 -1
    
        package/es/LcdpUeditor.d.ts.map
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"LcdpUeditor.d.ts","sourceRoot":"","sources":["LcdpUeditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAQhD,cAAM,WAAY,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,EAAE,EAAE,CAAC;IAC9D;;OAEG;IACH,WAAW,EAAE,MAAM,CAAwB;IAE3C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAwD;IAExE;;OAEG;IACH,OAAO,CAAC,YAAY,CAAwD;IAE5E;;OAEG;IACH,OAAO,CAAC,WAAW,CAAS;IAE5B;;OAEG;IACH,OAAO,CAAC,WAAW,CAAa;IAEhC;;OAEG;IACH,OAAO,CAAC,YAAY,CAAiB;IAErC;;OAEG;IACH,OAAO,CAAC,qBAAqB,CAAW;IAExC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAc;IAEpC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAM;IAE5B;;OAEG;IACH,OAAO,CAAC,OAAO,CAAkB;IAEjC;;OAEG;IACH,KAAK,EAAE,QAAQ,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAA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IAiCjB,MAAM,IAAI,KAAK,CAAC,SAAS;CAY1B;AAED,eAAe,WAAW,CAAC"}
         | 
    
        package/es/LcdpUeditor.js
    CHANGED
    
    | @@ -85,7 +85,8 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) { | |
| 85 85 | 
             
                if (_this.props.ueditorPath) {
         | 
| 86 86 | 
             
                  _this.ueditorPath = _this.props.ueditorPath;
         | 
| 87 87 | 
             
                }
         | 
| 88 | 
            -
                 | 
| 88 | 
            +
                var nextValue = filterHtmlNode(_this.props.value || '').str;
         | 
| 89 | 
            +
                _this.currentContent = nextValue;
         | 
| 89 90 | 
             
                _this.uploadFunction = function (file, type) {
         | 
| 90 91 | 
             
                  var _this$props$config;
         | 
| 91 92 | 
             
                  // TODO 内置上传 图片base64
         | 
| @@ -116,7 +117,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) { | |
| 116 117 | 
             
                    _this.fileSelect(cb, type);
         | 
| 117 118 | 
             
                  },
         | 
| 118 119 | 
             
                  uploadFunction: _this.uploadFunction,
         | 
| 119 | 
            -
                  initialContent:  | 
| 120 | 
            +
                  initialContent: nextValue || ''
         | 
| 120 121 | 
             
                });
         | 
| 121 122 | 
             
                _this.debounceContentChange = debounce(_this.onContentChange.bind(_assertThisInitialized(_this)), 300);
         | 
| 122 123 | 
             
                return _this;
         | 
| @@ -132,7 +133,7 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) { | |
| 132 133 | 
             
                  if (this.isReady) {
         | 
| 133 134 | 
             
                    if ('value' in nextProps && this.currentContent !== nextProps.value) {
         | 
| 134 135 | 
             
                      this.isReportFlag = false;
         | 
| 135 | 
            -
                      this.ueditorInst.setContent(nextProps.value || '');
         | 
| 136 | 
            +
                      this.ueditorInst.setContent(filterHtmlNode(nextProps.value || '').str);
         | 
| 136 137 | 
             
                    }
         | 
| 137 138 | 
             
                    // 禁用操作需要调用指定的api进行操作
         | 
| 138 139 | 
             
                    if (nextProps.disabled !== this.props.disabled) {
         | 
| @@ -158,8 +159,12 @@ var LcdpUeditor = /*#__PURE__*/function (_React$Component) { | |
| 158 159 | 
             
                  if (!this.isReportFlag) {
         | 
| 159 160 | 
             
                    this.isReportFlag = true;
         | 
| 160 161 | 
             
                  } else if (this.props.onChange) {
         | 
| 161 | 
            -
                    this.currentContent = this.ueditorInst.getContent();
         | 
| 162 | 
            -
                     | 
| 162 | 
            +
                    this.currentContent = this.ueditorInst.getContent() || '';
         | 
| 163 | 
            +
                    var _filterHtmlNode = filterHtmlNode(this.currentContent),
         | 
| 164 | 
            +
                      str = _filterHtmlNode.str,
         | 
| 165 | 
            +
                      flag = _filterHtmlNode.flag,
         | 
| 166 | 
            +
                      source = _filterHtmlNode.source;
         | 
| 167 | 
            +
                    this.props.onChange(flag ? str : source);
         | 
| 163 168 | 
             
                  }
         | 
| 164 169 | 
             
                }
         | 
| 165 170 | 
             
              }, {
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"filterHtmlNode.d.ts","sourceRoot":"","sources":["filterHtmlNode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAAS,MAAM, | 
| 1 | 
            +
            {"version":3,"file":"filterHtmlNode.d.ts","sourceRoot":"","sources":["filterHtmlNode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,QAAS,MAAM;;;;CAwCzC,CAAC"}
         | 
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            export var filterHtmlNode = function filterHtmlNode(str) {
         | 
| 2 | 
            +
              var flag = false;
         | 
| 2 3 | 
             
              if (typeof str !== 'string') return str || '';
         | 
| 3 4 | 
             
              var blacklist = ['script', 'style', 'iframe'];
         | 
| 4 5 |  | 
| @@ -23,6 +24,7 @@ export var filterHtmlNode = function filterHtmlNode(str) { | |
| 23 24 | 
             
                    var attr = node.attributes[i];
         | 
| 24 25 | 
             
                    if (attr.name.startsWith('on') || String(node.getAttribute(attr.name)).toLowerCase().indexOf('javascript:') !== -1) {
         | 
| 25 26 | 
             
                      node.removeAttribute(attr.name);
         | 
| 27 | 
            +
                      flag = true;
         | 
| 26 28 | 
             
                    }
         | 
| 27 29 | 
             
                  }
         | 
| 28 30 | 
             
                }
         | 
| @@ -31,5 +33,9 @@ export var filterHtmlNode = function filterHtmlNode(str) { | |
| 31 33 | 
             
                }
         | 
| 32 34 | 
             
              }
         | 
| 33 35 | 
             
              cleanNode(doc.body);
         | 
| 34 | 
            -
              return  | 
| 36 | 
            +
              return {
         | 
| 37 | 
            +
                str: doc.body.innerHTML,
         | 
| 38 | 
            +
                flag: flag,
         | 
| 39 | 
            +
                source: str
         | 
| 40 | 
            +
              };
         | 
| 35 41 | 
             
            };
         | 
    
        package/lib/LcdpUeditor.js
    CHANGED
    
    | @@ -84,7 +84,8 @@ var LcdpUeditor = class extends import_react.default.Component { | |
| 84 84 | 
             
                if (this.props.ueditorPath) {
         | 
| 85 85 | 
             
                  this.ueditorPath = this.props.ueditorPath;
         | 
| 86 86 | 
             
                }
         | 
| 87 | 
            -
                 | 
| 87 | 
            +
                const nextValue = (0, import_filterHtmlNode.filterHtmlNode)(this.props.value || "").str;
         | 
| 88 | 
            +
                this.currentContent = nextValue;
         | 
| 88 89 | 
             
                this.uploadFunction = (file, type) => {
         | 
| 89 90 | 
             
                  var _a;
         | 
| 90 91 | 
             
                  if (type === "image" && ((_a = this.props.config) == null ? void 0 : _a.imageType) === "base64") {
         | 
| @@ -112,7 +113,7 @@ var LcdpUeditor = class extends import_react.default.Component { | |
| 112 113 | 
             
                    this.fileSelect(cb, type);
         | 
| 113 114 | 
             
                  },
         | 
| 114 115 | 
             
                  uploadFunction: this.uploadFunction,
         | 
| 115 | 
            -
                  initialContent:  | 
| 116 | 
            +
                  initialContent: nextValue || ""
         | 
| 116 117 | 
             
                };
         | 
| 117 118 | 
             
                this.debounceContentChange = (0, import_lodash.debounce)(this.onContentChange.bind(this), 300);
         | 
| 118 119 | 
             
              }
         | 
| @@ -123,7 +124,7 @@ var LcdpUeditor = class extends import_react.default.Component { | |
| 123 124 | 
             
                if (this.isReady) {
         | 
| 124 125 | 
             
                  if ("value" in nextProps && this.currentContent !== nextProps.value) {
         | 
| 125 126 | 
             
                    this.isReportFlag = false;
         | 
| 126 | 
            -
                    this.ueditorInst.setContent(nextProps.value || "");
         | 
| 127 | 
            +
                    this.ueditorInst.setContent((0, import_filterHtmlNode.filterHtmlNode)(nextProps.value || "").str);
         | 
| 127 128 | 
             
                  }
         | 
| 128 129 | 
             
                  if (nextProps.disabled !== this.props.disabled) {
         | 
| 129 130 | 
             
                    if (nextProps.disabled) {
         | 
| @@ -144,8 +145,9 @@ var LcdpUeditor = class extends import_react.default.Component { | |
| 144 145 | 
             
                if (!this.isReportFlag) {
         | 
| 145 146 | 
             
                  this.isReportFlag = true;
         | 
| 146 147 | 
             
                } else if (this.props.onChange) {
         | 
| 147 | 
            -
                  this.currentContent = this.ueditorInst.getContent();
         | 
| 148 | 
            -
                   | 
| 148 | 
            +
                  this.currentContent = this.ueditorInst.getContent() || "";
         | 
| 149 | 
            +
                  const { str, flag, source } = (0, import_filterHtmlNode.filterHtmlNode)(this.currentContent);
         | 
| 150 | 
            +
                  this.props.onChange(flag ? str : source);
         | 
| 149 151 | 
             
                }
         | 
| 150 152 | 
             
              }
         | 
| 151 153 | 
             
              getExtString(str) {
         | 
| @@ -23,6 +23,7 @@ __export(filterHtmlNode_exports, { | |
| 23 23 | 
             
            });
         | 
| 24 24 | 
             
            module.exports = __toCommonJS(filterHtmlNode_exports);
         | 
| 25 25 | 
             
            var filterHtmlNode = (str) => {
         | 
| 26 | 
            +
              let flag = false;
         | 
| 26 27 | 
             
              if (typeof str !== "string")
         | 
| 27 28 | 
             
                return str || "";
         | 
| 28 29 | 
             
              const blacklist = ["script", "style", "iframe"];
         | 
| @@ -39,6 +40,7 @@ var filterHtmlNode = (str) => { | |
| 39 40 | 
             
                    const attr = node.attributes[i];
         | 
| 40 41 | 
             
                    if (attr.name.startsWith("on") || String(node.getAttribute(attr.name)).toLowerCase().indexOf("javascript:") !== -1) {
         | 
| 41 42 | 
             
                      node.removeAttribute(attr.name);
         | 
| 43 | 
            +
                      flag = true;
         | 
| 42 44 | 
             
                    }
         | 
| 43 45 | 
             
                  }
         | 
| 44 46 | 
             
                }
         | 
| @@ -47,7 +49,11 @@ var filterHtmlNode = (str) => { | |
| 47 49 | 
             
                }
         | 
| 48 50 | 
             
              }
         | 
| 49 51 | 
             
              cleanNode(doc.body);
         | 
| 50 | 
            -
              return  | 
| 52 | 
            +
              return {
         | 
| 53 | 
            +
                str: doc.body.innerHTML,
         | 
| 54 | 
            +
                flag,
         | 
| 55 | 
            +
                source: str
         | 
| 56 | 
            +
              };
         | 
| 51 57 | 
             
            };
         | 
| 52 58 | 
             
            // Annotate the CommonJS export names for ESM import in node:
         | 
| 53 59 | 
             
            0 && (module.exports = {
         |