Compare commits

..

2 commits
1.1.5 ... main

Author SHA1 Message Date
JLDiaz (m)
31fba5e798 1.1.6 2026-05-21 21:01:55 +02:00
JLDiaz (m)
d74842f728 fix: replace css-masks with native setIcon to bypass browser feature warnings; update demo.gif 2026-05-21 21:01:50 +02:00
6 changed files with 17 additions and 35 deletions

BIN
demo.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

View file

@ -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
View file

@ -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"

View file

@ -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",

View file

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

View file

@ -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,