mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 19:22:44 +08:00
* fix: #813 * add one more para of exportHtml.generate * remove debug codes
This commit is contained in:
parent
165e8985b0
commit
47da3bd193
@ -25,11 +25,29 @@ class ClickEvent {
|
||||
if (!start || !end) {
|
||||
return
|
||||
}
|
||||
const startBlock = contentState.getBlock(start.key)
|
||||
const nextTextBlock = contentState.findNextBlockInLocation(startBlock)
|
||||
|
||||
// Commit native cursor position because right-clicking doesn't update the cursor postion.
|
||||
contentState.cursor = {
|
||||
start,
|
||||
end
|
||||
if (
|
||||
nextTextBlock && nextTextBlock.key === end.key &&
|
||||
end.offset === 0 &&
|
||||
start.offset === startBlock.text.length
|
||||
) {
|
||||
// Set cursor at the end of start block and reset cursor
|
||||
// Because if you right click at the end of one text block, the cursor.start will at the end of
|
||||
// start block and the cursor.end will at the next text block beginning. So we reset the cursor
|
||||
// at the end of start block.
|
||||
contentState.cursor = {
|
||||
start,
|
||||
end: start
|
||||
}
|
||||
selection.setCursorRange(contentState.cursor)
|
||||
} else {
|
||||
// Commit native cursor position because right-clicking doesn't update the cursor postion.
|
||||
contentState.cursor = {
|
||||
start,
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
const sectionChanges = contentState.selectionChange(contentState.cursor)
|
||||
|
@ -15,6 +15,7 @@ class DragDrop {
|
||||
|
||||
eventCenter.attachDOMEvent(container, 'dragover', dragoverHandler)
|
||||
}
|
||||
|
||||
dropBinding () {
|
||||
const { container, eventCenter, contentState } = this.muya
|
||||
|
||||
|
@ -161,7 +161,7 @@ class ExportHtml {
|
||||
* @param {*} title Page title
|
||||
* @param {*} printOptimization Optimize HTML and CSS for printing
|
||||
*/
|
||||
async generate (title = '', printOptimization = false) {
|
||||
async generate (title = '', printOptimization = false, extraCss = '') {
|
||||
// WORKAROUND: Hide Prism.js style when exporting or printing. Otherwise the background color is white in the dark theme.
|
||||
const highlightCssStyle = printOptimization ? `@media print { ${highlightCss} }` : highlightCss
|
||||
const html = await this.renderHtml()
|
||||
@ -208,6 +208,7 @@ class ExportHtml {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style>${extraCss}</style>
|
||||
</head>
|
||||
<body>
|
||||
<article class="markdown-body">
|
||||
|
@ -36,7 +36,7 @@ export const showContextMenu = (event, { start, end }) => {
|
||||
)
|
||||
}
|
||||
|
||||
[CUT, COPY, COPY_AS_HTML, COPY_AS_MARKDOWN].forEach(item => {
|
||||
;[CUT, COPY, COPY_AS_HTML, COPY_AS_MARKDOWN].forEach(item => {
|
||||
item.enabled = !disableCutAndCopy
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user