Skip to content

Commit

Permalink
Merge pull request #4 from Muetze42/development
Browse files Browse the repository at this point in the history
0.0.1 with requirements
  • Loading branch information
Muetze42 authored Jul 2, 2022
2 parents 2eb3bae + 79d6707 commit 267d0e5
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 235 deletions.
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Nova Textarea- & Text field with BBCodes
# Nova Textarea with BBCodes
Quickly developed. Short tutorial.

With this Nova field you have the _Textarea_ or _Text_ with _BBCodes_.
With this Nova field you have the _Textarea_ with _BBCodes_.

(Tested with Nova 4)

Expand All @@ -20,16 +20,6 @@ BBCode::make(__('Name'), 'name')->codes([
'{date}' => __('This code insert the date'),
]),
```
Or Text Field:
```php

use NormanHuth\BBCode\BB;

BB::make(__('Name'), 'name')->codes([
'{author}' => __('This code insert the author'),
'{date}' => __('This code insert the date'),
]),
```

### Don't always show the content of textarea fields inside Nova
```php
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@
"laravel",
"nova"
],
"support": {
"issues": "https://github.com/Muetze42/nova-bbcode-textarea/issues",
"source": "https://github.com/Muetze42/nova-bbcode-textarea",
"docs": "https://github.com/Muetze42/nova-bbcode-textarea#readme"
},
"homepage": "https://github.com/Muetze42/nova-bbcode-textarea",
"authors": [
{
"name": "Norman Huth",
"email": "imprint-28847@huth.it",
"homepage": "https://huth.it"
}
],
"license": "MIT",
"require": {
"php": "^8.0",
"laravel/nova": "^4.5.2"
"laravel/nova": "^4.0.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions dist/js/field.js.LICENSE.txt

This file was deleted.

3 changes: 2 additions & 1 deletion dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"/js/field.js": "/js/field.js"
"/js/field.js": "/js/field.js",
"/css/field.css": "/css/field.css"
}
1 change: 1 addition & 0 deletions resources/css/field.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Nova Field CSS */
17 changes: 17 additions & 0 deletions resources/js/components/DetailField.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<PanelItem :index="index" :field="field">
<template #value>
<Excerpt
:content="field.value"
:plain-text="true"
:should-show="field.shouldShow"
/>
</template>
</PanelItem>
</template>

<script>
export default {
props: ['index', 'resource', 'resourceName', 'resourceId', 'field'],
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</template>

<script>
import {DependentFormField, HandlesValidationErrors} from './../../mixins'
import {DependentFormField, HandlesValidationErrors} from './../mixins'
export default {
mixins: [HandlesValidationErrors, DependentFormField],
Expand Down
75 changes: 0 additions & 75 deletions resources/js/components/bb/FormField.vue

This file was deleted.

8 changes: 4 additions & 4 deletions resources/js/field.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FormField from './components/bbcode/FormField'
import FormField2 from './components/bb/FormField'
import DetailField from './components/DetailField'
import FormField from './components/FormField'

Nova.booting((app, store) => {
app.component('form-bbcode', FormField)
app.component('form-bb', FormField2)
app.component('detail-bbcode', DetailField)
app.component('form-bbcode', FormField)
})
113 changes: 0 additions & 113 deletions src/BB.php

This file was deleted.

25 changes: 4 additions & 21 deletions src/BBCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

class BBCode extends Field
{
/**
* Whether to always show the content for the field expanded or not.
*
* @var bool
*/
public $alwaysShow = true;

/**
* The codes in key => value: code => title
*
Expand All @@ -34,23 +27,13 @@ class BBCode extends Field
*/
protected string $btnStyle = '';


/**
* Get the component name for the field.
* The field's component.
*
* @return string
* @var string
*/
public function component(): string
{
if (isset(static::$customComponents[get_class($this)])) {
return static::$customComponents[get_class($this)];
}

if (request()->input('editing')) {
return 'bbcode';
}

return 'textarea-field';
}
public $component = 'bbcode';

/**
* @param array $codes
Expand Down
1 change: 1 addition & 0 deletions src/FieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function boot()
{
Nova::serving(function (ServingNova $event) {
Nova::script('bbcode', __DIR__.'/../dist/js/field.js');
Nova::style('bbcode', __DIR__.'/../dist/css/field.css');
});
}

Expand Down
1 change: 1 addition & 0 deletions webpack.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ mix
.setPublicPath('dist')
.js('resources/js/field.js', 'js')
.vue({ version: 3 })
.css('resources/css/field.css', 'css')
.nova('norman-huth/bbcode')

0 comments on commit 267d0e5

Please sign in to comment.