Skip to content

Commit

Permalink
fix: unable to copy text in read-only mode (#251)
Browse files Browse the repository at this point in the history
* style: refactor by eslint

* fix: unable to copy text in read-only mode

* Create nice-pens-kick.md
  • Loading branch information
cycleccc committed Oct 15, 2024
1 parent e47fd28 commit 3dbff77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-pens-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wangeditor-next/core": patch
---

163 bug只读模式下无法复制文本内容
14 changes: 8 additions & 6 deletions packages/core/src/text-area/event-handlers/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
*/

import { IDomEditor } from '../../editor/interface'
// import { DomEditor } from '../../editor/dom-editor'
import TextArea from '../TextArea'
import { hasEditableTarget } from '../helpers'
import TextArea from '../TextArea'

function handleOnCopy(e: Event, textarea: TextArea, editor: IDomEditor) {
function handleOnCopy(e: Event, _textarea: TextArea, editor: IDomEditor) {
const event = e as ClipboardEvent

if (!hasEditableTarget(editor, event.target)) return
event.preventDefault()
if (!hasEditableTarget(editor, event.target)) { return }
const { readOnly } = editor.getConfig()

if (!readOnly) { event.preventDefault() }

const data = event.clipboardData
if (data == null) return

if (data == null) { return }
editor.setFragmentData(data)
}

Expand Down

0 comments on commit 3dbff77

Please sign in to comment.