• R/O
  • SSH
  • HTTPS

mantisbtmonitor: Commit


Commit MetaInfo

Revision66 (tree)
Time2021-11-24 04:10:04
Authorderekwildstar

Log Message

Criada a função PrepareCommentForEdition que prepara um comentário para ser usado na sua edição e passado para o TinyMCE via string JS
Criado o método NewComment para facilitar a abertura e edição de novo comentário
Código para uso do POST com o TEdgeBrowser comentado até que eu consiga usá-lo

Change Summary

Incremental Difference

--- trunk/client/prj/MantisBTMonitor.dproj (revision 65)
+++ trunk/client/prj/MantisBTMonitor.dproj (revision 66)
@@ -115,7 +115,7 @@
115115 <VerInfo_MinorVer>0</VerInfo_MinorVer>
116116 <VerInfo_Release>0</VerInfo_Release>
117117 <VerInfo_Locale>1033</VerInfo_Locale>
118- <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.49;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
118+ <VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.104;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
119119 <Debugger_RunParams>/desenvolvimento</Debugger_RunParams>
120120 <VerInfo_AutoGenVersion>false</VerInfo_AutoGenVersion>
121121 <VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
@@ -122,7 +122,7 @@
122122 <DCC_DebugInformation>2</DCC_DebugInformation>
123123 <DCC_SymbolReferenceInfo>2</DCC_SymbolReferenceInfo>
124124 <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
125- <VerInfo_Build>49</VerInfo_Build>
125+ <VerInfo_Build>104</VerInfo_Build>
126126 <DCC_MapFile>3</DCC_MapFile>
127127 </PropertyGroup>
128128 <ItemGroup>
--- trunk/client/src/lib/UScrapFunctions.pas (revision 65)
+++ trunk/client/src/lib/UScrapFunctions.pas (revision 66)
@@ -225,7 +225,7 @@
225225 function TaskDetails(AHandle: Cardinal; var ATask: TTask): Boolean;
226226 function GetAttachmentData(AHandle: Cardinal; AId: Cardinal; out AData: TMemoryStream): Boolean;
227227 function GetCommentForEdition(AHandle: Cardinal; ACommentId: Cardinal; out AComment: String): Boolean;
228-//function GetTinyMCEInitializationCode(AHandle: Cardinal): String;
228+function PrepareCommentForEdition(AComment: String): String;
229229
230230 implementation
231231
@@ -1460,44 +1460,96 @@
14601460
14611461 Req.AutoClearSSLState := True;
14621462
1463- Req.Content := TStringStream.Create('bugnote_id=' + ACommentId.ToString);
1463+ Req.InternetOpenParams.Agent := 'MantisBT Monitor';
1464+ Req.InternetOpenParams.AccessType := INTERNET_OPEN_TYPE_PRECONFIG;
1465+ Req.InternetConnectParams.ServerName := PChar(Configurations.MantisBTBaseUrl + '/mantis/bugnote_edit_page.php?bugnote_id=' + ACommentId.ToString);
1466+ Req.InternetConnectParams.Service := INTERNET_SERVICE_HTTP;
1467+ Req.InternetConnectParams.Context := AHandle;
1468+
1469+ Req.HttpOpenRequestParams.Verb := 'GET';
1470+ Req.HttpOpenRequestParams.AcceptTypes := TStringList.Create;
14641471 try
1465- Req.InternetOpenParams.Agent := 'MantisBT Monitor';
1466- Req.InternetOpenParams.AccessType := INTERNET_OPEN_TYPE_PRECONFIG;
1467- Req.InternetConnectParams.ServerName := PChar(Configurations.MantisBTBaseUrl + '/mantis/bugnote_edit_page.php');
1468- Req.InternetConnectParams.Service := INTERNET_SERVICE_HTTP;
1469- Req.InternetConnectParams.Context := AHandle;
1472+ Req.HttpOpenRequestParams.AcceptTypes.Add('*/*');
1473+ Req.HttpOpenRequestParams.Context := AHandle;
1474+ Req.HttpOpenRequestParams.AutoDetectHTTPS := True;
1475+ Req.HttpOpenRequestParams.IgnoreInvalidCertificates := True;
1476+ Req.HttpOpenRequestParams.Headers := TStringList.Create;
1477+ try
1478+ Req.HttpOpenRequestParams.Headers.Add('Content-Type: application/x-www-form-urlencoded');
1479+ Req.HttpSendRequestParams.IgnoreInvalidCertificateCA := True;
14701480
1471- Req.HttpOpenRequestParams.Verb := 'POST';
1472- Req.HttpOpenRequestParams.AcceptTypes := TStringList.Create;
1473- try
1474- Req.HttpOpenRequestParams.AcceptTypes.Add('*/*');
1475- Req.HttpOpenRequestParams.Context := AHandle;
1476- Req.HttpOpenRequestParams.AutoDetectHTTPS := True;
1477- Req.HttpOpenRequestParams.IgnoreInvalidCertificates := True;
1478- Req.HttpOpenRequestParams.Headers := TStringList.Create;
1481+ Res.Content := TStringStream.Create('',TEncoding.UTF8);
14791482 try
1480- Req.HttpOpenRequestParams.Headers.Add('Content-Type: application/x-www-form-urlencoded');
1481- Req.HttpSendRequestParams.IgnoreInvalidCertificateCA := True;
1483+ Request(Req,Res);
14821484
1483- Res.Content := TStringStream.Create('',TEncoding.UTF8);
1484- try
1485- Request(Req,Res);
1485+ HTMLDocument := coHTMLDocument.Create as IHTMLDocument;
14861486
1487- HTMLDocument := coHTMLDocument.Create as IHTMLDocument;
1487+ (HTMLDocument as IHTMLDocument2).DesignMode := 'On';
1488+ (HTMLDocument as IHTMLDocument2).charset := 'utf-8';
1489+ (HTMLDocument as IHTMLDocument2Disp).Write(TStringStream(Res.Content).DataString);
1490+ (HTMLDocument as IHTMLDocument2).Close;
14881491
1489- (HTMLDocument as IHTMLDocument2).DesignMode := 'On';
1490- (HTMLDocument as IHTMLDocument2).charset := 'utf-8';
1491- (HTMLDocument as IHTMLDocument2Disp).Write(TStringStream(Res.Content).DataString);
1492- (HTMLDocument as IHTMLDocument2).Close;
1492+ AComment := ((HTMLDocument as IHTMLDocument3).getElementById('bugnote_text') as IHTMLElement).innerText;
14931493
1494- AComment := ((HTMLDocument as IHTMLDocument3).getElementById('bugnote_text') as IHTMLElement).innerText;
1494+ Result := True;
1495+ finally
1496+ Res.Content.Free;
1497+ end;
1498+ finally
1499+ Req.HttpOpenRequestParams.Headers.Free;
1500+ end;
1501+ finally
1502+ Req.HttpOpenRequestParams.AcceptTypes.Free;
1503+ end;
1504+ finally
1505+ Screen.Cursor := crDefault;
1506+ end;
1507+end;
1508+{$WARN SYMBOL_PLATFORM ON}
14951509
1496- é necessário trabalhar no innerhtml fazendo o que está explicado abaixo, provavelmente de forma invertida
1497- existem quebras de linha fisicas 1310, que precisam ser transformadas em <br> apenas dentro de tags pre
1498- basicamente o que deve ser feito é dentro dos pre, pegar tudo qu for quebra fisica 1310, 13 10 e converter para <BR>
1499- (*
1510+{$WARN SYMBOL_PLATFORM OFF}
1511+function PrepareCommentForEdition(AComment: String): String;
1512+var
1513+ HTMLDocument: IHTMLDocument;
1514+ HTMLElementCollection: IHTMLElementCollection;
1515+ HTMLElement: IHTMLElement;
1516+begin
1517+ Result := AComment;
15001518
1519+ HTMLDocument := coHTMLDocument.Create as IHTMLDocument;
1520+
1521+ (HTMLDocument as IHTMLDocument2).DesignMode := 'On';
1522+ (HTMLDocument as IHTMLDocument2).charset := 'utf-8';
1523+ (HTMLDocument as IHTMLDocument2Disp).Write(AComment);
1524+ (HTMLDocument as IHTMLDocument2).Close;
1525+
1526+ HTMLElementCollection := (HTMLDocument as IHTMLDocument3).getElementsByTagName('pre');
1527+
1528+ if HTMLElementCollection.length > 0 then
1529+ for var i: Word := 0 to Pred(HTMLElementCollection.length) do
1530+ begin
1531+ HTMLElement := (HTMLElementCollection as IHTMLelementCollection4).item(i) as IHTMLElement;
1532+ HTMLElement.innerHTML := StringReplace(HTMLElement.innerHTML,#13#10,'<br>',[rfReplaceAll]);
1533+ HTMLElement.innerHTML := StringReplace(HTMLElement.innerHTML,#13,'<br>',[rfReplaceAll]);
1534+ HTMLElement.innerHTML := StringReplace(HTMLElement.innerHTML,#10,'<br>',[rfReplaceAll]);
1535+ end;
1536+
1537+ // Como a string com o fonte contém apenas um trecho de HTML, não um HTML
1538+ // completo, o MSHTML automaticamente cria um fonte completo para si e coloca
1539+ // nosso trecho em seu <body>, por isso, para obter o nosso trecho apenas,
1540+ // basta obter o conteúdo do <body> como é visto abaixo
1541+ Result := (HTMLDocument as IHTMLDocument2).body.innerHTML;
1542+ // Como esse conteúdo será processado via string JavaScript, precisamos
1543+ // escapar todas as aspas duplas existentes
1544+ Result := StringReplace(Result,'"','\"',[rfReplaceAll]);
1545+end;
1546+{$WARN SYMBOL_PLATFORM ON}
1547+
1548+// é necessário trabalhar no innerhtml fazendo o que está explicado abaixo, provavelmente de forma invertida
1549+// existem quebras de linha fisicas 1310, que precisam ser transformadas em <br> apenas dentro de tags pre
1550+// basicamente o que deve ser feito é dentro dos pre, pegar tudo qu for quebra fisica 1310, 13 10 e converter para <BR>
1551+ (*
1552+
15011553 Este texto está pré-formatado e pode ser usado para exibir qualquer texto que
15021554 não pode perder'#$D#$A'seu formato, isto é, espaços em branco. Ele é renderizado
15031555 em fonte monoespaçada e precisa ter'#$D#$A'quebras de linha adicionadas de forma
@@ -1508,53 +1560,35 @@
15081560 tags'#$D#$A'PRE, mas o Mantis ignora este fato e termina por incluir quebras de
15091561 linha adicionais, fazendo'#$D#$A'com que hajam duas quebras para cada linha quebrada.
15101562
1511- let html = (new DOMParser()).parseFromString(aEventData.content,"text/html");
1512- let pres = html.getElementsByTagName("pre");
1563+ let html = (new DOMParser()).parseFromString(aEventData.content,"text/html");
1564+ let pres = html.getElementsByTagName("pre");
15131565
1514- // Protege o conteúdo dos tags preformatados convertendo
1515- // tags br ou quebras de linha físicas por um tag
1516- // inexistente. Após este loop apenas vão existir
1517- // quebras de linha físicas fora de tags, as quais serão
1518- // removidas mais adiante.
1519- for (let pre of pres) {
1520- pre.innerHTML = pre.innerHTML.replaceAll("<br>","[br]");
1521- pre.innerHTML = pre.innerHTML.replaceAll("<br />","[br]");
1522- pre.innerHTML = pre.innerHTML.replaceAll("\\r\\n","[br]");
1523- pre.innerHTML = pre.innerHTML.replaceAll("\\r","[br]");
1524- pre.innerHTML = pre.innerHTML.replaceAll("\\n","[br]");
1525- }
1566+ // Protege o conteúdo dos tags preformatados convertendo
1567+ // tags br ou quebras de linha físicas por um tag
1568+ // inexistente. Após este loop apenas vão existir
1569+ // quebras de linha físicas fora de tags, as quais serão
1570+ // removidas mais adiante.
1571+ for (let pre of pres) {
1572+ pre.innerHTML = pre.innerHTML.replaceAll("<br>","[br]");
1573+ pre.innerHTML = pre.innerHTML.replaceAll("<br />","[br]");
1574+ pre.innerHTML = pre.innerHTML.replaceAll("\\r\\n","[br]");
1575+ pre.innerHTML = pre.innerHTML.replaceAll("\\r","[br]");
1576+ pre.innerHTML = pre.innerHTML.replaceAll("\\n","[br]");
1577+ }
15261578
1527- // Serializa o html com os tags protetores
1528- aEventData.content = html.body.innerHTML;
1579+ // Serializa o html com os tags protetores
1580+ aEventData.content = html.body.innerHTML;
15291581
1530- // Remove as quebras de linha físicas que são incluídas
1531- // automaticamente no código html
1532- aEventData.content = aEventData.content.replaceAll("\\r","");
1533- aEventData.content = aEventData.content.replaceAll("\\n","");
1582+ // Remove as quebras de linha físicas que são incluídas
1583+ // automaticamente no código html
1584+ aEventData.content = aEventData.content.replaceAll("\\r","");
1585+ aEventData.content = aEventData.content.replaceAll("\\n","");
15341586
1535- // Substitui os tags protetores pelo seu valor real
1536- aEventData.content = aEventData.content.replaceAll("[br]","\\n");
1587+ // Substitui os tags protetores pelo seu valor real
1588+ aEventData.content = aEventData.content.replaceAll("[br]","\\n");
15371589
1538- *)
1590+ *)
15391591
1540- Result := True;
1541- finally
1542- Res.Content.Free;
1543- end;
1544- finally
1545- Req.HttpOpenRequestParams.Headers.Free;
1546- end;
1547- finally
1548- Req.HttpOpenRequestParams.AcceptTypes.Free;
1549- end;
1550- finally
1551- Req.Content.Free;
1552- end;
1553- finally
1554- Screen.Cursor := crDefault;
1555- end;
1556-end;
1557-{$WARN SYMBOL_PLATFORM ON}
15581592
15591593 { TUserInfo }
15601594
@@ -1745,58 +1779,4 @@
17451779 end;
17461780 end;
17471781
1748-//function GetTinyMCEInitializationCode(AHandle: Cardinal): String;
1749-//var
1750-// Req: TRequestOptions;
1751-// Res: TResponse;
1752-//begin
1753-// Result := '';
1754-//
1755-// Screen.Cursor := crHourGlass;
1756-// try
1757-// ZeroMemory(@Req,SizeOf(Req));
1758-// ZeroMemory(@Res,SizeOf(Res));
1759-//
1760-// Req.AutoClearSSLState := True;
1761-//
1762-// Req.InternetOpenParams.Agent := 'MantisBT Monitor';
1763-// Req.InternetOpenParams.AccessType := INTERNET_OPEN_TYPE_PRECONFIG;
1764-// Req.InternetConnectParams.Service := INTERNET_SERVICE_HTTP;
1765-// Req.InternetConnectParams.Context := AHandle;
1766-//
1767-// Req.HttpOpenRequestParams.Verb := 'GET';
1768-// Req.HttpOpenRequestParams.AcceptTypes := TStringList.Create;
1769-// try
1770-// Req.HttpOpenRequestParams.AcceptTypes.Add('*/*');
1771-// Req.HttpOpenRequestParams.Context := AHandle;
1772-// Req.HttpOpenRequestParams.AutoDetectHTTPS := True;
1773-// Req.HttpOpenRequestParams.IgnoreInvalidCertificates := True;
1774-// Req.HttpSendRequestParams.IgnoreInvalidCertificateCA := True;
1775-//
1776-// Req.InternetConnectParams.ServerName := PChar(Configurations.MantisBTBaseUrl + '/mantis/config/TinyMCEInitializationCode.php');
1777-// Res.Content := TStringStream.Create('',TEncoding.UTF8);
1778-// try
1779-// Request(Req,Res);
1780-//
1781-// Result := (Res.Content as TStringStream).DataString;
1782-// // O código do TinyMCE está ajustado para trabalhar dentro do Mantis e
1783-// // por isso usa caminhos relativos e absolutos de acordo com o servidor
1784-// // do Mantis. Precisamos, pois, usar caminhos absolutos sempre
1785-// Result := StringReplace(Result,'src="js/','src="' + Configurations.MantisBTBaseUrl + '/mantis/js/',[]);
1786-//
1787-// Result := StringReplace(Result,'https://desenvolvimento.tjpe.gov.br/mantis/js/tinymce/tinymce.min.js','https://cdn.tiny.cloud/1/f015pbciy4iq7tzpvossjylof3tpkcy89bmwcdkd321qfsj4/tinymce/5/tinymce.min.js',[]);
1788-//
1789-//
1790-//
1791-// finally
1792-// Res.Content.Free;
1793-// end;
1794-// finally
1795-// Req.HttpOpenRequestParams.AcceptTypes.Free;
1796-// end;
1797-// finally
1798-// Screen.Cursor := crDefault;
1799-// end;
1800-//end;
1801-
18021782 end.
--- trunk/client/src/UDamoPrincipal.pas (revision 65)
+++ trunk/client/src/UDamoPrincipal.pas (revision 66)
@@ -373,7 +373,7 @@
373373 ShowInfoBalloon('Eu sou o ' + Application.Title + ' e irei monitorar as suas tarefas. Dentro de alguns segundos mostrarei suas atribuições. Aguarde...'
374374 ,'Olá ' + Configurations.UserInfo.FirstName + '!');
375375 // teste
376- //TFormIssue.ShowMe(65196);
376+ TFormTask.ShowMe(83766);
377377
378378 StartTasksChecking(Configurations.NotificationTimeOut);
379379 end;
--- trunk/client/src/UDamoTask.pas (revision 65)
+++ trunk/client/src/UDamoTask.pas (revision 66)
@@ -66,6 +66,7 @@
6666 private
6767 { Private declarations }
6868 FTask: TTask;
69+ procedure NewComment;
6970 public
7071 { Public declarations }
7172 procedure EditComment(ACommentId: Cardinal);
@@ -132,7 +133,7 @@
132133
133134 procedure TDamoTask.ACTNNoteNewExecute(Sender: TObject);
134135 begin
135- TFormManageNote.ShowMeModal(TForm(Owner),FTask.Id,0);
136+ NewComment;
136137 end;
137138
138139 procedure TDamoTask.ACTNNoteReplyExecute(Sender: TObject);
@@ -183,9 +184,19 @@
183184 end;
184185
185186 procedure TDamoTask.EditComment(ACommentId: Cardinal);
187+var
188+ Comment: String;
186189 begin
187- if TFormManageNote.ShowMeModal(TForm(Owner),FTask.Id,ACommentId) = mrOk then
188-// Refresh;
190+ if TFormManageNote.ShowMeModal(TForm(Owner),FTask.Id,ACommentId,Comment) = mrOk then
191+ Application.MessageBox('Código para salvar comentário editado','A fazer',MB_ICONINFORMATION);
189192 end;
190193
194+procedure TDamoTask.NewComment;
195+var
196+ Comment: String;
197+begin
198+ if TFormManageNote.ShowMeModal(TForm(Owner),FTask.Id,0,Comment) = mrOk then
199+ Application.MessageBox('Código para salvar novo comentário','A fazer',MB_ICONINFORMATION);
200+end;
201+
191202 end.
--- trunk/client/src/UFormManageNote.pas (revision 65)
+++ trunk/client/src/UFormManageNote.pas (revision 66)
@@ -11,18 +11,18 @@
1111 TFormManageNote = class(TFormBasicDialog)
1212 EDBR: TEdgeBrowser;
1313 procedure EDBRExecuteScript(Sender: TCustomEdgeBrowser; AResult: HRESULT; const AResultObjectAsJson: string);
14+ procedure EDBRCreateWebViewCompleted(Sender: TCustomEdgeBrowser; AResult: HRESULT);
15+ procedure FormCreate(Sender: TObject);
16+ procedure EDBRWebResourceRequested(Sender: TCustomEdgeBrowser; Args: TWebResourceRequestedEventArgs);
1417 procedure EDBRNavigationCompleted(Sender: TCustomEdgeBrowser; IsSuccess: Boolean; WebErrorStatus: TOleEnum);
15- procedure FormShow(Sender: TObject);
16- procedure PNBBSaveClick(Sender: TObject);
1718 private
1819 { Private declarations }
19- FCommentId: Cardinal;
2020 FComment: String;
2121 protected
2222 procedure ValidateOk; override;
2323 public
2424 { Public declarations }
25- class function ShowMeModal(AOwner: TComponent; ATaskNumber, ACommentId: Cardinal): TModalResult; reintroduce;
25+ class function ShowMeModal(AOwner: TComponent; ATaskNumber, ACommentId: Cardinal; out AComment: String): TModalResult; reintroduce;
2626 end;
2727
2828 implementation
@@ -30,10 +30,22 @@
3030 {$R *.dfm}
3131
3232 uses
33- JSON, UFunctions, UScrapFunctions;
33+ JSON, UFunctions, UScrapFunctions, KRK.Internet.WebView2, AxCtrls, EncdDecd;
3434
3535 { TFormManageNote }
3636
37+procedure TFormManageNote.EDBRCreateWebViewCompleted(Sender: TCustomEdgeBrowser; AResult: HRESULT);
38+begin
39+ inherited;
40+ // Adiciona um filtro que, se satisfeito, executa o evento
41+ // OnWebResourceRequested, no qual podemos alterar várias propriedades da
42+ // requisição que está sendo feita, como o método (POST ou GET), cabeçalhos e
43+ // conteúdo da requisição (requerido pelo método POST)
44+// EDBR.AddWebResourceRequestedFilter('*',COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL);
45+
46+ EDBR.Navigate('https://desenvolvimento.tjpe.gov.br/mantis/config/TinyMCEEditor.php');
47+end;
48+
3749 procedure TFormManageNote.EDBRExecuteScript(Sender: TCustomEdgeBrowser; AResult: HRESULT; const AResultObjectAsJson: string);
3850 begin
3951 // A execução de scripts na página atual com ExecuteJavaScript retorna sempre
@@ -45,7 +57,7 @@
4557
4658 if FunctionName = 'getComment' then
4759 begin
48- ShowMessage(GetValue<String>('result'));
60+ FComment := GetValue<String>('result');
4961 inherited ValidateOk;
5062 end
5163
@@ -60,23 +72,102 @@
6072 EDBR.ExecuteScript('setComment("' + FComment + '")');
6173 end;
6274
63-procedure TFormManageNote.FormShow(Sender: TObject);
75+//type
76+// TInterfaceStream = class(TMemoryStream)
77+// public
78+// procedure LoadFromIStream(Source: IStream);
79+// function GetIStream: IStream;
80+// end;
81+//
82+//
83+//Procedure TInterfaceStream.LoadFromIStream(Source : IStream);
84+//var
85+// Adapt : TOLEStream;
86+// Buff : Byte;
87+// I : Integer;
88+//begin
89+//ADapt := TOLEStream.Create(Source);
90+//Adapt.Position := 0;
91+//Self.Clear;
92+//Self.Position := 0;
93+//For I := 0 to Adapt.Size do
94+// begin
95+// Adapt.Read(Buff, 1);
96+// Self.Write(Buff, 1);
97+// end;
98+//Self.Position := 0;
99+//end;
100+//
101+//Function TInterfaceStream.GetIStream : IStream;
102+//var
103+// Adapt : TStreamAdapter;
104+// tPos : UInt64;
105+//begin
106+// Self.Position := 0;
107+// Adapt := TStreamAdapter.Create(Self);
108+//// Adapt.Seek(0, 0, tPos);
109+// Result := Adapt as IStream;
110+//end;
111+
112+
113+procedure TFormManageNote.EDBRWebResourceRequested(Sender: TCustomEdgeBrowser; Args: TWebResourceRequestedEventArgs);
114+//var
115+// r: ICoreWebView2WebResourceRequest;
116+// h: ICoreWebView2HttpRequestHeaders;
117+// S: TStringStream;
118+// i, j: IStream;
119+// x: Uint64;
120+// &IS: TInterfaceStream;
121+// u: Pchar;
64122 begin
65- inherited;
66- EDBR.Navigate('http://desenvolvimento.tjpe.gov.br/mantis/config/TinyMCEEditor.php');
123+// inherited;
124+//
125+// Args.ArgsInterface.Get_Request(r);
126+// r.Get_uri(u);
127+// if u = 'https://desenvolvimento.tjpe.gov.br/favicon.ico' then
128+// exit;
129+//
130+// r.Set_Method('POST');
131+//
132+// var xx: String := EncodeString('comment=deucertoporrra!');
133+//
134+// S := TStringStream.Create(xx);
135+//
136+// &IS := TInterfaceStream.Create;
137+// try
138+// &IS.CopyFrom(S,S.Size);
139+//
140+// i := &IS.GetIStream;
141+// i.SetSize(Length(xx));
142+// r.Set_Content(i);
143+//
144+//
145+// r.Get_Headers(h);
146+// h.SetHeader('content-type','text/plain'{'application/x-www-form-urlencoded'});
147+// h.SetHeader('content-length','23');
148+// finally
149+// &IS.Free;
150+// end;
151+
67152 end;
68153
69-procedure TFormManageNote.PNBBSaveClick(Sender: TObject);
154+procedure TFormManageNote.FormCreate(Sender: TObject);
70155 begin
71-// inherited;
72- EDBR.ExecuteScript('setComment("' + FComment + '")');
156+ inherited;
157+ // Cria a instância interna do WebView2 no TEdgeBrowser, permitindo que os
158+ // métodos Navigate e NavigateToString sejam executados. O método Navigate já
159+ // executa CreateWebView, mas o NavigateToString não. Mantive essa forma de
160+ // utilização apenas para poder explicar isso. O Método CreateWebView dispara
161+ // o evento OnCreateWebViewCompleted, no qual podemos seguramente executar
162+ // Navigate ou NavigateToString
163+ EDBR.CreateWebView;
73164 end;
74165
75-class function TFormManageNote.ShowMeModal(AOwner: TComponent; ATaskNumber, ACommentId: Cardinal): TModalResult;
166+class function TFormManageNote.ShowMeModal(AOwner: TComponent; ATaskNumber, ACommentId: Cardinal; out AComment: String): TModalResult;
76167 begin
77168 with Self.Create(AOwner) do
78169 begin
79- FCommentId := ACommentId;
170+ AComment := '';
80171 FComment := '';
81172
82173 AutoCaption := False;
@@ -84,11 +175,11 @@
84175 Caption := 'Gerenciador de anotações - ' + Application.Title;
85176
86177 if ACommentId > 0 then
87- LABECaption.Caption := 'Editando a anotação #' + IntToStr(FCommentId)
178+ LABECaption.Caption := 'Editando a anotação #' + IntToStr(ACommentId)
88179 else
89180 LABECaption.Caption := 'Redigindo uma nova anotação para a tarefa #' + IntToStr(ATaskNumber);
90181
91- if (ACommentId > 0) and not GetCommentForEdition(Handle,FCommentId,FComment) then
182+ if (ACommentId > 0) and not GetCommentForEdition(Handle,ACommentId,FComment) then
92183 begin
93184 Application.MessageBox('Não foi possível obter o comentário para edição. Por favor, tente novamente!','Erro ao obter o comentário',MB_ICONERROR);
94185 Result := mrAbort;
@@ -95,9 +186,12 @@
95186 end
96187 else
97188 begin
98- FComment := StringReplace(FComment,#13#10,'<br>',[rfReplaceAll]);
99- FComment := StringReplace(FComment,'"','\"',[rfReplaceAll]);
189+ // Caso se consiga usar o TEdgeBrowser com Post, a função abaixo não mais
190+ // será necessária, porque FComment não precisará ser manipulado via
191+ // JavaScript
192+ FComment := PrepareCommentForEdition(FComment);
100193 Result := ShowModal;
194+ AComment := FComment;
101195 end;
102196 end;
103197 end;
Show on old repository browser