MyBB Community Forums
re-assign a button in the editor - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Resources (https://community.mybb.com/forum-8.html)
+--- Forum: MyCodes (https://community.mybb.com/forum-117.html)
+--- Thread: re-assign a button in the editor (/thread-241043.html)



re-assign a button in the editor - rozbud - 2024-05-18

Hello All,
Is it possible to re-assign a button in the below editor*, to say "Hello World"?


[Image: ed.png]

* Quick Advanced Editor Plus[url=https://github.com/martec/quickadveditorplus][/url]


RE: re-assign a button in the editor - effone - 2024-05-18

Example js:
// Add SCEditor Command
$.sceditor.command.set('custom_insert_code', {
	exec: custom_insert_code_sce,
	txtExec: custom_insert_code_sce,
	tooltip: "Insert Code"
});

// SCEditor Driver
function custom_insert_code_sce() {
	var code = custom_insert_code();
	if (false !== code) {
		this.insert('[php]' + code + '[/php]');
	}
}

// Custom Function
function custom_insert_code() {
	return "console.log('Success!)";
}

Use CSS to insert the icon in the custom button.


RE: re-assign a button in the editor - rozbud - 2024-05-19

(2024-05-18, 10:35 PM)effone Wrote: Example js:
// Add SCEditor Command
$.sceditor.command.set('custom_insert_code', {
	exec: custom_insert_code_sce,
	txtExec: custom_insert_code_sce,
	tooltip: "Insert Code"
});

// SCEditor Driver
function custom_insert_code_sce() {
	var code = custom_insert_code();
	if (false !== code) {
		this.insert('[php]' + code + '[/php]');
	}
}

// Custom Function
function custom_insert_code() {
	return "console.log('Success!)";
}

Use CSS to insert the icon in the custom button.

Thank you!