优化 code 当开启 iframe 模式时对 `codeParse` 的解析支持

pull/1299/head
贤心 2023-06-24 23:47:25 +08:00
parent 5871d8248b
commit be13118fd1
1 changed files with 10 additions and 8 deletions

View File

@ -90,6 +90,14 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){
othis.data('code', codes);
// code
var html = finalCode = codes.join('');
// 外部重新解析 code
if(typeof options.codeParse === 'function'){
html = finalCode = options.codeParse(html);
}
// 工具栏
var tools = {
copy: {
@ -231,7 +239,7 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){
var run = function(thisItemBody){
var iframe = thisItemBody.children('iframe')[0];
if(isIframePreview && iframe){
iframe.srcdoc = codes.join('');
iframe.srcdoc = finalCode;
} else {
thisItemBody.html(codes.join(''));
}
@ -297,13 +305,7 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){
}
// code
var html = finalCode = codes.join('');
// 外部重新解析 code
if(typeof options.codeParse === 'function'){
html = finalCode = options.codeParse(html);
}
// 转义 HTML 标签
if(options.encode) html = util.escape(html); // 编码