@brillout/docpress 0.15.10-commit-05c2883 → 0.15.11

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.
@@ -51,8 +51,11 @@ function CopyButton() {
51
51
  )
52
52
  async function onClick(e: React.MouseEvent<HTMLButtonElement>) {
53
53
  let success: boolean
54
+ const preEl = e.currentTarget.parentElement!
55
+ let text = preEl.textContent || ''
56
+ text = removeTrailingWhitespaces(text)
54
57
  try {
55
- await copyToClipboard(e)
58
+ await navigator.clipboard.writeText(text)
56
59
  success = true
57
60
  } catch (error) {
58
61
  console.error(error)
@@ -61,16 +64,6 @@ function CopyButton() {
61
64
  onCopy(success)
62
65
  }
63
66
  }
64
-
65
- async function copyToClipboard(e: React.MouseEvent<HTMLButtonElement>) {
66
- const codeEl = e.currentTarget.nextElementSibling
67
- if (codeEl?.tagName === 'CODE') {
68
- let text = codeEl.textContent ?? ''
69
- text = removeTrailingWhitespaces(text)
70
- await navigator.clipboard.writeText(text)
71
- }
72
- }
73
-
74
67
  function removeTrailingWhitespaces(text: string) {
75
68
  return text
76
69
  .split('\n')
@@ -82,7 +82,7 @@ async function transformTsToJs(node, file) {
82
82
  "This likely happened due to invalid TypeScript syntax (see detype's error message above). You can either:",
83
83
  '- Fix the code block syntax',
84
84
  '- Set the code block language to js instead of ts',
85
- '- Use magic comments https://github.com/brillout/docpress#code-block-meta-and-comments',
85
+ '- Use custom meta or comments https://github.com/brillout/docpress#detype',
86
86
  ].join('\n') + '\n');
87
87
  return;
88
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.15.10-commit-05c2883",
3
+ "version": "0.15.11",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
package/remarkDetype.ts CHANGED
@@ -99,7 +99,7 @@ async function transformTsToJs(node: CodeNode, file: VFile) {
99
99
  "This likely happened due to invalid TypeScript syntax (see detype's error message above). You can either:",
100
100
  '- Fix the code block syntax',
101
101
  '- Set the code block language to js instead of ts',
102
- '- Use magic comments https://github.com/brillout/docpress#code-block-meta-and-comments',
102
+ '- Use custom meta or comments https://github.com/brillout/docpress#detype',
103
103
  ].join('\n') + '\n',
104
104
  )
105
105
  return