Skip to content

Commit

Permalink
Added the ability to set toolbar opts. Css updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickAsare committed Apr 23, 2023
1 parent 8a9f180 commit 4bef6ed
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@ composer require craft-cloud/nova-ck-light

## Usage

Default editor

```php
use CraftCloud\NovaCkLight\NovaCkLight;

NovaCkLight::make('MyFieldName'),
```

Editor options
```php
use CraftCloud\NovaCkLight\NovaCkLight;

NovaCkLight::make('MyFieldName')->toolbar(['heading', '|', 'bold', 'italic', 'link']),
```

If you require images without an editor

```php
use CraftCloud\NovaCkLight\NovaCkLight;

NovaCkLight::make('MyFieldName')->imageOnly(),
```
## Testing

``` bash
Expand Down
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion resources/js/components/DetailField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<PanelItem :index="index" :field="field">
<template #value>
<div v-if="field.imageOnly && field.value">
<ImageDisplay :src="field.value" :showClearButton="false" />
<div class="break-all md:w-3/4 md:py-3 lg:break-words">
<span>
<img
:src="field.value"
style="max-width: 128px"
class="aspect-square object-scale-down"
/>
</span>
</div>
</div>

<div v-else>
Expand Down
4 changes: 1 addition & 3 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
editorConfig: {
// The configuration of the editor.
toolbar: {
items: [
items: this.field.toolbar || [
"ckfinder",
"|",
"heading",
Expand All @@ -88,12 +88,10 @@ export default {
"redo",
],
},
ckfinder: {
uploadUrl:
"/ckfinder/connector?command=QuickUpload&type=Files&responseType=json",
options: {
resourceType: "Images",
connectorPath: "/ckfinder/connector",
},
},
Expand Down
14 changes: 12 additions & 2 deletions src/NovaCkLight.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ class NovaCkLight extends Field
*
* @return $this
*/
public function imageOnly()
public function imageOnly(bool $imageOnly = true)
{
return $this->withMeta(['imageOnly' => true]);
return $this->withMeta(['imageOnly' => $imageOnly]);
}

/**
* CK toolbar options
*
* @return $this
*/
public function toolbar(array $toolbar = [])
{
return $this->withMeta(['toolbar' => $toolbar]);
}
}

0 comments on commit 4bef6ed

Please sign in to comment.