There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(editor): remove replaceRichTextWithSvgElement (#11843)
Saul-Mirone12bf866dc5bc
diff --git a/blocksuite/affine/blocks/root/src/edgeless/clipboard/clipboard.ts b/blocksuite/affine/blocks/root/src/edgeless/clipboard/clipboard.tsindex 1f21a06071..5213300237 100644--- a/blocksuite/affine/blocks/root/src/edgeless/clipboard/clipboard.ts+++ b/blocksuite/affine/blocks/root/src/edgeless/clipboard/clipboard.ts@@ -415,8 +415,6 @@ export class EdgelessClipboardController extends PageClipboard {ctx.scale(dpr, dpr);const replaceImgSrcWithSvg = this._exportManager?.replaceImgSrcWithSvg;- const replaceRichTextWithSvgElementFunc =- this._replaceRichTextWithSvgElement.bind(this);const imageProxy = host.std.clipboard.configs.get('imageProxy');const html2canvasOption = {@@ -448,7 +446,6 @@ export class EdgelessClipboardController extends PageClipboard {}});await replaceImgSrcWithSvg?.(element);- replaceRichTextWithSvgElementFunc(element);},backgroundColor: 'transparent',useCORS: imageProxy ? false : true,@@ -520,30 +517,6 @@ export class EdgelessClipboardController extends PageClipboard {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(canvasElementIds: string[],blockIds: string[]@@ -638,19 +611,6 @@ export class EdgelessClipboardController extends PageClipboard {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() {document.dispatchEvent(new Event('copy', {diff --git a/blocksuite/affine/blocks/surface/src/extensions/export-manager/export-manager.ts b/blocksuite/affine/blocks/surface/src/extensions/export-manager/export-manager.tsindex 6ae38015cc..c285e09d07 100644--- a/blocksuite/affine/blocks/surface/src/extensions/export-manager/export-manager.ts+++ b/blocksuite/affine/blocks/surface/src/extensions/export-manager/export-manager.ts@@ -45,19 +45,6 @@ export class ExportManager {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) => {const imgList = Array.from(element.querySelectorAll('img'));// Create an array of promises@@ -232,7 +219,6 @@ export class ExportManager {},onclone: async (_documentClone: Document, element: HTMLElement) => {element.style.height = `${viewportHeight}px`;- // this._replaceRichTextWithSvgElement(element);await this.replaceImgSrcWithSvg(element);},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() {document.querySelectorAll('.media-print').forEach(mediaPrint => {mediaPrint.classList.remove('hide');@@ -358,7 +320,6 @@ export class ExportManager {}});- this._replaceRichTextWithSvgElement(element);await this.replaceImgSrcWithSvg(element);},useCORS: this._exportOptions.imageProxyEndpoint ? false : true,