mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 16:49:15 +08:00
fix: #546
This commit is contained in:
parent
79ee58ef7e
commit
2e133e21e0
1
.github/CHANGELOG.md
vendored
1
.github/CHANGELOG.md
vendored
@ -13,6 +13,7 @@
|
|||||||
- fix: #534
|
- fix: #534
|
||||||
- fix: #535 Application menu is not updated when switching windows
|
- fix: #535 Application menu is not updated when switching windows
|
||||||
- fix #216 and #311 key binding issues on Linux and Windows
|
- fix #216 and #311 key binding issues on Linux and Windows
|
||||||
|
- fix #546 paste issue in table
|
||||||
|
|
||||||
### 0.13.50
|
### 0.13.50
|
||||||
|
|
||||||
|
@ -131,6 +131,18 @@ const pasteCtrl = ContentState => {
|
|||||||
return this.partialRender()
|
return this.partialRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (/th|td/.test(startBlock.type)) {
|
||||||
|
const pendingText = text.trim().replace(/\n/g, '<br/>')
|
||||||
|
startBlock.text += pendingText
|
||||||
|
const { key } = startBlock
|
||||||
|
const offset = start.offset + pendingText.length
|
||||||
|
this.cursor = {
|
||||||
|
start: { key, offset },
|
||||||
|
end: { key, offset }
|
||||||
|
}
|
||||||
|
return this.partialRender()
|
||||||
|
}
|
||||||
|
|
||||||
// handle copyAsHtml
|
// handle copyAsHtml
|
||||||
if (copyType === 'copyAsHtml') {
|
if (copyType === 'copyAsHtml') {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -508,8 +508,8 @@ const tokenizerFac = (src, beginRules, inlineRules, pos = 0, top) => {
|
|||||||
return tokens
|
return tokens
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tokenizer = (src, highlights = []) => {
|
export const tokenizer = (src, highlights = [], hasBeginRules = true) => {
|
||||||
const tokens = tokenizerFac(src, beginRules, inlineRules, 0, true)
|
const tokens = tokenizerFac(src, hasBeginRules ? beginRules : null, inlineRules, 0, true)
|
||||||
const postTokenizer = tokens => {
|
const postTokenizer = tokens => {
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
for (const light of highlights) {
|
for (const light of highlights) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import katex from 'katex'
|
import katex from 'katex'
|
||||||
import mermaid from 'mermaid'
|
import mermaid from 'mermaid'
|
||||||
import prism, { loadedCache } from '../../../prism/'
|
import prism, { loadedCache } from '../../../prism/'
|
||||||
import { CLASS_OR_ID, DEVICE_MEMORY, isInElectron, PREVIEW_DOMPURIFY_CONFIG } from '../../../config'
|
import { CLASS_OR_ID, DEVICE_MEMORY, isInElectron, PREVIEW_DOMPURIFY_CONFIG, HAS_TEXT_BLOCK_REG } from '../../../config'
|
||||||
import { tokenizer } from '../../parse'
|
import { tokenizer } from '../../parse'
|
||||||
import { snakeToCamel, sanitize, escapeHtml, getLongUniqueId } from '../../../utils'
|
import { snakeToCamel, sanitize, escapeHtml, getLongUniqueId } from '../../../utils'
|
||||||
import { h, htmlToVNode } from '../snabbdom'
|
import { h, htmlToVNode } from '../snabbdom'
|
||||||
@ -70,12 +70,19 @@ export default function renderLeafBlock (block, cursor, activeBlocks, matches, u
|
|||||||
}
|
}
|
||||||
let children = ''
|
let children = ''
|
||||||
if (text) {
|
if (text) {
|
||||||
let tokens = null
|
let tokens = []
|
||||||
if (highlights.length === 0 && this.tokenCache.has(text)) {
|
if (highlights.length === 0 && this.tokenCache.has(text)) {
|
||||||
tokens = this.tokenCache.get(text)
|
tokens = this.tokenCache.get(text)
|
||||||
} else {
|
} else if (
|
||||||
tokens = tokenizer(text, highlights)
|
HAS_TEXT_BLOCK_REG.test(type) &&
|
||||||
if (highlights.length === 0 && useCache && DEVICE_MEMORY >= 4) this.tokenCache.set(text, tokens)
|
functionType !== 'codeLine' &&
|
||||||
|
functionType !== 'languageInput'
|
||||||
|
) {
|
||||||
|
const hasBeginRules = /^(h\d|span|hr)/.test(type)
|
||||||
|
tokens = tokenizer(text, highlights, hasBeginRules)
|
||||||
|
if (highlights.length === 0 && useCache && DEVICE_MEMORY >= 4) {
|
||||||
|
this.tokenCache.set(text, tokens)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
children = tokens.reduce((acc, token) => [...acc, ...this[snakeToCamel(token.type)](h, cursor, block, token)], [])
|
children = tokens.reduce((acc, token) => [...acc, ...this[snakeToCamel(token.type)](h, cursor, block, token)], [])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user