Commit ed18ec99 by Яков

add pdf to text

parent 66978172
{ {
"name": "react-ag-qeditor", "name": "react-ag-qeditor",
"version": "1.1.19", "version": "1.1.20",
"description": "WYSIWYG html editor", "description": "WYSIWYG html editor",
"author": "atma", "author": "atma",
"license": "MIT", "license": "MIT",
......
...@@ -49,6 +49,7 @@ import IframeCustomModal from './modals/IframeCustomModal' ...@@ -49,6 +49,7 @@ import IframeCustomModal from './modals/IframeCustomModal'
import { isMobile } from 'react-device-detect' import { isMobile } from 'react-device-detect'
import { ExportPdf } from './extensions/ExportPdf' import { ExportPdf } from './extensions/ExportPdf'
import { mergeAttributes } from "@tiptap/core"; import { mergeAttributes } from "@tiptap/core";
import Upload from "rc-upload";
// const CustomImage = Image.extend({ // const CustomImage = Image.extend({
// options: {inline: true}, // options: {inline: true},
...@@ -246,6 +247,10 @@ const QEditor = ({ ...@@ -246,6 +247,10 @@ const QEditor = ({
title: 'Вставить презентацию pdf', title: 'Вставить презентацию pdf',
onClick: () => modalOpener('iframe_pdf', 'Вставить презентацию pdf') onClick: () => modalOpener('iframe_pdf', 'Вставить презентацию pdf')
}, },
pdf: {
title: 'Вставить pdf -> text',
onClick: () => modalOpener('pdf', 'Вставить pdf -> text')
},
export_pdf: { export_pdf: {
title: 'Экспорт в pdf', title: 'Экспорт в pdf',
onClick: () => ExportPdf() onClick: () => ExportPdf()
...@@ -258,6 +263,10 @@ const QEditor = ({ ...@@ -258,6 +263,10 @@ const QEditor = ({
title: 'Загрузить изображение', title: 'Загрузить изображение',
onClick: () => modalOpener('image', 'Загрузить изображение') onClick: () => modalOpener('image', 'Загрузить изображение')
}, },
pdfToText: {
title: 'Загрузить pdf',
onClick: () => modalOpener('pdf', 'Загрузить pdf')
},
interactiveImage: { interactiveImage: {
title: 'Интерактивное изображение', title: 'Интерактивное изображение',
onClick: () => { onClick: () => {
...@@ -610,7 +619,7 @@ const QEditor = ({ ...@@ -610,7 +619,7 @@ const QEditor = ({
) )
} }
const getUploader = ({accept = '*', ...o}) => { const getUploader = ({accept = '*', ...o}, custom_url = '') => {
let url = uploadOptions.url let url = uploadOptions.url
let multiple = true let multiple = true
if (o.afterParams && o.afterParams.length > 0) { if (o.afterParams && o.afterParams.length > 0) {
...@@ -630,7 +639,7 @@ const QEditor = ({ ...@@ -630,7 +639,7 @@ const QEditor = ({
<Uploader <Uploader
key={uploaderUid} key={uploaderUid}
accept={accept} accept={accept}
action={url} action={custom_url.length > 0 ? custom_url : url}
errorMessage={uploadOptions.errorMessage} errorMessage={uploadOptions.errorMessage}
onSuccess={(file) => { onSuccess={(file) => {
const _uploadedPaths = [...uploadedPaths] const _uploadedPaths = [...uploadedPaths]
...@@ -719,6 +728,15 @@ const QEditor = ({ ...@@ -719,6 +728,15 @@ const QEditor = ({
})} })}
</Fragment> </Fragment>
) )
case 'pdf':
return (
<Fragment>
{getUploader({
accept: 'application/pdf',
afterParams: ['no_convert=1']
}, '/ru/pdf-to-text/')}
</Fragment>
)
case 'video': case 'video':
return <Fragment>{getUploader({accept: 'video/mp4,.mp4'})}</Fragment> return <Fragment>{getUploader({accept: 'video/mp4,.mp4'})}</Fragment>
case 'image': case 'image':
...@@ -1261,6 +1279,9 @@ const QEditor = ({ ...@@ -1261,6 +1279,9 @@ const QEditor = ({
).run() ).run()
}) })
break break
case 'pdf':
editor.chain().focus().insertContent(embedContent).run()
break
case 'file': case 'file':
uploadedPaths.map((file, i) => { uploadedPaths.map((file, i) => {
let exp = file.path.split('.') let exp = file.path.split('.')
......
...@@ -50,6 +50,7 @@ const toolsInit = { ...@@ -50,6 +50,7 @@ const toolsInit = {
'iframe', 'iframe',
'iframe_pptx', 'iframe_pptx',
'iframe_pdf', 'iframe_pdf',
'pdf',
'audio', 'audio',
'iframe_custom', 'iframe_custom',
'insertToggleBlock' 'insertToggleBlock'
......
...@@ -183,6 +183,9 @@ export default class Uploader extends React.Component { ...@@ -183,6 +183,9 @@ export default class Uploader extends React.Component {
}); });
} }
if (resp.state === 'success') {
console.log(resp);
}
}} }}
onProgress={(o, file) => { onProgress={(o, file) => {
if (this.files[file.uid]) { if (this.files[file.uid]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment