Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自动高亮当前单词的行为和风格能否调整下? #27

Closed
tylerlong opened this issue Mar 3, 2015 · 12 comments
Closed

自动高亮当前单词的行为和风格能否调整下? #27

tylerlong opened this issue Mar 3, 2015 · 12 comments

Comments

@tylerlong
Copy link
Contributor

这个问题可能是属于CodeMirror,在这里mark下。

比如 https://pandao.github.io/editor.md/examples/full.html

光标放到 world 这个单词上,当前markdown中所有的world单词都被加上了波浪形的下划线.

我是费了很大劲才明白这个功能是咋回事。 因为一般来讲,编辑器单词下面有下划线, 代表的含义是 当前单词有拼写错误

我研究了两个比较出名的编辑器sublime text和ACE, 它们是这么处理的: 光标放倒单词那里, 并不会触发高亮当前单词; 选中整个单词才会触发。 高亮的风格是单词周围加上一个颜色较浅的框框,而不是波浪形下划线。

@tylerlong
Copy link
Contributor Author

刚才到CodeMirror官网试了下,发现它默认是没有这个特性的。

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

我特别加上的,CodeMirror有这种功能,找出同个单词并标示出来,像Adobe的Brackets就有这样的标示,不过不是用波浪线。
还有红色波浪线是表示有空格,箭头表示Tab缩进等等。像同单词的波浪线,可以通过重新定义CodeMirror的样式来实现自定义src/scss/editormd.codemirror.scss.cm-matchhighlight,如果你不喜欢这样的颜色或线型的话。

@tylerlong
Copy link
Contributor Author

好,我可以自己改CSS。

不过我尝试了Mac版本的Adobe Brackets,没有发现这个特性。即使选中一个单词也没有触发高亮。

我感觉这个特性太过了。 可以改成选中单词再触发。

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

@tylerlong 有些主题或扩展有这样的提示。

@pandao pandao closed this as completed Mar 3, 2015
@tylerlong
Copy link
Contributor Author

http://codemirror.net/demo/matchhighlighter.html

我已经找到问题的开关了:

showToken: /\w/

showToken: false 就可以只在选中才会highlight。

建议做成可配置项。

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

@tylerlong 嗯,可以考虑,先标记一下。

@pandao pandao reopened this Mar 3, 2015
@tylerlong
Copy link
Contributor Author

我马上就PR, 稍等。

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

已经在改了,不过要highlightSelectionMatches : false才能禁用匹配单词。

@tylerlong
Copy link
Contributor Author

我已经提交了 tylingsoft/markdown-plus@dfe197e?diff=split#diff-0e9de32597dadf1ade9f6c3fde902e21

我的编辑器貌似把你的换行符都给替换了。 导致太多替换,github不显示diff。我就不提交PR了。
你是在Windows开发的吧?

我改的也是默认保持原有行为不变。

https://github.com/tylerlong/editor.markdown/blob/master/src/js/editormd.js#L86

https://github.com/tylerlong/editor.markdown/blob/master/src/js/editormd.js#L436

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

嗯。现在变成有三种选项:

  • highlightSelectionMatches : false 完全不匹配相同单词;
  • highlightSelectionMatches : {showToken: /\w/} 自动匹配相同单词,选取时也匹配;
  • highlightSelectionMatches : {showToken: false} 不自动匹配相同单词,选取时才匹配;

@tylerlong
Copy link
Contributor Author

👍 👌

期待新版本

@pandao
Copy link
Owner

pandao commented Mar 3, 2015

Improved @v1.1.8.

{
     matchWordHighlight : false // or "onselected"
}

@pandao pandao closed this as completed Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants