diff --git a/.drone.yml b/.drone.yml
index 90aca39..ade7d26 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -16,14 +16,14 @@ steps:
branch:
- master
image: appleboy/drone-scp
- repo: b12f/bbcom
settings:
host: web5svsvy.wh.hosting.zone
port: 2244
username:
- from_secret: bbcom_ssh_user
+ from_secret: dev_ssh_user
key:
- from_secret: bbcom_ssh_key
+ from_secret: dev_ssh_key
source: ./dist/*
target: /home/web5svsvy/html/schlechtenburg.b12f.io/
+ strip_components: 1
rm: true
diff --git a/babel.config.js b/babel.config.js
index 757ff9b..6116429 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,5 +1,6 @@
module.exports = {
presets: [
+ 'vca-jsx',
'@vue/cli-plugin-babel/preset',
],
};
diff --git a/package-lock.json b/package-lock.json
index d4e4884..c545f30 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3124,6 +3124,15 @@
"babel-plugin-jest-hoist": "^24.9.0"
}
},
+ "babel-preset-vca-jsx": {
+ "version": "0.3.5",
+ "resolved": "https://registry.npmjs.org/babel-preset-vca-jsx/-/babel-preset-vca-jsx-0.3.5.tgz",
+ "integrity": "sha512-UUsTwaUDn2y/7x32dc2veBj4+mqjNOhcxMlHFA4EHZLLxlVWMEFhSYROStpBkmZBy38iw8qFN8+SB9RVlhQ68w==",
+ "dev": true,
+ "requires": {
+ "@babel/plugin-syntax-jsx": "^7.2.0"
+ }
+ },
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
diff --git a/package.json b/package.json
index 61bd76a..eaa991a 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"@vue/eslint-config-airbnb": "^5.0.2",
"@vue/eslint-config-typescript": "^5.0.2",
"@vue/test-utils": "1.0.0-beta.31",
+ "babel-preset-vca-jsx": "^0.3.5",
"chromedriver": "^80.0.1",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
diff --git a/src/App.tsx b/src/App.tsx
index a12aaea..c4d49d1 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -4,6 +4,7 @@ import {
watchEffect,
} from '@vue/composition-api';
import Schlechtenburg from '@components/Schlechtenburg';
+import { BlockData } from './components/TreeElement';
import './App.scss';
@@ -18,21 +19,24 @@ export default defineComponent({
orientation: 'vertical',
children: [],
},
- });
+ }) as BlockData;
- watchEffect(() => {
- console.log('base block update', block);
- });
-
- return { block };
- },
-
- render() {
- return (
+ return () => (
-
+
{
+ block.name = newBlock.name;
+ block.blockId = newBlock.blockId;
+ block.data = newBlock.data;
+ },
+ },
+ }}
+ />
- {JSON.stringify(this.block, null, 2)}
+ {JSON.stringify(block, null, 2)}
);
},
diff --git a/src/components/Schlechtenburg.tsx b/src/components/Schlechtenburg.tsx
index f1b1a24..8ab7a64 100644
--- a/src/components/Schlechtenburg.tsx
+++ b/src/components/Schlechtenburg.tsx
@@ -8,7 +8,7 @@ import {
import {
model,
ActiveBlock,
- BlockProps,
+ BlockData,
BlockDefinition,
BlockLibraryDefinition,
BlockLibrary,
@@ -21,6 +21,11 @@ import SbParagraph from '@user/Paragraph/index';
import SbImage from '@user/Image/index';
import SbHeading from '@user/Heading/index';
+export interface SchlechtenburgProps {
+ customBlocks: BlockDefinition[];
+ block: BlockData;
+}
+
export default defineComponent({
name: 'schlechtenburg-main',
@@ -28,10 +33,10 @@ export default defineComponent({
props: {
customBlocks: { type: (null as unknown) as PropType, default: () => [] },
- block: { type: Object, required: true },
+ block: { type: (null as unknown) as PropType, required: true },
},
- setup(props: BlockProps) {
+ setup(props, context) {
const activeBlock = ref(null);
provide(ActiveBlock, activeBlock);
@@ -42,24 +47,21 @@ export default defineComponent({
'sb-heading': SbHeading,
...props.customBlocks.reduce(
(
- blocks: BlockLibraryDefinition,
- block: BlockLibraryDefinition,
+ blocks,
+ block,
) => ({ ...blocks, [block.name]: block }),
{},
),
});
provide(BlockLibrary, blockLibrary);
- },
- render() {
- console.log('render base');
- return (
+ return () => (
this.$emit('update', block),
+ update: (block: BlockDefinition) => context.emit('update', block),
},
}}
/>
diff --git a/src/components/TreeElement.ts b/src/components/TreeElement.ts
index 256fd51..e7bcf60 100644
--- a/src/components/TreeElement.ts
+++ b/src/components/TreeElement.ts
@@ -22,12 +22,12 @@ export interface BlockLibraryDefinition {
export interface BlockData {
name: string;
- blockId: string|number;
+ blockId: string;
data: { [name: string]: any };
}
export interface BlockProps {
- blockId: string|number;
+ blockId: string;
data: { [key: string]: any};
}
@@ -37,7 +37,7 @@ export const model = {
};
export const blockProps = {
- blockId: { type: [String, Number], required: true },
+ blockId: { type: String, required: true },
data: { type: Object, default: () => ({}) },
};
@@ -48,10 +48,10 @@ export function useDynamicBlocks() {
return { customBlocks, getBlock };
}
-export function useActivation(currentBlockId: string|number) {
- const activeBlockId: Ref = inject(ActiveBlock, ref(null));
+export function useActivation(currentBlockId: string) {
+ const activeBlockId: Ref = inject(ActiveBlock, ref(null));
const isActive = computed(() => activeBlockId.value === currentBlockId);
- const activate = (blockId?: string|number|null) => {
+ const activate = (blockId?: string|null) => {
activeBlockId.value = blockId !== undefined ? blockId : currentBlockId;
};
const requestActivation = () => {
diff --git a/src/components/internal/Block.tsx b/src/components/internal/Block.tsx
index d8096f3..b81a7ae 100644
--- a/src/components/internal/Block.tsx
+++ b/src/components/internal/Block.tsx
@@ -16,11 +16,11 @@ export default defineComponent({
name: 'sb-block',
props: {
- block: { type: (null as unknown) as PropType, default: false },
+ block: { type: (null as unknown) as PropType, required: true },
},
setup(props, context) {
- const { isActive, activate, requestActivation } = useActivation(props.block.blockId);
+ const { isActive, activate } = useActivation(props.block.blockId);
const { getBlock } = useDynamicBlocks();
const classes = computed(() => ({
'sb-block': true,
@@ -28,7 +28,6 @@ export default defineComponent({
}));
const onChildUpdate = (updated: {[key: string]: any}) => {
- console.log('child update', updated);
context.emit('update', {
...props.block,
data: {
@@ -38,33 +37,24 @@ export default defineComponent({
});
};
- return {
- getBlock,
- classes,
- onChildUpdate,
- activate,
- };
- },
+ const Block = getBlock(props.block.name).edit as any;
- render() {
- console.log('render block', this.block);
- const Block = this.getBlock(this.block.name).edit;
- return this.$emit('insert-block', block),
- 'append-block': (block: BlockDefinition) => this.$emit('append-block', block),
+ ...context.listeners,
+ update: onChildUpdate,
+ 'insert-block': (block: BlockDefinition) => context.emit('insert-block', block),
+ 'append-block': (block: BlockDefinition) => context.emit('append-block', block),
},
nativeOn: {
- click: ($event) => {
+ click: ($event: MouseEvent) => {
$event.stopPropagation();
- this.activate();
+ activate();
},
},
}}
diff --git a/src/components/internal/BlockPicker.tsx b/src/components/internal/BlockPicker.tsx
index b3d3641..0b29175 100644
--- a/src/components/internal/BlockPicker.tsx
+++ b/src/components/internal/BlockPicker.tsx
@@ -1,31 +1,31 @@
import { computed, defineComponent } from '@vue/composition-api';
-import { useDynamicBlocks } from '../TreeElement';
+import {
+ useDynamicBlocks,
+ BlockDefinition,
+} from '../TreeElement';
import './BlockPicker.scss';
export default defineComponent({
+ name: 'sb-block-picker',
+
props: {},
- setup() {
+ setup(props, context) {
const { customBlocks } = useDynamicBlocks();
const blockList = computed(() => Object.keys(customBlocks).map((key) => customBlocks[key]));
- console.log(customBlocks, blockList);
- return { blockList };
- },
-
- render() {
- return (
+ return () => (
- {...this.blockList.map((block: BlockDefinition) => (
+ {...blockList.value.map((block: BlockDefinition) => (