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

fix: 输入法相关问题 #81

Merged
merged 2 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/defaultEditorOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import FullScreen from './plugin/FullScreen'
import ExtraFormat from './plugin/ExtraFormat'
import RemoveFormat from './plugin/RemoveFormat/RemoveFormat'
import AttachmentUpload from './plugin/AttachmentUpload'
import FixComposing from './plugin/FixComposing'

export default {
plugins: [
Expand Down Expand Up @@ -67,7 +68,8 @@ export default {
FullScreen,
ExtraFormat,
RemoveFormat,
AttachmentUpload
AttachmentUpload,
FixComposing
],
toolbar: [
'undo',
Expand Down
30 changes: 30 additions & 0 deletions src/plugin/FixComposing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @hack 如果哪天崩了要看回 @ckeditor/ckeditor5-engine/src/view/{view|renderer}.js 源码
* 已知负面影响:在线协作功能
*
* 详情看相关 issues & pr:
* - https://github.com/ckeditor/ckeditor5/issues/5877
* - https://github.com/ckeditor/ckeditor5-engine/pull/861
*
* PS:这个可能是更优的方案,如果还有问题的话可以参考
* https://github.com/ckeditor/ckeditor5/issues/5877#issuecomment-566369164
* https://github.com/mycolorway/ckeditor5-engine/commit/7d921207054e327088fe7496a8cde451ddd87423
*/
export default function(editor) {
const {_renderer, document} = editor.editing.view
/**
* 注入 isComposing,在 render 中使用
* @see https://github.com/ckeditor/ckeditor5-engine/pull/861/files#diff-644366cecbdf61171130f59482de38e0R114
*/
_renderer.bind('isComposing').to(document)
const {render} = _renderer
/**
* 输入法进行间停止 render
* https://github.com/ckeditor/ckeditor5-engine/pull/861/files#diff-4c87133ed830fc4ea0646426deba32cfR188
*/
_renderer.render = function() {
// console.log('isComposing', this.isComposing)
if (this.isComposing) return
return render.call(this)
}
}