Skip to content

Commit f6e517b

Browse files
committed
Upgrade to Nova v4
1 parent fa58483 commit f6e517b

16 files changed

+166
-83
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
max_line_length = 120
11+
tab_width = 4
12+
13+
[*.{yml,yaml}]
14+
indent_size = 2

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ composer require interaction-design-foundation/nova-html-code-field
2525
## Usage
2626

2727
```php
28+
use InteractionDesignFoundation\NovaHtmlCodeField\HtmlCode;
29+
2830
public function fields()
2931
{
30-
return [
31-
HtmlCode::make('HTML content'),
32+
return [
33+
HtmlCode::make('HTML content', 'content'),
3234
];
3335
}
3436
```
3537

3638

3739
### Options
3840

39-
- `->styles(array $stylesUrls)`: optional, you can inject your custom css files.
40-
- `->previewTemplate(string | \Closure $template)`: optional, wrap editable code to have even better preview.
41-
4241
Full example:
4342
```php
44-
HtmlCode::make('HTML content')
45-
->styles([asset(mix('css/app.css'))]),
46-
->previewTemplate('<section class="panel">%CODE%</section>')
43+
HtmlCode::make('HTML content', 'content')
44+
->styles([asset(mix('css/app.css'))]), // optional, you can inject your custom CSS files to have more realistic preview.
45+
->previewTemplate('<section class="panel">%CODE%</section>') // optional, wrap editable code to have even better preview (good together with custom styles).
4746
```
4847

48+
4949
### Changelog
5050

5151
Please see [Releases](https://github.com/InteractionDesignFoundation/nova-unlayer-field/releases) for more information on what has changed recently.

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
{
22
"name": "interaction-design-foundation/nova-html-code-field",
3-
"description": "An HTML Laravel Nova field.",
3+
"description": "A Laravel Nova field to write raw HTML and preview.",
44
"keywords": [
55
"laravel",
6-
"nova"
6+
"nova",
7+
"laravel-nova-field",
8+
"html"
79
],
810
"license": "MIT",
911
"require": {
1012
"php": ">=8.0",
11-
"laravel/nova": "^3.0"
13+
"ext-json": "*",
14+
"laravel/nova": "^4.0"
1215
},
1316
"require-dev": {
14-
"mockery/mockery": "^1.4",
15-
"orchestra/testbench": "^6.0",
16-
"phpunit/phpunit": "^9.4"
17+
"orchestra/testbench": "^7.0",
18+
"phpunit/phpunit": "^9.5"
1719
},
1820
"repositories": [
1921
{
20-
"type": "composer", "url": "https://nova.laravel.com"
22+
"type": "composer",
23+
"url": "https://nova.laravel.com"
2124
}
2225
],
2326
"autoload": {
@@ -43,6 +46,6 @@
4346
"minimum-stability": "dev",
4447
"prefer-stable": true,
4548
"scripts": {
46-
"test": "phpunit"
49+
"test": "phpunit --colors=always"
4750
}
4851
}

dist/js/field.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/field.js.LICENSE.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*!
2+
* vuex v4.0.2
3+
* (c) 2021 Evan You
4+
* @license MIT
5+
*/

dist/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"/js/field.js": "/js/field.js?id=da291d7e3b1780f03465"
3-
}
2+
"/js/field.js": "/js/field.js?id=a4d881891bb699eb7539dd36cb3ada95"
3+
}

nova.mix.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const mix = require('laravel-mix')
2+
const webpack = require('webpack')
3+
const path = require('path')
4+
5+
class NovaExtension {
6+
name() {
7+
return 'nova-extension'
8+
}
9+
10+
register(name) {
11+
this.name = name
12+
}
13+
14+
webpackPlugins() {
15+
return new webpack.ProvidePlugin({
16+
_: 'lodash',
17+
Errors: 'form-backend-validation',
18+
})
19+
}
20+
21+
webpackConfig(webpackConfig) {
22+
webpackConfig.externals = {
23+
vue: 'Vue',
24+
}
25+
26+
webpackConfig.resolve.alias = {
27+
...(webpackConfig.resolve.alias || {}),
28+
'laravel-nova': path.join(
29+
__dirname,
30+
'../../vendor/laravel/nova/resources/js/mixins/packages.js'
31+
),
32+
}
33+
34+
webpackConfig.output = {
35+
uniqueName: this.name,
36+
}
37+
}
38+
}
39+
40+
mix.extend('nova', new NovaExtension())

package.json

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
{
22
"private": true,
3+
"engines": {
4+
"node": ">=16.0"
5+
},
36
"scripts": {
47
"dev": "npm run development",
5-
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6-
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7-
"watch-poll": "npm run watch -- --watch-poll",
8-
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
8+
"development": "mix",
9+
"watch": "mix watch",
10+
"watch-poll": "mix watch -- --watch-options-poll=1000",
11+
"hot": "mix watch --hot",
912
"prod": "npm run production",
10-
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
13+
"production": "mix --production",
14+
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci"
1115
},
1216
"devDependencies": {
13-
"cross-env": "^5.0.0",
14-
"laravel-mix": "^1.0",
15-
"laravel-nova": "^1.0"
17+
"@vue/compiler-sfc": "^3.2.33",
18+
"form-backend-validation": "^2.3.3",
19+
"laravel-mix": "^6.0.41",
20+
"lodash": "^4.17.21",
21+
"postcss": "^8.3.11",
22+
"vue-loader": "^16.8.3"
1623
},
17-
"dependencies": {
18-
"vue": "^2.5.0"
19-
}
24+
"dependencies": {}
2025
}

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.4/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
33
<coverage>
44
<include>
55
<directory suffix=".php">src/</directory>
@@ -12,4 +12,4 @@
1212
</testsuites>
1313
<php>
1414
</php>
15-
</phpunit>
15+
</phpunit>
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<panel-item :field="field">
3-
<template slot="value">
2+
<PanelItem :index="index" :field="field">
3+
<template #value>
44
<div class="overflow-hidden">
5-
<preview-html
5+
<PreviewHtml
66
class="resize-y"
77
:fieldNameToPreview="field.name"
88
:src="field.value"
@@ -11,17 +11,17 @@
1111
/>
1212
</div>
1313
</template>
14-
</panel-item>
14+
</PanelItem>
1515
</template>
1616

1717
<script>
18-
import {PreviewHtml} from './PreviewHtml'
18+
import PreviewHtml from './PreviewHtml'
1919
2020
export default {
21-
components: [
22-
PreviewHtml,
23-
],
21+
components: {
22+
PreviewHtml
23+
},
2424
25-
props: ['resource', 'resourceName', 'resourceId', 'field'],
25+
props: ['index', 'resource', 'resourceName', 'resourceId', 'field'],
2626
}
2727
</script>

0 commit comments

Comments
 (0)