mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-31 00:23:57 +00:00
Drawing: Text with text-decoration support, Fixes: #139
This commit is contained in:
parent
289abf344f
commit
f01cf63a6c
@ -16,6 +16,7 @@ describe('TextConverter', () => {
|
|||||||
node.setAttribute("font-family", "TypeWriter");
|
node.setAttribute("font-family", "TypeWriter");
|
||||||
node.setAttribute("font-size", "10.0");
|
node.setAttribute("font-size", "10.0");
|
||||||
node.setAttribute("font-weight", "bold");
|
node.setAttribute("font-weight", "bold");
|
||||||
|
node.setAttribute("text-decoration", "line-through");
|
||||||
|
|
||||||
const drawing = textConverter.convert(node);
|
const drawing = textConverter.convert(node);
|
||||||
expect(drawing.text).toEqual("Text");
|
expect(drawing.text).toEqual("Text");
|
||||||
@ -24,6 +25,7 @@ describe('TextConverter', () => {
|
|||||||
expect(drawing.font_family).toEqual("TypeWriter");
|
expect(drawing.font_family).toEqual("TypeWriter");
|
||||||
expect(drawing.font_size).toEqual(10.0);
|
expect(drawing.font_size).toEqual(10.0);
|
||||||
expect(drawing.font_weight).toEqual("bold");
|
expect(drawing.font_weight).toEqual("bold");
|
||||||
|
expect(drawing.text_decoration).toEqual("line-through");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -33,6 +33,12 @@ export class TextConverter implements SvgConverter {
|
|||||||
drawing.font_weight = font_weight.value;
|
drawing.font_weight = font_weight.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const text_decoration = node.attributes.getNamedItem('text-decoration');
|
||||||
|
if (text_decoration) {
|
||||||
|
drawing.text_decoration = text_decoration.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return drawing;
|
return drawing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,5 @@ export class TextElement implements DrawingElement, Font {
|
|||||||
font_family: string;
|
font_family: string;
|
||||||
font_size: number;
|
font_size: number;
|
||||||
font_weight: string;
|
font_weight: string;
|
||||||
|
text_decoration: string;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ describe('TextDrawingWidget', () => {
|
|||||||
text.font_family = "TypeWriter";
|
text.font_family = "TypeWriter";
|
||||||
text.font_size = 10.0;
|
text.font_size = 10.0;
|
||||||
text.font_weight = "bold";
|
text.font_weight = "bold";
|
||||||
|
text.text_decoration = "line-through";
|
||||||
|
|
||||||
drawing.element = text;
|
drawing.element = text;
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ describe('TextDrawingWidget', () => {
|
|||||||
expect(text_element.innerHTML).toEqual('<tspan xml:space="preserve" x="0" dy="0em">THIS IS TEXT</tspan>');
|
expect(text_element.innerHTML).toEqual('<tspan xml:space="preserve" x="0" dy="0em">THIS IS TEXT</tspan>');
|
||||||
expect(text_element.getAttribute('fill')).toEqual("#000000");
|
expect(text_element.getAttribute('fill')).toEqual("#000000");
|
||||||
expect(text_element.getAttribute('style')).toEqual('font-family: "Noto Sans"; font-size: 11pt; font-weight: bold');
|
expect(text_element.getAttribute('style')).toEqual('font-family: "Noto Sans"; font-size: 11pt; font-weight: bold');
|
||||||
|
expect(text_element.getAttribute('text-decoration')).toEqual("line-through");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should draw multiline text', () => {
|
it('should draw multiline text', () => {
|
||||||
|
@ -42,7 +42,8 @@ export class TextDrawingWidget implements DrawingWidget {
|
|||||||
}
|
}
|
||||||
return styles.join("; ");
|
return styles.join("; ");
|
||||||
})
|
})
|
||||||
.attr('fill', (text) => text.fill);
|
.attr('fill', (text) => text.fill)
|
||||||
|
.attr('text-decoration', (text) => text.text_decoration);
|
||||||
|
|
||||||
const lines = merge.selectAll<SVGTSpanElement, string>('tspan')
|
const lines = merge.selectAll<SVGTSpanElement, string>('tspan')
|
||||||
.data((text: TextElement) => {
|
.data((text: TextElement) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user