Skip to content

Commit

Permalink
it seems initializing now works
Browse files Browse the repository at this point in the history
  • Loading branch information
MekDrop committed Oct 13, 2021
1 parent a5ca566 commit c7b3442
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/EditorAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ImpressCMS\Modules\CodeMirrorIntegration;

use Imponeer\Contracts\Editor\Adapter\EditorAdapterInterface;
use JsonException;

/**
* Describes editor adapter instance
Expand Down Expand Up @@ -141,25 +142,24 @@ public function getScriptURLs(): array

/**
* @inheritDoc
*
* @throws JsonException
*/
public function getScriptCode(): string
{
$config = json_encode(
[
'width' => $this->width,
'height' => $this->height,
'lineNumbers' => true,
'continuousScanning' => 500,
'textWrapping' => false,
'readOnly' => $this->readonly,
'mode' => $this->syntax,
],
JSON_PRETTY_PRINT
);
$config = json_encode([
'width' => $this->width,
'height' => $this->height,
'lineNumbers' => true,
'continuousScanning' => 500,
'textWrapping' => false,
'readOnly' => $this->readonly,
'mode' => $this->syntax,
], JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);

$selectorHash = sha1($this->targetSelector);

return "var editor_{$selectorHash} = CodeMirror.fromTextArea('{$this->targetSelector}', {$config});";
return "var editor_{$selectorHash} = CodeMirror.fromTextArea(document.querySelector('{$this->targetSelector}'), {$config});";
}

/**
Expand Down

0 comments on commit c7b3442

Please sign in to comment.