From 31db0593dbc77fba9b4a719bc0f48f1223afd680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=A6=8F=E6=9C=8B?= Date: Wed, 23 Feb 2022 13:00:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20divider=20-=20=E9=94=AE=E7=9B=98?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic-modules/src/assets/divider.less | 13 +++++---- .../src/modules/divider/index.ts | 4 +-- ...ividerMenu.ts => DeleteDividerMenu.ts.bak} | 0 .../src/modules/divider/menu/index.ts | 15 ++++++----- .../src/modules/divider/render-elem.tsx | 27 ++++++++++++------- .../init-default-config/config/hoverbar.ts | 3 --- 6 files changed, 33 insertions(+), 29 deletions(-) rename packages/basic-modules/src/modules/divider/menu/{DeleteDividerMenu.ts => DeleteDividerMenu.ts.bak} (100%) diff --git a/packages/basic-modules/src/assets/divider.less b/packages/basic-modules/src/assets/divider.less index 99337ee58..569ae6660 100644 --- a/packages/basic-modules/src/assets/divider.less +++ b/packages/basic-modules/src/assets/divider.less @@ -1,17 +1,16 @@ @import "../../../vars.less"; .w-e-textarea-divider { - padding: 10px 0; - cursor: pointer; + padding: 20px 20px; + margin: 20px auto; + border-radius: 3px; - &:hover { - background-color: @textarea-slight-bg-color; - } + // &:hover { + // background-color: @textarea-slight-bg-color; + // } hr { display: block; - width: 90%; - margin: 20px auto; border: 0; height: 1px; background-color: @textarea-border-color; diff --git a/packages/basic-modules/src/modules/divider/index.ts b/packages/basic-modules/src/modules/divider/index.ts index fa7fce99b..d4f49e00d 100644 --- a/packages/basic-modules/src/modules/divider/index.ts +++ b/packages/basic-modules/src/modules/divider/index.ts @@ -8,13 +8,13 @@ import withDivider from './plugin' import { renderDividerConf } from './render-elem' import { dividerToHtmlConf } from './elem-to-html' import { parseHtmlConf } from './parse-elem-html' -import { insertDividerMenuConf, deleteDividerMenuConf } from './menu/index' +import { insertDividerMenuConf } from './menu/index' const image: Partial = { renderElems: [renderDividerConf], elemsToHtml: [dividerToHtmlConf], parseElemsHtml: [parseHtmlConf], - menus: [insertDividerMenuConf, deleteDividerMenuConf], + menus: [insertDividerMenuConf], editorPlugin: withDivider, } diff --git a/packages/basic-modules/src/modules/divider/menu/DeleteDividerMenu.ts b/packages/basic-modules/src/modules/divider/menu/DeleteDividerMenu.ts.bak similarity index 100% rename from packages/basic-modules/src/modules/divider/menu/DeleteDividerMenu.ts rename to packages/basic-modules/src/modules/divider/menu/DeleteDividerMenu.ts.bak diff --git a/packages/basic-modules/src/modules/divider/menu/index.ts b/packages/basic-modules/src/modules/divider/menu/index.ts index b21b0c1fd..da05475b8 100644 --- a/packages/basic-modules/src/modules/divider/menu/index.ts +++ b/packages/basic-modules/src/modules/divider/menu/index.ts @@ -4,7 +4,7 @@ */ import InsertDividerMenu from './InsertDividerMenu' -import DeleteDividerMenu from './DeleteDividerMenu' +// import DeleteDividerMenu from './DeleteDividerMenu.ts' export const insertDividerMenuConf = { key: 'divider', @@ -13,9 +13,10 @@ export const insertDividerMenuConf = { }, } -export const deleteDividerMenuConf = { - key: 'deleteDivider', - factory() { - return new DeleteDividerMenu() - }, -} +// export const deleteDividerMenuConf = { +// key: 'deleteDivider', +// factory() { +// return new DeleteDividerMenu() +// }, +// } +// divider 可用键盘删除了,所以注释掉该菜单 wangfupeng 22.02.23 diff --git a/packages/basic-modules/src/modules/divider/render-elem.tsx b/packages/basic-modules/src/modules/divider/render-elem.tsx index 7b4023254..95de65491 100644 --- a/packages/basic-modules/src/modules/divider/render-elem.tsx +++ b/packages/basic-modules/src/modules/divider/render-elem.tsx @@ -4,7 +4,7 @@ */ import { Element as SlateElement } from 'slate' -import { jsx, VNode } from 'snabbdom' +import { h, VNode } from 'snabbdom' import { IDomEditor, DomEditor } from '@wangeditor/core' function renderDivider( @@ -17,15 +17,22 @@ function renderDivider( // 是否选中 const selected = DomEditor.isNodeSelected(editor, elemNode) - const vnode = ( -
-
-
+ const vnode = h( + 'div', + { + props: { + contentEditable: false, + className: 'w-e-textarea-divider', + }, + dataset: { + selected: selected ? 'true' : '', + }, + style: renderStyle, + on: { + mousedown: event => event.preventDefault(), + }, + }, + [h('hr')] ) // 【注意】void node 中,renderElem 不用处理 children 。core 会统一处理。 diff --git a/packages/editor/src/init-default-config/config/hoverbar.ts b/packages/editor/src/init-default-config/config/hoverbar.ts index 5ec46e2b9..b7f821a8d 100644 --- a/packages/editor/src/init-default-config/config/hoverbar.ts +++ b/packages/editor/src/init-default-config/config/hoverbar.ts @@ -35,9 +35,6 @@ const COMMON_HOVERBAR_KEYS = { 'deleteTable', ], }, - divider: { - menuKeys: ['deleteDivider'], - }, } export function genDefaultHoverbarKeys() {