There are several wysiwyg editors available, but I am researching it's implementation from scratch.
execCommand("removeformat") doesn't strip certain tags (h2) but works with (b, em). We can strip each tag.
For example we have
12345
we can select "234" and usind window.getSelection()
we could transform it to
1
234
5
But there is a lot of edge cases. And it is hard to check every case.
If we have a nested DOM structure, it’s difficult to tell using text nodes which tag should be copied from and to which if we select "hello" here.
3 hello 5
the output will could be
3
hello
5
If we selected whole text node we can remove some tags.
123
to
123
It is quite hard to understand how we convert these nodes especially when we selected several text nodes.
We can get text nodes using this approach How to get nodes lying inside a range with javascript?
Are there any libraries that provides those methods
bold, unbold text and removeFormatting or an algorithm.
0 comments:
Post a Comment
Thanks