Skip to content

Commit 3ba7866

Browse files
committed
feat: improve code
1 parent 9935d7e commit 3ba7866

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

packages/core/src/utils/to-image.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ function cloneCSSStyle<T extends HTMLElement>(nativeNode: T, clonedNode: T, styl
9090
return;
9191
}
9292
const sourceStyle = window.getComputedStyle(nativeNode);
93-
// Only clone a subset of styles related to font color and size
94-
const ALLOWLIST = [...(styleNames || [])];
95-
ALLOWLIST.forEach((prop) => {
93+
// Only clone a subset of styles
94+
(styleNames || []).forEach((prop) => {
9695
const value = sourceStyle.getPropertyValue(prop);
9796
const priority = sourceStyle.getPropertyPriority(prop);
9897
if (value) {
@@ -108,10 +107,11 @@ function cloneCSSStyle<T extends HTMLElement>(nativeNode: T, clonedNode: T, styl
108107
* @param inlineStyleClassNames
109108
*/
110109
function batchCloneCSSStyle(sourceNode: SVGGElement, cloneNode: SVGGElement, inlineStyleClassNames?: string, styleNames?: string[]) {
111-
// text
110+
// handle text style, Hardcoded to slate editor framework
111+
const textSelector = '[data-slate-node="text"]';
112112
const textStyle = ['font-size', 'font-family', 'line-height', 'text-decoration', 'font-weight', 'font-style', 'word-break'];
113-
const sourceTextNodes = Array.from(sourceNode.querySelectorAll('[data-slate-node="text"]'));
114-
const cloneTextNodes = Array.from(cloneNode.querySelectorAll('[data-slate-node="text"]'));
113+
const sourceTextNodes = Array.from(sourceNode.querySelectorAll(textSelector));
114+
const cloneTextNodes = Array.from(cloneNode.querySelectorAll(textSelector));
115115
sourceTextNodes.map((node, index) => {
116116
cloneCSSStyle(node as HTMLElement, cloneTextNodes[index] as HTMLElement, textStyle);
117117
});

src/app/components/menu/menu.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export const base64ToBlob = (base64: string) => {
7979
export const boardToImage = (board: PlaitBoard, options: ToImageOptions = {}) => {
8080
return toImage(board, {
8181
fillStyle: 'transparent',
82-
inlineStyleClassNames: '.extend,.emojis,.text',
8382
padding: 20,
8483
ratio: 4,
8584
...options

0 commit comments

Comments
 (0)