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

update fix issue

parent 66da5bdf
{
"name": "react-ag-qeditor",
"version": "1.1.76",
"version": "1.1.77",
"description": "WYSIWYG html editor",
"author": "atma",
"license": "MIT",
......
import { Node } from '@tiptap/core'
import { ReactNodeViewRenderer, NodeViewWrapper, NodeViewContent } from '@tiptap/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 = () => (
<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
<div
className="toggle-drag-handle"
contentEditable={false}
draggable={true}
data-drag-handle=""
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 />
</div>
......@@ -169,12 +182,15 @@ const ToggleBlock = Node.create({
return [{
tag: 'div.toggle-block',
getAttrs: (element) => {
const wrapper = element.querySelector('.toggle-block-inner')
const titleEl = wrapper?.querySelector('.toggle-header')
const inner = element.querySelector('.toggle-block-inner')
const titleEl = inner?.querySelector('.toggle-header')
const title = titleEl?.textContent?.trim() || 'Заголовок'
if (titleEl?.parentNode) {
titleEl.parentNode.removeChild(titleEl)
// Удаляем весь toggle-block-inner из DOM — иначе его содержимое
// (span.toggle-button и пр.) парсится ProseMirror как блочный контент
// и создаёт лишний параграф перед текстом блока
if (inner?.parentNode) {
inner.parentNode.removeChild(inner)
}
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