Skip to content

Commit

Permalink
fix: 输入法相关问题 (#81)
Browse files Browse the repository at this point in the history
* fix: 输入法相关问题

* docs: 补充注释
  • Loading branch information
donaldshen authored Mar 4, 2020
1 parent 3cb459e commit f6a4460
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
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)
}
}

0 comments on commit f6a4460

Please sign in to comment.