1
0

downgrade to kirby v3

This commit is contained in:
Philip Wagner
2024-09-01 10:47:15 +02:00
parent a4b2aece7b
commit af86acb7a1
1085 changed files with 54743 additions and 65042 deletions

View File

@@ -0,0 +1,12 @@
# OS files
.DS_Store
# npm modules
/node_modules
# Composer files
/vendor
# Lock Files
yarn.lock
package-lock.json

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Jon Gacnik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,74 @@
# Kirby Fields Block
Kirby [block preview](https://getkirby.com/docs/reference/plugins/extensions/blocks) plugin to directly render block fields, allowing for inline editing.
<img src="https://files.jongacnik.com/kirby-fields-preview-1.png" width="975" height="auto" />
## Usage
### Block definition
When creating a custom block in your blueprints, pass `preview: fields` to utilize this plugin
```yaml
blockname:
name: Block Name
preview: fields # required
wysiwyg: true # recommended
fields:
text:
label: Text
type: text
```
Setting `wysiwyg: true` prevents drawer from automatically opening when creating a new block.
### Disable block title
You can disable the block title bar by passing `label: false`
```yaml
blockname:
name: Block Name
preview: fields
wysiwyg: true
label: false # disables block title bar
fields:
text:
label: Text
type: text
```
<details>
<summary>Example</summary>
<img src="https://files.jongacnik.com/kirby-fields-preview-2.png" width="975" height="auto" />
</details>
### Collapse/Expand block
You can collapse or expand the block preview by double clicking the block title bar.
## Notes
- The block `icon` will appear in the title bar.
- Currently does not support blocks with tabs.
## Installation
```
composer require jg/kirby-fields-block
```
<details>
<summary>Other installation methods</summary>
### Download
Download and copy this repository to `/site/plugins/kirby-fields-block`.
### Git submodule
```
git submodule add https://github.com/jongacnik/kirby-fields-block.git site/plugins/kirby-fields-block
```
</details>

View File

@@ -0,0 +1,15 @@
{
"name": "jg/kirby-fields-block",
"description": "Kirby Fields Block",
"type": "kirby-plugin",
"license": "MIT",
"authors": [
{
"name": "Jon Gacnik",
"email": "jon@folderstudio.com"
}
],
"require": {
"getkirby/composer-installer": "^1.1"
}
}

View File

@@ -0,0 +1,42 @@
.k-block-fields-preview {
margin: -0.75rem;
overflow: hidden;
border-radius: var(--rounded);
}
.k-block-fields-preview .k-block-title {
padding: 0.75rem;
background: #f7f7f7;
}
.k-block-fields-preview:not([data-hidden="true"]) .k-block-title {
border-bottom: 1px solid rgba(0,0,0,.1);
}
.k-block-fields-preview .k-fields-block-toggle {
margin-left: auto;
cursor: pointer;
}
.k-block-fields-preview[data-hidden="true"] .k-fields-block-toggle {
transform: scaleY(-1);
}
.k-block-fields-preview .k-form {
padding: 1.25rem 1.5rem 1.5rem 1.5rem;
}
/**
* Reset `.k-layout-column .k-empty` overrides
*/
.k-block-fields-preview .k-empty {
position: static !important;
opacity: 1 !important;
align-items: stretch !important;
justify-content: flex-start !important;
color: #777 !important;
border: 1px dashed #ccc !important;
border-radius: 1px !important;
}
.k-block-fields-preview .k-empty[data-layout="cards"] {
justify-content: center !important;
}
.k-block-fields-preview .k-empty[data-layout="list"] .k-icon {
border-right: 1px solid rgba(0,0,0,.05) !important;
}

View File

@@ -0,0 +1,122 @@
(function() {
"use strict";
const FieldsBlock_vue_vue_type_style_index_0_lang = "";
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
if (render) {
options.render = render;
options.staticRenderFns = staticRenderFns;
options._compiled = true;
}
if (functionalTemplate) {
options.functional = true;
}
if (scopeId) {
options._scopeId = "data-v-" + scopeId;
}
var hook;
if (moduleIdentifier) {
hook = function(context) {
context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
context = __VUE_SSR_CONTEXT__;
}
if (injectStyles) {
injectStyles.call(this, context);
}
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier);
}
};
options._ssrRegister = hook;
} else if (injectStyles) {
hook = shadowMode ? function() {
injectStyles.call(
this,
(options.functional ? this.parent : this).$root.$options.shadowRoot
);
} : injectStyles;
}
if (hook) {
if (options.functional) {
options._injectStyles = hook;
var originalRender = options.render;
options.render = function renderWithStyleInjection(h, context) {
hook.call(context);
return originalRender(h, context);
};
} else {
var existing = options.beforeCreate;
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
}
}
return {
exports: scriptExports,
options
};
}
const _sfc_main = {
data() {
return {
isHidden: JSON.parse(sessionStorage.getItem(`kirby.fieldsBlock.${this.$attrs.endpoints.field}.${this.$attrs.id}`))
};
},
methods: {
toggle() {
this.isHidden = !this.isHidden;
sessionStorage.setItem(`kirby.fieldsBlock.${this.$attrs.endpoints.field}.${this.$attrs.id}`, this.isHidden);
},
preventSelect(event) {
if (event.detail > 1) {
if (!event.target.closest(".k-input")) {
event.preventDefault();
}
}
}
}
};
var _sfc_render = function render() {
var _vm = this, _c = _vm._self._c;
return _c("div", { staticClass: "k-block-fields-preview", attrs: { "data-hidden": _vm.isHidden }, on: { "mousedown": _vm.preventSelect } }, [_vm.fieldset.label === null || _vm.fieldset.label ? _c("k-fields-block-title", { attrs: { "content": _vm.content, "fieldset": _vm.fieldset }, on: { "dblclick": _vm.toggle, "toggle": _vm.toggle } }) : _vm._e(), !_vm.isHidden ? _c("k-form", { ref: "form", attrs: { "autofocus": true, "fields": _vm.fieldset.tabs.content.fields, "value": _vm.$helper.clone(_vm.content) }, on: { "input": function($event) {
return _vm.$emit("update", $event);
} } }) : _vm._e()], 1);
};
var _sfc_staticRenderFns = [];
_sfc_render._withStripped = true;
var __component__ = /* @__PURE__ */ normalizeComponent(
_sfc_main,
_sfc_render,
_sfc_staticRenderFns,
false,
null,
null,
null,
null
);
__component__.options.__file = "/Users/jongacnik/Sites/_kirby/kirby-fields-block/src/FieldsBlock.vue";
const FieldsBlock = __component__.exports;
panel.plugin("jg/fields-block", {
components: {
"k-fields-block-title": {
extends: "k-block-title",
template: `
<div class="k-block-title" v-on="$listeners">
<k-icon :type="icon" class="k-block-icon" />
<span class="k-block-name">
{{ name }}
</span>
<span v-if="label" class="k-block-label">
{{ label }}
</span>
<span class="k-fields-block-toggle" v-on:click="$emit('toggle')">
<k-icon type="angle-up"/>
</span>
</div>
`
}
},
blocks: {
fields: FieldsBlock
}
});
})();

View File

@@ -0,0 +1,3 @@
<?php
Kirby::plugin('jongacnik/fields-block', []);

View File

@@ -0,0 +1,15 @@
{
"name": "kirby-fields-block",
"version": "1.2.1",
"main": "src/index.js",
"repository": "https://github.com/jongacnik/kirby-fields-block.git",
"author": "jongacnik <jon@folderstudio.com>",
"license": "MIT",
"devDependencies": {
"kirbyup": "latest"
},
"scripts": {
"dev": "kirbyup src/index.js --watch",
"build": "kirbyup src/index.js"
}
}

View File

@@ -0,0 +1,3 @@
module.exports = {
plugins: { }
}

View File

@@ -0,0 +1,94 @@
<template>
<div class="k-block-fields-preview" @mousedown="preventSelect" :data-hidden="isHidden">
<k-fields-block-title
:content="content"
:fieldset="fieldset"
v-if="fieldset.label === null || fieldset.label"
@dblclick="toggle"
@toggle="toggle"
/>
<k-form
ref="form"
:autofocus="true"
:fields="fieldset.tabs.content.fields"
:value="$helper.clone(content)"
@input="$emit('update', $event)"
v-if="!isHidden"
/>
</div>
</template>
<script>
export default {
data () {
return {
isHidden: JSON.parse(sessionStorage.getItem(`kirby.fieldsBlock.${this.$attrs.endpoints.field}.${this.$attrs.id}`))
}
},
methods: {
toggle () {
this.isHidden = !this.isHidden
sessionStorage.setItem(`kirby.fieldsBlock.${this.$attrs.endpoints.field}.${this.$attrs.id}`, this.isHidden)
},
preventSelect (event) {
if (event.detail > 1) {
if(!event.target.closest('.k-input')) {
event.preventDefault()
}
}
}
}
}
</script>
<style>
.k-block-fields-preview {
margin: -0.75rem;
overflow: hidden;
border-radius: var(--rounded);
}
.k-block-fields-preview .k-block-title {
padding: 0.75rem;
background: #f7f7f7;
}
.k-block-fields-preview:not([data-hidden="true"]) .k-block-title {
border-bottom: 1px solid rgba(0,0,0,.1);
}
.k-block-fields-preview .k-fields-block-toggle {
margin-left: auto;
cursor: pointer;
}
.k-block-fields-preview[data-hidden="true"] .k-fields-block-toggle {
transform: scaleY(-1);
}
.k-block-fields-preview .k-form {
padding: 1.25rem 1.5rem 1.5rem 1.5rem;
}
/**
* Reset `.k-layout-column .k-empty` overrides
*/
.k-block-fields-preview .k-empty {
position: static !important;
opacity: 1 !important;
align-items: stretch !important;
justify-content: flex-start !important;
color: #777 !important;
border: 1px dashed #ccc !important;
border-radius: 1px !important;
}
.k-block-fields-preview .k-empty[data-layout="cards"] {
justify-content: center !important;
}
.k-block-fields-preview .k-empty[data-layout="list"] .k-icon {
border-right: 1px solid rgba(0,0,0,.05) !important;
}
</style>

View File

@@ -0,0 +1,26 @@
import FieldsBlock from "./FieldsBlock.vue"
panel.plugin("jg/fields-block", {
components: {
'k-fields-block-title': {
extends: 'k-block-title',
template: `
<div class="k-block-title" v-on="$listeners">
<k-icon :type="icon" class="k-block-icon" />
<span class="k-block-name">
{{ name }}
</span>
<span v-if="label" class="k-block-label">
{{ label }}
</span>
<span class="k-fields-block-toggle" v-on:click="$emit('toggle')">
<k-icon type="angle-up"/>
</span>
</div>
`
}
},
blocks: {
fields: FieldsBlock
}
})