我正在制作一个基于网络的聊天程序。当用户从聊天记录中选择并复制到剪贴板时,我想更好地控制文本的格式。例如,聊天日志的内容如下:
当用户选择此项并复制到剪贴板时,这是他们得到的内容:
Alice Springs 12:45 PM
Hi this is some text, what's up?
Boo Radley 12:47 PM
Whoa, didn't see ya there... not much.
这实际上并没有那么糟糕,但随着应用程序变得越来越复杂,这将变得越来越模糊。我希望能够更好地控制它,并为基于文本的聊天记录复制更友好的东西:
[12:45] <Alice Springs> Hi this is some text, what's up?
[12:47] <Boo Radley> Whoa, didn't see ya there... not much.
以下是单条消息的标记:
<div class="chatLogMessageEntry">
<div class="avatar"></div>
<div>
<div class="senderName">Boo Radley</div>
<div class="timestamp">12:47 PM</div>
<div class="confirmation"></div>
<div class="message">Whoa, didn't see ya there... not much.</div>
</div>
</div>
这可能吗?这是如何完成的?