Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

应在用户【拖蓝】选择结束后显示摘录框 #28

Open
Zacharia2 opened this issue Sep 9, 2023 · 6 comments
Open

应在用户【拖蓝】选择结束后显示摘录框 #28

Zacharia2 opened this issue Sep 9, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@Zacharia2
Copy link
Contributor

这样可以加快速度,解决在手机上选择文本,一不小心就选到底了的情况。

具体实现:

  1. 用户选择文本,并持续到选择动作结束
  2. 触发监听事件
  3. 显示摘录框。
@Zacharia2
Copy link
Contributor Author

要判断用户是否选择了文本动作,可以使用 JavaScript 中的事件监听器来检测用户的行为。以下是一种常见的判断用户是否选择了文本的方法:

document.addEventListener("mouseup", function(event) {
  var selectedText = window.getSelection().toString();
  
  if (selectedText !== "") {
    // 用户选择了文本
    console.log("用户选择了文本:" + selectedText);
  } else {
    // 用户没有选择文本
    console.log("用户没有选择文本");
  }
});

上述代码中,我们使用了 mouseup 事件来监听用户鼠标松开的动作。在事件处理函数中,我们使用 window.getSelection().toString() 获取用户选择的文本,然后判断是否为空。如果不为空,则表示用户选择了文本,否则表示用户没有选择文本。

你可以根据实际需求修改事件类型和处理逻辑来适应不同的场景。

@Zacharia2
Copy link
Contributor Author

要判断用户是否选择了文本动作,可以使用以下方法:

  1. JS 监听文本选择事件:
document.addEventListener('selectionchange', function() {
  var selection = window.getSelection().toString();
  if (selection.length > 0) {
    // 用户选择了文本动作
    console.log('用户选择了文本动作');
  } else {
    // 用户取消了文本选择
    console.log('用户取消了文本选择');
  }
});

@Zacharia2
Copy link
Contributor Author

@Zacharia2 Zacharia2 changed the title 网页HTML,应在在用户选择文本后显示摘录框(annotation-wrapper) 应在用户【拖蓝】选择结束后显示摘录框 Sep 9, 2023
@Zacharia2
Copy link
Contributor Author

https://github.com/oflg/fishing-catchfish/blob/main/ui/tiddler.tid

fishing-catchfish/ui/ViewTemplate/tiddler

@oflg oflg added the enhancement New feature or request label Sep 9, 2023
@oflg
Copy link
Owner

oflg commented Sep 9, 2023

当前的拖蓝摘录功能基于Dynannotate插件,它插件在5.3.0后新增了一种支持拖蓝结束后延迟显示弹窗的方法。

我是有这个想法,但是目前还没跟上更新哈。

@Zacharia2
Copy link
Contributor Author

嗯嗯,明白啦

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants