Skip to content

Commit

Permalink
Ability to customize editor minHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
maaz1n committed Jun 22, 2022
1 parent 720e106 commit df5f83f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 516 deletions.
514 changes: 1 addition & 513 deletions resources/dist/js/editor.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions resources/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import DragDrop from "editorjs-drag-drop";
document.addEventListener("alpine:init", () => {
Alpine.data(
"editorjs",
({ state, statePath, placeholder, readOnly, tools }) => ({
({ state, statePath, placeholder, readOnly, tools, minHeight }) => ({
instance: null,
state: state,
tools: tools,
Expand Down Expand Up @@ -82,7 +82,7 @@ document.addEventListener("alpine:init", () => {
if (this.tools.includes("style")) enabledTools.style = StyleInlineTool;
this.instance = new EditorJS({
holder: this.$el,
minHeight: 30,
minHeight: minHeight,
data: this.state,
placeholder: placeholder,
readOnly: readOnly,
Expand Down
3 changes: 2 additions & 1 deletion resources/views/forms/components/fields/editorjs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class="editorjs-wrapper"
statePath: '{{ $getStatePath() }}',
placeholder: '{{ $getPlaceholder() }}',
readOnly: {{ $isDisabled() ? 'true' : 'false' }},
tools: @js($getTools())
tools: @js($getTools()),
minHeight: @js($getMinHeight())
})"
>
</div>
Expand Down
14 changes: 14 additions & 0 deletions src/Forms/Components/EditorJs.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,18 @@ class EditorJs extends Field implements HasFileAttachmentsContract
'inline-code',
'style',
];

protected int | Closure | null $minHeight = 30;

public function minHeight(int | Closure | null $minHeight): static
{
$this->minHeight = $minHeight;

return $this;
}

public function getMinHeight(): ?int
{
return $this->evaluate($this->minHeight);
}
}

0 comments on commit df5f83f

Please sign in to comment.