Definition of ExecCommand function for bold?

前端 未结 2 1608
囚心锁ツ
囚心锁ツ 2020-12-31 23:23

ExecCommand offers a way to bold text inside iFrame, make it italic, underline it etc.

But it\'s missing an option to create or

相关标签:
2条回答
  • 2020-12-31 23:26

    I researched this problem a year ago and could not found any solution except using regex instead EC on nested tags. I developted my text editor without using ExecCommand.

    0 讨论(0)
  • 2020-12-31 23:45

    I see that CKEditor was mentioned in one of previous comments :) So this is how we handle executing commands:

    • We do everything manually. As you can see DOM API isn't sufficient and implementations differ between browsers, so I guess (but I haven't checked this) that HTML containing some text with applied styles in one browser won't work in other (because one browser applied strong and second b or span with inline style).
    • First of all we need custom Range and Selection implementations. You can't use them, but there's a cool Rangy lib.
    • Next component that you need is set of methods for applying, removing and checking styles. Here's our impl.
    • And the last component is trivial - custom commands, because it's convenient to mimic W3C's APIs and ideas.
    0 讨论(0)
提交回复
热议问题