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 = () => ({}); export const getDefaultData = () => ({});

View file

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

View file

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

View file

@ -14,14 +14,14 @@ import {
useActivation, useActivation,
} from '@components/TreeElement'; } from '@components/TreeElement';
import SbToolbar from '@internal/Toolbar';
import { import {
getDefaultData, getDefaultData,
ParagraphData, ParagraphData,
ParagraphProps, ParagraphProps,
} from './util'; } from './util';
import SbToolbar from '@internal/Toolbar';
import './style.scss'; import './style.scss';
export default defineComponent({ 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" "jest"
], ],
"paths": { "paths": {
"@/*": [ "@/*": [ "src/*" ],
"src/*" "@components/*": [ "src/components/*" ],
] "@user/*": [ "src/components/user/*" ],
"@internal/*": [ "src/components/internal/*" ]
}, },
"lib": [ "lib": [
"esnext", "esnext",