fix: error converting some element types to HTML #257
This commit is contained in:
@@ -4,6 +4,7 @@ export const ZERO = '\u200B'
|
|||||||
export const WRAP = '\n'
|
export const WRAP = '\n'
|
||||||
export const HORIZON_TAB = '\t'
|
export const HORIZON_TAB = '\t'
|
||||||
export const NBSP = '\u0020'
|
export const NBSP = '\u0020'
|
||||||
|
export const NON_BREAKING_SPACE = ' '
|
||||||
export const PUNCTUATION_LIST = [
|
export const PUNCTUATION_LIST = [
|
||||||
'·',
|
'·',
|
||||||
'、',
|
'、',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
} from '..'
|
} from '..'
|
||||||
import { LaTexParticle } from '../core/draw/particle/latex/LaTexParticle'
|
import { LaTexParticle } from '../core/draw/particle/latex/LaTexParticle'
|
||||||
import { defaultCheckboxOption } from '../dataset/constant/Checkbox'
|
import { defaultCheckboxOption } from '../dataset/constant/Checkbox'
|
||||||
import { ZERO } from '../dataset/constant/Common'
|
import { NON_BREAKING_SPACE, ZERO } from '../dataset/constant/Common'
|
||||||
import { defaultControlOption } from '../dataset/constant/Control'
|
import { defaultControlOption } from '../dataset/constant/Control'
|
||||||
import {
|
import {
|
||||||
EDITOR_ELEMENT_CONTEXT_ATTR,
|
EDITOR_ELEMENT_CONTEXT_ATTR,
|
||||||
@@ -697,6 +697,9 @@ export function convertElementToDom(
|
|||||||
if (element.highlight) {
|
if (element.highlight) {
|
||||||
dom.style.backgroundColor = element.highlight
|
dom.style.backgroundColor = element.highlight
|
||||||
}
|
}
|
||||||
|
if (element.underline) {
|
||||||
|
dom.style.textDecoration = 'underline'
|
||||||
|
}
|
||||||
dom.innerText = element.value.replace(new RegExp(`${ZERO}`, 'g'), '\n')
|
dom.innerText = element.value.replace(new RegExp(`${ZERO}`, 'g'), '\n')
|
||||||
return dom
|
return dom
|
||||||
}
|
}
|
||||||
@@ -811,6 +814,10 @@ export function createDomFromElementList(
|
|||||||
checkbox.setAttribute('checked', 'true')
|
checkbox.setAttribute('checked', 'true')
|
||||||
}
|
}
|
||||||
clipboardDom.append(checkbox)
|
clipboardDom.append(checkbox)
|
||||||
|
} else if (element.type === ElementType.TAB) {
|
||||||
|
const tab = document.createElement('span')
|
||||||
|
tab.innerHTML = `${NON_BREAKING_SPACE}${NON_BREAKING_SPACE}`
|
||||||
|
clipboardDom.append(tab)
|
||||||
} else if (
|
} else if (
|
||||||
!element.type ||
|
!element.type ||
|
||||||
element.type === ElementType.LATEX ||
|
element.type === ElementType.LATEX ||
|
||||||
@@ -873,6 +880,10 @@ export function convertTextNodeToElement(
|
|||||||
if (style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
|
if (style.backgroundColor !== 'rgba(0, 0, 0, 0)') {
|
||||||
element.highlight = style.backgroundColor
|
element.highlight = style.backgroundColor
|
||||||
}
|
}
|
||||||
|
// 下划线
|
||||||
|
if (style.textDecorationLine === 'underline') {
|
||||||
|
element.underline = true
|
||||||
|
}
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user