Commit 18e10c9c authored by Яков's avatar Яков
Browse files

update fix issue

parent 09d32905
{
"name": "react-ag-qeditor",
"version": "1.1.48",
"version": "1.1.49",
"description": "WYSIWYG html editor",
"author": "atma",
"license": "MIT",
......
......@@ -641,31 +641,27 @@ const QEditor = ({
},
insertToggleBlock: {
title: 'Раскрывающийся список',
onClick: () =>
editor.commands.insertContent([
{
type: 'toggleBlock',
attrs: {
title: 'Заголовок',
open: true,
},
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'Введите подробности...',
},
],
},
],
},
{
type: 'paragraph',
content: [],
onClick: () => {
const { state, view } = editor
const { $from } = state.selection
// Всегда вставляем после текущего блока верхнего уровня,
// а не в позицию курсора — иначе insertContent может «съесть»
// пустой параграф, разделяющий два раскрывающихся списка.
const insertPos = $from.after(Math.min($from.depth, 1))
const schema = state.schema
const toggleNode = schema.nodes.toggleBlock.create(
{ title: 'Заголовок', open: true },
schema.nodes.paragraph.create(
null,
schema.text('Введите подробности...')
)
)
const paraNode = schema.nodes.paragraph.create()
view.dispatch(state.tr.insert(insertPos, [toggleNode, paraNode]))
},
]),
},
toggleTableBorders: {
......@@ -795,7 +791,7 @@ const QEditor = ({
)
}
const getUploader = ({accept = '*', ...o}, custom_url = '') => {
const getUploader = ({accept = '*', processingMessage = null, ...o}, custom_url = '') => {
let url = uploadOptions.url
let multiple = true
if (o.afterParams && o.afterParams.length > 0) {
......@@ -817,6 +813,7 @@ const QEditor = ({
accept={accept}
action={custom_url.length > 0 ? custom_url : url}
errorMessage={uploadOptions.errorMessage}
processingMessage={processingMessage}
onSuccess={(file, html) => {
if (typeof file !== "undefined") {
const _uploadedPaths = [...uploadedPaths]
......@@ -1019,7 +1016,8 @@ const QEditor = ({
<Fragment>
{getUploader({
accept: 'application/pdf',
afterParams: ['no_convert=1']
afterParams: ['no_convert=1'],
processingMessage: 'Распознаём текст PDF, подождите...'
}, '/ru/pdf-to-text/')}
</Fragment>
)
......
......@@ -102,6 +102,10 @@ export default class Uploader extends React.Component {
}
}
get processingMessage () {
return this.props.processingMessage;
}
render () {
let {disabledFileUpload, isUpload, progress, dropFiles} = this.state;
......@@ -113,6 +117,12 @@ export default class Uploader extends React.Component {
{this.state.html.length > 0 ? <div dangerouslySetInnerHTML={{__html: this.state.html}} />
:
<>
{isUpload && this.processingMessage && (
<div className='atma-editor-uploader-processing'>
<span className='atma-editor-uploader-processing-spinner' />
{this.processingMessage}
</div>
)}
<div className={'atma-editor-uploader-uitems'}>
{
Object.keys(this.state.files).map((uid, i) => (
......@@ -223,5 +233,6 @@ Uploader.defaultProps = {
type: '',
onSuccess: ()=>{},
errorMessage: null,
modalType: null
modalType: null,
processingMessage: null
};
......@@ -458,7 +458,10 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
const imageContent = (
<>
<img
{...node.attrs}
src={node.attrs.src}
alt={node.attrs.alt || undefined}
title={node.attrs.title || undefined}
data-node-id={node.attrs['data-node-id'] || undefined}
ref={imgRef}
draggable={true}
style={getImageStyle()}
......
......@@ -184,7 +184,46 @@ const ToggleBlock = Node.create({
},
addProseMirrorPlugins () {
const buildGapFix = (state) => {
const doc = state.doc
const tr = state.tr
let additionalOffset = 0
let pos = 1
for (let i = 0; i < doc.childCount - 1; i++) {
const node = doc.child(i)
const nextNode = doc.child(i + 1)
pos += node.nodeSize
if (
node.type.name === 'toggleBlock' &&
nextNode.type.name === 'toggleBlock'
) {
tr.insert(
pos + additionalOffset,
state.schema.nodes.paragraph.create()
)
additionalOffset += 2
}
}
return additionalOffset > 0 ? tr : null
}
return [
new Plugin({
key: new PluginKey('toggleBlockGap'),
view (editorView) {
// Fix adjacent toggle blocks present in initially loaded content
const tr = buildGapFix(editorView.state)
if (tr) editorView.dispatch(tr)
return {}
},
appendTransaction (transactions, _oldState, newState) {
if (!transactions.some(tr => tr.docChanged)) return null
return buildGapFix(newState)
}
}),
new Plugin({
key: new PluginKey('toggleBlockPaste'),
props: {
......
......@@ -234,6 +234,10 @@ body{
// }
//}
@keyframes atma-spin {
to { transform: rotate(360deg); }
}
.atma-editor {
position: relative;
border-radius: 8px;
......@@ -814,6 +818,30 @@ body{
}
&-processing{
display: flex;
align-items: center;
gap: 10px;
padding: 12px 16px;
margin-bottom: 12px;
background: #f0f7ff;
border: 1px solid #bae0ff;
border-radius: 8px;
color: #1677ff;
font-size: 14px;
}
&-processing-spinner{
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid #bae0ff;
border-top-color: #1677ff;
border-radius: 50%;
flex-shrink: 0;
animation: atma-spin 0.8s linear infinite;
}
&-progress{
display: flex;
position: relative;
......
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