Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2009-11-16 22:59:22

rain
New member
Registered: 2009-11-13
Posts: 4

How can I write a new plug-in for Xinha by myself?

Hi all,

I'm a junior web developer, for now I'm working on an CMS project using Xinha as the text editor. Recently, we want to add a new button in the tool bar to embed video codes into articles, I think it can be implemented as a new plug-in. Even I've hacked the insert link and image plug-in before, I find it is difficult for me to write a new plug-in by myself.

I'd like the new pug-in works like this:
1.click the button, pop up a new window with a textarea for inputing and a frame for preview video
2.after click the OK button, the video codes will be inserted into the article
3.an image will be displayed instead of the video while editing the article
4.change the position of the video by moving the image in the article
5.add right click menu for the image, same as the click the icon in the tool bar
6.while viewing the article in some pages, it will show the real video

Are there any guidelines or references for me somewhere? For now, I'm blocked in adding this image. How can I add such image?

Thanks!
rain

Offline

#2 2009-11-17 00:25:19

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: How can I write a new plug-in for Xinha by myself?

Look at InsertSmiley plugin in the latest svn trunk version of Xinha, it is a good example of how to make a plugin I think :-)


James Sleeman

Offline

#3 2009-11-17 00:31:18

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: How can I write a new plug-in for Xinha by myself?

As for swapping between image and video, you could make your plugin have inwardHtml() and outwardHtml() methods, inwardHtml() takes html and converts it to what xinha works with (take your video, convert to image), outwardHtml() takes html and converts it to what you wan tin the end (take the image, convert to video). 

Both deal with a plain html string, so you would use regular expression.

  myPlugin.prototype.inwardHtml = function(html)
  {
     // change html to replace the video with picture
     return html;
  }

  myPlugin.prototype.outwardHtml = function(html)
  {
     // change html to replace the picture with video
     return html;
  }

James Sleeman

Offline

#4 2009-11-17 00:47:47

rain
New member
Registered: 2009-11-13
Posts: 4

Re: How can I write a new plug-in for Xinha by myself?

Hi gogo,

Thanks for your quick reply! I will try it.

rain

Offline

Board footer

Powered by FluxBB