Fix:修复一些情况下,节点显示时的文本区域宽度和编辑时的宽度不一致导致的文本换行不一致的问题
This commit is contained in:
parent
3593990f9b
commit
b52497b3f6
@ -159,7 +159,7 @@ function createRichTextNode() {
|
|||||||
height = elTmp.getBoundingClientRect().height
|
height = elTmp.getBoundingClientRect().height
|
||||||
div.innerHTML = html
|
div.innerHTML = html
|
||||||
}
|
}
|
||||||
width = Math.ceil(width) + 1 // 修复getBoundingClientRect方法对实际宽度是小数的元素获取到的值是整数,导致宽度不够文本发生换行的问题
|
width = Math.min(Math.ceil(width) + 1, textAutoWrapWidth) // 修复getBoundingClientRect方法对实际宽度是小数的元素获取到的值是整数,导致宽度不够文本发生换行的问题
|
||||||
height = Math.ceil(height)
|
height = Math.ceil(height)
|
||||||
g.attr('data-width', width)
|
g.attr('data-width', width)
|
||||||
g.attr('data-height', height)
|
g.attr('data-height', height)
|
||||||
@ -222,7 +222,7 @@ function createTextNode() {
|
|||||||
g.add(node)
|
g.add(node)
|
||||||
})
|
})
|
||||||
let { width, height } = g.bbox()
|
let { width, height } = g.bbox()
|
||||||
width = Math.ceil(width)
|
width = Math.min(Math.ceil(width), maxWidth)
|
||||||
height = Math.ceil(height)
|
height = Math.ceil(height)
|
||||||
g.attr('data-width', width)
|
g.attr('data-width', width)
|
||||||
g.attr('data-height', height)
|
g.attr('data-height', height)
|
||||||
|
|||||||
@ -201,7 +201,8 @@ class RichText {
|
|||||||
box-shadow: 0 0 20px rgba(0,0,0,.5);
|
box-shadow: 0 0 20px rgba(0,0,0,.5);
|
||||||
outline: none;
|
outline: none;
|
||||||
word-break:
|
word-break:
|
||||||
break-all;padding: ${paddingY}px ${paddingX}px;
|
break-all;
|
||||||
|
padding: ${paddingY}px ${paddingX}px;
|
||||||
`
|
`
|
||||||
this.textEditNode.addEventListener('click', e => {
|
this.textEditNode.addEventListener('click', e => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user