Добавляем все файлы
This commit is contained in:
30
main_plugin/dgrm/diagram/dgrm-png.js
Executable file
30
main_plugin/dgrm/diagram/dgrm-png.js
Executable file
@@ -0,0 +1,30 @@
|
||||
import { CanvasSmbl } from '../infrastructure/canvas-smbl.js';
|
||||
|
||||
/**
|
||||
* @param {CanvasElement} canvas
|
||||
* @param {any} serializedData
|
||||
* @param {function(Blob):void} callBack
|
||||
*/
|
||||
export function fileSaveSvg(canvas, serializedData, callBack) {
|
||||
const svgVirtual = /** @type {SVGSVGElement} */(canvas.ownerSVGElement.cloneNode(true));
|
||||
|
||||
svgVirtual.style.backgroundImage = null;
|
||||
svgVirtual.querySelectorAll('.select, .highlight').forEach(el => el.classList.remove('select', 'highlight'));
|
||||
|
||||
const nonSvgElems = svgVirtual.getElementsByTagName('foreignObject');
|
||||
while (nonSvgElems[0]) { nonSvgElems[0].parentNode.removeChild(nonSvgElems[0]); }
|
||||
|
||||
/* svgVirtual.querySelectorAll('g.hovertrack.shtxt.ta-1').forEach(group => {
|
||||
group.querySelectorAll('text, tspan').forEach(el => console.log(el));
|
||||
}); */
|
||||
|
||||
const svgStr = new XMLSerializer().serializeToString(svgVirtual);
|
||||
const blob = new Blob([svgStr], { type: 'image/svg+xml;charset=utf-8' });
|
||||
callBack(blob);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** @typedef { {x:number, y:number} } Point */
|
||||
/** @typedef { import('../infrastructure/canvas-smbl.js').CanvasElement } CanvasElement */
|
||||
Reference in New Issue
Block a user