guardian/scribe

Scribe transactionManager assumes that selection is always inside an editor

オープン

#153 opened on 2014/05/02

 (10 件のコメント) (0 件のリアクション) (0 人の担当者)JavaScript (265 件のフォーク)batch import
bughelp wanted

Repository metrics

Stars
 (3,516 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

Scribe transactionManager assumes that selection is always inside an editor, but this can be wrong. I discovered issues because Scribe was modifying DOM outside editor.

We have the following scenario. User selects text outside the editor and based on that selection we prepopulate editor's content (I simply call jQuery .html(...) on the editor to set the content – should I use something else?). The issue is that as I prepopulate editor's content, mutation observer is triggered which calls transactionManager. And transaction manager calls:

var selection = new this.api.Selection();
selection.placeMarkers();

This places <em/> tags where selection is. But selection is outside the editor, not inside.

I think that code should check if selection is inside the editor element our outside.

コントリビューターガイド