From 2d0f4e73aac805501ca2426445772596520e071b Mon Sep 17 00:00:00 2001 From: naive231 Date: Fri, 15 Nov 2024 16:14:40 +0800 Subject: [PATCH] [add] Add a notification to the Reading View when the content is copied to the clipboard. --- main.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index a45d789..e6215d5 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,4 @@ -import { Plugin, setIcon } from 'obsidian'; +import { Plugin, setIcon, Notice } from 'obsidian'; export default class LineConverterPlugin extends Plugin { async onload() { @@ -11,8 +11,8 @@ export default class LineConverterPlugin extends Plugin { // Create the header for the code block (where buttons are placed) const codeBlockHeader = codeBlockEl.createEl('div', { cls: 'code-block-header' }); - // Create the copy button - const copyButton = codeBlockHeader.createEl('div', { cls: 'copy-code-button' }); + // Create the copy button with the 'clickable-icon' class + const copyButton = codeBlockHeader.createEl('div', { cls: 'copy-code-button clickable-icon' }); setIcon(copyButton, 'copy'); // Add event listener to copy the content to the clipboard @@ -21,6 +21,9 @@ export default class LineConverterPlugin extends Plugin { // Provide feedback to the user copyButton.addClass('mod-copied'); setTimeout(() => copyButton.removeClass('mod-copied'), 1500); + + // Show a notification to the user + new Notice('Copied to clipboard!'); }); });