diff --git a/public/static/js/phone-image.js b/public/static/js/phone-image.js index 56bc2a8..e3ebdaf 100644 --- a/public/static/js/phone-image.js +++ b/public/static/js/phone-image.js @@ -13,7 +13,6 @@ var PhoneImageEngine = (function () { // ===== 配置 ===== var config = { size: 'xiaohongshu', - fontSize: 14, watermark: '', pageAlignments: {}, // key=页码(1-based), value='top'|'center' sizes: { @@ -39,25 +38,6 @@ var PhoneImageEngine = (function () { // ===== 分页结果 ===== var pages = []; - // ===== 截图缓存 ===== - var convertedBlockCache = {}; // key: simpleHash(block.html), value: { imgHtml: '...' } - - /** - * 简单字符串哈希 (djb2 变体) - * @param {string} str - * @returns {string} 哈希字符串 - */ - function simpleHash(str) { - var hash = 0; - if (!str) return '0'; - for (var i = 0; i < str.length; i++) { - var char = str.charCodeAt(i); - hash = ((hash << 5) - hash) + char; - hash = hash & hash; // 转32位整数 - } - return '' + hash; - } - /** * 确保隐藏渲染区域存在 */ @@ -91,38 +71,11 @@ var PhoneImageEngine = (function () { if (userConfig) { $.extend(config, userConfig); } - - // 清空缓存,避免旧数据干扰 - convertedBlockCache = {}; - - // 内容流事件委托(只绑定一次) - $(document).off('click', '.break-inserter-btn'); - $(document).off('click', '.remove-break-btn'); - $(document).off('click', '.thumb-alignment-toggle'); - - $(document).on('click', '.break-inserter-btn', function () { - var afterIndex = parseInt($(this).parent().data('after-index'), 10); - insertPageBreak(afterIndex); - }); - - $(document).on('click', '.remove-break-btn', function () { - var index = parseInt($(this).data('index'), 10); - removePageBreak(index); - }); - - $(document).on('click', '.thumb-alignment-toggle', function () { - var pageNum = parseInt($(this).data('page-num'), 10); - var currentAlign = (config.pageAlignments && config.pageAlignments[pageNum]) || 'top'; - var newAlign = currentAlign === 'top' ? 'center' : 'top'; - - setPageAlignment(pageNum, newAlign); - render(); - }); } /** * 渲染排版预览 - 生成分页后的HTML - * 管线: preprocess -> parse -> renderContentFlow -> measure -> paginate -> generate -> renderThumbnails + * 管线: editorHtml -> parseHtmlToBlocks -> captureEditorBlocks -> generatePages -> renderThumbnails * 带并发锁:防止多次 render 同时执行造成数据混乱 * @returns {jQuery Deferred} resolves with pages array */ @@ -142,79 +95,54 @@ var PhoneImageEngine = (function () { var pageHeight = sizeConfig.height; var contentAreaHeight = pageHeight - (config.contentPadding * 2); - var cleanHtml = preprocessContent(postData.content_html); + // 从 wangeditor 读取内容 + var editorHtml = window.phoneImageEditor ? window.phoneImageEditor.getHtml() : postData.content_html; + var cleanHtml = preprocessContent(editorHtml); var blocks = parseHtmlToBlocks(cleanHtml); - // 动态设置字号CSS变量,让fontSize滑块真正生效 - var effectiveFontSize = parseInt(config.fontSize, 10) || 14; - document.documentElement.style.setProperty('--pi-font-size-base', effectiveFontSize + 'px'); - - // 缓存清理:如果缓存条目过多则清空,防止内存膨胀 - var cacheKeys = Object.keys(convertedBlockCache); - if (cacheKeys.length > blocks.length * 3) { - convertedBlockCache = {}; - } - - // 空内容检测:blocks 为空时直接提示,不进入渲染流程 + // 空内容检测 if (blocks.length === 0) { $('#paginated-preview').html('
文章正文内容为空
'); render._locked = false; return deferred.resolve([]).promise(); } - // 先渲染内容流(DOM) - 用于实测高度 - renderContentFlow(blocks); + // 封面页 + pages.push(generateCoverPage(sizeConfig)); - // 等待一帧确保中间栏渲染完成 - requestAnimationFrame(function () { - // 在中间栏中将表格和代码块截图转为图片 - convertFlowBlocksToImages(blocks).then(function () { - // 再等一帧让替换后的img渲染 - requestAnimationFrame(function () { - measureBlockHeights(blocks); + // 内容分页(使用 captureEditorBlocks,T3 会完善截图逻辑) + captureEditorBlocks(editorHtml, blocks, contentAreaHeight, sizeConfig).then(function(contentPages) { + pages = pages.concat(contentPages); - // 封面页 - pages.push(generateCoverPage(sizeConfig)); + // 尾页 + pages.push(generateSummaryPage(sizeConfig, pages.length)); - // 内容分页(使用实测高度) - var contentPages = paginateContent(blocks, contentAreaHeight, sizeConfig); - pages = pages.concat(contentPages); + // 页码 N/M + var totalPages = pages.length; + for (var i = 0; i < pages.length; i++) { + if (pages[i].type === 'content') { + pages[i].html = pages[i].html.replace( + '' + pages[i].pageNum + '', + '' + (i + 1) + '/' + totalPages + '' + ); + } + } - // 尾页 - pages.push(generateSummaryPage(sizeConfig, pages.length)); - - // 两遍遍历: 现在知道了总页数, 给每页补上 N/M 页码 - var totalPages = pages.length; - for (var i = 0; i < pages.length; i++) { - if (pages[i].type === 'content') { - // 在页脚中添加 N/M 格式页码 - pages[i].html = pages[i].html.replace( - '' + pages[i].pageNum + '', - '' + (i + 1) + '/' + totalPages + '' - ); - } - } - - // 渲染缩略图(右侧)- 异步截图 - renderThumbnails(sizeConfig).then(function () { - render._locked = false; - // 如果渲染期间有新的渲染请求排队,自动触发 - if (render._pending) { - render._pending = false; - render().catch(function () { - // 静默处理递归渲染失败 - }); - } - deferred.resolve(pages); - }).catch(function (err) { - render._locked = false; - deferred.reject(err); - }); - }); - }).catch(function (err) { + // 渲染缩略图 + renderThumbnails(sizeConfig).then(function() { + render._locked = false; + if (render._pending) { + render._pending = false; + render().catch(function() {}); + } + deferred.resolve(pages); + }).catch(function(err) { render._locked = false; deferred.reject(err); }); + }).catch(function(err) { + render._locked = false; + deferred.reject(err); }); return deferred.promise(); @@ -311,7 +239,7 @@ var PhoneImageEngine = (function () { blocks.push({ type: 'p', html: '

' + p + '

', - estimatedHeight: estimateTextHeight(p, config.fontSize) + estimatedHeight: 40 }); } } @@ -340,7 +268,7 @@ var PhoneImageEngine = (function () { case 'h5': case 'h6': block.type = tagName; - block.estimatedHeight = estimateHeadingHeight(tagName, $el.text()); + block.estimatedHeight = 40; break; case 'table': block.type = 'table'; @@ -359,7 +287,7 @@ var PhoneImageEngine = (function () { var imgW = parseInt($el.attr('data-original-width'), 10); var imgH = parseInt($el.attr('data-original-height'), 10); if (imgW > 0 && imgH > 0) { - var imgRatio = getContentWidth() / imgW; + var imgRatio = 500 / imgW; block.estimatedHeight = Math.round(imgH * imgRatio) + 20; } else { block.estimatedHeight = 0; @@ -368,15 +296,15 @@ var PhoneImageEngine = (function () { break; case 'ul': case 'ol': - block.estimatedHeight = estimateListHeight($el); + block.estimatedHeight = 40; break; case 'blockquote': - block.estimatedHeight = estimateBlockquoteHeight($el); + block.estimatedHeight = 40; break; case 'p': default: block.type = 'p'; - block.estimatedHeight = estimateTextHeight($el.text(), config.fontSize); + block.estimatedHeight = 40; break; } @@ -386,56 +314,126 @@ var PhoneImageEngine = (function () { return blocks; } - // ===== 高度估算 ===== + // ===== wangeditor 集成层 ===== /** - * 获取内容区可用宽度 (540 - 40px padding) + * 获取 wangeditor 编辑区的子元素 + * @returns {Array} DOM元素数组 */ - function getContentWidth() { - return 500; + function getEditorChildren() { + var editorArea = document.querySelector('#editor-text-area [data-slate-editor]'); + if (!editorArea) return []; + + var children = editorArea.children; + // wangeditor v5: [data-slate-editor] 下可能有一层 div 包装 + // 如果只有一个 child 且是 div,则取其子元素 + if (children.length === 1 && children[0].tagName.toLowerCase() === 'div') { + return Array.prototype.slice.call(children[0].children); + } + return Array.prototype.slice.call(children); } /** - * 估算文本高度 - * @param {string} text - * @param {number} fontSize - * @returns {number} px + * 从 wangeditor 内容构建分页数据 + * 完整实现:从编辑器DOM截图测高 -> 按分割线分组 -> 按高度分页 -> 生成staging HTML + * @param {string} html - 编辑器HTML内容 + * @param {Array} blocks - parseHtmlToBlocks 解析后的块数组 + * @param {number} contentAreaHeight - 内容区可用高度(px) + * @param {Object} sizeConfig - {width, height} + * @returns {jQuery Deferred} resolves with contentPages array */ - function estimateTextHeight(text, fontSize) { - var charCount = text.length; - if (charCount === 0) return 0; - var charsPerLine = Math.floor(getContentWidth() / (fontSize * 1.0)); - if (charsPerLine < 1) charsPerLine = 1; - var lines = Math.ceil(charCount / charsPerLine); - return lines * fontSize * 1.8 + 10; // 1.8行高 + 10px段落间距 - } + function captureEditorBlocks(html, blocks, contentAreaHeight, sizeConfig) { + var deferred = $.Deferred(); - /** - * 估算标题高度 - */ - function estimateHeadingHeight(tag, text) { - var sizeMap = { h1: 28, h2: 24, h3: 20, h4: 18, h5: 16, h6: 14 }; - var hSize = sizeMap[tag] || 20; - var charsPerLine = Math.floor(getContentWidth() / (hSize * 1.0)); - if (charsPerLine < 1) charsPerLine = 1; - var lines = Math.ceil(text.length / charsPerLine); - return lines * hSize * 1.4 + 20; // heading行高1.4 + 20px上下间距 - } + // 按 page-break 分组 + var groups = []; + var currentGroup = { blocks: [], domIndices: [] }; + var domIdx = 0; - /** - * 估算列表高度 - */ - function estimateListHeight($list) { - var items = $list.find('li').length; - return items * (config.fontSize * 1.8 + 5) + 15; - } + for (var i = 0; i < blocks.length; i++) { + if (blocks[i].type === 'page-break') { + if (currentGroup.blocks.length > 0) groups.push(currentGroup); + currentGroup = { blocks: [], domIndices: [] }; + // page-break 对应 wangeditor 中的 divider(hr),在 DOM 中也是一个子元素 + domIdx++; + continue; + } + currentGroup.blocks.push(blocks[i]); + currentGroup.domIndices.push(domIdx); + domIdx++; + } + if (currentGroup.blocks.length > 0) groups.push(currentGroup); - /** - * 估算引用块高度 - */ - function estimateBlockquoteHeight($bq) { - var text = $bq.text(); - return estimateTextHeight(text, config.fontSize) + 10; + if (groups.length === 0) { + deferred.resolve([]); + return deferred.promise(); + } + + // 获取编辑器子元素 + var editorChildren = getEditorChildren(); + + // 创建测量容器(500px = 540 - 20*2 padding,与内容区一致) + var $mc = $('
').css({ + width: '500px', + position: 'fixed', + left: '-9999px', + top: '0', + visibility: 'hidden', + background: '#ffffff', + fontSize: '14px', + lineHeight: '1.8', + boxSizing: 'border-box' + }); + $('body').append($mc); + + // 串行测高每组 + var gi = 0; + + function measureNext() { + if (gi >= groups.length) { + $mc.remove(); + // 给尚未设置高度的 block 设默认值 + for (var k = 0; k < blocks.length; k++) { + if (!blocks[k].estimatedHeight) { + blocks[k].estimatedHeight = 40; + } + } + // 用测量的实际高度后的 blocks 调用原有 paginateContent 分页 + var contentPages = paginateContent(blocks, contentAreaHeight, sizeConfig); + deferred.resolve(contentPages); + return; + } + + var group = groups[gi]; + $mc.empty(); + + for (var j = 0; j < group.domIndices.length; j++) { + var di = group.domIndices[j]; + if (di < editorChildren.length) { + $mc.append(editorChildren[di].cloneNode(true)); + } + } + + requestAnimationFrame(function () { + var h = Math.round($mc[0].getBoundingClientRect().height); + + // 按比例分配测量的实际高度给组内各个 block + var totalEstimated = 0; + for (var k = 0; k < group.blocks.length; k++) { + totalEstimated += (group.blocks[k].estimatedHeight || 40); + } + for (var k = 0; k < group.blocks.length; k++) { + var ratio = (group.blocks[k].estimatedHeight || 40) / (totalEstimated || 1); + group.blocks[k].estimatedHeight = Math.round(h * ratio); + } + + gi++; + measureNext(); + }); + } + + measureNext(); + return deferred.promise(); } // ===== 分页核心算法 ===== @@ -558,7 +556,7 @@ var PhoneImageEngine = (function () { } // 按句子拆分:句号、问号、叹号、换行(兼容不支持 lookbehind 的浏览器) - var effectiveFontSize = parseInt(config.fontSize, 10) || 14; + var effectiveFontSize = 14; var parts = text.split(/([。!?\n])/); var sentences = []; var current = ''; @@ -574,7 +572,7 @@ var PhoneImageEngine = (function () { if (sentences.length <= 1) { // 无法按句子拆分,按固定字符数拆分 sentences = []; - var chunkSize = Math.floor(getContentWidth() / effectiveFontSize) * + var chunkSize = Math.floor(500 / effectiveFontSize) * Math.floor(pageHeight / (effectiveFontSize * 1.8)); if (chunkSize < 10) chunkSize = 10; for (var ci = 0; ci < text.length; ci += chunkSize) { @@ -586,7 +584,10 @@ var PhoneImageEngine = (function () { for (var j = 0; j < sentences.length; j++) { var s = sentences[j].trim(); if (!s) continue; - var h = estimateTextHeight(s, effectiveFontSize); + var lineChars = Math.floor(500 / effectiveFontSize); + if (lineChars < 1) lineChars = 1; + var lines = Math.ceil(s.length / lineChars); + var h = lines * effectiveFontSize * 1.8 + 10; result.push({ type: wrapperTag === 'blockquote' ? 'blockquote' : 'p', html: '<' + wrapperTag + '>' + s + '', @@ -1041,228 +1042,6 @@ var PhoneImageEngine = (function () { }); } - /** - * 在中间栏 #content-flow 中将表格和代码块截图转为图片 - * 在 renderContentFlow(blocks) 之后、measureBlockHeights(blocks) 之前调用 - * 使用 convertedBlockCache 缓存已转换的图片,仅对新增/变更的 block 执行截图 - * @param {Array} blocks - parseHtmlToBlocks 返回的块数组 - * @returns {jQuery Deferred} resolves with blocks array - */ - function convertFlowBlocksToImages(blocks) { - var deferred = $.Deferred(); - var $flow = $('#content-flow'); - var blocksToConvert = []; // 需要重新截图的 block 索引 - - // 第一遍:检查缓存,命中则直接复用 - for (var i = 0; i < blocks.length; i++) { - if (blocks[i].type !== 'table' && blocks[i].type !== 'pre') continue; - - var cacheKey = simpleHash(blocks[i].html); - if (convertedBlockCache[cacheKey]) { - // 命中缓存 - blocks[i].html = convertedBlockCache[cacheKey].imgHtml; - blocks[i].type = 'img'; - // 更新中间栏显示 - var $cachedEl = $flow.find('.content-flow-block[data-index="' + i + '"]'); - if ($cachedEl.length) $cachedEl.html(blocks[i].html); - } else { - blocksToConvert.push(i); - } - } - - if (blocksToConvert.length === 0) { - deferred.resolve(blocks); - return deferred.promise(); - } - - // 第二遍:串行截图未缓存的 block - var convertIdx = 0; - - function convertNext() { - if (convertIdx >= blocksToConvert.length) { - deferred.resolve(blocks); - return; - } - - var blockIdx = blocksToConvert[convertIdx]; - var block = blocks[blockIdx]; - var $blockEl = $flow.find('.content-flow-block[data-index="' + blockIdx + '"]'); - - if (!$blockEl.length) { - convertIdx++; - convertNext(); - return; - } - - // 对代码块:先应用 Prism 高亮 - if (block.type === 'pre' && typeof Prism !== 'undefined') { - $blockEl.find('pre > code:not([class*="language-"])').addClass('language-plaintext'); - $blockEl.find('pre code').each(function () { Prism.highlightElement(this); }); - } - - html2canvas($blockEl[0], { - scale: 2, - useCORS: true, - backgroundColor: block.type === 'table' ? '#ffffff' : '#f5f5f5', - logging: false - }).then(function (canvas) { - var imgData = canvas.toDataURL('image/jpeg', 0.92); - var imgHtml = ''; - - // 存入缓存(用截图前的原始HTML做key) - var originalHtml = block.html; - var cacheKey = simpleHash(originalHtml); - convertedBlockCache[cacheKey] = { imgHtml: imgHtml }; - - block.html = imgHtml; - block.type = 'img'; - $blockEl.html(imgHtml); - - convertIdx++; - convertNext(); - }).catch(function () { - // 截图失败,保留原样 - convertIdx++; - convertNext(); - }); - } - - convertNext(); - return deferred.promise(); - } - - /** - * DOM实测高度 - 从#content-flow中读取每个块的实际渲染高度 - * @param {Array} blocks - parseHtmlToBlocks 返回的块数组 - */ - function measureBlockHeights(blocks) { - var $flow = $('#content-flow'); - if (!$flow.length) return; - - for (var i = 0; i < blocks.length; i++) { - var block = blocks[i]; - if (block.type === 'page-break') continue; - - var $blockEl = $flow.find('.content-flow-block[data-index="' + i + '"]'); - if ($blockEl.length) { - var actualHeight = Math.round($blockEl[0].getBoundingClientRect().height); - if (actualHeight > 0) { - block.estimatedHeight = actualHeight; - } - } - } - } - - /** - * 渲染内容流到 #content-flow 容器 - * @param {Array} blocks - parseHtmlToBlocks 返回的块数组 - */ - function renderContentFlow(blocks) { - var $flow = $('#content-flow'); - if (!$flow.length) return; - - $flow.empty(); - - for (var i = 0; i < blocks.length; i++) { - var block = blocks[i]; - - // 分页标记 - if (block.type === 'page-break') { - var $marker = $('
' + - '-- 分页标记 --' + - '' + - '
'); - $flow.append($marker); - continue; - } - - // 内容块 - var $block = $('
' + block.html + '
'); - $flow.append($block); - - // 块与块之间的分页插入区域(不在最后一个块之后添加) - if (i < blocks.length - 1) { - var $inserter = $('
' + - '' + - '
'); - $flow.append($inserter); - } - } - } - - /** - * 在指定位置插入分页标记 - * 修改 postData.content_html,在对应位置插入
- * @param {number} blockIndex - 在哪个块之后插入 (对应 break-inserter 的 data-after-index) - */ - function insertPageBreak(blockIndex) { - // 如果正在渲染,延迟重试 - if (render._locked) { - insertPageBreak._retryCount = (insertPageBreak._retryCount || 0) + 1; - if (insertPageBreak._retryCount >= 15) { - insertPageBreak._retryCount = 0; - layer.msg('操作超时,请重试'); - return; - } - setTimeout(function () { insertPageBreak(blockIndex); }, 200); - return; - } - insertPageBreak._retryCount = 0; - - var cleanHtml = preprocessContent(postData.content_html); - var $temp = $('
').html(cleanHtml); - var children = $temp.children(); - - // 在 blockIndex 位置的元素之后插入
- if (blockIndex >= 0 && blockIndex < children.length) { - $(children[blockIndex]).after('
'); - } else { - $temp.append('
'); - } - - postData.content_html = $temp.html(); - - // 重新渲染 - render(); - } - - /** - * 删除指定位置的分页标记 - * @param {number} blockIndex - 分页标记的 data-index - */ - function removePageBreak(blockIndex) { - // 如果正在渲染,延迟重试 - if (render._locked) { - removePageBreak._retryCount = (removePageBreak._retryCount || 0) + 1; - if (removePageBreak._retryCount >= 15) { - removePageBreak._retryCount = 0; - layer.msg('操作超时,请重试'); - return; - } - setTimeout(function () { removePageBreak(blockIndex); }, 200); - return; - } - removePageBreak._retryCount = 0; - - // 统计这是第几个 page-break - var cleanHtml = preprocessContent(postData.content_html); - var $temp = $('
').html(cleanHtml); - var hrElements = $temp.find('hr'); - - // 在 blocks 数组中找到这个 page-break 是第几个 - var breakOrder = 0; - var currentBlocks = parseHtmlToBlocks(cleanHtml); - for (var i = 0; i < currentBlocks.length && i < blockIndex; i++) { - if (currentBlocks[i].type === 'page-break') breakOrder++; - } - - if (breakOrder < hrElements.length) { - $(hrElements[breakOrder]).remove(); - postData.content_html = $temp.html(); - render(); - } - } - // ===== 图片生成 ===== /** @@ -1364,7 +1143,6 @@ var PhoneImageEngine = (function () { output_type: 'phone_image', config: { size: saveConfig.size || config.size, - fontSize: saveConfig.fontSize || config.fontSize, watermark: saveConfig.watermark || config.watermark, pageAlignments: config.pageAlignments || {} }, @@ -1405,56 +1183,74 @@ var PhoneImageEngine = (function () { config.pageAlignments[pageNum] = align; } + // ===== 导出长图 ===== + /** - * 导出内容流为长图 + * 导出长图:从 wangeditor DOM 截取完整长图 + * @returns {jQuery Deferred} resolves with canvas */ function exportLongImage() { var deferred = $.Deferred(); if (render._locked) { - layer.msg('请等待渲染完成'); deferred.reject('rendering'); return deferred.promise(); } - var $flow = $('#content-flow'); - if (!$flow.length) { - deferred.reject('内容流容器不存在'); + var editorChildren = getEditorChildren(); + if (editorChildren.length === 0) { + deferred.reject('编辑器内容为空'); return deferred.promise(); } - // 临时隐藏交互元素 - $flow.find('.break-inserter').hide(); - $flow.find('.page-break-marker').hide(); + // 创建临时容器,宽度540px与编辑器一致 + var $container = $('
').css({ + width: '540px', + position: 'fixed', + left: '-9999px', + top: '0', + visibility: 'visible', + background: '#ffffff', + padding: '20px', + boxSizing: 'border-box', + fontSize: '14px', + lineHeight: '1.8' + }); - // 获取内容流的实际高度 - var flowWidth = $flow.outerWidth(); - var flowHeight = $flow[0].scrollHeight; + // 克隆所有非 divider 的子元素 + for (var i = 0; i < editorChildren.length; i++) { + var el = editorChildren[i]; + var isDivider = el.getAttribute('data-w-e-type') === 'divider' || + el.tagName.toLowerCase() === 'hr'; + if (!isDivider) { + $container.append(el.cloneNode(true)); + } + } - html2canvas($flow[0], { - scale: 2, - useCORS: true, - backgroundColor: '#ffffff', - width: flowWidth, - height: flowHeight, - logging: false - }).then(function (canvas) { - // 恢复交互元素 - $flow.find('.break-inserter').show(); - $flow.find('.page-break-marker').show(); + $('body').append($container); - // 触发下载 - var link = document.createElement('a'); - link.download = 'phone-image-long-' + Date.now() + '.png'; - link.href = canvas.toDataURL('image/png'); - link.click(); + requestAnimationFrame(function () { + var width = $container.outerWidth(); + var height = $container[0].scrollHeight; - deferred.resolve(canvas); - }).catch(function (err) { - // 恢复交互元素 - $flow.find('.break-inserter').show(); - $flow.find('.page-break-marker').show(); - deferred.reject('长图导出失败: ' + err); + html2canvas($container[0], { + scale: 2, + useCORS: true, + backgroundColor: '#ffffff', + width: width, + height: height, + logging: false + }).then(function (canvas) { + $container.remove(); + var link = document.createElement('a'); + link.download = 'phone-image-long-' + Date.now() + '.png'; + link.href = canvas.toDataURL('image/png'); + link.click(); + deferred.resolve(canvas); + }).catch(function (err) { + $container.remove(); + deferred.reject('长图导出失败: ' + err); + }); }); return deferred.promise(); @@ -1480,16 +1276,17 @@ var PhoneImageEngine = (function () { saveImages: saveImages, saveConfig: saveConfig, setPageAlignment: setPageAlignment, - insertPageBreak: insertPageBreak, - removePageBreak: removePageBreak, + exportLongImage: exportLongImage, getContentHtml: function () { + if (window.phoneImageEditor) { + return window.phoneImageEditor.getHtml(); + } return postData.content_html; }, updateConfig: function (newConfig) { if (newConfig) { $.extend(config, newConfig); } - }, - exportLongImage: exportLongImage + } }; })(); diff --git a/view/admin/post/phone_image.html b/view/admin/post/phone_image.html index a6da654..11c110e 100644 --- a/view/admin/post/phone_image.html +++ b/view/admin/post/phone_image.html @@ -7,9 +7,9 @@ {$post.title} - 手机图片排版 + - @@ -98,69 +105,30 @@