mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 12:41:56 +08:00
Allow to copy table cells text as plaintext (#2409)
This commit is contained in:
parent
f6ac392c32
commit
fff183e32e
@ -223,9 +223,6 @@ const copyCutCtrl = ContentState => {
|
|||||||
if (selectedTableCells) {
|
if (selectedTableCells) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const { row, column, cells } = selectedTableCells
|
const { row, column, cells } = selectedTableCells
|
||||||
const figureBlock = this.createBlock('figure', {
|
|
||||||
functionType: 'table'
|
|
||||||
})
|
|
||||||
const tableContents = []
|
const tableContents = []
|
||||||
let i
|
let i
|
||||||
let j
|
let j
|
||||||
@ -242,6 +239,15 @@ const copyCutCtrl = ContentState => {
|
|||||||
tableContents.push(rowWrapper)
|
tableContents.push(rowWrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (row === 1 && column === 1) {
|
||||||
|
// Copy cells text if only one is selected
|
||||||
|
event.clipboardData.setData('text/html', '')
|
||||||
|
event.clipboardData.setData('text/plain', tableContents[0][0].text)
|
||||||
|
} else {
|
||||||
|
// Copy as markdown table
|
||||||
|
const figureBlock = this.createBlock('figure', {
|
||||||
|
functionType: 'table'
|
||||||
|
})
|
||||||
const table = this.createTableInFigure({ rows: row, columns: column }, tableContents)
|
const table = this.createTableInFigure({ rows: row, columns: column }, tableContents)
|
||||||
this.appendChild(figureBlock, table)
|
this.appendChild(figureBlock, table)
|
||||||
const { isGitlabCompatibilityEnabled, listIndentation } = this
|
const { isGitlabCompatibilityEnabled, listIndentation } = this
|
||||||
@ -251,6 +257,7 @@ const copyCutCtrl = ContentState => {
|
|||||||
event.clipboardData.setData('text/plain', markdown)
|
event.clipboardData.setData('text/plain', markdown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ContentState.prototype.copyHandler = function (event, type, copyInfo = null) {
|
ContentState.prototype.copyHandler = function (event, type, copyInfo = null) {
|
||||||
if (this.selectedTableCells) {
|
if (this.selectedTableCells) {
|
||||||
|
Loading…
Reference in New Issue
Block a user