jldiaz_copy-protocol-plugin/styles.css

137 lines
4.7 KiB
CSS

/*
* Visual indicator for obsidian://copy protocol links.
*/
/* ── Reading View (Standard Links) ── */
/*
* We target the same pseudo-element Obsidian uses (::after) but with higher
* specificity to override it completely without !important.
*/
.markdown-rendered a.copy-protocol-link,
.markdown-preview-view a.copy-protocol-link,
.markdown-rendered a.external-link[href^="obsidian://copy"],
.markdown-preview-view a.external-link[href^="obsidian://copy"] {
background-image: none;
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,
.markdown-preview-view a[href^="obsidian://copy"] .external-link,
.markdown-preview-view a[href^="obsidian://copy"] + .external-link,
.markdown-rendered a.copy-protocol-link .external-link,
.markdown-rendered a.copy-protocol-link + .external-link,
.markdown-preview-view a.copy-protocol-link .external-link,
.markdown-preview-view a.copy-protocol-link + .external-link {
display: none;
}
/* ── Live Preview (Managed by ViewPlugin Widget) ── */
/*
* Hide Obsidian's default external link icon on our copy links.
* Instead of :has(), we use the .has-copy-protocol-line class added in JS.
*/
.markdown-source-view.mod-cm6 .has-copy-protocol-line .external-link,
.markdown-source-view.mod-cm6 .has-copy-protocol-line .cm-url.external-link {
display: none;
}
/* Ensure the link text looks like a link */
.markdown-source-view.mod-cm6 .copy-protocol-link {
text-decoration: underline;
text-underline-offset: 2px;
}
/* Copy cursor on hover */
.markdown-source-view.mod-cm6 .copy-protocol-link:hover,
.markdown-source-view.mod-cm6 a[href^="obsidian://copy"]:hover,
a.copy-protocol-link:hover {
cursor: copy;
}
/* ── Widget Styles (Live Preview) ── */
.copy-protocol-icon {
cursor: copy;
display: inline-flex;
margin-left: 5px;
vertical-align: middle;
opacity: 0.8;
transition: transform 0.1s ease-out, opacity 0.1s ease-out;
}
.copy-protocol-icon:hover {
opacity: 1;
}
.copy-protocol-icon svg {
width: 0.85em;
height: 0.85em;
}
.copy-protocol-icon.is-clicked {
transform: scale(1.2);
}
/* ── Custom Premium Tooltip ── */
.copy-protocol-tooltip {
position: absolute;
z-index: 10000;
background-color: var(--background-tooltip, var(--background-secondary-alt, #303030));
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
color: var(--text-normal);
border: 1px solid var(--border-color, var(--background-modifier-border, #444));
border-radius: 6px;
padding: 6px 12px;
font-size: 12px;
font-family: var(--font-interface);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
pointer-events: none;
opacity: 0;
transition: opacity 0.15s ease-in-out, transform 0.15s ease-in-out;
transform: translateY(5px);
white-space: nowrap;
max-width: 350px;
overflow: hidden;
text-overflow: ellipsis;
}
.copy-protocol-tooltip.is-visible {
opacity: 1;
transform: translateY(0);
}