mirror of
https://github.com/jldiaz/copy-protocol-plugin.git
synced 2026-07-22 06:56:55 +00:00
Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31fba5e798 | ||
|
|
d74842f728 |
6 changed files with 17 additions and 35 deletions
BIN
demo.gif
BIN
demo.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.7 MiB |
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "copy-text-protocol",
|
||||
"name": "Copy Text Protocol",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Adds support for copying text to the clipboard using a custom protocol.",
|
||||
"author": "jldiaz",
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "copy-text-protocol",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "copy-text-protocol",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"license": "0-BSD",
|
||||
"dependencies": {
|
||||
"obsidian": "latest"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "copy-text-protocol",
|
||||
"version": "1.1.5",
|
||||
"version": "1.1.6",
|
||||
"description": "A plugin that adds support for copying text via a custom protocol.",
|
||||
"main": "main.js",
|
||||
"type": "module",
|
||||
|
|
|
|||
16
src/main.ts
16
src/main.ts
|
|
@ -181,14 +181,24 @@ export default class CopyProtocolPlugin extends Plugin {
|
|||
});
|
||||
|
||||
this.registerMarkdownPostProcessor((element, context) => {
|
||||
const links = element.querySelectorAll('a.external-link');
|
||||
const links = element.querySelectorAll('a.external-link, a.copy-protocol-link');
|
||||
links.forEach(link => {
|
||||
const href = link.getAttribute('href') || '';
|
||||
if (href.startsWith('obsidian://copy')) {
|
||||
link.classList.remove('external-link');
|
||||
link.classList.add('copy-protocol-link');
|
||||
if (link.classList.contains('external-link')) {
|
||||
link.classList.remove('external-link');
|
||||
}
|
||||
if (!link.classList.contains('copy-protocol-link')) {
|
||||
link.classList.add('copy-protocol-link');
|
||||
}
|
||||
link.removeAttribute('aria-label');
|
||||
link.removeAttribute('data-tooltip-position');
|
||||
|
||||
// Add an inline icon span if it doesn't already have one
|
||||
if (!link.querySelector('.copy-protocol-icon')) {
|
||||
const span = link.createSpan({ cls: 'copy-protocol-icon' });
|
||||
setIcon(span, 'copy');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
28
styles.css
28
styles.css
|
|
@ -16,34 +16,6 @@
|
|||
padding-inline-end: 0;
|
||||
}
|
||||
|
||||
.markdown-rendered a.copy-protocol-link::after,
|
||||
.markdown-preview-view a.copy-protocol-link::after,
|
||||
.markdown-rendered a.external-link[href^="obsidian://copy"]::after,
|
||||
.markdown-preview-view a.external-link[href^="obsidian://copy"]::after {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 0.85em;
|
||||
height: 0.85em;
|
||||
margin-left: 5px;
|
||||
vertical-align: middle;
|
||||
background-color: currentColor;
|
||||
background-image: none; /* Clears Obsidian's default icon if set via background-image */
|
||||
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2' ry='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E");
|
||||
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2' ry='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E");
|
||||
-webkit-mask-size: contain;
|
||||
mask-size: contain;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
mask-repeat: no-repeat;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.markdown-rendered a.copy-protocol-link:hover::after,
|
||||
.markdown-preview-view a.copy-protocol-link:hover::after,
|
||||
.markdown-rendered a.external-link[href^="obsidian://copy"]:hover::after,
|
||||
.markdown-preview-view a.external-link[href^="obsidian://copy"]:hover::after {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Hide Obsidian's default external link icon elements in Reading Mode */
|
||||
.markdown-rendered a[href^="obsidian://copy"] .external-link,
|
||||
.markdown-rendered a[href^="obsidian://copy"] + .external-link,
|
||||
|
|
|
|||
Loading…
Reference in a new issue