提交 02ee8d01 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 在编辑器中恢复选择逻辑,优化空段落处理

上级 8d6dd989
...@@ -97,10 +97,6 @@ const ExpandModal = (props, ref) => { ...@@ -97,10 +97,6 @@ const ExpandModal = (props, ref) => {
}, [expandInfo]) }, [expandInfo])
const onFinish = async (values) => { const onFinish = async (values) => {
editor.restoreSelection()
if (parseInt(values.flex) === 1) {
removeSelectedEmptyParagraph(editor, SlateTransforms)
}
setLoadLoading(true) setLoadLoading(true)
const { flex, theme, fontSize, ...other } = values const { flex, theme, fontSize, ...other } = values
...@@ -148,7 +144,9 @@ const ExpandModal = (props, ref) => { ...@@ -148,7 +144,9 @@ const ExpandModal = (props, ref) => {
...other, ...other,
}) })
editor.restoreSelection()
if (parseInt(values.flex) === 1) { if (parseInt(values.flex) === 1) {
removeSelectedEmptyParagraph(editor, SlateTransforms)
insertBlockNodesAndFocus(editor, SlateTransforms, { insertBlockNodesAndFocus(editor, SlateTransforms, {
type: 'chapterExpandRead', type: 'chapterExpandRead',
flex: parseInt(values.flex), flex: parseInt(values.flex),
......
...@@ -210,15 +210,10 @@ const GalleryModal = (props, ref) => { ...@@ -210,15 +210,10 @@ const GalleryModal = (props, ref) => {
}, [galleryInfo]) }, [galleryInfo])
const onFinish = async (values) => { const onFinish = async (values) => {
editor.restoreSelection()
// setLoading(true); // setLoading(true);
const { galleryTitle, flex, gallery, fontSize, theme = '' } = values const { galleryTitle, flex, gallery, fontSize, theme = '' } = values
console.log(values) console.log(values)
if (parseInt(flex) !== 2) {
removeSelectedEmptyParagraph(editor, SlateTransforms)
}
if (nowRandom) { if (nowRandom) {
const props = { const props = {
title: galleryTitle, title: galleryTitle,
...@@ -265,6 +260,10 @@ const GalleryModal = (props, ref) => { ...@@ -265,6 +260,10 @@ const GalleryModal = (props, ref) => {
content: JSON.stringify(gallery), content: JSON.stringify(gallery),
position: random, position: random,
}) })
editor.restoreSelection()
if (parseInt(flex) !== 2) {
removeSelectedEmptyParagraph(editor, SlateTransforms)
}
if (parseInt(flex) === 2) { if (parseInt(flex) === 2) {
editor.insertNode({ editor.insertNode({
type: 'chapterGalleryInline', type: 'chapterGalleryInline',
......
...@@ -65,7 +65,6 @@ const TooltipModal = (props, ref) => { ...@@ -65,7 +65,6 @@ const TooltipModal = (props, ref) => {
} }
const onFinish = async (values) => { const onFinish = async (values) => {
editor.restoreSelection()
setLoading(true) setLoading(true)
const { tooltipType, link, theme, ...other } = values const { tooltipType, link, theme, ...other } = values
let newLink = '' let newLink = ''
...@@ -118,6 +117,7 @@ const TooltipModal = (props, ref) => { ...@@ -118,6 +117,7 @@ const TooltipModal = (props, ref) => {
}) })
if (data) { if (data) {
editor.restoreSelection()
editor.insertNode({ editor.insertNode({
type: 'chapterTooltip', type: 'chapterTooltip',
title: values.title, title: values.title,
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论