Opened 13 years ago

Closed 12 years ago

#622 closed defect (fixed)

new plugin InsertSnippet

Reported by: ray Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords: plugin insert html
Cc:

Description

please have a look at my new plugin:
It can load snippets of HTML from an external file and insert them with one click in Xinha

Attachments (3)

InsertSnippet.zip (6.1 KB) - added by ray 13 years ago.
InsertSnippetv1.1.zip (6.3 KB) - added by ray 13 years ago.
added preview button
InsertSnippet_focus.patch (429 bytes) - added by ray 13 years ago.
added editor.focus()

Download all attachments as: .zip

Change History (11)

Changed 13 years ago by ray

comment:1 Changed 13 years ago by mharrisonline

Wow! It works great!

I can imagine that the page would eventually get really long, will it scroll?

Also, it might be more of a time saver if there was a list of snippets to choose from, that would allow you to either insert or preview. If someone has 20 snippets, they wouldn't want to scroll to number 18 if that was five feet down the page.

comment:2 Changed 13 years ago by ray

You´re right. try the new version.

Changed 13 years ago by ray

added preview button

comment:3 Changed 13 years ago by mharrisonline

Wow! Much better. Will it scroll when the list gets really long? If not you could put the list into a div and assign a class like this to it:

div.scroll {
	height: 200px;
	width: 575px;
	overflow: auto;
	border: 1px solid #666;
	background-color: #FFFFFF;
	padding: 5px;

}

comment:4 Changed 13 years ago by gocher

add to xinha in Changeset 439

comment:5 Changed 13 years ago by ray

yes, it does scroll

comment:6 Changed 13 years ago by mharrisonline

If you click outside of the editor area before clicking on the button to launch the plugin, it will paste the HTML outside the editor. You need the line

editor.focusEditor();

before the HTML is inserted. So, the function:

InsertSnippet.prototype.buttonPress = function(editor) {
		var args = editor.config;
		editor._popupDialog( "plugin://InsertSnippet/insertsnippet", function( param ) {
	
		if ( !param ) { 
	      return false;
	    }
				   	   
		eval(HTMLArea._geturlcontent(editor.config.InsertSnippet.snippets));
		if (param['how'] == 'variable') {
			editor.insertHTML('{'+snippets[param["snippetnum"]].id+'}');
		} else {
			editor.insertHTML(snippets[param["snippetnum"]].HTML);
	   	}
  
    }, args);
  };

would become:

InsertSnippet.prototype.buttonPress = function(editor) {
		var args = editor.config;
		editor._popupDialog( "plugin://InsertSnippet/insertsnippet", function( param ) {
	
		if ( !param ) { 
	      return false;
	    }
				   	   
		eval(HTMLArea._geturlcontent(editor.config.InsertSnippet.snippets));
		editor.focusEditor();
		if (param['how'] == 'variable') {
			editor.insertHTML('{'+snippets[param["snippetnum"]].id+'}');
		} else {
			editor.insertHTML(snippets[param["snippetnum"]].HTML);
	   	}
  
    }, args);
  };

...which stops this from happening.

comment:7 Changed 13 years ago by ray

Ah, I see it´s commited now. I made a patch, so someone with access to svn can patch it.

Changed 13 years ago by ray

added editor.focus()

comment:8 Changed 12 years ago by ray

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.