Bindza
asked on
Get <p>, <span>, <ul> and <ol> from DHTMLEdit
How can I get the code from a paragraph or span tag in DHTMLEdit?
What I want to do is change a paragraph tag from <p> to somethig like <p style=""> etc... I want to do the same thing with the span, ol and ul tags, but I have no idea how to do this.
Marko
What I want to do is change a paragraph tag from <p> to somethig like <p style=""> etc... I want to do the same thing with the span, ol and ul tags, but I have no idea how to do this.
Marko
ASKER
This is not what I ment, I know how to get and replace all of them, but i need the tag from the current line the caret is in.
mmm...you said --> What I want to do is change a paragraph tag from <p> to somethig like <p style="">....
So please explain better what do you need (maybe with some example)
So please explain better what do you need (maybe with some example)
ASKER
Well I'm trying to make a format paragraph dialog, like in Front Page. It has the align property, then there's indenting and spacing.
This is where I got so far:
procedure TForm1.Button1Click(Sender : TObject);
var
r: IHTMLTxtRange;
begin
r := DHTMLEdit1.DOM.selection.c reateRange as IHTMLTxtRange;
FormatParagraphWin.ShowMod al;
if FormatParagraphWin.ModalRe sult = mrOK then
begin
if FormatParagraphWin.AlignBo x.ItemInde x = 0 then
r.parentElement.style.text Align := ''
else
r.parentElement.style.text Align := FormatParagraphWin.AlignBo x.Items.St rings[Form atParagrap hWin.Align Box.ItemIn dex];
r.parentElement.style.line Height := OleVariant(IntToStr(Format ParagraphW in.SpBox.I temIndex * 50) + '%');
r.parentElement.style. <-- here I wanna add the indent and spacing property, but I don't know how. I want to add these : indent before, indent after, indent first line, spacing before, spacing after and word spacing.
This is where I got so far:
procedure TForm1.Button1Click(Sender
var
r: IHTMLTxtRange;
begin
r := DHTMLEdit1.DOM.selection.c
FormatParagraphWin.ShowMod
if FormatParagraphWin.ModalRe
begin
if FormatParagraphWin.AlignBo
r.parentElement.style.text
else
r.parentElement.style.text
r.parentElement.style.line
r.parentElement.style. <-- here I wanna add the indent and spacing property, but I don't know how. I want to add these : indent before, indent after, indent first line, spacing before, spacing after and word spacing.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help, but I've just solved the problem myself, like this:
procedure TForm1.Button1Click(Sender : TObject);
var
r: IHTMLTxtRange;
begin
if DHTMLEdit1.DOM.selection.t ype_ = 'Text' then
begin
r := DHTMLEdit1.DOM.selection.c reateRange as IHTMLTxtRange;
FormatParagraphWin.ShowMod al;
// set paragraph styles
if FormatParagraphWin.ModalRe sult = mrOK then
begin
if FormatParagraphWin.AlignBo x.ItemInde x = 0 then
r.parentElement.style.text Align := ''
else
r.parentElement.style.text Align := FormatParagraphWin.AlignBo x.Items.St rings[Form atParagrap hWin.Align Box.ItemIn dex];
r.parentElement.style.marg inLeft := OleVariant(FormatParagraph Win.IndBef ore.Value) ;
r.parentElement.style.marg inRight := OleVariant(FormatParagraph Win.IndAft er.Value);
r.parentElement.style.text Indent := OleVariant(FormatParagraph Win.IndFir st.Value);
r.parentElement.style.marg inTop := OleVariant(FormatParagraph Win.SpBefo re.Value);
r.parentElement.style.marg inBottom := OleVariant(FormatParagraph Win.SpAfte r.Value);
r.parentElement.style.word Spacing := OleVariant(FormatParagraph Win.SpWord .Value);
r.parentElement.style.line Height := OleVariant(IntToStr((Forma tParagraph Win.SpBox. ItemIndex + 1)*50) + '%');
// reset dialog controls
with FormatParagraphWin do
begin
IndBefore.Value := 0;
IndAfter.Value := 0;
IndFirst.Value := 0;
AlignBox.ItemIndex := 0;
SpBefore.Value := 0;
SpAfter.Value := 0;
SpWord.Value := 0;
SpBox.ItemIndex := 1;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender
var
r: IHTMLTxtRange;
begin
if DHTMLEdit1.DOM.selection.t
begin
r := DHTMLEdit1.DOM.selection.c
FormatParagraphWin.ShowMod
// set paragraph styles
if FormatParagraphWin.ModalRe
begin
if FormatParagraphWin.AlignBo
r.parentElement.style.text
else
r.parentElement.style.text
r.parentElement.style.marg
r.parentElement.style.marg
r.parentElement.style.text
r.parentElement.style.marg
r.parentElement.style.marg
r.parentElement.style.word
r.parentElement.style.line
// reset dialog controls
with FormatParagraphWin do
begin
IndBefore.Value := 0;
IndAfter.Value := 0;
IndFirst.Value := 0;
AlignBox.ItemIndex := 0;
SpBefore.Value := 0;
SpAfter.Value := 0;
SpWord.Value := 0;
SpBox.ItemIndex := 1;
end;
end;
end;
end;
Solved by yourself?
I hope that it is, because it seems just that you got exactly the needed params after my link post....
BTW good work.
I hope that it is, because it seems just that you got exactly the needed params after my link post....
BTW good work.
ASKER
I've been on that site 100 times and couldn't understand a thing. Thanks for your help anyway. You deserve these points, so I'll give um to you.
Cheers!
Cheers!
var
List: Tstrings;
begin
List := TSTringList.Create;
try
List.LoadFromFile('c:\file
List.Text := STringReplace(List.Text,'<
finally
list.Free;
end;