Disable image copy & paste

This commit is contained in:
Paulo Gustavo Veiga 2023-01-15 00:28:19 -08:00
parent 20973246a8
commit 05cddf7a2b

View File

@ -57,7 +57,6 @@ import WidgetManager from './WidgetManager';
import { TopicShapeType } from './model/INodeModel'; import { TopicShapeType } from './model/INodeModel';
import { LineType } from './ConnectionLine'; import { LineType } from './ConnectionLine';
import XMLSerializerFactory from './persistence/XMLSerializerFactory'; import XMLSerializerFactory from './persistence/XMLSerializerFactory';
import ImageExpoterFactory from './export/ImageExporterFactory';
class Designer extends Events { class Designer extends Events {
private _mindmap: Mindmap | null; private _mindmap: Mindmap | null;
@ -399,25 +398,25 @@ class Designer extends Events {
const textPlainBlob = new Blob([xmlStr], { type: 'text/plain' }); const textPlainBlob = new Blob([xmlStr], { type: 'text/plain' });
// Create image blob ... // Create image blob ...
const workspace = designer.getWorkSpace(); // const workspace = designer.getWorkSpace();
const svgElement = workspace.getSVGElement(); // const svgElement = workspace.getSVGElement();
const size = { width: window.innerWidth, height: window.innerHeight }; // const size = { width: window.innerWidth, height: window.innerHeight };
const imageUrl = ImageExpoterFactory.create( // const imageUrl = ImageExpoterFactory.create(
'png', // 'png',
svgElement, // svgElement,
size.width, // size.width,
size.height, // size.height,
false, // false,
); // );
let imgStr = await imageUrl.exportAndEncode(); // let imgStr = await imageUrl.exportAndEncode();
imgStr = imgStr.replace('octet/stream', 'image/png'); // imgStr = imgStr.replace('octet/stream', 'image/png');
const imgBlob = await (await fetch(imgStr)).blob(); // const imgBlob = await (await fetch(imgStr)).blob();
// Finally, add to clipboard ... // Finally, add to clipboard ...
const clipboard = new ClipboardItem({ const clipboard = new ClipboardItem({
[textPlainBlob.type]: textPlainBlob, [textPlainBlob.type]: textPlainBlob,
[imgBlob.type]: imgBlob, // [imgBlob.type]: imgBlob,
}); });
navigator.clipboard.write([clipboard]).then( navigator.clipboard.write([clipboard]).then(