mirror of
https://github.com/moyf/easy-copy.git
synced 2026-07-22 05:43:47 +00:00
fix: add console warning when paste is preempted, add community-plugins.json hint to tooltip, inline info icon
This commit is contained in:
parent
a34ce4648a
commit
3143de6edf
3 changed files with 16 additions and 5 deletions
|
|
@ -110,7 +110,7 @@ export const translations: Record<Language, Record<TranslationKey, string>> = {
|
|||
'wiki-link': 'Wiki link',
|
||||
'resolve-link-path-on-paste': 'Resolve link path on paste',
|
||||
'resolve-link-path-on-paste-desc': 'Regenerate the link path at paste time based on the destination file. Under "Follow Obsidian settings", uses your vault\'s path style (shortest/relative/absolute); otherwise uses shortest-unique paths only.',
|
||||
'resolve-link-path-on-paste-tooltip': 'Plugins loaded earlier take priority for paste handling. If another plugin (e.g. Linter) intercepts paste first, this feature will be bypassed.',
|
||||
'resolve-link-path-on-paste-tooltip': 'Plugins loaded earlier take priority for paste handling. If another plugin (e.g. Linter) intercepts paste first, this feature will be bypassed. You can adjust plugin load order in the community-plugins.json file.',
|
||||
'customize-targets': 'Customize targets',
|
||||
'customize-targets-desc': 'Enable to customize which elements can be copied (disable to copy all elements)',
|
||||
'enable-inline-code': 'Enable inline code',
|
||||
|
|
@ -211,7 +211,7 @@ export const translations: Record<Language, Record<TranslationKey, string>> = {
|
|||
'wiki-link': 'Wiki链接',
|
||||
'resolve-link-path-on-paste': '粘贴时解析链接路径',
|
||||
'resolve-link-path-on-paste-desc': '粘贴时根据目标文件重新生成链接路径。使用"跟随 Obsidian 设置"时,会沿用软件设置中的路径风格(最短/相对/绝对);否则,仅使用最短唯一路径。',
|
||||
'resolve-link-path-on-paste-tooltip': '越早加载的插件越先处理粘贴事件。若其他插件(如 Linter)抢先处理,本功能会被跳过。',
|
||||
'resolve-link-path-on-paste-tooltip': '越早加载的插件越先处理粘贴事件。若其他插件(如 Linter)抢先处理,本功能会被跳过。可在 community-plugins.json 文件中调整插件加载顺序。',
|
||||
'customize-targets': '自定义复制对象',
|
||||
'customize-targets-desc': '启用后可以自定义哪些元素可以被复制(不启用则默认可复制所有元素)',
|
||||
'enable-inline-code': '启用行内代码',
|
||||
|
|
@ -322,7 +322,7 @@ export const translations: Record<Language, Record<TranslationKey, string>> = {
|
|||
'wiki-link': 'Wiki連結',
|
||||
'resolve-link-path-on-paste': '貼上時解析連結路徑',
|
||||
'resolve-link-path-on-paste-desc': '貼上時根據目標檔案重新生成連結路徑。使用「跟隨 Obsidian 設定」時,會沿用軟體設定中的路徑風格(最短/相對/絕對);否則,僅使用最短唯一路徑。',
|
||||
'resolve-link-path-on-paste-tooltip': '越早載入的外掛越先處理貼上事件。若其他外掛(如 Linter)搶先處理,本功能會被略過。',
|
||||
'resolve-link-path-on-paste-tooltip': '越早載入的外掛越先處理貼上事件。若其他外掛(如 Linter)搶先處理,本功能會被略過。可在 community-plugins.json 檔案中調整外掛載入順序。',
|
||||
'customize-targets': '自定義複製對象',
|
||||
'customize-targets-desc': '啟用後可以自定義哪些元素可以被複製(不啟用則默认可複製所有元素)',
|
||||
'enable-inline-code': '啟用行內代碼',
|
||||
|
|
|
|||
|
|
@ -176,6 +176,13 @@ export default class EasyCopy extends Plugin {
|
|||
*/
|
||||
private handlePaste(evt: ClipboardEvent, editor: Editor, info: MarkdownView | MarkdownFileInfo): void {
|
||||
const clipboardText = evt.clipboardData?.getData('text/plain');
|
||||
|
||||
// 如果有活跃的 meta 且剪贴板内容匹配,但被其他插件抢先处理了,输出提示
|
||||
if (evt.defaultPrevented && this.lastCopyMeta && clipboardText === this.lastCopyMeta.clipboardText) {
|
||||
console.log('[Easy Copy] Paste event was already handled by another plugin. Link path resolution skipped. You can adjust plugin load order in .obsidian/community-plugins.json.');
|
||||
return;
|
||||
}
|
||||
|
||||
const decision = decidePasteResolution({
|
||||
defaultPrevented: evt.defaultPrevented,
|
||||
resolveLinkPathOnPaste: this.settings.resolveLinkPathOnPaste,
|
||||
|
|
|
|||
|
|
@ -130,9 +130,13 @@ export class EasyCopySettingTab extends PluginSettingTab {
|
|||
const descFragment = document.createDocumentFragment();
|
||||
descFragment.append(this.plugin.t('resolve-link-path-on-paste-desc') + ' ');
|
||||
const infoIcon = descFragment.createEl('span', {
|
||||
attr: { 'aria-label': this.plugin.t('resolve-link-path-on-paste-tooltip'), class: 'clickable-icon setting-editor-extra-setting-button' },
|
||||
attr: {
|
||||
'aria-label': this.plugin.t('resolve-link-path-on-paste-tooltip'),
|
||||
'class': 'clickable-icon setting-editor-extra-setting-button',
|
||||
'style': 'display:inline; vertical-align:middle; cursor:help;',
|
||||
},
|
||||
});
|
||||
infoIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>';
|
||||
infoIcon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:middle;"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>';
|
||||
|
||||
setting
|
||||
.setName(this.plugin.t('resolve-link-path-on-paste'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue