EmberJSでこれを達成しようとしています。あなたが見ることができるように上記の画像でテキストをハイライトしてポップアップウィジェットに送信します。
、ユーザーは、いくつかのテキストをハイライト表示することができ、mouseup
イベント時に、ウィジェットは、いくつかのアイコンがポップアップ表示されます。私はハイライトされたテキストを表示するウィジェットで同じことを達成したい。
これは私がこれまでに得たものである:
export default Component.extend({
classNames: ['widgetText'],
didDrag: false,
startDragPosition: null,
endDragPosition: null,
getSelected() {
if (window.getSelection) {
return window.getSelection().toString();
} else if (document.selection) {
return document.selection.createRange().text;
}
return '';
},
mouseUp(e) {
if (this.get('startDragPosition') && this.get('didDrag')) {
this.set('endDragPosition', { left: e.pageX, top: e.pageY });
const selection = this.getSelected();
console.log(selection); //I'm able to print my selection, I want this to be sent to a widget and position the widget...?
}
this.setProperties({ didDrag: false, startDragPosition: null, endDragPosition: null });
},
mouseMove() {
this.set('didDrag', true);
},
mouseDown(e) {
this.set('startDragPosition', { left: e.pageX, top: e.pageY });
},
私はhighlighted text
を取得し、それをログ慰めることができるんだけど、私はウィジェットを開き、正確にそれを配置する方法についてこだわっています選択したテキストをそのウィジェット内に表示します。