aboutsummaryrefslogtreecommitdiffstats
path: root/tiddlers/plugin-copy-codeblock-widget.tid
diff options
context:
space:
mode:
authorshu <nvcsadjkojf@outlook.com>2026-08-19 15:56:06 +0800
committershu <nvcsadjkojf@outlook.com>2026-08-19 15:56:06 +0800
commitca1a4a31706d0c03673fe4c414c645ed826b21c6 (patch)
treec412265a19dd4694c39aac65b6e1a8903a513978 /tiddlers/plugin-copy-codeblock-widget.tid
parent490d41f154615a52734f117d7d7bda5a9331e303 (diff)
精简 Wiki 构建与运行方式
将浏览器端工具整理为 utilities 插件,移除 Docker、Org GTD 和 files API,并补充单文件构建及 Node.js 运行入口。
Diffstat (limited to 'tiddlers/plugin-copy-codeblock-widget.tid')
-rw-r--r--tiddlers/plugin-copy-codeblock-widget.tid72
1 files changed, 0 insertions, 72 deletions
diff --git a/tiddlers/plugin-copy-codeblock-widget.tid b/tiddlers/plugin-copy-codeblock-widget.tid
deleted file mode 100644
index 2251c62..0000000
--- a/tiddlers/plugin-copy-codeblock-widget.tid
+++ /dev/null
@@ -1,72 +0,0 @@
-title: $:/plugins/local/copy-codeblock/copy-codeblock.js
-type: application/javascript
-module-type: widget
-
-/*\
-title: $:/plugins/local/copy-codeblock/copy-codeblock.js
-type: application/javascript
-module-type: widget
-
-Adds a copy button to code blocks.
-\*/
-(function() {
-"use strict";
-
-var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock;
-
-var CopyCodeBlockWidget = function(parseTreeNode,options) {
- this.initialise(parseTreeNode,options);
-};
-
-CopyCodeBlockWidget.prototype = new CodeBlockWidget();
-CopyCodeBlockWidget.prototype.constructor = CopyCodeBlockWidget;
-
-CopyCodeBlockWidget.prototype.postRender = function() {
- var self = this,
- preNode = this.domNodes[0],
- previousNode,
- button;
-
- // Preserve syntax highlighting supplied by the highlight plugin.
- if(CodeBlockWidget.prototype.postRender) {
- CodeBlockWidget.prototype.postRender.call(this);
- }
-
- if(!$tw.browser || !preNode || preNode.isTiddlyWikiFakeDom) {
- return;
- }
-
- // The system code view already renders its own copy button.
- previousNode = preNode.previousElementSibling;
- if(previousNode && previousNode.querySelector && previousNode.querySelector(".tc-image-copy-clipboard")) {
- return;
- }
-
- preNode.style.position = "relative";
- preNode.style.paddingRight = "5em";
-
- button = this.document.createElement("button");
- button.setAttribute("type","button");
- button.setAttribute("aria-label","Copy code");
- button.setAttribute("title","Copy code");
- button.className = "tc-btn-invisible tc-copy-codeblock-button";
- button.textContent = "Copy";
- button.style.position = "absolute";
- button.style.top = "0.5em";
- button.style.right = "0.5em";
- button.style.zIndex = "1";
- button.style.padding = "0.2em 0.45em";
- button.style.cursor = "pointer";
-
- button.addEventListener("click",function(event) {
- event.preventDefault();
- event.stopPropagation();
- $tw.utils.copyToClipboard(self.getAttribute("code",""));
- });
-
- preNode.appendChild(button);
-};
-
-exports.codeblock = CopyCodeBlockWidget;
-
-})();