1 unit fpWebToolsUnit;
2 
3 {$mode objfpc}{$H+}
4 
5 interface
6 
7 uses
8   Classes, SysUtils,
9   // LCL
10   LCLType, LResources, Forms, Controls, Dialogs,
11   // BuildIntf
12   ProjectIntf, NewItemIntf,
13   // IdeIntf
14   MenuIntf, SrcEditorIntf, IDECommands;
15 
16 type
17 
18    { THtmlFileDescriptor }
19 
20    THtmlFileDescriptor = class(TProjectFileDescriptor)
21    public
22      constructor Create; override;
GetLocalizedNamenull23      function GetLocalizedName: string; override;
GetLocalizedDescriptionnull24      function GetLocalizedDescription: string; override;
GetResourceSourcenull25      function GetResourceSource(const ResourceName: string): string; override;
CreateSourcenull26      function CreateSource(const Filename, SourceName,
27                            ResourceName: string): string; override;
28      procedure UpdateDefaultPascalFileExtension(const DefPasExt: string); override;
29    end;
30 
31    { TJSFileDescriptor }
32 
33    TJSFileDescriptor = class(TProjectFileDescriptor)
34    public
35      constructor Create; override;
GetLocalizedNamenull36      function GetLocalizedName: string; override;
GetLocalizedDescriptionnull37      function GetLocalizedDescription: string; override;
GetResourceSourcenull38      function GetResourceSource(const ResourceName: string): string; override;
CreateSourcenull39      function CreateSource(const Filename, SourceName,
40                            ResourceName: string): string; override;
41      procedure UpdateDefaultPascalFileExtension(const DefPasExt: string); override;
42    end;
43 
44    { TCSSFileDescriptor }
45 
46    TCSSFileDescriptor = class(TProjectFileDescriptor)
47    public
48      constructor Create; override;
GetLocalizedNamenull49      function GetLocalizedName: string; override;
GetLocalizedDescriptionnull50      function GetLocalizedDescription: string; override;
GetResourceSourcenull51      function GetResourceSource(const ResourceName: string): string; override;
CreateSourcenull52      function CreateSource(const Filename, SourceName,
53                            ResourceName: string): string; override;
54      procedure UpdateDefaultPascalFileExtension(const DefPasExt: string); override;
55    end;
56 
57 procedure Register;
58 
59 //---
60 procedure ProcHTMLTextBold(Sender: TObject);
61 procedure ProcHTMLTextItalic(Sender: TObject);
62 procedure ProcHTMLTextUnderline(Sender: TObject);
63 procedure ProcHTMLHR(Sender: TObject);
64 procedure ProcHTMLBR(Sender: TObject);
65 procedure ProcHTMLNBSP(Sender: TObject);
66 procedure ProcHTMLComment(Sender: TObject);
67 procedure ProcHTMLLink(Sender: TObject);
68 procedure ProcHTMLImageTag(Sender: TObject);
69 procedure ProcHTMLTextAlignLeft(Sender: TObject);
70 procedure ProcHTMLTextAlignRight(Sender: TObject);
71 procedure ProcHTMLTextAlignCenter(Sender: TObject);
72 procedure ProcHTMLTextAlignJustify(Sender: TObject);
73 
74 //--
75 procedure ProcHTMLTable(Sender: TObject);
76 procedure ProcHTMLGenList(Sender: TObject);
77 
78 procedure ProcHTMLTableRow(Sender: TObject);
79 procedure ProcHTMLTableData(Sender: TObject);
80 
81 procedure ProcHTMLTableRowWD(Sender: TObject);
82 procedure ProcHTMLTableDataWD(Sender: TObject);
83 
84 //-- Styles
85 procedure ProcHTMLDIVBlock(Sender: TObject);
86 procedure ProcHTMLSpanText(Sender: TObject);
87 procedure ProcHTMLPre(Sender: TObject);
88 procedure ProcHTMLSub(Sender: TObject);
89 procedure ProcHTMLSuper(Sender: TObject);
90 procedure ProcHTMLColor(Sender: TObject);
91 procedure ProcHTMLTextHeader1(Sender: TObject);
92 procedure ProcHTMLTextHeader2(Sender: TObject);
93 procedure ProcHTMLTextHeader3(Sender: TObject);
94 procedure ProcHTMLTextHeader4(Sender: TObject);
95 procedure ProcHTMLTextHeader5(Sender: TObject);
96 
97 procedure ProcHTMLForm(Sender: TObject);
98 procedure ProcHTMLSelect(Sender: TObject);
99 procedure ProcHTMLSelectOptions(Sender: TObject);
100 procedure ProcHTMLSelectOptionsWD(Sender: TObject);
101 procedure ProcHTMLCheckButton(Sender: TObject);
102 procedure ProcHTMLRadioButton(Sender: TObject);
103 procedure ProcHTMLButton(Sender: TObject);
104 procedure ProcHTMLInputTag(Sender: TObject);
105 procedure ProcHTMLInputSubmitTag(Sender: TObject);
106 procedure ProcHTMLInputResetTag(Sender: TObject);
107 procedure ProcHTMLFormFieldSet(Sender: TObject);
108 procedure ProcHTMLFormLegend(Sender: TObject);
109 
110 procedure ProcOtherInsertFileName(Sender: TObject);
111 
112 procedure InsertTextToCurEditor(const S:string);
113 
114 implementation
115 
116 uses
117   //HTML
118   fpWebNewHTMLFileUnit, fpWebStrConsts, fpWebNewHtmlTableUnit,
119   fpwebNewHTMLListUnit, fpwebNewHtmlTagTRUnit, fpwebNewHTMLFormUnit,
120   fpwebNewHTMLInputUnit, fpwebNewHTMLImgUnit, fpWebNewHtmlTagPreUnit,
121   fpWebHREFEditUnit, fpWebSelectOptionsUnit, fpWebSelectTagUnit,
122   fpWebHtmlTagLegendUnit,  fpWebFieldSetTagUnit, fpwebNewHtmlTagTDUnit,
123   //Other
124   fpIDEExtEditorInsertFileNameUnit;
125 
126 var
127   //Standart items
128   CmdHTMLBold : TIDECommand;
129   CmdHTMLItalic : TIDECommand;
130   CmdHTMLUnderline : TIDECommand;
131   //----
132   CmdHTMLBR : TIDECommand;
133   //Paragraph
134   CmdHTMLNBSP : TIDECommand;
135   //----
136   CmdHTMLLink    : TIDECommand ;
137   CmdHTMLIMG : TIDECommand;
138   CmdHTMLHR : TIDECommand;
139   CmdHTMLComment : TIDECommand;
140   //----
141   CmdHTMLTextAlignLeft : TIDECommand;
142   CmdHTMLTextAlignRight : TIDECommand;
143   CmdHTMLTextAlignCenter : TIDECommand;
144   CmdHTMLTextAlignJustify : TIDECommand;
145   //Span text
146 
147   CmdHTMLTable : TIDECommand;
148   CmdHTMLList : TIDECommand;
149 
150   CmdHTMLTableRow : TIDECommand;
151   CmdHTMLTableData : TIDECommand;
152 
153   CmdHTMLTableRowWD : TIDECommand;
154   CmdHTMLTableDataWD : TIDECommand;
155 
156   //Styles
157   CmdHTMLDIVBlock    : TIDECommand;
158   CmdHTMLSpanText    : TIDECommand;
159   CmdHTMLPre         : TIDECommand;
160   CmdHTMLSub         : TIDECommand;
161   CmdHTMLSuper       : TIDECommand;
162   CmdHTMLColor       : TIDECommand;
163   CmdHTMLTextStyleH1 : TIDECommand;
164   CmdHTMLTextStyleH2 : TIDECommand;
165   CmdHTMLTextStyleH3 : TIDECommand;
166   CmdHTMLTextStyleH4 : TIDECommand;
167   CmdHTMLTextStyleH5 : TIDECommand;
168 
169   CmdHTMLFrom             : TIDECommand;
170   CmdHTMLFormSelect       : TIDECommand;
171   CmdHTMLFormSelectOpt    : TIDECommand;
172   CmdHTMLFormSelectOptWD  : TIDECommand;
173   CmdHTMLFormCheckBtn     : TIDECommand;
174   CmdHTMLFormRadioBtn     : TIDECommand;
175   CmdHTMLFormButton       : TIDECommand;
176   CmdHTMLInput            : TIDECommand;
177   CmdHTMLInputSubmit      : TIDECommand;
178   CmdHTMLInputReset       : TIDECommand;
179   CmdHTMLFormFieldSet     : TIDECommand;
180   CmdHTMLFormLegend       : TIDECommand;
181 
182   CmdOtherInsFileName : TIDECommand;
183 
184 procedure CreateHTMLToolsMenu;
185 var
186   Key: TIDEShortCut;
187   Cat: TIDECommandCategory;
188   mnuHTMLMain : TIDEMenuSection;
189   mnuHTMLSection : TIDEMenuSection;
190 
191   mnuHTMLStandart : TIDEMenuSection;
192   mnuHTMLStyles : TIDEMenuSection;
193   mnuHTMLTables : TIDEMenuSection;
194   mnuHTMLLists : TIDEMenuSection;
195   mnuHTMLForms : TIDEMenuSection;
196   mnuHTMLOther : TIDEMenuSection;
197 begin
198   Key:=IDEShortCut(VK_UNKNOWN,[],VK_UNKNOWN,[]);
199 
200   Cat:=IDECommandList.CreateCategory(nil, 'HTMLEditor', SmiHTMLEditor,
201     IDECmdScopeSrcEditOnly);
202   //--
203   CmdHTMLBold := RegisterIDECommand(Cat, 'HTMLTable', SmiHTMLTextBold, Key, nil, @ProcHTMLTextBold);
204   CmdHTMLItalic := RegisterIDECommand(Cat, 'HTMLTable', SmiHTMLTextItalic, Key, nil, @ProcHTMLTextItalic);
205   CmdHTMLUnderline := RegisterIDECommand(Cat, 'HTMLTable', SmiHTMLTextUnderline, Key, nil, @ProcHTMLTextUnderline);
206   CmdHTMLBR := RegisterIDECommand(Cat, 'HTMLBR', SmiHTMLInsertBR, Key, nil, @ProcHTMLBR);
207   //Para
208   CmdHTMLNBSP := RegisterIDECommand(Cat, 'HTMLNBSP', SmiHTMLInsertBR, Key, nil, @ProcHTMLNBSP);
209 
210   CmdHTMLHR := RegisterIDECommand(Cat, 'HTMLHR', SmiHTMLInsertHR, Key, nil, @ProcHTMLHR);
211   CmdHTMLComment := RegisterIDECommand(Cat, 'HTMLComment', SmiHTMLInsertComment, Key, nil, @ProcHTMLComment);
212   CmdHTMLIMG := RegisterIDECommand(Cat, 'HTMLIMG', SmiHTMLInsertIMG, Key, nil, @ProcHTMLImageTag);
213   CmdHTMLLink:= RegisterIDECommand(Cat, 'HTMLLink', SmiHTMLInsertLink, Key, nil, @ProcHTMLLink);
214 
215   CmdHTMLTextAlignLeft :=RegisterIDECommand(Cat, 'HTMLTextAlignLeft', SmiHTMLTextAlignLeft, Key, nil, @ProcHTMLTextAlignLeft);
216   CmdHTMLTextAlignRight :=RegisterIDECommand(Cat, 'HTMLTextAlignRight', SmiHTMLTextAlignRight, Key, nil, @ProcHTMLTextAlignRight);
217   CmdHTMLTextAlignCenter :=RegisterIDECommand(Cat, 'HTMLTextAlignCenter', SmiHTMLTextAlignCenter, Key, nil, @ProcHTMLTextAlignCenter);
218   CmdHTMLTextAlignJustify :=RegisterIDECommand(Cat, 'HTMLTextAlignJustify', SmiHTMLTextAlignJustify, Key, nil, @ProcHTMLTextAlignJustify);
219 
220   //--
221   CmdHTMLTable := RegisterIDECommand(Cat, 'HTMLTable', SmiHTMLInsertTable, Key, nil, @ProcHTMLTable);
222   CmdHTMLList := RegisterIDECommand(Cat, 'HTMLList', SmiHTMLInsertList, Key, nil, @ProcHTMLGenList);
223 
224   CmdHTMLTableRow := RegisterIDECommand(Cat, 'HTMLTableRow', SmiHTMLInsertTableRow, Key, nil, @ProcHTMLTableRow);
225   CmdHTMLTableData := RegisterIDECommand(Cat, 'HTMLTableData', SmiHTMLInsertTableData, Key, nil, @ProcHTMLTableData);
226 
227   CmdHTMLTableRowWD  := RegisterIDECommand(Cat, 'HTMLTableRowWD', SmiHTMLInsertTableRowWD, Key, nil, @ProcHTMLTableRowWD);
228   CmdHTMLTableDataWD := RegisterIDECommand(Cat, 'HTMLTableDataWD', SmiHTMLInsertTableDataWD, Key, nil, @ProcHTMLTableDataWD);
229 
230   //Styles
231   CmdHTMLDIVBlock    := RegisterIDECommand(Cat, 'HTMLDIVBlock', SmiHTMLInsertDIVBlock, Key, nil, @ProcHTMLDIVBlock);
232   CmdHTMLSpanText    := RegisterIDECommand(Cat, 'HTMLSpanText', SmiHTMLInsertSpanText, Key, nil, @ProcHTMLSpanText);
233   CmdHTMLPre         := RegisterIDECommand(Cat, 'HTMLPre', SmiHTMLInsertPre, Key, nil, @ProcHTMLPre);
234   CmdHTMLSub         := RegisterIDECommand(Cat, 'HTMLSub', SmiHTMLInsertSub, Key, nil, @ProcHTMLSub);
235   CmdHTMLSuper       := RegisterIDECommand(Cat, 'HTMLSuper', SmiHTMLInsertSuper, Key, nil, @ProcHTMLSuper);
236   CmdHTMLColor       := RegisterIDECommand(Cat, 'HTMLColor', SmiHTMLInsertColor, Key, nil, @ProcHTMLColor);
237   CmdHTMLTextStyleH1 := RegisterIDECommand(Cat, 'HTMLTextStyleH1', SmiHTMLInsertHeader1Level, Key, nil, @ProcHTMLTextHeader1);
238   CmdHTMLTextStyleH2 := RegisterIDECommand(Cat, 'HTMLTextStyleH2', SmiHTMLInsertHeader2Level, Key, nil, @ProcHTMLTextHeader2);
239   CmdHTMLTextStyleH3 := RegisterIDECommand(Cat, 'HTMLTextStyleH3', SmiHTMLInsertHeader3Level, Key, nil, @ProcHTMLTextHeader3);
240   CmdHTMLTextStyleH4 := RegisterIDECommand(Cat, 'HTMLTextStyleH4', SmiHTMLInsertHeader4Level, Key, nil, @ProcHTMLTextHeader4);
241   CmdHTMLTextStyleH5 := RegisterIDECommand(Cat, 'HTMLTextStyleH5', SmiHTMLInsertHeader5Level, Key, nil, @ProcHTMLTextHeader5);
242 
243 
244   //Forms---
245   CmdHTMLFrom := RegisterIDECommand(Cat, 'HTMLForm', SmiHTMLInsertForm, Key, nil, @ProcHTMLForm);
246   CmdHTMLFormSelect      := RegisterIDECommand(Cat, 'HTMLFormSelect', SmiHTMLFormSelect, Key, nil, @ProcHTMLSelect);
247   CmdHTMLFormSelectOpt   := RegisterIDECommand(Cat, 'HTMLFormSelectOpt', SmiHTMLFormSelectOpt, Key, nil, @ProcHTMLSelectOptionsWD);
248   CmdHTMLFormSelectOptWD := RegisterIDECommand(Cat, 'HTMLFormSelectOptWD', SmiHTMLFormSelectOptWD, Key, nil, @ProcHTMLSelectOptions);
249   CmdHTMLFormCheckBtn    := RegisterIDECommand(Cat, 'HTMLFormCheckBtn', SmiHTMLFormCheckBox, Key, nil, @ProcHTMLCheckButton);
250   CmdHTMLFormRadioBtn    := RegisterIDECommand(Cat, 'HTMLFormRadioBtn', SmiHTMLFormRadioBtn, Key, nil, @ProcHTMLRadioButton);
251   CmdHTMLFormButton      := RegisterIDECommand(Cat, 'HTMLFormButton', SmiHTMLFormButtton, Key, nil, @ProcHTMLButton);
252   CmdHTMLInput           := RegisterIDECommand(Cat, 'HTMLInput', SmiHTMLInsertInput, Key, nil, @ProcHTMLInputTag);
253   CmdHTMLInputSubmit     := RegisterIDECommand(Cat, 'HTMLInputSubmit', SmiHTMLInsertInputSubmit, Key, nil, @ProcHTMLInputSubmitTag);
254   CmdHTMLInputReset      := RegisterIDECommand(Cat, 'HTMLInputReset', SmiHTMLInsertInputReset, Key, nil, @ProcHTMLInputResetTag);
255   CmdHTMLFormFieldSet    := RegisterIDECommand(Cat, 'HTMLFormFieldSet', SmiHTMLFormFieldSet, Key, nil, @ProcHTMLFormFieldSet);
256   CmdHTMLFormLegend      := RegisterIDECommand(Cat, 'HTMLFormLegend', SmiHTMLFormLegend, Key, nil, @ProcHTMLFormLegend);
257   CmdHTMLFrom := RegisterIDECommand(Cat, 'HTMLForm', SmiHTMLInsertForm, Key, nil, @ProcHTMLForm);
258   CmdHTMLInput:= RegisterIDECommand(Cat, 'HTMLInput', SmiHTMLInsertInput, Key, nil, @ProcHTMLInputTag);
259   CmdHTMLInputSubmit := RegisterIDECommand(Cat, 'HTMLInputSubmit', SmiHTMLInsertInputSubmit, Key, nil, @ProcHTMLInputSubmitTag);
260   CmdHTMLInputReset := RegisterIDECommand(Cat, 'HTMLInputReset', SmiHTMLInsertInputReset, Key, nil, @ProcHTMLInputResetTag);
261 
262   CmdOtherInsFileName:=RegisterIDECommand(Cat, 'OtherInsFN', SmiOtherInsertFN, Key, nil, @ProcOtherInsertFileName);
263 
264   //  mnuHTMLMain := RegisterIDEMenuRoot('HTML');//RegisterIDEMenuSection(itmCustomTools, 'HTMLEditor');
265   mnuHTMLMain := RegisterIDEMenuSection(mnuMain, 'HTMLEditor');
266 
267   mnuHTMLSection:=RegisterIDESubMenu(mnuHTMLMain, 'HTMLEditor', SmiHTMLEditor, nil, nil);
268 
269   mnuHTMLStandart := RegisterIDESubMenu(mnuHTMLSection, 'HTMLStandart', SmiHTMLStandart, nil, nil);
270     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLBold', SmiHTMLTextBold, nil, nil, CmdHTMLBold, 'tag_bold');
271     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLItalic', SmiHTMLTextItalic, nil, nil, CmdHTMLItalic, 'tag_i');
272     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLUnderline', SmiHTMLTextUnderline, nil, nil, CmdHTMLUnderline, 'tag_u');
273     RegisterIDEMenuCommand(mnuHTMLStandart, '', '-', nil, nil, nil, '');
274     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLBR', SmiHTMLInsertBR, nil, nil, CmdHTMLBR, 'tag_br');
275     //Paragraph
276     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLNBSP', SmiHTMLInsertNBSP, nil, nil, CmdHTMLNBSP, 'tag_nbsp');
277     RegisterIDEMenuCommand(mnuHTMLStandart, '', '-', nil, nil, nil, '');
278     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLLink', SmiHTMLInsertLink, nil, nil, CmdHTMLLink, 'tag_a');
279     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLIMG', SmiHTMLInsertIMG, nil, nil, CmdHTMLIMG, 'tag_image');
280     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLHR', SmiHTMLInsertHR, nil, nil, CmdHTMLHR, 'tag_hr');
281     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLComment', SmiHTMLInsertComment, nil, nil, CmdHTMLComment, 'tag_comm');
282     RegisterIDEMenuCommand(mnuHTMLStandart, '', '-', nil, nil, nil, '');
283     //--
284     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLTextAlignLeft', SmiHTMLTextAlignLeft, nil, nil, CmdHTMLTextAlignLeft, 'div_left');
285     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLTextAlignRight', SmiHTMLTextAlignRight, nil, nil, CmdHTMLTextAlignRight, 'div_right');
286     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLTextAlignCenter', SmiHTMLTextAlignCenter, nil, nil, CmdHTMLTextAlignCenter, 'div_center');
287     RegisterIDEMenuCommand(mnuHTMLStandart, 'HTMLTextAlignJustify', SmiHTMLTextAlignJustify, nil, nil, CmdHTMLTextAlignJustify, 'div_justify');
288     //Span text
289 
290   //List's
291   mnuHTMLLists := RegisterIDESubMenu(mnuHTMLSection, 'HTMLLists', SmiHTMLLists, nil, nil);
292     RegisterIDEMenuCommand(mnuHTMLLists, 'HTMLList', SmiHTMLInsertList, nil, nil,
293       CmdHTMLList, 'HTMLList');
294 
295   //Style's
296   mnuHTMLStyles :=RegisterIDESubMenu(mnuHTMLSection, 'HTMLStyle', SmiHTMLStyle, nil, nil);
297     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLDIVBlock', SmiHTMLInsertDIVBlock, nil, nil, CmdHTMLDIVBlock, 'div_justify');
298     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLSpanText', SmiHTMLInsertSpanText, nil, nil, CmdHTMLSpanText, 'tag_font');
299     RegisterIDEMenuCommand(mnuHTMLStyles, '', '-', nil, nil, nil, '');
300     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLPre', SmiHTMLInsertPre, nil, nil, CmdHTMLPre, 'tag_pre');
301     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLSub', SmiHTMLInsertSub, nil, nil, CmdHTMLSub, 'tag_sub');
302     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLSuper', SmiHTMLInsertSuper, nil, nil, CmdHTMLSuper, 'tag_sup');
303     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLColor', SmiHTMLInsertColor, nil, nil, CmdHTMLColor, 'color-picker');
304     RegisterIDEMenuCommand(mnuHTMLStyles, '', '-', nil, nil, nil, '');
305     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLTextHeader1', SmiHTMLInsertHeader1Level, nil, nil, CmdHTMLTextStyleH1, 'tag_h1');
306     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLTextHeader2', SmiHTMLInsertHeader2Level, nil, nil, CmdHTMLTextStyleH2, 'tag_h2');
307     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLTextHeader3', SmiHTMLInsertHeader3Level, nil, nil, CmdHTMLTextStyleH3, 'tag_h3');
308     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLTextHeader4', SmiHTMLInsertHeader4Level, nil, nil, CmdHTMLTextStyleH4, 'tag_h4');
309     RegisterIDEMenuCommand(mnuHTMLStyles, 'HTMLTextHeader5', SmiHTMLInsertHeader5Level, nil, nil, CmdHTMLTextStyleH5, 'tag_h5');
310 
311   //Table menus
312   mnuHTMLTables := RegisterIDESubMenu(mnuHTMLSection, 'HTMLTables', SmiHTMLTables, nil, nil);
313     RegisterIDEMenuCommand(mnuHTMLTables, 'HTMLTable', SmiHTMLInsertTable, nil, nil,
314       CmdHTMLTable, 'quick_table');
315     RegisterIDEMenuCommand(mnuHTMLTables, 'HTMLTableRow', SmiHTMLInsertTableRow, nil, nil,
316       CmdHTMLTableRow, 'tag_tr');
317     RegisterIDEMenuCommand(mnuHTMLTables, 'HTMLTableData', SmiHTMLInsertTableData, nil, nil,
318       CmdHTMLTableData, 'tag_td');
319     RegisterIDEMenuCommand(mnuHTMLTables, 'HTMLTableRowWD', SmiHTMLInsertTableRowWD, nil, nil,
320       CmdHTMLTableRowWD, 'tag_table_row');
321     RegisterIDEMenuCommand(mnuHTMLTables, 'HTMLTableDataWD', SmiHTMLInsertTableDataWD, nil, nil,
322       CmdHTMLTableDataWD, 'tag_table_data');
323 
324 
325   //Forms menu
326   mnuHTMLForms := RegisterIDESubMenu(mnuHTMLSection, 'HTMLForms', SmiHTMLForms, nil, nil);
327     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLForm', SmiHTMLInsertForm, nil, nil, CmdHTMLFrom, 'HTMLForm');
328     RegisterIDEMenuCommand(mnuHTMLForms, '', '-', nil, nil, nil, '');
329     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormSelect', SmiHTMLFormSelect, nil, nil, CmdHTMLFormSelect, 'select');
330     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormSelectOpt', SmiHTMLFormSelectOpt, nil, nil, CmdHTMLFormSelectOpt, 'tag_li');
331     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormSelectOptWD', SmiHTMLFormSelectOptWD, nil, nil, CmdHTMLFormSelectOptWD, 'tag_li');
332     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormCheckBtn', SmiHTMLFormCheckBox, nil, nil, CmdHTMLFormCheckBtn, 'check');
333     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormRadioBtn', SmiHTMLFormRadioBtn, nil, nil, CmdHTMLFormRadioBtn, 'radio');
334     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormButton', SmiHTMLFormButtton, nil, nil, CmdHTMLFormButton, 'button');
335     RegisterIDEMenuCommand(mnuHTMLForms, '', '-', nil, nil, nil, '');
336     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLInput', SmiHTMLInsertInput, nil, nil, CmdHTMLInput, 'lineedit');
337     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLInputSubmit', SmiHTMLInsertInputSubmit, nil, nil, CmdHTMLInputSubmit, 'submit');
338     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLInputReset', SmiHTMLInsertInputReset, nil, nil, CmdHTMLInputReset, 'reset');
339     RegisterIDEMenuCommand(mnuHTMLForms, '', '-', nil, nil, nil, '');
340     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormFieldSet', SmiHTMLFormFieldSet, nil, nil, CmdHTMLFormFieldSet, 'tag_element');
341     RegisterIDEMenuCommand(mnuHTMLForms, 'HTMLFormLegend', SmiHTMLFormLegend, nil, nil, CmdHTMLFormLegend, 'tag_attribute');
342 
343   //Other tools
344   mnuHTMLOther :=RegisterIDESubMenu(mnuHTMLSection, 'HTMLOther', SmiHTMLOther, nil, nil);
345     RegisterIDEMenuCommand(mnuHTMLOther, 'OtherInsFN', SmiOtherInsertFN, nil, nil,
346       CmdOtherInsFileName, '');
347 
348 end;
349 
350 procedure Register;
351 begin
352   RegisterNewItemCategory(TNewIDEItemCategory.Create(SHtmlDesign));
353   RegisterProjectFileDescriptor(THtmlFileDescriptor.Create, SHtmlDesign);
354   RegisterProjectFileDescriptor(TJSFileDescriptor.Create, SHtmlDesign);
355   RegisterProjectFileDescriptor(TCSSFileDescriptor.Create, SHtmlDesign);
356 
357   CreateHTMLToolsMenu;
358 end;
359 
360 Procedure InsertHTMLSnippet(Const AText : String);
361 begin
362   if Assigned(SourceEditorManagerIntf) and Assigned(SourceEditorManagerIntf.ActiveEditor) then
363     With SourceEditorManagerIntf.ActiveEditor do
364       Selection:=AText;
365 end;
366 
CheckEditornull367 Function CheckEditor : Boolean;
368 begin
369   Result:=Assigned(SourceEditorManagerIntf) and Assigned(SourceEditorManagerIntf.ActiveEditor);
370 end;
371 
372 Procedure InsertHTMLTag(Const ATag : String; Const AAttribute : String = '');
373 begin
374   If CheckEditor then
375     With SourceEditorManagerIntf.ActiveEditor do
376       if (AAttribute='') then
377         Selection:='<'+ATag+'>'+Selection+'</'+ATag+'>'
378       else
379         Selection:='<'+ATag+' '+AAttribute+' >'+Selection+'</'+ATag+'>';
380 end;
381 
ShowEditInputTagFormnull382 function ShowEditInputTagForm(const ATagType:string; const ADefValue:string = ''):string;
383 begin
384   If Not CheckEditor then Exit;
385   With TFpwebNewHTMLInputForm.Create(Application) do
386     try
387       cbType.Text:=ATagType;
388       if ADefValue<>'' then
389         edtValue.Text:=ADefValue
390       else
391         edtValue.Text:=SourceEditorManagerIntf.ActiveEditor.Selection;
392       if ShowModal = mrOk then
393         InsertHTMLSnippet(HtmlText);
394     finally
395       Free;
396     end;
397 end;
398 
399 procedure ProcHTMLTableRow(Sender: TObject);
400 begin
401   InsertHTMLTag('tr');
402 end;
403 
404 procedure ProcHTMLTableData(Sender: TObject);
405 begin
406   InsertHTMLTag('td');
407 end;
408 
409 procedure ProcHTMLTextHeader1(Sender: TObject);
410 begin
411   InsertHTMLTag('H1');
412 end;
413 
414 procedure ProcHTMLTextHeader2(Sender: TObject);
415 begin
416   InsertHTMLTag('H2');
417 end;
418 
419 procedure ProcHTMLTextHeader3(Sender: TObject);
420 begin
421   InsertHTMLTag('H3');
422 end;
423 
424 procedure ProcHTMLTextHeader4(Sender: TObject);
425 begin
426   InsertHTMLTag('H4');
427 end;
428 
429 procedure ProcHTMLTextHeader5(Sender: TObject);
430 begin
431   InsertHTMLTag('H5');
432 end;
433 
434 procedure ProcHTMLTextBold(Sender: TObject);
435 begin
436   InsertHTMLTag('strong');
437 end;
438 
439 procedure ProcHTMLTextItalic(Sender: TObject);
440 begin
441   InsertHTMLTag('em');
442 end;
443 
444 procedure ProcHTMLTextUnderline(Sender: TObject);
445 begin
446   InsertHTMLTag('u');
447 end;
448 
449 procedure ProcHTMLHR(Sender: TObject);
450 begin
451   InsertHTMLSnippet('<HR>');
452 end;
453 
454 procedure ProcHTMLBR(Sender: TObject);
455 begin
456   InsertHTMLSnippet('<BR>');
457 end;
458 
459 procedure ProcHTMLNBSP(Sender: TObject);
460 begin
461   InsertHTMLSnippet(' &nbsp; ');
462 end;
463 
464 procedure ProcHTMLTextAlignLeft(Sender: TObject);
465 begin
466   InsertHTMLTag('div','align="left"');
467 end;
468 
469 procedure ProcHTMLTextAlignRight(Sender: TObject);
470 begin
471   InsertHTMLTag('div','align="right"');
472 end;
473 
474 procedure ProcHTMLTextAlignCenter(Sender: TObject);
475 begin
476   InsertHTMLTag('div','align="center"');
477 end;
478 
479 procedure ProcHTMLTextAlignJustify(Sender: TObject);
480 begin
481   InsertHTMLTag('div','align="justify"');
482 end;
483 
484 procedure ProcHTMLComment(Sender: TObject);
485 begin
486   If Not CheckEditor then Exit;
487   with SourceEditorManagerIntf.ActiveEditor do
488     Selection:='<!-- '+Selection+' -->';
489 end;
490 
491 procedure ProcHTMLDIVBlock(Sender: TObject);
492 begin
493   If Not CheckEditor then Exit;
494   With TfpWebNewHtmlTagPreForm.Create(Application) do
495   try
496     if ShowModal = mrOk then
497       InsertHTMLSnippet(HtmlText(SourceEditorManagerIntf.ActiveEditor.Selection));
498   finally
499     Free;
500   end;
501 end;
502 
503 procedure ProcHTMLSpanText(Sender: TObject);
504 begin
505   { TODO : Необходимо добавить окно диалога с запросом параметров - события/стили }
506   InsertHTMLTag('SPAN');
507 end;
508 
509 procedure ProcHTMLPre(Sender: TObject);
510 begin
511   InsertHTMLTag('pre');
512 end;
513 
514 procedure ProcHTMLSub(Sender: TObject);
515 begin
516   InsertHTMLTag('sub');
517 end;
518 
519 procedure ProcHTMLSuper(Sender: TObject);
520 begin
521   InsertHTMLTag('sup');
522 end;
523 
524 procedure ProcHTMLColor(Sender: TObject);
525 var
526   Dlg:TColorDialog;
527 begin
528   If Not CheckEditor then Exit;
529   Dlg:=TColorDialog.Create(Application);
530   try
531     if Dlg.Execute then
532       InsertHTMLSnippet('#'+IntToHex(Dlg.Color,6));
533   finally
534     Dlg.Free;
535   end;
536 end;
537 
538 procedure ProcHTMLTable(Sender: TObject);
539 begin
540   If Not CheckEditor then Exit;
541   With TfpWebNewHtmlTableForm.Create(Application) do
542     try
543       if ShowModal = mrOk then
544          InsertHTMLSnippet(HtmlText);
545     finally
546       fpWebNewHtmlTableForm.Free;
547     end;
548 end;
549 
550 procedure ProcHTMLGenList(Sender: TObject);
551 begin
552   If Not CheckEditor then Exit;
553   With TfpWebNewHTMLListForm.Create(Application) do
554     try
555       if ShowModal = mrOk then
556          InsertHTMLSnippet(HtmlText);
557     finally
558       Free;
559     end;
560 end;
561 
562 procedure ProcHTMLTableRowWD(Sender: TObject);
563 begin
564   If Not CheckEditor then Exit;
565   With TfpWebNewHtmlTagTRForm.Create(Application) do
566     try
567       if ShowModal = mrOk then
568          InsertHTMLSnippet(HtmlText);
569     Finally
570       Free;
571     end
572 end;
573 
574 procedure ProcHTMLTableDataWD(Sender: TObject);
575 begin
576   If Not CheckEditor then Exit;
577   With TfpwebNewHtmlTagTDForm.Create(Application) do
578   try
579     edtText.Text:=SourceEditorManagerIntf.ActiveEditor.Selection;
580     if ShowModal = mrOk then
581       InsertHTMLSnippet(HtmlText);
582   finally
583     Free;
584   end;
585 end;
586 
587 procedure ProcHTMLForm(Sender: TObject);
588 begin
589   If Not CheckEditor then Exit;
590   With TfpWebNewHTMLFormForm.Create(Application) do
591     try
592       if ShowModal = mrOk then
593         InsertHTMLSnippet(HtmlText(SourceEditorManagerIntf.ActiveEditor.Selection));
594     finally
595       Free;
596     end;
597 end;
598 
599 {procedure ProcHTMLInputTag(Sender: TObject);
600 begin
601   If Not CheckEditor then Exit;
602   With TfpWebNewHTMLInputForm.Create(Application) do
603     try
604       if ShowModal = mrOk then
605          InsertHTMLSnippet(HtmlText);
606     finally
607       Free;
608     end;
609 end;}
610 
611 
612 procedure ProcHTMLImageTag(Sender: TObject);
613 begin
614   If Not CheckEditor then Exit;
615   With TfpWebNewHTMLImgForm.Create(Application) do
616     try
617       if ShowModal = mrOk then
618        InsertHTMLSnippet(HtmlText);
619     finally
620       Free;
621     end;
622 end;
623 
624 procedure ProcHTMLSelect(Sender: TObject);
625 begin
626   If Not CheckEditor then Exit;
627   With TfpWebSelectTagForm.Create(Application) do
628     try
629       edtName.Text:=SourceEditorManagerIntf.ActiveEditor.Selection;
630       if ShowModal = mrOk then
631         InsertHTMLSnippet(HtmlText);
632     finally
633       Free;
634     end;
635 end;
636 
637 procedure ProcHTMLSelectOptions(Sender: TObject);
638 begin
639   InsertHTMLTag('option');
640 end;
641 
642 procedure ProcHTMLSelectOptionsWD(Sender: TObject);
643 begin
644   If Not CheckEditor then exit;
645   With TfpWebSelectOptionsForm.Create(Application) do
646     try
647       edtCaption.Text:=SourceEditorManagerIntf.ActiveEditor.Selection;
648       if ShowModal = mrOk then
649          InsertHTMLSnippet(HtmlText);
650     finally
651       Free;
652     end;
653 end;
654 
655 procedure ProcHTMLCheckButton(Sender: TObject);
656 begin
657   ShowEditInputTagForm('checkbox');
658 end;
659 
660 procedure ProcHTMLRadioButton(Sender: TObject);
661 begin
662   ShowEditInputTagForm('radio');
663 end;
664 
665 procedure ProcHTMLButton(Sender: TObject);
666 begin
667   ShowEditInputTagForm('button');
668 end;
669 
670 procedure ProcHTMLInputTag(Sender: TObject);
671 begin
672   ShowEditInputTagForm('');
673 end;
674 
675 procedure ProcHTMLInputSubmitTag(Sender: TObject);
676 begin
677   ShowEditInputTagForm('submit', SHTMLTagCaptionSubmit);
678 end;
679 
680 procedure ProcHTMLInputResetTag(Sender: TObject);
681 begin
682   ShowEditInputTagForm('reset', SHTMLTagCaptionReset);
683 end;
684 
685 procedure ProcHTMLFormFieldSet(Sender: TObject);
686 begin
687   If Not CheckEditor then exit;
688   With TfpWebFieldSetTagForm.Create(Application) do
689     try
690       if ShowModal = mrOk then
691         InsertHTMLSnippet(HtmlText(SourceEditorManagerIntf.ActiveEditor.Selection));
692     Finally
693       Free;
694     end;
695 end;
696 
697 procedure ProcHTMLFormLegend(Sender: TObject);
698 begin
699   If Not CheckEditor then exit;
700   With TfpWebHtmlTagLegendForm.Create(Application) do
701     try
702       edtCaption.Text:=SourceEditorManagerIntf.ActiveEditor.Selection;
703       if ShowModal = mrOk then
704         InsertHTMLSnippet(HtmlText);
705     finally
706       Free;
707     end;
708 end;
709 
710 procedure ProcHTMLLink(Sender: TObject);
711 begin
712   If Not CheckEditor then exit;
713   With TfpWebHREFEditForm.Create(Application) do
714     try
715       edtLinkText.Text:=SourceEditorManagerIntf.ActiveEditor.Selection;
716       if ShowModal = mrOk then
717         InsertHTMLSnippet(HtmlText);
718     finally
719       Free;
720     end;
721 end;
722 
723 
724 procedure ProcOtherInsertFileName(Sender: TObject);
725 begin
726   With TfpIDEExtEditorInsertFileNameForm.Create(Application) do
727     try
728       if ShowModal = mrOk then
729         InsertHTMLSnippet(SelectedFile);
730     finally
731       Free;
732     end;
733 end;
734 
735 procedure InsertTextToCurEditor(const S: string);
736 var
737   i:integer;
738 begin
739   { TODO -oalexs : Add code for positiopn cursor to position of char |, also insert curent selection into new string at position of %s }
740 
741 {  if Assigned(SourceEditorManagerIntf) and Assigned(SourceEditorManagerIntf.ActiveEditor) then
742   begin
743     if Pos('|', S)
744     SourceEditorManagerIntf.ActiveEditor.Selection:=fpWebIDEExtEditorInsertFileNameForm.SelectedFile;
745   end;}
746 end;
747 
748 { THtmlFileDescriptor }
749 
750 constructor THtmlFileDescriptor.Create;
751 begin
752   inherited Create;
753   Name:='Html file';
754   DefaultFilename:='index.html';
755   DefaultResFileExt:='';
756   DefaultFileExt:='.html';
757   VisibleInNewDialog:=true;
758 end;
759 
GetLocalizedNamenull760 function THtmlFileDescriptor.GetLocalizedName: string;
761 begin
762   Result:=SHtmlFile;
763 end;
764 
GetLocalizedDescriptionnull765 function THtmlFileDescriptor.GetLocalizedDescription: string;
766 begin
767   Result:=SHtmlFileDesc;
768 end;
769 
THtmlFileDescriptor.GetResourceSourcenull770 function THtmlFileDescriptor.GetResourceSource(const ResourceName: string): string;
771 begin
772   Result:='';
773 end;
774 
CreateSourcenull775 function THtmlFileDescriptor.CreateSource(const Filename, SourceName,
776   ResourceName: string): string;
777 begin
778   Result:='';
779   fpWebNewHTMLFileForm:=TfpWebNewHTMLFileForm.Create(Application);
780   if fpWebNewHTMLFileForm.ShowModal = mrOk then
781   begin
782     Result:=fpWebNewHTMLFileForm.HtmlText;
783   end;
784   fpWebNewHTMLFileForm.Free;
785 end;
786 
787 procedure THtmlFileDescriptor.UpdateDefaultPascalFileExtension(
788   const DefPasExt: string);
789 begin
790   //inherited UpdateDefaultPascalFileExtension(DefPasExt);
791 end;
792 
793 { TJSFileDescriptor }
794 
795 constructor TJSFileDescriptor.Create;
796 begin
797   inherited Create;
798   Name:='Java script file';
799   DefaultFilename:='functions.js';
800   DefaultResFileExt:='';
801   DefaultFileExt:='.js';
802   VisibleInNewDialog:=true;
803 end;
804 
GetLocalizedNamenull805 function TJSFileDescriptor.GetLocalizedName: string;
806 begin
807   Result:=SJSFile;
808 end;
809 
GetLocalizedDescriptionnull810 function TJSFileDescriptor.GetLocalizedDescription: string;
811 begin
812   Result:=SJSFileDesc;
813 end;
814 
GetResourceSourcenull815 function TJSFileDescriptor.GetResourceSource(const ResourceName: string): string;
816 begin
817   Result:='';
818 end;
819 
TJSFileDescriptor.CreateSourcenull820 function TJSFileDescriptor.CreateSource(const Filename, SourceName,
821   ResourceName: string): string;
822 begin
823   Result:='/* '+SJSSource+ '*/';
824 end;
825 
826 procedure TJSFileDescriptor.UpdateDefaultPascalFileExtension(
827   const DefPasExt: string);
828 begin
829   //
830 end;
831 
832 { TCSSFileDescriptor }
833 
834 constructor TCSSFileDescriptor.Create;
835 begin
836   inherited Create;
837   Name:='CSS file';
838   DefaultFilename:='styles.css';
839   DefaultResFileExt:='';
840   DefaultFileExt:='.css';
841   VisibleInNewDialog:=true;
842 end;
843 
TCSSFileDescriptor.GetLocalizedNamenull844 function TCSSFileDescriptor.GetLocalizedName: string;
845 begin
846   Result:=SCSSFile;
847 end;
848 
GetLocalizedDescriptionnull849 function TCSSFileDescriptor.GetLocalizedDescription: string;
850 begin
851   Result:=SCSSFileDesc;
852 end;
853 
TCSSFileDescriptor.GetResourceSourcenull854 function TCSSFileDescriptor.GetResourceSource(const ResourceName: string): string;
855 begin
856   Result:='';
857 end;
858 
CreateSourcenull859 function TCSSFileDescriptor.CreateSource(const Filename, SourceName,
860   ResourceName: string): string;
861 begin
862   Result:='/* '+SCSSSource+' */';
863 end;
864 
865 procedure TCSSFileDescriptor.UpdateDefaultPascalFileExtension(
866   const DefPasExt: string);
867 begin
868   //
869 end;
870 
871 end.
872 
873