Skip to content

Commit a0eec4a

Browse files
committed
Add missing files
1 parent cf72200 commit a0eec4a

15 files changed

+419
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/vendor
2+
/node_modules
3+
package-lock.json
4+
yarn.lock
5+
composer.lock
6+
phpunit.xml
7+
.phpunit.result.cache

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Nova HTML code Field
2+
3+
[![Latest Stable Version](https://poser.pugx.org/interaction-design-foundation/nova-html-code-field/v/stable)](https://packagist.org/packages/interaction-design-foundation/nova-html-code-field)
4+
[![Total Downloads](https://poser.pugx.org/interaction-design-foundation/nova-html-code-field/downloads)](https://packagist.org/packages/interaction-design-foundation/nova-html-code-field)
5+
6+
7+
## ToDo
8+
9+
1. Add HTML validator (https://www.npmjs.com/package/html-validator)
10+
1. Add toolbar
11+
1. Optimize a preview: re-render only changed node
12+
13+
## Installation
14+
15+
You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
16+
17+
```bash
18+
composer require interaction-design-foundation/nova-html-code-field
19+
```
20+
21+
## Usage
22+
23+
24+
25+
### Options
26+
27+
28+
### Changelog
29+
30+
Please see [Releases](https://github.com/InteractionDesignFoundation/nova-unlayer-field/releases) for more information on what has changed recently.
31+
32+
## Contributing
33+
34+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
35+
36+
### Compiling Assets
37+
38+
```bash
39+
# Compile and minify your assets:
40+
npm run prod
41+
42+
# Compile your assets for local development:
43+
npm run dev
44+
45+
# Run the NPM "watch" command to auto-compile your assets when they are changed:
46+
npm run watch
47+
```
48+
49+
## License
50+
51+
The MIT License (MIT). Please see [License File](LICENSE) for more information.

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "interaction-design-foundation/nova-html-code-field",
3+
"description": "An HTML Laravel Nova field.",
4+
"keywords": [
5+
"laravel",
6+
"nova"
7+
],
8+
"license": "MIT",
9+
"require": {
10+
"php": ">=7.4"
11+
},
12+
"autoload": {
13+
"psr-4": {
14+
"InteractionDesignFoundation\\NovaHtmlCodeField\\": "src/"
15+
}
16+
},
17+
"extra": {
18+
"laravel": {
19+
"providers": [
20+
"InteractionDesignFoundation\\NovaHtmlCodeField\\ServiceProvider"
21+
]
22+
}
23+
},
24+
"config": {
25+
"sort-packages": true
26+
},
27+
"minimum-stability": "dev",
28+
"prefer-stable": true
29+
}

dist/js/field.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mix-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"/js/field.js": "/js/field.js"
3+
}

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"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",
9+
"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"
11+
},
12+
"devDependencies": {
13+
"cross-env": "^5.0.0",
14+
"laravel-mix": "^1.0",
15+
"laravel-nova": "^1.0"
16+
},
17+
"dependencies": {
18+
"vue": "^2.5.0"
19+
}
20+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<panel-item :field="field">
3+
<template slot="value">
4+
<div class="overflow-hidden">
5+
<preview-html
6+
class="resize-y"
7+
:fieldNameToPreview="field.name"
8+
:src="field.value"
9+
:styles="field.styles"
10+
:template="field.template"
11+
/>
12+
</div>
13+
</template>
14+
</panel-item>
15+
</template>
16+
17+
<script>
18+
import {PreviewHtml} from './PreviewHtml'
19+
20+
export default {
21+
components: [
22+
PreviewHtml,
23+
],
24+
25+
props: ['resource', 'resourceName', 'resourceId', 'field'],
26+
}
27+
</script>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<template>
2+
<default-field :field="field" :errors="errors" :full-width-content="true">
3+
<template slot="field">
4+
<div class="flex mb-4">
5+
<div class="w-1/2 m-3">
6+
<label :for="field.name" class="block mb-1">Code</label>
7+
</div>
8+
9+
<div class="w-1/2 m-3">
10+
<label class="block mb-1">Preview</label>
11+
</div>
12+
</div>
13+
<div class="flex mb-4">
14+
<div class="w-1/2 m-3">
15+
<textarea
16+
:id="field.name"
17+
type="text"
18+
class="w-full form-input form-input-bordered"
19+
:class="errorClasses"
20+
:placeholder="field.name"
21+
v-model="value"
22+
v-bind="extraAttributes"
23+
/>
24+
</div>
25+
26+
<div class="w-1/2 m-3">
27+
<preview-html
28+
class="resize-y"
29+
:fieldNameToPreview="field.name"
30+
:src="value"
31+
:styles="field.styles"
32+
:template="field.template"
33+
/>
34+
35+
</div>
36+
</div>
37+
38+
</template>
39+
</default-field>
40+
</template>
41+
42+
<script>
43+
import {FormField, HandlesValidationErrors} from 'laravel-nova'
44+
import {PreviewHtml} from './PreviewHtml'
45+
46+
export default {
47+
mixins: [FormField, HandlesValidationErrors],
48+
49+
components: [
50+
PreviewHtml,
51+
],
52+
53+
props: ['resourceName', 'resourceId', 'field'],
54+
55+
methods: {
56+
/*
57+
* Set the initial, internal value for the field.
58+
*/
59+
setInitialValue() {
60+
this.value = this.field.value || ''
61+
},
62+
63+
/**
64+
* Fill the given FormData object with the field's internal value.
65+
*/
66+
fill(formData) {
67+
formData.append(this.field.attribute, this.value)
68+
},
69+
70+
/**
71+
* Update the field's internal value.
72+
*/
73+
handleChange(value) {
74+
this.value = value
75+
},
76+
},
77+
78+
computed: {
79+
defaultAttributes() {
80+
return {
81+
rows: 10,
82+
class: this.errorClasses,
83+
placeholder: this.field.name,
84+
}
85+
},
86+
87+
extraAttributes() {
88+
const attrs = this.field.extraAttributes || [];
89+
90+
return {
91+
...this.defaultAttributes,
92+
...attrs,
93+
}
94+
},
95+
96+
},
97+
}
98+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<div v-html="field.value"></div>
3+
</template>
4+
5+
<script>
6+
export default {
7+
props: ['resourceName', 'field'],
8+
}
9+
</script>

0 commit comments

Comments
 (0)