mirror of
https://github.com/nymbo/Copy-Highlighter.git
synced 2026-07-22 06:56:52 +00:00
Rename plugin to Copy Highlighter
This commit is contained in:
parent
a2fbbeae54
commit
1fad04603b
7 changed files with 36 additions and 36 deletions
10
README.md
10
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# Copy Flasher
|
||||
# Copy Highlighter
|
||||
|
||||
Copy Flasher highlights text when you copy it in Obsidian, giving a clear visual confirmation that the copy action worked.
|
||||
Copy Highlighter highlights text when you copy it in Obsidian, giving a clear visual confirmation that the copy action worked.
|
||||
|
||||
## Features
|
||||
|
||||
|
|
@ -14,11 +14,11 @@ Copy Flasher highlights text when you copy it in Obsidian, giving a clear visual
|
|||
|
||||
Select text in Obsidian and copy it. The selected text is highlighted while the copy shortcut is held, then returns to normal when the keys are released.
|
||||
|
||||
For mouse or menu-based copy actions, Copy Flasher uses a short configurable fallback duration because there is no keyboard release event to observe.
|
||||
For mouse or menu-based copy actions, Copy Highlighter uses a short configurable fallback duration because there is no keyboard release event to observe.
|
||||
|
||||
## Settings
|
||||
|
||||
Open **Settings -> Community plugins -> Copy Flasher** to customize:
|
||||
Open **Settings -> Community plugins -> Copy Highlighter** to customize:
|
||||
|
||||
- Highlight color
|
||||
- Editor opacity
|
||||
|
|
@ -30,7 +30,7 @@ Open **Settings -> Community plugins -> Copy Flasher** to customize:
|
|||
|
||||
## Privacy and permissions
|
||||
|
||||
Copy Flasher runs entirely inside Obsidian. It does not collect data, send network requests, read your clipboard contents, or access files directly.
|
||||
Copy Highlighter runs entirely inside Obsidian. It does not collect data, send network requests, read your clipboard contents, or access files directly.
|
||||
|
||||
## Development
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "copy-flasher",
|
||||
"name": "Copy Flasher",
|
||||
"version": "0.1.3",
|
||||
"id": "copy-highlighter",
|
||||
"name": "Copy Highlighter",
|
||||
"version": "0.2.0",
|
||||
"minAppVersion": "0.16.0",
|
||||
"description": "Highlights copied text in Obsidian.",
|
||||
"author": "Nymbo",
|
||||
|
|
|
|||
9
package-lock.json
generated
9
package-lock.json
generated
|
|
@ -1,13 +1,12 @@
|
|||
{
|
||||
"name": "copy-flasher",
|
||||
"version": "0.1.3",
|
||||
"name": "copy-highlighter",
|
||||
"version": "0.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "copy-flasher",
|
||||
"version": "0.1.3",
|
||||
"description": "Highlights copied text in Obsidian.",
|
||||
"name": "copy-highlighter",
|
||||
"version": "0.2.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.6.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "copy-flasher",
|
||||
"version": "0.1.3",
|
||||
"name": "copy-highlighter",
|
||||
"version": "0.2.0",
|
||||
"description": "Highlights copied text in Obsidian.",
|
||||
"main": "main.js",
|
||||
"type": "module",
|
||||
|
|
|
|||
30
src/main.ts
30
src/main.ts
|
|
@ -6,7 +6,7 @@ const LOST_KEYUP_FALLBACK_MS = 5000;
|
|||
const NON_KEYBOARD_COPY_FALLBACK_MS = 650;
|
||||
const MAX_DOM_FLASH_RECTS = 80;
|
||||
|
||||
interface CopyFlasherSettings {
|
||||
interface CopyHighlighterSettings {
|
||||
highlightColor: string;
|
||||
editorOpacity: number;
|
||||
renderedOpacity: number;
|
||||
|
|
@ -23,7 +23,7 @@ type FlashRange = {
|
|||
|
||||
type ClearHighlight = () => void;
|
||||
|
||||
const DEFAULT_SETTINGS: CopyFlasherSettings = {
|
||||
const DEFAULT_SETTINGS: CopyHighlighterSettings = {
|
||||
highlightColor: "#ffd54f",
|
||||
editorOpacity: 0.5,
|
||||
renderedOpacity: 0.46,
|
||||
|
|
@ -37,7 +37,7 @@ const addFlash = StateEffect.define<FlashRange[]>();
|
|||
const clearFlash = StateEffect.define<void>();
|
||||
|
||||
const flashMark = Decoration.mark({
|
||||
class: "copy-flasher-editor-highlight",
|
||||
class: "copy-highlighter-editor-highlight",
|
||||
});
|
||||
|
||||
const flashField = StateField.define<DecorationSet>({
|
||||
|
|
@ -76,7 +76,7 @@ class HighlightSession {
|
|||
private cDown = false;
|
||||
private fallbackTimer: number | null = null;
|
||||
|
||||
constructor(private getSettings: () => CopyFlasherSettings) {}
|
||||
constructor(private getSettings: () => CopyHighlighterSettings) {}
|
||||
|
||||
register(clearHighlight: ClearHighlight) {
|
||||
this.clearers.add(clearHighlight);
|
||||
|
|
@ -208,15 +208,15 @@ function copyFlashExtension(highlightSession: HighlightSession) {
|
|||
];
|
||||
}
|
||||
|
||||
export default class CopyFlasherPlugin extends Plugin {
|
||||
settings: CopyFlasherSettings = DEFAULT_SETTINGS;
|
||||
export default class CopyHighlighterPlugin extends Plugin {
|
||||
settings: CopyHighlighterSettings = DEFAULT_SETTINGS;
|
||||
private highlightSession = new HighlightSession(() => this.settings);
|
||||
private domHighlights = new Set<HTMLElement>();
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
this.applyCssVariables();
|
||||
this.addSettingTab(new CopyFlasherSettingTab(this.app, this));
|
||||
this.addSettingTab(new CopyHighlighterSettingTab(this.app, this));
|
||||
|
||||
this.highlightSession.register(() => {
|
||||
this.clearDomHighlights();
|
||||
|
|
@ -251,8 +251,8 @@ export default class CopyFlasherPlugin extends Plugin {
|
|||
|
||||
onunload() {
|
||||
this.clearDomHighlights();
|
||||
document.body.style.removeProperty("--copy-flasher-editor-background");
|
||||
document.body.style.removeProperty("--copy-flasher-border-radius");
|
||||
document.body.style.removeProperty("--copy-highlighter-editor-background");
|
||||
document.body.style.removeProperty("--copy-highlighter-border-radius");
|
||||
}
|
||||
|
||||
private flashDomSelection(event: ClipboardEvent) {
|
||||
|
|
@ -301,7 +301,7 @@ export default class CopyFlasherPlugin extends Plugin {
|
|||
for (const rect of rects) {
|
||||
const overlay = document.createElement("div");
|
||||
|
||||
overlay.className = "copy-flasher-dom-highlight";
|
||||
overlay.className = "copy-highlighter-dom-highlight";
|
||||
overlay.style.left = `${rect.left + window.scrollX}px`;
|
||||
overlay.style.top = `${rect.top + window.scrollY}px`;
|
||||
overlay.style.width = `${rect.width}px`;
|
||||
|
|
@ -326,7 +326,7 @@ export default class CopyFlasherPlugin extends Plugin {
|
|||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData() as Partial<CopyFlasherSettings>);
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData() as Partial<CopyHighlighterSettings>);
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
|
|
@ -341,18 +341,18 @@ export default class CopyFlasherPlugin extends Plugin {
|
|||
|
||||
private applyCssVariables() {
|
||||
document.body.style.setProperty(
|
||||
"--copy-flasher-editor-background",
|
||||
"--copy-highlighter-editor-background",
|
||||
hexToRgba(this.settings.highlightColor, this.settings.editorOpacity)
|
||||
);
|
||||
document.body.style.setProperty(
|
||||
"--copy-flasher-border-radius",
|
||||
"--copy-highlighter-border-radius",
|
||||
`${this.settings.borderRadius}px`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CopyFlasherSettingTab extends PluginSettingTab {
|
||||
constructor(app: App, private plugin: CopyFlasherPlugin) {
|
||||
class CopyHighlighterSettingTab extends PluginSettingTab {
|
||||
constructor(app: App, private plugin: CopyHighlighterPlugin) {
|
||||
super(app, plugin);
|
||||
}
|
||||
|
||||
|
|
|
|||
10
styles.css
10
styles.css
|
|
@ -1,12 +1,12 @@
|
|||
.copy-flasher-editor-highlight {
|
||||
background-color: var(--copy-flasher-editor-background, rgba(255, 213, 79, 0.5));
|
||||
border-radius: var(--copy-flasher-border-radius, 3px);
|
||||
.copy-highlighter-editor-highlight {
|
||||
background-color: var(--copy-highlighter-editor-background, rgba(255, 213, 79, 0.5));
|
||||
border-radius: var(--copy-highlighter-border-radius, 3px);
|
||||
}
|
||||
|
||||
.copy-flasher-dom-highlight {
|
||||
.copy-highlighter-dom-highlight {
|
||||
position: absolute;
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
background-color: rgba(255, 213, 79, 0.46);
|
||||
border-radius: var(--copy-flasher-border-radius, 3px);
|
||||
border-radius: var(--copy-highlighter-border-radius, 3px);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,6 @@
|
|||
"0.1.0": "0.15.0",
|
||||
"0.1.1": "0.15.0",
|
||||
"0.1.2": "0.16.0",
|
||||
"0.1.3": "0.16.0"
|
||||
"0.1.3": "0.16.0",
|
||||
"0.2.0": "0.16.0"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue