Tryna calm TS

This commit is contained in:
Benjamin Bädorf 2020-05-25 20:07:34 +02:00
parent 7506f5b666
commit 517dd91119
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
7 changed files with 47 additions and 67 deletions

29
.drone.yml Normal file
View file

@ -0,0 +1,29 @@
workspace:
path: /sb
kind: pipeline
type: docker
name: default
steps:
- name: build
image: node:12
commands:
- npm ci
- npm run build
- name: publish
when:
branch:
- master
image: appleboy/drone-scp
repo: b12f/bbcom
settings:
host: web5svsvy.wh.hosting.zone
port: 2244
username:
from_secret: bbcom_ssh_user
key:
from_secret: bbcom_ssh_key
source: ./dist/*
target: /home/web5svsvy/html/schlechtenburg.b12f.io/
rm: true

View file

@ -1 +1,2 @@
export const a = 1;
export const getDefaultData = () => ({});

View file

@ -1,10 +1,8 @@
import {
defineComponent,
reactive,
computed,
ref,
Ref,
onMounted,
watch,
PropType,
} from '@vue/composition-api';
@ -14,14 +12,14 @@ import {
useActivation,
} from '@components/TreeElement';
import SbToolbar from '@internal/Toolbar';
import {
getDefaultData,
ImageData,
ImageProps,
} from './util';
import SbToolbar from '@internal/Toolbar';
import './style.scss';
export default defineComponent({
@ -37,33 +35,27 @@ export default defineComponent({
},
},
setup(props: ImageProps, context) {
setup(props: ImageProps) {
const localData = reactive({
src: props.data.src,
alt: props.data.alt,
});
console.log(localData);
const fileInput: Ref<null|HTMLInputElement> = ref(null);
const { isActive } = useActivation(props.blockId);
watch(() => props.data, () => {
console.log('props update image');
localData.src = props.data.src;
localData.alt = props.data.alt;
});
const selectImage = () => {
console.log(fileInput);
if (fileInput.value) {
fileInput.value.click();
}
};
const onImageSelect = () => {
console.log('select image');
if (fileInput.value && fileInput.value.files && fileInput.value.files.length) {
localData.src = window.URL.createObjectURL(fileInput.value.files[0]);
}
@ -93,9 +85,9 @@ export default defineComponent({
}}
/>
</SbToolbar>
{this.localData.src ?
<img src={this.localData.src} alt={this.localData.alt} /> :
<button
{this.localData.src
? <img src={this.localData.src} alt={this.localData.alt} />
: <button
{...{
on: {
click: this.selectImage,

View file

@ -1,5 +1,4 @@
import {
inject,
reactive,
computed,
defineComponent,
@ -14,16 +13,17 @@ import {
BlockData,
BlockDefinition,
} from '@components/TreeElement';
import SbBlock from '@internal/Block';
import SbToolbar from '@internal/Toolbar';
import SbBlockPlaceholder from '@internal/BlockPlaceholder';
import {
LayoutData,
LayoutProps,
getDefaultData,
} from './util';
import SbBlock from '@internal/Block';
import SbToolbar from '@internal/Toolbar';
import SbBlockPlaceholder from '@internal/BlockPlaceholder';
import './style.scss';
export default defineComponent({

View file

@ -14,14 +14,14 @@ import {
useActivation,
} from '@components/TreeElement';
import SbToolbar from '@internal/Toolbar';
import {
getDefaultData,
ParagraphData,
ParagraphProps,
} from './util';
import SbToolbar from '@internal/Toolbar';
import './style.scss';
export default defineComponent({

View file

@ -1,43 +0,0 @@
/* eslint no-param-reassign: 0 */
function addUserBlock(Vue, block) {
if (Vue.prototype.$sb.blocks[block.name]) {
console.warn(`Block ${block.name} is already registered`);
}
Vue.prototype.$sb.blocks[block.name] = block;
}
export default {
install(Vue, { blocks }: { blocks: UserBlock[] } = { blocks: [] }) {
Vue.prototype.$sb = {
blocks: {},
activeBlockId: null,
};
addUserBlock(Vue, {
name: 'sb-layout',
edit: () => import('@user/Layout'),
display: () => import('@user/Layout'),
});
addUserBlock(Vue, {
name: 'sb-image',
edit: () => import('@user/Image'),
display: () => import('@user/Image'),
});
addUserBlock(Vue, {
name: 'sb-paragraph',
edit: () => import('@user/Paragraph'),
display: () => import('@user/Paragraph'),
});
addUserBlock(Vue, {
name: 'sb-heading',
edit: () => import('@user/Heading'),
display: () => import('@user/Heading'),
});
blocks.forEach((block) => addUserBlock(Vue, block));
},
};

View file

@ -15,9 +15,10 @@
"jest"
],
"paths": {
"@/*": [
"src/*"
]
"@/*": [ "src/*" ],
"@components/*": [ "src/components/*" ],
"@user/*": [ "src/components/user/*" ],
"@internal/*": [ "src/components/internal/*" ]
},
"lib": [
"esnext",