From 99ba7be92d530b7d5f3c625a8df6846cd56bb9e3 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sun, 2 Mar 2025 00:06:40 +0800 Subject: [PATCH] perf(plugin-md-power): improve code embed (#497) --- .../__snapshots__/codepenPlugin.spec.ts.snap | 4 +- .../__snapshots__/jsfiddlePlugin.spec.ts.snap | 4 +- .../src/client/components/Annotation.vue | 6 +++ .../src/client/components/CanIUse.vue | 6 +-- .../src/client/components/CodePen.vue | 54 +++++++++++++++++++ .../src/client/components/JsFiddle.vue | 40 ++++++++++++++ .../src/client/components/Replit.vue | 8 +-- .../src/client/composables/pdf.ts | 2 +- .../plugin-md-power/src/client/utils/is.ts | 15 ------ .../src/node/container/codeTabs.ts | 4 +- .../src/node/container/tabs.ts | 4 +- .../src/node/embed/code/codepen.ts | 39 +++----------- .../src/node/embed/code/jsfiddle.ts | 25 ++++----- .../src/node/prepareConfigFile.ts | 10 ++++ .../plugin-md-power/src/shared/jsfiddle.ts | 3 +- plugins/plugin-md-power/tsup.config.ts | 2 +- 16 files changed, 145 insertions(+), 81 deletions(-) create mode 100644 plugins/plugin-md-power/src/client/components/CodePen.vue create mode 100644 plugins/plugin-md-power/src/client/components/JsFiddle.vue delete mode 100644 plugins/plugin-md-power/src/client/utils/is.ts diff --git a/plugins/plugin-md-power/__test__/__snapshots__/codepenPlugin.spec.ts.snap b/plugins/plugin-md-power/__test__/__snapshots__/codepenPlugin.spec.ts.snap index a8832100..53944bba 100644 --- a/plugins/plugin-md-power/__test__/__snapshots__/codepenPlugin.spec.ts.snap +++ b/plugins/plugin-md-power/__test__/__snapshots__/codepenPlugin.spec.ts.snap @@ -1,9 +1,9 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`codepenPlugin > should not work 1`] = ` -"

@[codepen]xxx

+"

@[codepen]xxx

@[codepen preview](

" `; -exports[`codepenPlugin > should work 1`] = `""`; +exports[`codepenPlugin > should work 1`] = `""`; diff --git a/plugins/plugin-md-power/__test__/__snapshots__/jsfiddlePlugin.spec.ts.snap b/plugins/plugin-md-power/__test__/__snapshots__/jsfiddlePlugin.spec.ts.snap index 528bb0a7..e527ceb9 100644 --- a/plugins/plugin-md-power/__test__/__snapshots__/jsfiddlePlugin.spec.ts.snap +++ b/plugins/plugin-md-power/__test__/__snapshots__/jsfiddlePlugin.spec.ts.snap @@ -1,9 +1,9 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`codeSandboxPlugin > should not work 1`] = ` -"

@[jsfiddle]xxx

+"

@[jsfiddle]xxx

@[jsfiddle](

" `; -exports[`codeSandboxPlugin > should work 1`] = `""`; +exports[`codeSandboxPlugin > should work 1`] = `""`; diff --git a/plugins/plugin-md-power/src/client/components/Annotation.vue b/plugins/plugin-md-power/src/client/components/Annotation.vue index ab31402f..42ecd476 100644 --- a/plugins/plugin-md-power/src/client/components/Annotation.vue +++ b/plugins/plugin-md-power/src/client/components/Annotation.vue @@ -82,6 +82,12 @@ useEventListener('scroll', updatePosition, { passive: true }) transform: rotate(0deg); } +@media print { + .vpi-annotation { + display: none; + } +} + .vp-annotation.active { z-index: 10; } diff --git a/plugins/plugin-md-power/src/client/components/CanIUse.vue b/plugins/plugin-md-power/src/client/components/CanIUse.vue index 9449e12d..870541f3 100644 --- a/plugins/plugin-md-power/src/client/components/CanIUse.vue +++ b/plugins/plugin-md-power/src/client/components/CanIUse.vue @@ -1,6 +1,7 @@ + +