Commit 2bf763b4 authored by Яков's avatar Яков
Browse files

update fix issue

parent 66da5bdf
{ {
"name": "react-ag-qeditor", "name": "react-ag-qeditor",
"version": "1.1.76", "version": "1.1.77",
"description": "WYSIWYG html editor", "description": "WYSIWYG html editor",
"author": "atma", "author": "atma",
"license": "MIT", "license": "MIT",
......
import { Node } from '@tiptap/core' import { Node } from '@tiptap/core'
import { ReactNodeViewRenderer, NodeViewWrapper, NodeViewContent } from '@tiptap/react' import { ReactNodeViewRenderer, NodeViewWrapper, NodeViewContent } from '@tiptap/react'
import React, { useEffect, useRef, useState } from 'react' import React, { useEffect, useRef, useState } from 'react'
import { TextSelection, Plugin, PluginKey } from 'prosemirror-state' import { TextSelection, NodeSelection, Plugin, PluginKey } from 'prosemirror-state'
const DragHandleIcon = () => ( const DragHandleIcon = () => (
<svg width="10" height="16" viewBox="0 0 10 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="10" height="16" viewBox="0 0 10 16" fill="none" xmlns="http://www.w3.org/2000/svg">
...@@ -77,8 +77,21 @@ export const ToggleBlockComponent = ({node, updateAttributes, getPos, editor, se ...@@ -77,8 +77,21 @@ export const ToggleBlockComponent = ({node, updateAttributes, getPos, editor, se
<div <div
className="toggle-drag-handle" className="toggle-drag-handle"
contentEditable={false} contentEditable={false}
draggable={true}
data-drag-handle="" data-drag-handle=""
title="Перетащить" title="Перетащить"
onDragStart={(e) => {
try {
const pos = getPos?.()
if (typeof pos === 'number') {
editor.view.dispatch(
editor.view.state.tr.setSelection(
NodeSelection.create(editor.view.state.doc, pos)
)
)
}
} catch {}
}}
> >
<DragHandleIcon /> <DragHandleIcon />
</div> </div>
...@@ -169,12 +182,15 @@ const ToggleBlock = Node.create({ ...@@ -169,12 +182,15 @@ const ToggleBlock = Node.create({
return [{ return [{
tag: 'div.toggle-block', tag: 'div.toggle-block',
getAttrs: (element) => { getAttrs: (element) => {
const wrapper = element.querySelector('.toggle-block-inner') const inner = element.querySelector('.toggle-block-inner')
const titleEl = wrapper?.querySelector('.toggle-header') const titleEl = inner?.querySelector('.toggle-header')
const title = titleEl?.textContent?.trim() || 'Заголовок' const title = titleEl?.textContent?.trim() || 'Заголовок'
if (titleEl?.parentNode) { // Удаляем весь toggle-block-inner из DOM — иначе его содержимое
titleEl.parentNode.removeChild(titleEl) // (span.toggle-button и пр.) парсится ProseMirror как блочный контент
// и создаёт лишний параграф перед текстом блока
if (inner?.parentNode) {
inner.parentNode.removeChild(inner)
} }
return {title} return {title}
......
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