Skip to content

Commit

Permalink
perf: variable naming correction & delete redundant judgment conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
cycleccc committed Oct 17, 2024
1 parent ff11e79 commit 9629d5f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/text-area/event-handlers/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function handleCompositionStart(e: Event, textarea: TextArea, editor: IDo
})
}

if (editor.selection && (Range.isExpanded(editor.selection) || Range.isCollapsed(editor.selection))) {
if (editor.selection) {
// 记录下 dom text ,以便触发 maxLength 时使用
const domRange = DomEditor.toDOMRange(editor, editor.selection)
const startContainer = domRange.startContainer
Expand Down Expand Up @@ -179,13 +179,13 @@ export function handleCompositionEnd(e: Event, textarea: TextArea, editor: IDomE
// 检查拼音输入是否夸 DOM 节点了,解决 wangEditor-v5/issues/47
if (!IS_SAFARI) {
setTimeout(() => {
const { selection: setTImeoutSelection } = editor
const { selection: setTimeoutSelection } = editor

if (setTImeoutSelection == null) { return }
if (setTimeoutSelection == null) { return }
const oldStartContainer = EDITOR_TO_START_CONTAINER.get(editor) // 拼音输入开始时的 text node

if (oldStartContainer == null) { return }
const curStartContainer = DomEditor.toDOMRange(editor, setTImeoutSelection).startContainer // 拼音输入结束时的 text node
const curStartContainer = DomEditor.toDOMRange(editor, setTimeoutSelection).startContainer // 拼音输入结束时的 text node

if (curStartContainer === oldStartContainer) {
// 拼音输入的开始和结束,都在同一个 text node ,则不做处理
Expand Down

0 comments on commit 9629d5f

Please sign in to comment.