fix(editor): remove replaceRichTextWithSvgElement (#11843)
This commit is contained in:
@@ -415,8 +415,6 @@ export class EdgelessClipboardController extends PageClipboard {
|
|||||||
ctx.scale(dpr, dpr);
|
ctx.scale(dpr, dpr);
|
||||||
|
|
||||||
const replaceImgSrcWithSvg = this._exportManager?.replaceImgSrcWithSvg;
|
const replaceImgSrcWithSvg = this._exportManager?.replaceImgSrcWithSvg;
|
||||||
const replaceRichTextWithSvgElementFunc =
|
|
||||||
this._replaceRichTextWithSvgElement.bind(this);
|
|
||||||
|
|
||||||
const imageProxy = host.std.clipboard.configs.get('imageProxy');
|
const imageProxy = host.std.clipboard.configs.get('imageProxy');
|
||||||
const html2canvasOption = {
|
const html2canvasOption = {
|
||||||
@@ -448,7 +446,6 @@ export class EdgelessClipboardController extends PageClipboard {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
await replaceImgSrcWithSvg?.(element);
|
await replaceImgSrcWithSvg?.(element);
|
||||||
replaceRichTextWithSvgElementFunc(element);
|
|
||||||
},
|
},
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
useCORS: imageProxy ? false : true,
|
useCORS: imageProxy ? false : true,
|
||||||
@@ -520,30 +517,6 @@ export class EdgelessClipboardController extends PageClipboard {
|
|||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _elementToSvgElement(
|
|
||||||
node: HTMLElement,
|
|
||||||
width: number,
|
|
||||||
height: number
|
|
||||||
) {
|
|
||||||
const xmlns = 'http://www.w3.org/2000/svg';
|
|
||||||
const svg = document.createElementNS(xmlns, 'svg');
|
|
||||||
const foreignObject = document.createElementNS(xmlns, 'foreignObject');
|
|
||||||
|
|
||||||
svg.setAttribute('width', `${width}`);
|
|
||||||
svg.setAttribute('height', `${height}`);
|
|
||||||
svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
|
|
||||||
|
|
||||||
foreignObject.setAttribute('width', '100%');
|
|
||||||
foreignObject.setAttribute('height', '100%');
|
|
||||||
foreignObject.setAttribute('x', '0');
|
|
||||||
foreignObject.setAttribute('y', '0');
|
|
||||||
foreignObject.setAttribute('externalResourcesRequired', 'true');
|
|
||||||
|
|
||||||
svg.append(foreignObject);
|
|
||||||
foreignObject.append(node);
|
|
||||||
return svg;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _emitSelectionChangeAfterPaste(
|
private _emitSelectionChangeAfterPaste(
|
||||||
canvasElementIds: string[],
|
canvasElementIds: string[],
|
||||||
blockIds: string[]
|
blockIds: string[]
|
||||||
@@ -638,19 +611,6 @@ export class EdgelessClipboardController extends PageClipboard {
|
|||||||
this.gfx.tool.setTool('default');
|
this.gfx.tool.setTool('default');
|
||||||
}
|
}
|
||||||
|
|
||||||
private _replaceRichTextWithSvgElement(element: HTMLElement) {
|
|
||||||
const richList = Array.from(element.querySelectorAll('.inline-editor'));
|
|
||||||
richList.forEach(rich => {
|
|
||||||
const svgEle = this._elementToSvgElement(
|
|
||||||
rich.cloneNode(true) as HTMLElement,
|
|
||||||
rich.clientWidth,
|
|
||||||
rich.clientHeight + 1
|
|
||||||
);
|
|
||||||
rich.parentElement?.append(svgEle);
|
|
||||||
rich.remove();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
copy() {
|
copy() {
|
||||||
document.dispatchEvent(
|
document.dispatchEvent(
|
||||||
new Event('copy', {
|
new Event('copy', {
|
||||||
|
|||||||
@@ -45,19 +45,6 @@ export class ExportManager {
|
|||||||
imageProxyEndpoint: DEFAULT_IMAGE_PROXY_ENDPOINT,
|
imageProxyEndpoint: DEFAULT_IMAGE_PROXY_ENDPOINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly _replaceRichTextWithSvgElement = (element: HTMLElement) => {
|
|
||||||
const richList = Array.from(element.querySelectorAll('.inline-editor'));
|
|
||||||
richList.forEach(rich => {
|
|
||||||
const svgEle = this._elementToSvgElement(
|
|
||||||
rich.cloneNode(true) as HTMLElement,
|
|
||||||
rich.clientWidth,
|
|
||||||
rich.clientHeight + 1
|
|
||||||
);
|
|
||||||
rich.parentElement?.append(svgEle);
|
|
||||||
rich.remove();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
replaceImgSrcWithSvg = async (element: HTMLElement) => {
|
replaceImgSrcWithSvg = async (element: HTMLElement) => {
|
||||||
const imgList = Array.from(element.querySelectorAll('img'));
|
const imgList = Array.from(element.querySelectorAll('img'));
|
||||||
// Create an array of promises
|
// Create an array of promises
|
||||||
@@ -232,7 +219,6 @@ export class ExportManager {
|
|||||||
},
|
},
|
||||||
onclone: async (_documentClone: Document, element: HTMLElement) => {
|
onclone: async (_documentClone: Document, element: HTMLElement) => {
|
||||||
element.style.height = `${viewportHeight}px`;
|
element.style.height = `${viewportHeight}px`;
|
||||||
// this._replaceRichTextWithSvgElement(element);
|
|
||||||
await this.replaceImgSrcWithSvg(element);
|
await this.replaceImgSrcWithSvg(element);
|
||||||
},
|
},
|
||||||
backgroundColor: window.getComputedStyle(viewportElement).backgroundColor,
|
backgroundColor: window.getComputedStyle(viewportElement).backgroundColor,
|
||||||
@@ -291,30 +277,6 @@ export class ExportManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _elementToSvgElement(
|
|
||||||
node: HTMLElement,
|
|
||||||
width: number,
|
|
||||||
height: number
|
|
||||||
) {
|
|
||||||
const xmlns = 'http://www.w3.org/2000/svg';
|
|
||||||
const svg = document.createElementNS(xmlns, 'svg');
|
|
||||||
const foreignObject = document.createElementNS(xmlns, 'foreignObject');
|
|
||||||
|
|
||||||
svg.setAttribute('width', `${width}`);
|
|
||||||
svg.setAttribute('height', `${height}`);
|
|
||||||
svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
|
|
||||||
|
|
||||||
foreignObject.setAttribute('width', '100%');
|
|
||||||
foreignObject.setAttribute('height', '100%');
|
|
||||||
foreignObject.setAttribute('x', '0');
|
|
||||||
foreignObject.setAttribute('y', '0');
|
|
||||||
foreignObject.setAttribute('externalResourcesRequired', 'true');
|
|
||||||
|
|
||||||
svg.append(foreignObject);
|
|
||||||
foreignObject.append(node);
|
|
||||||
return svg;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _enableMediaPrint() {
|
private _enableMediaPrint() {
|
||||||
document.querySelectorAll('.media-print').forEach(mediaPrint => {
|
document.querySelectorAll('.media-print').forEach(mediaPrint => {
|
||||||
mediaPrint.classList.remove('hide');
|
mediaPrint.classList.remove('hide');
|
||||||
@@ -358,7 +320,6 @@ export class ExportManager {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this._replaceRichTextWithSvgElement(element);
|
|
||||||
await this.replaceImgSrcWithSvg(element);
|
await this.replaceImgSrcWithSvg(element);
|
||||||
},
|
},
|
||||||
useCORS: this._exportOptions.imageProxyEndpoint ? false : true,
|
useCORS: this._exportOptions.imageProxyEndpoint ? false : true,
|
||||||
|
|||||||
Reference in New Issue
Block a user