@halo-dev/shiki-code-element 1.0.6 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -615,7 +615,7 @@ var o = e(e$1);
615
615
  function n$1(b, F, U) {
616
616
  return b ? F(b) : U?.(b);
617
617
  }
618
- var shiki_default = ".shiki{color-scheme:var(--shiki-theme-type,light);padding:.875em;overflow-x:auto}code{z-index:0;width:max-content;min-width:100%;font-size:var(--font-size,.875em);counter-reset:step;counter-increment:step 0;display:block;position:relative}code .line:before{content:counter(step);counter-increment:step;text-align:right;color:#738a9480;width:1rem;margin-right:1.5rem;display:inline-block}code .line:last-child:empty:before{content:none;counter-increment:none}.has-diff .diff,.has-highlighted .highlighted{width:100%;display:inline-block;position:relative}.has-diff .diff.remove:before{content:\"-\"}.has-diff .diff.add:before{content:\"+\"}.has-diff .diff.remove:after{content:\"\";z-index:-1;background:#ef444426;border-left:1px solid #ef4444cc;position:absolute;inset:0 -1rem}.has-diff .diff.add:after{content:\"\";z-index:-1;background:#22c55e26;border-left:1px solid #22c55ecc;position:absolute;inset:0 -1rem}.has-focused .line:not(.focused){opacity:.7;filter:blur(.095rem);transition:filter .35s,opacity .35s}.has-focused:hover .line:not(.focused){opacity:1;filter:blur()}.has-highlighted .highlighted:after{content:\"\";z-index:-1;background:#65758529;border-left:1px solid #22c55ecc;position:absolute;inset:0 -1rem}.has-highlighted .highlighted.error:after{background:#f43f5e29!important}.has-highlighted .highlighted.warning:after{background:#eab30829!important}:host([color-scheme=dark]) .shiki,:host([color-scheme=dark]) .shiki span{color:var(--shiki-dark)!important}:host([color-scheme=dark]) .shiki{background-color:var(--shiki-dark-bg)!important}";
618
+ var shiki_default = ".shiki{color-scheme:var(--shiki-theme-type,light);padding:.875em;overflow-x:auto}code{z-index:0;width:max-content;min-width:100%;font-size:var(--font-size,.875em);counter-reset:step;counter-increment:step 0;display:block;position:relative}code .line:before{content:counter(step);counter-increment:step;text-align:right;color:#738a9480;width:1rem;margin-right:1.5rem;display:inline-block}code .line:last-child:empty:before{content:none;counter-increment:none}.has-diff .diff,.has-highlighted .highlighted{width:100%;display:inline-block;position:relative}.has-diff .diff.remove:before{content:\"-\"}.has-diff .diff.add:before{content:\"+\"}.has-diff .diff.remove:after{content:\"\";z-index:-1;background:#ef444426;border-left:1px solid #ef4444cc;position:absolute;inset:0 -.875em}.has-diff .diff.add:after{content:\"\";z-index:-1;background:#22c55e26;border-left:1px solid #22c55ecc;position:absolute;inset:0 -.875em}.has-focused .line:not(.focused){opacity:.7;filter:blur(.095rem);transition:filter .35s,opacity .35s}.has-focused:hover .line:not(.focused){opacity:1;filter:blur()}.has-highlighted .highlighted:after{content:\"\";z-index:-1;background:#65758529;border-left:1px solid #22c55ecc;position:absolute;inset:0 -.875em}.has-highlighted .highlighted.error:after{background:#f43f5e29!important}.has-highlighted .highlighted.warning:after{background:#eab30829!important}:host([color-scheme=dark]) .shiki,:host([color-scheme=dark]) .shiki span{color:var(--shiki-dark)!important}:host([color-scheme=dark]) .shiki{background-color:var(--shiki-dark-bg)!important}";
619
619
  function copyText(b, F) {
620
620
  if (navigator.clipboard) navigator.clipboard.writeText(b).then(() => {
621
621
  F();
@@ -641,7 +641,6 @@ var ShikiCodeBaseVariant = class extends i$1 {
641
641
  constructor(...b) {
642
642
  super(...b), this.options = {
643
643
  html: "",
644
- code: "",
645
644
  languageName: "Unknown",
646
645
  colorScheme: "light",
647
646
  theme: null,
@@ -652,7 +651,8 @@ var ShikiCodeBaseVariant = class extends i$1 {
652
651
  b.has("options") && (this.setAttribute("color-scheme", this.options.colorScheme), this.style.setProperty("--shiki-theme-type", this.options.theme?.type || "light"), this.style.setProperty("--font-size", this.options.fontSize || "0.875em"));
653
652
  }
654
653
  handleCopyCode() {
655
- copyText(this.options.code, () => {
654
+ let b = this.shadowRoot?.querySelector("pre");
655
+ copyText(b?.innerText || b?.textContent || "", () => {
656
656
  this.copied = !0, setTimeout(() => {
657
657
  this.copied = !1;
658
658
  }, 2e3);
@@ -834,7 +834,6 @@ var ShikiCode = class extends i$1 {
834
834
  if (this.loading) return x``;
835
835
  if (this.error) return x`<div class="text-sm text-red-500">错误: ${this.error}</div>`;
836
836
  let b = {
837
- code: this.code,
838
837
  html: this.html,
839
838
  languageName: this.languageName,
840
839
  colorScheme: this._colorScheme,
@@ -2,7 +2,6 @@ import { ThemeRegistration } from 'shiki';
2
2
  export type ColorScheme = "light" | "dark";
3
3
  export interface VariantOptions {
4
4
  html: string;
5
- code: string;
6
5
  languageName: string;
7
6
  colorScheme: ColorScheme;
8
7
  theme: ThemeRegistration | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halo-dev/shiki-code-element",
3
- "version": "1.0.6",
3
+ "version": "1.0.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/halo-sigs/plugin-shiki.git",
@@ -30,8 +30,8 @@
30
30
  "vite-plugin-dts": "^4.5.4"
31
31
  },
32
32
  "peerDependencies": {
33
- "@shikijs/transformers": "^3",
34
- "shiki": "^3"
33
+ "@shikijs/transformers": "^3.15.x",
34
+ "shiki": "^3.15.x"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc && vite build --config vite.lib.config.ts",