Jump to content

Recommended Posts

Posted
Hi

I wrote this component

A professional editor that takes advantage of the capabilities of TinyMCE

Two of my problem, I need your help

1.Component of the output html text for what to do, the following


 


Function TUniXTinyMCE.GetPlainText: String;

begin

  // Result:=  UniSession. Query['????????']; Or Other Solution

End;

 

2.The problem with this view is not the first time, but the time to update the page with the error go away


 


Grateful


 


----


Component Body


----


 


Unit UniXTinyMCE;

Interface

Uses

  SysUtils, Classes, Controls,

  Ext, ExtPascal, ExtForm,

  UniGUIBaseClasses, UniGUIClasses,

  UniPageControl,

  UniGUIApplication,

  UniGUIUtils, ExtPascalUtils,

  uniHTMLFrame, uniGUIServer, UniGUIForm;

Const

  PackageVersion = '1.1.0';

 

Type

  TMyExtButton = Class(TExtButton);

 

  TButtonList = Record

    JSName: String;

    OnClick: TNotifyEvent;

  End;

 

  TUniXTinyMCE = Class(TUniHTMLFrame)

  Private

    { Private declarations }

    Function GetVersion: String;

 

  Protected

    { Protected declarations }

 

  Public

    { Public declarations }

    Constructor Create(Owner: TComponent); Override;

    Destructor Destroy; Override;

    Procedure Loaded; Override;

    procedure SetHtmlText(HtmlText: string);

    Function GetPlainText: String;

 

  Published

    { Published declarations }

    Property Vesrion: String Read GetVersion;

  End;

 

Procedure Register;

 

Implementation

 

Function GetWindowJSName: String;

Var

  I: Integer;

  C: TList;

  UF: TUniForm;

  FC: TClass;

Begin

  Result := '';

 

  FC := UniSession.MainFormClass;

  C := UniSession.FormsList;

  For I := 0 To C.Count - 1 Do

  Begin

    UF := TUniForm(C);

    If SameText(UF.ClassName, FC.ClassName) Then

    Begin

      Result := UF.WebForm.ExtForm.JSName;

      Exit;

    End;

  End;

End;

 

// ------------------------------------------------------------------------------

Procedure Register;

Begin

  RegisterComponents('uniGUI Editor', [TUniXTinyMCE]);

End;

 

// ------------------------------------------------------------------------------

 

Constructor TUniXTinyMCE.Create(Owner: TComponent);

Begin

  Inherited;

 

End;

 

// ------------------------------------------------------------------------------

Destructor TUniXTinyMCE.Destroy;

Begin

  Inherited;

End;

 

// ------------------------------------------------------------------------------

Function TUniXTinyMCE.GetPlainText: String;

begin

  // Result:=  UniSession. Query['????????']; Or Other Solution

End;

 

// -------------------------------------------------------------------------------

procedure TUniXTinyMCE.SetHtmlText(HtmlText: string);

begin

  UniSession.AddJS('tinyMCE.get("ed1").setContent(' + StrToJS(HtmlText) + ')');

 

end;

 

// ------------------------------------------------------------------------------

Function TUniXTinyMCE.GetVersion: String;

Begin

  Result := PackageVersion;

End;

 

// ------------------------------------------------------------------------------

Procedure TUniXTinyMCE.Loaded;

 

var

  FilesFolder: String;

Begin

  Inherited;

 

  If Not WebMode Then

    Exit;

 

  FilesFolder := StringReplace

    (IncludeTrailingBackslash(uniGUIServer.UniServerInstance.FilesFolder), '\',

    '/', [RfReplaceAll]);

 

  If uniGUIServer.UniServerInstance.CustomFiles.IndexOf

    (FilesFolder + 'tiny_mce/tiny_mce.js') < 0 Then

  begin

    uniGUIServer.UniServerInstance.CustomFiles.Add

      (FilesFolder + 'tiny_mce/tiny_mce.js');

 

    self.HTML.Clear;

    self.HTML.Add

      ('<textarea id="ed1" style="width: 100%; height: 100%;"></textarea>');

    self.HTML.Add('<script>');

    self.HTML.Add('tinyMCE.init({');

    self.HTML.Add('theme : "advanced",');

    self.HTML.Add

      ('plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu'

      + ',paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",');

    self.HTML.Add

      ('theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",');

    self.HTML.Add

      ('theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",');

    self.HTML.Add

      ('theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",');

    self.HTML.Add

      ('theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",');

    self.HTML.Add('theme_advanced_toolbar_location : "top",');

    self.HTML.Add('theme_advanced_toolbar_align : "left",');

    self.HTML.Add('theme_advanced_statusbar_location : "bottom",');

    self.HTML.Add('theme_advanced_resizing : true,');

    self.HTML.Add

      ('extended_valid_elements : "img[class=myclass|!src|border:0|alt|title|width|height]",');

    self.HTML.Add('mode: "exact",');

    self.HTML.Add('elements : "ed1"');

    self.HTML.Add('});');

    self.HTML.Add('</script>');

 

  End;

End;

 

End.

UniXTinyMCE.rar

Posted
1.Component of the output html text for what to do, the following

 

Function TUniXTinyMCE.GetPlainText: String;
begin
  // Result:=  UniSession. Query['????????']; Or Other Solution
End;

 

Do you want something like this:

UniSession.AddJS('ajaxRequest(MainForm.form, "mce", ["text="+encodeURIComponent(tinyMCE.get("ed1").getContent())])');

? (see here)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...