简体   繁体   English

在文本中拖放

[英]Drag and drop within a text

Is it possible to drop html element into a text at mouse pointer position, using JQuery? 是否可以使用JQuery将html元素拖放到鼠标指针位置的文本中?

I've been implementing song text editor (yet another...) with drag-and-drop guitar chord positioning. 我一直在通过拖放吉他和弦定位实现歌曲文本编辑器(还有另一个)。 I would click a chord, drag it and drop between lyrics letters . 我将单击一个和弦,将其拖放到歌词字母之间 Lyrics are contentEditable div. 歌词是contentEditable div。

My quick solution was surrounding each letter with a <span class="letter"> tag and make entire song (letters + chords) sortable. 我的快速解决方案是在每个字母周围加上一个<span class="letter">标签,并使整个歌曲(字母和和弦)可排序。 Sortable has cancel attribute for span.letter , so you cannot move letters :-). Sortable具有span.letter cancel属性,因此您不能移动字母:-)。 But it implies maintaining this text structure while editing lyrics and seems not to be so efficient. 但这意味着在编辑歌词时保持这种文本结构,似乎效率不高。

Can I achieve this in a more simple way, particularily without surrounding each letter with a tag? 我能以更简单的方式实现这一点,特别是不用在每个字母周围都加上标签吗?

您可能要尝试使用滑块,每个音符一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM