mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
upd: optimize code to html
This commit is contained in:
@@ -83,7 +83,7 @@ const RunCode = defineComponent({
|
||||
const runResult = result.value || cache[hash.value]
|
||||
|
||||
return [
|
||||
h('div', { class: 'p-mcr-run-code-action' }, [
|
||||
h('div', { class: 'p-mcr-run-code-action skip-export' }, [
|
||||
h('div', {
|
||||
title: t('code-run.run'),
|
||||
class: 'p-mcr-run-btn',
|
||||
@@ -96,7 +96,7 @@ const RunCode = defineComponent({
|
||||
onClick: runInXterm
|
||||
}),
|
||||
]),
|
||||
h('div', { class: 'p-mcr-run-code-result', style: 'padding: .5em 0 0 0', key: runResult, innerHTML: runResult }),
|
||||
h('div', { class: 'p-mcr-run-code-result skip-export', style: 'padding: .5em 0 0 0', key: runResult, innerHTML: runResult }),
|
||||
h('div', { class: 'p-mcr-clear-btn-wrapper no-print' }, h(
|
||||
h(
|
||||
'div',
|
||||
|
||||
@@ -68,6 +68,7 @@ defaultRules.code_block = function (tokens: Token[], idx: number, _: any, __: an
|
||||
defaultRules.fence = function (tokens: Token[], idx: number, options: any, _: any, slf: Renderer) {
|
||||
const token = tokens[idx]
|
||||
const info = token.info ? unescapeAll(token.info).trim() : ''
|
||||
token.attrSet('data-export-text', token.content)
|
||||
let langName = ''
|
||||
let langAttrs = ''
|
||||
let highlighted: any; let i; let arr; let tmpAttrs; let tmpToken
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { escape } from 'lodash-es'
|
||||
import { Escape } from '@fe/core/command'
|
||||
import { getActionHandler, registerAction } from '@fe/core/action'
|
||||
import { useToast } from '@fe/support/ui/toast'
|
||||
@@ -73,12 +74,16 @@ export function getContentHtml (nodeProcessor?: (node: HTMLElement) => void) {
|
||||
}
|
||||
|
||||
const filter = (node: HTMLElement) => {
|
||||
if (node.classList.contains('no-print')) {
|
||||
if (node.classList.contains('no-print') || node.classList.contains('skip-export')) {
|
||||
node.remove()
|
||||
return
|
||||
}
|
||||
|
||||
if (node.dataset) {
|
||||
if (node.dataset.exportText) {
|
||||
node.innerHTML = escape(node.dataset.exportText)
|
||||
}
|
||||
|
||||
Object.keys(node.dataset).forEach(key => {
|
||||
delete node.dataset[key]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user