Sample Javascript Code for tinymce init

Kakao Share

Testing for javscript code is not issue for frontend working

(function () {
	tinymce.PluginManager.add('init', function( editor ) {
		// Replace window manager.
		editor.on('init', function() {
			// Add Shortcut key for full screen
			editor.addShortcut('f11', 'template', () => {
				editor.execCommand('mceFullScreen');
			});
			// Add Shortcut key for anchor
			editor.addShortcut('alt+shift+k', 'pop-up anchor', () => {
				editor.execCommand('mceAnchor');
			});
			// Add Shortcut key for date
			editor.addShortcut('alt+shift+i', 'insert Date', () => {
				var weekdays = ['일', '월', '화', '수', '목', '금', '토'];
				const today24 = new Date(); //today
				var cur_yyyy = today24.getFullYear(); 
				var cur_mm = ("0" + (today24.getMonth() + 1)).slice(-2);
				var cur_dd = ("0" + today24.getDate()).slice(-2);
				var cur_wd = weekdays[today24.getDay()];
				var timestamp = cur_yyyy + "-" + cur_mm + "-" + cur_dd + "(" + cur_wd + ")";
				editor.execCommand('mceInsertContent', false, timestamp);	
			});
			// Add Shortcut key for rest api 
			editor.addShortcut('alt+p', 'Rest API Shortcode', () => {
				var resetapi_shortcode = "Error fetching data"
				editor.execCommand('mceInsertContent', false, resetapi_shortcode);
			});
			// Add Shortcut key for split
			editor.addShortcut('alt+h', 'Horizontal Split', () => {
				editor.execCommand('InsertHorizontalRule');
			});

			/* 
			// Add Shortcut key font increase
			editor.addShortcut('alt+p', 'Increase font', () => {
				editor.execCommand("FontSize", false, "20px");
			});
			// Add Shortcut key font general
			editor.addShortcut('alt+o', 'Increase font', () => {
				editor.execCommand("FontSize", false, "16px");
			});
			*/
		});
	});
})();



0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

카카오톡 채널 친구추가
0
Would love your thoughts, please comment.x
()
x