提交 d05c842f authored 作者: 钟是志's avatar 钟是志

WangEditor 增加pdf 阅读功能

上级 479194fb
...@@ -17,7 +17,7 @@ import React, { useState, useEffect } from 'react'; ...@@ -17,7 +17,7 @@ import React, { useState, useEffect } from 'react';
import WangEditor from './includes/wangEditor.min'; import WangEditor from './includes/wangEditor.min';
import { uploadFile } from "@/webPublic/one_stop_public/libs/PictureSignature/ShowItem"; import { uploadFile } from "@/webPublic/one_stop_public/libs/PictureSignature/ShowItem";
import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig'; import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
// import PdfMenu from './PdfMenu'; import PdfMenu from '@/webPublic/zyd_public/WangEditor/PdfMenu';
let editor = null; let editor = null;
...@@ -37,6 +37,8 @@ export default function Index({ ...@@ -37,6 +37,8 @@ export default function Index({
// const menuKey = 'PdfMenuKey'; // const menuKey = 'PdfMenuKey';
// WangEditor.registerMenu(menuKey, PdfMenu); // WangEditor.registerMenu(menuKey, PdfMenu);
editor = new WangEditor(`#wangEditor${domKey}`); editor = new WangEditor(`#wangEditor${domKey}`);
const menuKey = 'PdfMenuKey';
editor.menus.extend(menuKey, PdfMenu);
if (height) { if (height) {
editor.config.height = height; // 编辑器高度 editor.config.height = height; // 编辑器高度
} }
...@@ -90,9 +92,10 @@ export default function Index({ ...@@ -90,9 +92,10 @@ export default function Index({
// 'emoticon', // 'emoticon',
'image', 'image',
'video', 'video',
// 'table', 'table',
// 'code', // 'code',
'splitLine', 'splitLine',
'PdfMenuKey',
// 'undo', // 'undo',
// 'redo', // 'redo',
]; ];
......
// https://www.wangeditor.com/v4/pages/02-%E5%86%85%E5%AE%B9%E5%A4%84%E7%90%86/02-%E8%BF%BD%E5%8A%A0%E6%96%B0%E5%86%85%E5%AE%B9.html // https://www.wangeditor.com/v4/pages/02-%E5%86%85%E5%AE%B9%E5%A4%84%E7%90%86/02-%E8%BF%BD%E5%8A%A0%E6%96%B0%E5%86%85%E5%AE%B9.html
import Editor from '@/webPublic/zyd_public/WangEditor/includes/wangEditor.min'; import Editor from '@/webPublic/zyd_public/WangEditor/includes/wangEditor.min';
import { message } from 'antd'; import { message } from 'antd';
import uploadFile from '@/webPublic/zyd_public/WangEditor/uploadFile'; import { uploadFile } from "@/webPublic/one_stop_public/libs/PictureSignature/ShowItem";
import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
const E = Editor; const E = Editor;
const { BtnMenu } = E; const { BtnMenu } = E;
...@@ -38,8 +39,9 @@ export default class AlertMenu extends BtnMenu { ...@@ -38,8 +39,9 @@ export default class AlertMenu extends BtnMenu {
const file = dom.files[0]; const file = dom.files[0];
console.log(file); console.log(file);
const fileName = file.name; const fileName = file.name;
uploadFile({ file: file }).then((res) => { uploadFile(file).then((res) => {
if (res && res.url) { if (res && res.length > 10) {
let url = queryApiActionPath() + res;
window.message.success('上传文件成功'); window.message.success('上传文件成功');
console.log(this); console.log(this);
this.editor.txt.append(` this.editor.txt.append(`
...@@ -48,12 +50,12 @@ export default class AlertMenu extends BtnMenu { ...@@ -48,12 +50,12 @@ export default class AlertMenu extends BtnMenu {
height='768px' height='768px'
name='plugin' name='plugin'
id='plugin' id='plugin'
src='${res.url}' src='${url}'
type='application/pdf' type='application/pdf'
internalinstanceid='3' internalinstanceid='3'
title='${fileName}'/> title='${fileName}'/>
</p> </p>
<p class='wangEditor-aHref'><a href='${res.url}' target='_blank'>${fileName}</a></p>`); <p class='wangEditor-aHref'><a href='${url}' target='_blank' download='${fileName}'>${fileName}</a></p>`);
} }
}); });
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论