[add] Add a notification to the Reading View when the content is copied to the clipboard.

This commit is contained in:
naive231 2024-11-15 16:14:40 +08:00
parent 395ee9b142
commit 2d0f4e73aa
1 changed files with 6 additions and 3 deletions

View File

@ -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!');
});
});