[Interest] How to develop a WYSIWYG HTML editor based on QtWebkit?

程梁 chengliang.soft at gmail.com
Thu Aug 9 04:57:53 CEST 2012


I'll try this JS code. In fact, I feel rather confuse about the HTML code
webkit generates.
Say I set content editable and enter some words line by line. Instead of
<p>, webkit's
code (using QWebFrame::toHtml()) is <div> wrapped. I thought it is more
natural to wrap
words line by line with <p>. Of course I could replace all <div>s with
<p>s, but I couldn't
find out which should be <p> and which should be <div>.



2012/8/8 Josiah Bryan <josiahbryan at gmail.com>

> On Tue, Aug 7, 2012 at 11:35 PM, 程梁 <chengliang.soft at gmail.com> wrote:
>
>> Thanks! I saw this example before. There is the same problem as I met.
>> If you clear editing area and type something, you will got some HTML
>> code like:
>>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
>> http://www.w3.org/TR/html4/strict.dtd"><html><head>
>>
>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>>
>> <title>HTML Editor Demo</title>
>>
>> </head><body style="word-wrap: break-word; -webkit-nbsp-mode: space;
>> -webkit-line-break: after-white-space; ">hey</body></html>
>>
>> in which I just write hey and I want to get
>>
>> <p>hey</p>
>>
>> <snip>
>
> If that's the case, I'd just do a simple javascript function to HTML-ize
> everything underneath body. Not sure if this works in WebKit, but a
> javascript call like: document.body.innerHTML() should give you just the
> content of the body. You could wrap it in <p> tags if no tags found in the
> HTML (e.g. just one long string.)
>



-- 
Cheng Liang <http://about.me/devbean>
Nanjing, China
http://www.devbean.info
from: devbean at devbean.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120809/497d0c31/attachment.html>


More information about the Interest mailing list