Skip to content

Commit 285509c

Browse files
committed
fix: log
1 parent 3e6b755 commit 285509c

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

src/components/editor/components/blocks/image/ImageToolbar.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Align from '@/components/editor/components/toolbar/selection-toolbar/acti
1616
import { ImageBlockNode } from '@/components/editor/editor.type';
1717
import { useEditorContext } from '@/components/editor/EditorContext';
1818
import { convertBlobToPng, fetchImageBlob } from '@/utils/image';
19+
import { Log } from '@/utils/log';
1920

2021
function ImageToolbar({ node }: { node: ImageBlockNode }) {
2122
const editor = useSlateStatic() as YjsEditor;
@@ -28,7 +29,6 @@ function ImageToolbar({ node }: { node: ImageBlockNode }) {
2829
};
2930

3031
const onCopyImage = async () => {
31-
console.debug("onCopyImage", node.data.url);
3232
let blob = await fetchImageBlob(node.data.url || '');
3333

3434
if (blob) {
@@ -38,22 +38,23 @@ function ImageToolbar({ node }: { node: ImageBlockNode }) {
3838
try {
3939
blob = await convertBlobToPng(blob);
4040
} catch (conversionError) {
41-
console.warn('Failed to convert image to PNG, trying original format', conversionError);
41+
Log.warn('Failed to convert image to PNG, trying original format', conversionError);
4242
}
4343
}
4444

45-
console.debug("Copying blob to clipboard:", { type: blob.type, size: blob.size });
46-
4745
await navigator.clipboard.write([
4846
new ClipboardItem({
4947
[blob.type]: blob,
5048
}),
5149
]);
5250
notify.success(t('document.plugins.image.copiedToPasteBoard'));
5351
} catch (error) {
54-
console.error("Failed to write to clipboard:", error);
55-
notify.error('Failed to copy image');
52+
Log.error("Failed to write to clipboard:", error);
53+
notify.error('Failed to write image to clipboard');
5654
}
55+
} else {
56+
Log.error("Failed to fetch image blob for copying");
57+
notify.error('Failed to download the image');
5758
}
5859
};
5960

vite.config.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ export default defineConfig({
100100
}),
101101
isProd
102102
? viteExternalsPlugin({
103-
react: 'React',
104-
'react-dom': 'ReactDOM',
105-
})
103+
react: 'React',
104+
'react-dom': 'ReactDOM',
105+
})
106106
: undefined,
107107
svgr({
108108
svgrOptions: {
@@ -143,22 +143,22 @@ export default defineConfig({
143143
// Enable istanbul for code coverage (active if isTest is true)
144144
isTest
145145
? istanbul({
146-
cypress: true,
147-
requireEnv: false,
148-
include: ['src/**/*'],
149-
exclude: ['**/__tests__/**/*', 'cypress/**/*', 'node_modules/**/*'],
150-
})
146+
cypress: true,
147+
requireEnv: false,
148+
include: ['src/**/*'],
149+
exclude: ['**/__tests__/**/*', 'cypress/**/*', 'node_modules/**/*'],
150+
})
151151
: undefined,
152152
process.env.ANALYZE_MODE
153153
? visualizer({
154-
emitFile: true,
155-
})
154+
emitFile: true,
155+
})
156156
: undefined,
157157
process.env.ANALYZE_MODE
158158
? totalBundleSize({
159-
fileNameRegex: /\.(js|css)$/,
160-
calculateGzip: false,
161-
})
159+
fileNameRegex: /\.(js|css)$/,
160+
calculateGzip: false,
161+
})
162162
: undefined,
163163
],
164164
// prevent vite from obscuring rust errors
@@ -180,7 +180,8 @@ export default defineConfig({
180180
sourcemap: true,
181181
minifyIdentifiers: false, // Disable identifier minification in development
182182
minifySyntax: false, // Disable syntax minification in development
183-
drop: !isDev ? ['console', 'debugger'] : [],
183+
drop: !isDev ? ['debugger'] : [],
184+
pure: !isDev ? ['console.log', 'console.debug'] : [],
184185
},
185186
build: {
186187
target: `esnext`,
@@ -214,7 +215,7 @@ export default defineConfig({
214215
}
215216
},
216217
},
217-
}
218+
}
218219
: {},
219220
},
220221
resolve: {

0 commit comments

Comments
 (0)