From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/tabviews/custom/components/editor/braft-editor/index.jsx | 52 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/tabviews/custom/components/editor/braft-editor/index.jsx b/src/tabviews/custom/components/editor/braft-editor/index.jsx index 5729372..5158f7d 100644 --- a/src/tabviews/custom/components/editor/braft-editor/index.jsx +++ b/src/tabviews/custom/components/editor/braft-editor/index.jsx @@ -63,16 +63,19 @@ } else { _data = [_data] } - } else if (config.html) { - if (/blank_space_\d+/ig.test(config.html)) { - config.html = config.html.replace(/blank_space_\d+/ig, (w) => { - let n = +w.replace(/blank_space_/ig, '') - if (n) { - return new Array(n).fill(' ').join('') - } + } else if (_config.html) { + if (_config.wrap.prefunc) { + let _html = '' + try { + // eslint-disable-next-line + let func = new Function('html', 'data', _config.wrap.prefunc) + _html = func(_config.html, {}) + } catch (e) { + _html = '' + console.warn(e) + } - return w - }) + _config.html = _html || _config.html } } @@ -273,16 +276,29 @@ }) } - if (/blank_space_\d+/ig.test(item.$html)) { - item.$html = item.$html.replace(/blank_space_\d+/ig, (w) => { - let n = +w.replace(/blank_space_/ig, '') - if (n) { - return new Array(n).fill(' ').join('') - } + if (wrap.prefunc) { + let _html = '' + try { + // eslint-disable-next-line + let func = new Function('html', 'data', wrap.prefunc) + _html = func(item.$html, item) + } catch (e) { + _html = '' + console.warn(e) + } - return w - }) + item.$html = _html || item.$html } + // if (/\$blank_space_\d+\$/ig.test(item.$html)) { + // item.$html = item.$html.replace(/\$blank_space_\d+\$/ig, (w) => { + // let n = +w.replace(/blank_space_|\$/ig, '') + // if (n) { + // return new Array(n).fill(' ').join('') + // } + + // return w + // }) + // } } }) @@ -308,7 +324,7 @@ /> : data.map((item, index) => <BraftContent key={index} value={item.$html} - script={config.wrap.loaded === 'true' ? config.wrap.loadedfunc : ''} + script={config.wrap.loadedfunc || ''} />)} </div> ) -- Gitblit v1.8.0