从数据库使用四肢瘦长还原多种选择瘦长、多种、数据库

2023-09-10 18:12:47 作者:偏为你流浪

我想要做的:

- >显示一个普通的HTML页面给用户 - >用户有能力突出的文本在该网页上 - >当用户登录在接下来的时间,我应该能够检索和显示他的previous(多)的亮点在页面上

->Show a plain HTML page to a user ->User has the ability to highlight text on that page ->When user logs in next time , i should be able to retrieve and show his previous (multiple) highlight on the page.

我做了什么:

我用库/ API:四肢瘦长。随着这个IAM能选择文本,并与用户preferred颜色突出显示。

I used the Library/API : Rangy.With this iam able to select the text and highlight it with the users preferred color.

的问题:

我尝试了序列化和反序列化功能,但是当我尝试反序列化(页面被重新加载后),它给了我一个错误说

I tried the serialize and de-serialize function , but when i try to deserialize (after page has been reloaded) it gives me an error saying

连载范围根节点(ec0c8cf0)和目标根校验   节点(d4997863)不匹配

checksums of serialized range root node (ec0c8cf0) and target root node (d4997863) do not match

每次我重新加载页面,有一个新的根节点,如何解决在这种情况下,反序列化?

Everytime i reload the page , there is a new root node , how can i fix the deserialize in this case ?

创建一个JS-小​​提琴:演示 / JS-小提琴

这是什么 - 如果你检查我的演示,我选择的描述,即第一个字请,我得到的高亮显示文本,并且我也得到了序列为:

What is this - If you check my demo , i select the first word of the description ie "Please " , i get the text highlighted , and i also get the serial as :

0/3/1/3/0/1/1/2:9,0 / 3/1/3/0/1/1/2:9 {b3002d92}

0/3/1/3/0/1/1/2:9,0/3/1/3/0/1/1/2:9{b3002d92}

所以我所做的是,我很难codeD这个序列,并把它变成像这样的页面的onLoad功能deserializeSelection功能可按: -

so what i did is , i hard coded this serial and put it into the deserializeSelection funciton in the page onLoad function like this :-

rangy.deserializeSelection('0/3/1/3/0/1/1/2:9,0/3/1/3/0/1/1/2:9{b3002d92}');

所以在技术上,它应该在说明中强调了请,每当页面加载,irrespectively.But没有,反而给我上述错误块。 你能不能帮我解决this.please.Thank你

so technically , it should highlight the "Please" in the description , whenever the page loads , irrespectively.But it does not , instead give me the above error in block. Can you help me solve this.please.Thank you

额外的:

1.我真不明白,四肢瘦长的序列化和反序列化的方法。

1.I really do not understand the serialize and de-serialize methods of rangy.

2.My很抽象的路线图是,做一个AJAX调用,在页面加载和提取所有(连载)用户的选择本页从我的分贝,并在它们之间迭代,做一个反序列化。

2.My very abstract road map from here is to , do an AJAX call , on page load and fetch all (serialized) selection of the user for this page from my db and iterate over them and do a de-serialize.

任何帮助,将是真正的AP preciated。 谢谢你。

Any help , would be really appreciated. Thank you.

推荐答案

我觉得你应该试试这个:

What I think is you should try this:

var selObj = rangy.getSelection();
var se = rangy.serializeSelection(selObj, true); //true to avoid DOM checksum