@mistweaverco/mdsvex-shiki 1.1.0 → 1.2.0

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/README.md CHANGED
@@ -9,7 +9,8 @@ limited in features and customization options.
9
9
  We needed a better solution for our SvelteKit projects,
10
10
  so we created this package to fill the gap.
11
11
 
12
- <img width="945" height="874" alt="Screenshot" src="https://github.com/user-attachments/assets/c717f559-ae96-4372-a1ac-3eba3d4db340" />
12
+ <img width="794" height="558" alt="Screenshot" src="https://github.com/user-attachments/assets/38250632-432a-4f2a-8722-0ef1e4108f38" />
13
+
13
14
 
14
15
  ## Installation
15
16
 
@@ -17,19 +18,19 @@ Using your package manager of choice, run:
17
18
 
18
19
  ```bash
19
20
  # npm
20
- npm install @mistweaverco/mdsvex-shiki@v1.1.0
21
+ npm install @mistweaverco/mdsvex-shiki@v1.1.1
21
22
 
22
23
  # yarn
23
- yarn add @mistweaverco/mdsvex-shiki@v1.1.0
24
+ yarn add @mistweaverco/mdsvex-shiki@v1.1.1
24
25
 
25
26
  # bun
26
- bun add @mistweaverco/mdsvex-shiki@v1.1.0
27
+ bun add @mistweaverco/mdsvex-shiki@v1.1.1
27
28
 
28
29
  # pnpm
29
- pnpm add @mistweaverco/mdsvex-shiki@v1.1.0
30
+ pnpm add @mistweaverco/mdsvex-shiki@v1.1.1
30
31
 
31
32
  # deno
32
- deno add npm:@mistweaverco/mdsvex-shiki@v1.1.0
33
+ deno add npm:@mistweaverco/mdsvex-shiki@v1.1.1
33
34
  ```
34
35
 
35
36
  ## Configuration
@@ -0,0 +1,71 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
6
+ var __toCommonJS = (from) => {
7
+ var entry = __moduleCache.get(from), desc;
8
+ if (entry)
9
+ return entry;
10
+ entry = __defProp({}, "__esModule", { value: true });
11
+ if (from && typeof from === "object" || typeof from === "function")
12
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ }));
16
+ __moduleCache.set(from, entry);
17
+ return entry;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true,
24
+ configurable: true,
25
+ set: (newValue) => all[name] = () => newValue
26
+ });
27
+ };
28
+
29
+ // src/copy-action.ts
30
+ var exports_copy_action = {};
31
+ __export(exports_copy_action, {
32
+ copyAction: () => copyAction
33
+ });
34
+ module.exports = __toCommonJS(exports_copy_action);
35
+ var copyAction = (node) => {
36
+ const handleClick = (event) => {
37
+ const target = event.target;
38
+ const button = target.closest("button.copy");
39
+ if (button) {
40
+ const codeText = button.getAttribute("data-code");
41
+ if (codeText) {
42
+ navigator.clipboard.writeText(codeText).then(() => {
43
+ button.classList.add("copied");
44
+ setTimeout(() => {
45
+ button.classList.remove("copied");
46
+ }, 2000);
47
+ }).catch((err) => {
48
+ console.error("Failed to copy code:", err);
49
+ });
50
+ } else {
51
+ const codeBlock = button.closest(".mdsvex-shiki")?.querySelector("code");
52
+ if (codeBlock) {
53
+ navigator.clipboard.writeText(codeBlock.textContent || "").then(() => {
54
+ button.classList.add("copied");
55
+ setTimeout(() => {
56
+ button.classList.remove("copied");
57
+ }, 2000);
58
+ }).catch((err) => {
59
+ console.error("Failed to copy code:", err);
60
+ });
61
+ }
62
+ }
63
+ }
64
+ };
65
+ node.addEventListener("click", handleClick);
66
+ return {
67
+ destroy() {
68
+ node.removeEventListener("click", handleClick);
69
+ }
70
+ };
71
+ };
@@ -0,0 +1,18 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { Action } from 'svelte/action';
4
+
5
+ /**
6
+ * Svelte action to enable copy button functionality for mdsvex-shiki code blocks.
7
+ * Apply this action to a container element that contains the code blocks.
8
+ *
9
+ * @example
10
+ * ```svelte
11
+ * <div use:copyAction>
12
+ * {@html content}
13
+ * </div>
14
+ * ```
15
+ */
16
+ export declare const copyAction: Action<HTMLElement>;
17
+
18
+ export {};
@@ -0,0 +1,41 @@
1
+ // src/copy-action.ts
2
+ var copyAction = (node) => {
3
+ const handleClick = (event) => {
4
+ const target = event.target;
5
+ const button = target.closest("button.copy");
6
+ if (button) {
7
+ const codeText = button.getAttribute("data-code");
8
+ if (codeText) {
9
+ navigator.clipboard.writeText(codeText).then(() => {
10
+ button.classList.add("copied");
11
+ setTimeout(() => {
12
+ button.classList.remove("copied");
13
+ }, 2000);
14
+ }).catch((err) => {
15
+ console.error("Failed to copy code:", err);
16
+ });
17
+ } else {
18
+ const codeBlock = button.closest(".mdsvex-shiki")?.querySelector("code");
19
+ if (codeBlock) {
20
+ navigator.clipboard.writeText(codeBlock.textContent || "").then(() => {
21
+ button.classList.add("copied");
22
+ setTimeout(() => {
23
+ button.classList.remove("copied");
24
+ }, 2000);
25
+ }).catch((err) => {
26
+ console.error("Failed to copy code:", err);
27
+ });
28
+ }
29
+ }
30
+ }
31
+ };
32
+ node.addEventListener("click", handleClick);
33
+ return {
34
+ destroy() {
35
+ node.removeEventListener("click", handleClick);
36
+ }
37
+ };
38
+ };
39
+ export {
40
+ copyAction
41
+ };
package/dist/index.cjs CHANGED
@@ -4209,8 +4209,7 @@ var exports_src = {};
4209
4209
  __export(exports_src, {
4210
4210
  mdsvexShiki: () => mdsvexShiki,
4211
4211
  defaultShikiOptions: () => defaultShikiOptions,
4212
- default: () => src_default,
4213
- copyAction: () => copyAction
4212
+ default: () => src_default
4214
4213
  });
4215
4214
  module.exports = __toCommonJS(exports_src);
4216
4215
 
@@ -4661,45 +4660,6 @@ function transformerNotationWordHighlight(options = {}) {
4661
4660
  return true;
4662
4661
  }, options.matchAlgorithm);
4663
4662
  }
4664
-
4665
- // src/copy-action.ts
4666
- var copyAction = (node) => {
4667
- const handleClick = (event) => {
4668
- const target = event.target;
4669
- const button = target.closest("button.copy");
4670
- if (button) {
4671
- const codeText = button.getAttribute("data-code");
4672
- if (codeText) {
4673
- navigator.clipboard.writeText(codeText).then(() => {
4674
- button.classList.add("copied");
4675
- setTimeout(() => {
4676
- button.classList.remove("copied");
4677
- }, 2000);
4678
- }).catch((err) => {
4679
- console.error("Failed to copy code:", err);
4680
- });
4681
- } else {
4682
- const codeBlock = button.closest(".mdsvex-shiki")?.querySelector("code");
4683
- if (codeBlock) {
4684
- navigator.clipboard.writeText(codeBlock.textContent || "").then(() => {
4685
- button.classList.add("copied");
4686
- setTimeout(() => {
4687
- button.classList.remove("copied");
4688
- }, 2000);
4689
- }).catch((err) => {
4690
- console.error("Failed to copy code:", err);
4691
- });
4692
- }
4693
- }
4694
- }
4695
- };
4696
- node.addEventListener("click", handleClick);
4697
- return {
4698
- destroy() {
4699
- node.removeEventListener("click", handleClick);
4700
- }
4701
- };
4702
- };
4703
4663
  // src/utils.ts
4704
4664
  var escapeHTML = (html) => {
4705
4665
  return html.replace(/{/g, "&lbrace;").replace(/}/g, "&rbrace;").replace(/`/g, "&#96;");
package/dist/index.d.ts CHANGED
@@ -1,20 +1,7 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
3
  import { BundledLanguage, BundledTheme, CodeToHastOptions } from 'shiki';
4
- import { Action } from 'svelte/action';
5
4
 
6
- /**
7
- * Svelte action to enable copy button functionality for mdsvex-shiki code blocks.
8
- * Apply this action to a container element that contains the code blocks.
9
- *
10
- * @example
11
- * ```svelte
12
- * <div use:copyAction>
13
- * {@html content}
14
- * </div>
15
- * ```
16
- */
17
- export declare const copyAction: Action<HTMLElement>;
18
5
  export type HighlighterOptions = {
19
6
  displayPath?: boolean;
20
7
  displayLanguage?: boolean;
package/dist/index.js CHANGED
@@ -4634,45 +4634,6 @@ function transformerNotationWordHighlight(options = {}) {
4634
4634
  return true;
4635
4635
  }, options.matchAlgorithm);
4636
4636
  }
4637
-
4638
- // src/copy-action.ts
4639
- var copyAction = (node) => {
4640
- const handleClick = (event) => {
4641
- const target = event.target;
4642
- const button = target.closest("button.copy");
4643
- if (button) {
4644
- const codeText = button.getAttribute("data-code");
4645
- if (codeText) {
4646
- navigator.clipboard.writeText(codeText).then(() => {
4647
- button.classList.add("copied");
4648
- setTimeout(() => {
4649
- button.classList.remove("copied");
4650
- }, 2000);
4651
- }).catch((err) => {
4652
- console.error("Failed to copy code:", err);
4653
- });
4654
- } else {
4655
- const codeBlock = button.closest(".mdsvex-shiki")?.querySelector("code");
4656
- if (codeBlock) {
4657
- navigator.clipboard.writeText(codeBlock.textContent || "").then(() => {
4658
- button.classList.add("copied");
4659
- setTimeout(() => {
4660
- button.classList.remove("copied");
4661
- }, 2000);
4662
- }).catch((err) => {
4663
- console.error("Failed to copy code:", err);
4664
- });
4665
- }
4666
- }
4667
- }
4668
- };
4669
- node.addEventListener("click", handleClick);
4670
- return {
4671
- destroy() {
4672
- node.removeEventListener("click", handleClick);
4673
- }
4674
- };
4675
- };
4676
4637
  // src/utils.ts
4677
4638
  var escapeHTML = (html) => {
4678
4639
  return html.replace(/{/g, "&lbrace;").replace(/}/g, "&rbrace;").replace(/`/g, "&#96;");
@@ -13929,6 +13890,5 @@ var src_default = mdsvexShiki;
13929
13890
  export {
13930
13891
  mdsvexShiki,
13931
13892
  defaultShikiOptions,
13932
- src_default as default,
13933
- copyAction
13893
+ src_default as default
13934
13894
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistweaverco/mdsvex-shiki",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -11,6 +11,11 @@
11
11
  "import": "./dist/index.js",
12
12
  "require": "./dist/index.cjs"
13
13
  },
14
+ "./copy-action": {
15
+ "types": "./dist/copy-action.d.ts",
16
+ "import": "./dist/copy-action.js",
17
+ "require": "./dist/copy-action.cjs"
18
+ },
14
19
  "./styles.css": "./styles.css"
15
20
  },
16
21
  "files": [
package/styles.css CHANGED
@@ -112,7 +112,8 @@
112
112
  align-items: center;
113
113
  gap: 0.25em;
114
114
  max-width: calc(100% - 100px);
115
- overflow: hidden;
115
+ overflow-y: hidden;
116
+ overflow-x: auto;
116
117
  white-space: nowrap;
117
118
  }
118
119