[add] Add a notification to the Reading View when the content is copied to the clipboard.
This commit is contained in:
parent
395ee9b142
commit
2d0f4e73aa
9
main.ts
9
main.ts
|
@ -1,4 +1,4 @@
|
||||||
import { Plugin, setIcon } from 'obsidian';
|
import { Plugin, setIcon, Notice } from 'obsidian';
|
||||||
|
|
||||||
export default class LineConverterPlugin extends Plugin {
|
export default class LineConverterPlugin extends Plugin {
|
||||||
async onload() {
|
async onload() {
|
||||||
|
@ -11,8 +11,8 @@ export default class LineConverterPlugin extends Plugin {
|
||||||
// Create the header for the code block (where buttons are placed)
|
// Create the header for the code block (where buttons are placed)
|
||||||
const codeBlockHeader = codeBlockEl.createEl('div', { cls: 'code-block-header' });
|
const codeBlockHeader = codeBlockEl.createEl('div', { cls: 'code-block-header' });
|
||||||
|
|
||||||
// Create the copy button
|
// Create the copy button with the 'clickable-icon' class
|
||||||
const copyButton = codeBlockHeader.createEl('div', { cls: 'copy-code-button' });
|
const copyButton = codeBlockHeader.createEl('div', { cls: 'copy-code-button clickable-icon' });
|
||||||
setIcon(copyButton, 'copy');
|
setIcon(copyButton, 'copy');
|
||||||
|
|
||||||
// Add event listener to copy the content to the clipboard
|
// 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
|
// Provide feedback to the user
|
||||||
copyButton.addClass('mod-copied');
|
copyButton.addClass('mod-copied');
|
||||||
setTimeout(() => copyButton.removeClass('mod-copied'), 1500);
|
setTimeout(() => copyButton.removeClass('mod-copied'), 1500);
|
||||||
|
|
||||||
|
// Show a notification to the user
|
||||||
|
new Notice('Copied to clipboard!');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue