Skip to content

Commit 49a8047

Browse files
committed
fix: export image should be compatible with .text
1 parent 0baf15a commit 49a8047

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mind-elixir",
3-
"version": "3.2.5",
3+
"version": "3.2.6",
44
"type": "module",
55
"description": "Mind elixir is a free open source mind map core.",
66
"keywords": [

src/index.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@
248248
margin-bottom: 8px;
249249
object-fit: cover;
250250
}
251+
& > .text {
252+
display: inline-block;
253+
}
251254
}
252255
.circle {
253256
position: absolute;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ MindElixir.DARK_THEME = DARK_THEME
126126
* @memberof MindElixir
127127
* @static
128128
*/
129-
MindElixir.version = '3.2.5'
129+
MindElixir.version = '3.2.6'
130130
/**
131131
* @function
132132
* @memberof MindElixir

src/plugin/exportImage.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ function lineHightToPadding(lineHeight: string, fontSize: string) {
2020

2121
function generateSvgText(tpc: HTMLElement, tpcStyle: CSSStyleDeclaration, x: number, y: number) {
2222
const g = document.createElementNS('http://www.w3.org/2000/svg', 'g')
23-
const content = tpc.childNodes[0].textContent
23+
let content = ''
24+
if ((tpc as Topic).text) {
25+
content = (tpc as Topic).text.textContent!
26+
} else {
27+
content = tpc.childNodes[0].textContent!
28+
}
2429
const lines = content!.split('\n')
2530
lines.forEach((line, index) => {
2631
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text')
@@ -45,7 +50,12 @@ function generateSvgText(tpc: HTMLElement, tpcStyle: CSSStyleDeclaration, x: num
4550
}
4651

4752
function generateSvgTextUsingForeignObject(tpc: HTMLElement, tpcStyle: CSSStyleDeclaration, x: number, y: number) {
48-
const content = tpc.childNodes[0].textContent!
53+
let content = ''
54+
if ((tpc as Topic).text) {
55+
content = (tpc as Topic).text.textContent!
56+
} else {
57+
content = tpc.childNodes[0].textContent!
58+
}
4959
const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')
5060
setAttributes(foreignObject, {
5161
x: x + parseInt(tpcStyle.paddingLeft) + '',
@@ -144,7 +154,7 @@ const generateSvg = (mei: MindElixirInstance, noForiegnObject = false) => {
144154
summaries && g.appendChild(summaries)
145155

146156
mapDiv.querySelectorAll('me-tpc').forEach(tpc => {
147-
g.appendChild(convertDivToSvg(mei, (tpc as Topic).text, noForiegnObject ? false : true))
157+
g.appendChild(convertDivToSvg(mei, tpc as Topic, noForiegnObject ? false : true))
148158
})
149159
mapDiv.querySelectorAll('.tags > span').forEach(tag => {
150160
g.appendChild(convertDivToSvg(mei, tag as HTMLElement))

0 commit comments

Comments
 (0)