Skip to content

Commit

Permalink
Allow user settings in browser attachEditor (#125)
Browse files Browse the repository at this point in the history
Allow the user to supply settings in addition to the defaults.

Props to @cnmade
  • Loading branch information
johngodley authored Apr 15, 2022
1 parent 9c08c66 commit 36763f4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ function onLoad( content, parser, rawHandler ) {
/**
* Attach IsolatedBlockEditor to a textarea
* @param {HTMLTextAreaElement} textarea Textarea node
* @param {BlockEditorSettings} userSettings Settings object
*/
function attachEditor( textarea ) {
function attachEditor( textarea, userSettings = {} ) {
// Check it's a textarea
if ( textarea.type.toLowerCase() !== 'textarea' ) {
return;
Expand All @@ -72,7 +73,7 @@ function attachEditor( textarea ) {
// Render the editor
render(
<IsolatedBlockEditor
settings={ settings }
settings={ { ...settings, ...userSettings } }
onLoad={ ( parser, rawHandler ) => onLoad( textarea.value, parser, rawHandler ) }
onSaveContent={ ( content ) => saveBlocks( content, textarea ) }
onError={ () => document.location.reload() }
Expand Down

0 comments on commit 36763f4

Please sign in to comment.