Skip to content

Commit

Permalink
Merge pull request #48 from grrr-amsterdam/heading-options
Browse files Browse the repository at this point in the history
Allow heading options to be configured
  • Loading branch information
mostafaznv committed May 11, 2023
2 parents a8e2885 + 4517085 commit b0e6102
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ $this->app->bind('ckeditor-image-storage', MyImageStorage::class);
| imageBrowser | Boolean | from config file | Enable/Disable image picker |
| videoBrowser | Boolean | from config file | Enable/Disable video picker |
| snippets | Array | from config file | Set Snippet items |
| headings | Array | from config file | Set heading options |



Expand All @@ -218,6 +219,7 @@ You can change configuration options in `config/nova-ckeditor.php`
| max-width | Integer | 1024 | Image max width |
| max-height | Integer | 768 | Image max height |
| image-naming-method | String | hash-file | Naming Method of Images. <br>Available methods: `hash-file`, `real-file-name`, `unique-real-file-name` |
| headings | Array | | Heading options. |
| toolbar.height | Integer | 400 | Editor's height. |
| toolbar.content-lang | String `format: ISO 639-1` | en | Language of editor's content. if you want to change text-direction (RTL, LTR), you need this |
| toolbar.ui-language.name | String `format: ISO 639-1` | en | Language of editor's ui. |
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,11 @@
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
}
]
}
52 changes: 52 additions & 0 deletions config/nova-ckeditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,58 @@

'image-naming-method' => 'hash-file',

/*
|--------------------------------------------------------------------------
| Headings
|--------------------------------------------------------------------------
|
| Heading options
|
*/
'headings' => [
[
'model' => 'paragraph',
'title' => 'Paragraph',
'class' => 'ck-heading_paragraph',
],
[
'model' => 'heading1',
'view' => 'h1',
'title' => 'Heading 1',
'class' => 'ck-heading_heading1',
],
[
'model' => 'heading2',
'view' => 'h2',
'title' => 'Heading 2',
'class' => 'ck-heading_heading2',
],
[
'model' => 'heading3',
'view' => 'h3',
'title' => 'Heading 3',
'class' => 'ck-heading_heading3',
],
[
'model' => 'heading4',
'view' => 'h4',
'title' => 'Heading 4',
'class' => 'ck-heading_heading4',
],
[
'model' => 'heading5',
'view' => 'h5',
'title' => 'Heading 5',
'class' => 'ck-heading_heading5',
],
[
'model' => 'heading6',
'view' => 'h6',
'title' => 'Heading 6',
'class' => 'ck-heading_heading6',
]
],

/*
|--------------------------------------------------------------------------
| Toolbar
Expand Down
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions resources/js/components/editor-field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export default {
content: this.field.contentLanguage,
textPartLanguage: this.field.textPartLanguage
},
heading: {
options: this.field.headings,
},
toolbar: {
items: this.field.toolbar,
shouldNotGroupWhenFull: this.field.shouldNotGroupWhenFull
Expand Down
22 changes: 22 additions & 0 deletions src/CkEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ class CkEditor extends Field
*/
public string $videoModel = '';

/**
* Heading options
*
* @var array
*/
public array $headings = [];


public function __construct($name, $attribute = null, callable $resolveCallback = null)
{
Expand All @@ -116,6 +123,7 @@ public function __construct($name, $attribute = null, callable $resolveCallback
$this->uiLanguage = $config['toolbar']['ui-language']['name'] ?? 'en';
$this->shouldNotGroupWhenFull = $config['toolbar']['should-not-group-when-full'];
$this->videoModel = $config['video-model'];
$this->headings = $config['headings'];
}


Expand Down Expand Up @@ -223,6 +231,19 @@ public function videoBrowser(bool $enabled = true): self
return $this;
}

/**
* Add heading options.
*
* @param array $headings
* @return $this
*/
public function headings(array $headings = []): self
{
$this->headings = $headings;

return $this;
}

/**
* Enable Snippets Browser
*
Expand Down Expand Up @@ -257,6 +278,7 @@ public function jsonSerialize(): array
'shouldNotGroupWhenFull' => $this->shouldNotGroupWhenFull,
'shouldShow' => $this->shouldBeExpanded(),
'videoHasLaruploadTrait' => $this->hasLaruploadTrait(),
'headings' => $this->headings,
]);
}

Expand Down

0 comments on commit b0e6102

Please sign in to comment.