md-editor-v3 5.4.0-0 → 5.4.0-1

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.
@@ -5,6 +5,7 @@ const eventName = require("./event-name.cjs");
5
5
  const util = require("@vavt/util");
6
6
  const dom = require("./dom.cjs");
7
7
  const mediumZoom = require("medium-zoom");
8
+ const copy2clipboard = require("@vavt/copy2clipboard");
8
9
  const mdit = require("markdown-it");
9
10
  const ImageFiguresPlugin = require("markdown-it-image-figures");
10
11
  const SubPlugin = require("markdown-it-sub");
@@ -49,28 +50,6 @@ const userZoom = (props, html) => {
49
50
  }
50
51
  });
51
52
  };
52
- const copy2Clipboard = async (text) => {
53
- if (typeof text !== "string") return;
54
- if (window.isSecureContext && navigator.clipboard) {
55
- return await navigator.clipboard.writeText(text);
56
- } else {
57
- const textarea = document.createElement("textarea");
58
- let successed = false;
59
- textarea.value = text;
60
- textarea.style.position = "fixed";
61
- textarea.style.opacity = 0;
62
- textarea.style.zIndex = "-10000";
63
- textarea.style.top = "-10000";
64
- document.body.appendChild(textarea);
65
- textarea.select();
66
- successed = document.execCommand("copy");
67
- document.body.removeChild(textarea);
68
- if (successed) {
69
- return;
70
- }
71
- throw new Error('Failed to copy content via "execCommand"!');
72
- }
73
- };
74
53
  const useCopyCode = (props, html, key) => {
75
54
  const editorId = vue.inject("editorId");
76
55
  const rootRef = vue.inject("rootRef");
@@ -89,7 +68,7 @@ const useCopyCode = (props, html, key) => {
89
68
  const codeText = activeCode.textContent;
90
69
  const { text, successTips, failTips } = ult.value.copyCode;
91
70
  let msg = successTips;
92
- copy2Clipboard(props.formatCopiedText(codeText)).catch(() => {
71
+ copy2clipboard(props.formatCopiedText(codeText)).catch(() => {
93
72
  msg = failTips;
94
73
  }).finally(() => {
95
74
  if (copyButton.dataset.isIcon) {
@@ -4,6 +4,7 @@ import { b as bus, g as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as
4
4
  import { debounce, randomId, deepMerge, deepClone } from "@vavt/util";
5
5
  import { a as appendHandler, u as updateHandler, z as zoomMermaid } from "./dom.mjs";
6
6
  import mediumZoom from "medium-zoom";
7
+ import copy2clipboard from "@vavt/copy2clipboard";
7
8
  import mdit from "markdown-it";
8
9
  import ImageFiguresPlugin from "markdown-it-image-figures";
9
10
  import SubPlugin from "markdown-it-sub";
@@ -48,28 +49,6 @@ const userZoom = (props, html) => {
48
49
  }
49
50
  });
50
51
  };
51
- const copy2Clipboard = async (text) => {
52
- if (typeof text !== "string") return;
53
- if (window.isSecureContext && navigator.clipboard) {
54
- return await navigator.clipboard.writeText(text);
55
- } else {
56
- const textarea = document.createElement("textarea");
57
- let successed = false;
58
- textarea.value = text;
59
- textarea.style.position = "fixed";
60
- textarea.style.opacity = 0;
61
- textarea.style.zIndex = "-10000";
62
- textarea.style.top = "-10000";
63
- document.body.appendChild(textarea);
64
- textarea.select();
65
- successed = document.execCommand("copy");
66
- document.body.removeChild(textarea);
67
- if (successed) {
68
- return;
69
- }
70
- throw new Error('Failed to copy content via "execCommand"!');
71
- }
72
- };
73
52
  const useCopyCode = (props, html, key) => {
74
53
  const editorId = inject("editorId");
75
54
  const rootRef = inject("rootRef");
@@ -88,7 +67,7 @@ const useCopyCode = (props, html, key) => {
88
67
  const codeText = activeCode.textContent;
89
68
  const { text, successTips, failTips } = ult.value.copyCode;
90
69
  let msg = successTips;
91
- copy2Clipboard(props.formatCopiedText(codeText)).catch(() => {
70
+ copy2clipboard(props.formatCopiedText(codeText)).catch(() => {
92
71
  msg = failTips;
93
72
  }).finally(() => {
94
73
  if (copyButton.dataset.isIcon) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-editor-v3",
3
- "version": "5.4.0-0",
3
+ "version": "5.4.0-1",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "vue",
@@ -39,7 +39,9 @@
39
39
  ],
40
40
  "scripts": {
41
41
  "dev": "tsx ./scripts/dev",
42
- "build": "tsx ./scripts/build"
42
+ "build": "tsx ./scripts/build",
43
+ "lint-staged": "lint-staged",
44
+ "prepare": "husky"
43
45
  },
44
46
  "dependencies": {
45
47
  "@codemirror/lang-markdown": "^6.3.0",
@@ -75,8 +77,10 @@
75
77
  "eslint-plugin-prettier": "^5.1.3",
76
78
  "eslint-plugin-vue": "^9.29.1",
77
79
  "highlight.js": "^11.7.0",
80
+ "husky": "^9.1.7",
78
81
  "katex": "^0.16.9",
79
82
  "less": "^4.1.3",
83
+ "lint-staged": "^15.4.3",
80
84
  "mermaid": "^11.3.0",
81
85
  "multiparty": "^4.2.3",
82
86
  "prettier": "^3.2.5",
@@ -89,5 +93,14 @@
89
93
  },
90
94
  "peerDependencies": {
91
95
  "vue": "^3.5.3"
96
+ },
97
+ "lint-staged": {
98
+ "*.{ts,tsx,vue}": [
99
+ "eslint --fix",
100
+ "prettier --write"
101
+ ],
102
+ "*.{json,md}": [
103
+ "prettier --write"
104
+ ]
92
105
  }
93
106
  }