Mercurial Hosting > sceditor
diff src/sceditor.js @ 12:933a459aa182
allow selector for textarea
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 07 Aug 2022 13:58:27 -0600 |
parents | 9159df67520a |
children | 8d32537e0ca7 |
line wrap: on
line diff
--- a/src/sceditor.js Sun Aug 07 01:09:17 2022 -0600 +++ b/src/sceditor.js Sun Aug 07 13:58:27 2022 -0600 @@ -9027,6 +9027,11 @@ * @author Sam Clarke */ + function getTextarea(textarea) { + if( typeof(textarea) === 'string' ) + textarea = document.querySelector(textarea); + return textarea; + } window.sceditor = { command: SCEditor.command, @@ -9076,6 +9081,7 @@ plugins: PluginManager.plugins, formats: SCEditor.formats, create: function (textarea, options) { + textarea = getTextarea(textarea); options = options || {}; // Don't allow the editor to be initialised @@ -9089,7 +9095,8 @@ (new SCEditor(textarea, options)); } }, - instance: function (textarea) { + instance: function(textarea) { + textarea = getTextarea(textarea); return textarea._sceditor; } };