[Webkit-unassigned] [Bug 35028] New: [Qt] Add selectedHTML function to QWebView
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Feb 17 03:57:32 PST 2010
https://bugs.webkit.org/show_bug.cgi?id=35028
Summary: [Qt] Add selectedHTML function to QWebView
Product: WebKit
Version: 528+ (Nightly build)
Platform: PC
OS/Version: All
Status: NEW
Severity: Enhancement
Priority: P2
Component: WebKit Qt
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: andreas.kling at nokia.com
Original bug report: http://bugreports.qt.nokia.com/browse/QTBUG-5525
toUpper and toLower
This is a feature request, not a bug report. I've been building what I
call a "RichTextEdit", aka a simple text editor built on top of an
editable QWebView. Things like bold, underline, italic all work pretty
well. I need one additional piece of functionality: toUpper and
toLower. There is no built in support for such functionality in
QWebKit, nor do I suggest there necessarily should be. But it would be
nice if there was a way for me to implement it myself. This is what I
do currently:
void RichTextEdit::toUpperCase() { execCommand("insertHTML",
selectedText().toUpper()); }
void RichTextEdit::toLowerCase() { execCommand("insertHTML",
selectedText().toLower()); }
void RichTextEdit::execCommand(const QString &cmd, const QString &arg)
{ QWebFrame *frame = page()->mainFrame(); QString js =
QString("document.execCommand(\"%1\", false, \"%2\")").arg(cmd).arg(arg);
std::string str = js.toStdString(); frame->evaluateJavaScript(js); }
Aka, I use the insertHTML function and simply replace the selected
text. The problem with this is:
1) I'd like to preserve the selection and
2) I lose complex internal formatting within the selection. For
example, if the text was
<b>One</b> Two <b>Three</b> Four <b>Five</b>
Add I select the entire thing and do a toUpper then the result is the
entire text becomes bolded. If I could get at the HTML, do my
modifications, and push that HTML back over the selected html, then
I'd be a very happy camper. I suspect that would work if I simply had
a function like
QString QWebView::sectedHTML()
and if the insertHTML javascript function provided a means to maintain
the selection (aka select the insertion if we're doing a replace).
If there is a way to improve my existing code without modifications to
Qt I'd love to hear about it. :)
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list