Fix TypeScript errors
This commit is contained in:
parent
190a8be207
commit
ff668eff31
|
@ -6,7 +6,15 @@ import {
|
|||
ref,
|
||||
Ref,
|
||||
} from 'vue';
|
||||
import { IBlockData } from '../types';
|
||||
import {
|
||||
IBlockData,
|
||||
OnUpdateBlockCb,
|
||||
OnActivateNextCb,
|
||||
OnRemoveSelfCb,
|
||||
OnAppendBlockCb,
|
||||
OnPrependBlockCb,
|
||||
OnActivatePreviousCb,
|
||||
} from '../types';
|
||||
import { SbMode } from '../mode';
|
||||
import { useResizeObserver, SymBlockDimensions } from '../use-resize-observer';
|
||||
import { useActivation } from '../use-activation';
|
||||
|
@ -34,12 +42,30 @@ export const SbBlock = defineComponent({
|
|||
type: String,
|
||||
default: null,
|
||||
},
|
||||
onUpdate: { type: Function, default: () => {} },
|
||||
onPrependBlock: { type: Function, default: () => {} },
|
||||
onAppendBlock: { type: Function, default: () => {} },
|
||||
onRemoveSelf: { type: Function, default: () => {} },
|
||||
onActivatePrevious: { type: Function, default: () => {} },
|
||||
onActivateNext: { type: Function, default: () => {} },
|
||||
onUpdate: {
|
||||
type: (null as unknown) as PropType<OnUpdateBlockCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onPrependBlock: {
|
||||
type: (null as unknown) as PropType<OnPrependBlockCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onAppendBlock: {
|
||||
type: (null as unknown) as PropType<OnAppendBlockCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onRemoveSelf: {
|
||||
type: (null as unknown) as PropType<OnRemoveSelfCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onActivatePrevious: {
|
||||
type: (null as unknown) as PropType<OnActivatePreviousCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onActivateNext: {
|
||||
type: (null as unknown) as PropType<OnActivateNextCb>,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, context) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { useDynamicBlocks } from '../use-dynamic-blocks';
|
|||
import { IBlockDefinition } from '../types';
|
||||
|
||||
import { SbButton } from './Button';
|
||||
import { SbContextMenu } from './ContextMenu';
|
||||
import { SbContextMenu, IContextMenuSlotContext } from './ContextMenu';
|
||||
|
||||
import './BlockPicker.scss';
|
||||
|
||||
|
@ -39,7 +39,7 @@ export const SbBlockPicker = defineComponent({
|
|||
<SbContextMenu
|
||||
class="sb-tree-block-select"
|
||||
v-slots={{
|
||||
context: (slotContext) => context.slots.context
|
||||
context: (slotContext:IContextMenuSlotContext) => context.slots.context
|
||||
? context.slots.context(slotContext)
|
||||
: <SbButton {...{ onClick: slotContext.toggle }}>Insert a block</SbButton>,
|
||||
default: ({ close }: { close: Function }) => blockList.value.map((block: IBlockDefinition<any>) => (
|
||||
|
|
|
@ -2,11 +2,19 @@ import {
|
|||
watch,
|
||||
defineComponent,
|
||||
ref,
|
||||
Ref,
|
||||
} from 'vue';
|
||||
import { SbButton } from './Button';
|
||||
|
||||
import './ContextMenu.scss';
|
||||
|
||||
export interface IContextMenuSlotContext {
|
||||
opened: Ref<boolean>;
|
||||
open: () => void;
|
||||
close: () => void;
|
||||
toggle: () => void;
|
||||
}
|
||||
|
||||
export const SbContextMenu = defineComponent({
|
||||
name: 'sb-context-menu',
|
||||
|
||||
|
|
|
@ -13,15 +13,23 @@ export interface IBlockData<T> {
|
|||
data: T;
|
||||
}
|
||||
|
||||
export type OnUpdateSelfCb<T> = (updated: Partial<T>) => void;
|
||||
export type OnUpdateBlockCb = (updated: IBlockData<any>) => void;
|
||||
export type OnPrependBlockCb = (block: IBlockData<any>) => void;
|
||||
export type OnAppendBlockCb = (block: IBlockData<any>) => void;
|
||||
export type OnRemoveSelfCb = () => void;
|
||||
export type OnActivatePreviousCb = () => void;
|
||||
export type OnActivateNextCb = () => void;
|
||||
|
||||
export interface IBlockProps<T> {
|
||||
blockId: string;
|
||||
blockId?: string;
|
||||
data?: T,
|
||||
onUpdate?: (b?: IBlockData<T>) => void;
|
||||
onPrependBlock?: (b?: IBlockData<T>) => void;
|
||||
onAppendBlock?: (b?: IBlockData<T>) => void;
|
||||
onRemoveSelf?: () => void;
|
||||
onActivateNext?: () => void;
|
||||
onActivatePrevious?: () => void;
|
||||
onUpdate?: OnUpdateSelfCb<T>;
|
||||
onPrependBlock?: OnPrependBlockCb;
|
||||
onAppendBlock?: OnAppendBlockCb;
|
||||
onRemoveSelf?: OnRemoveSelfCb;
|
||||
onActivateNext?: OnActivateNextCb;
|
||||
onActivatePrevious?: OnActivatePreviousCb;
|
||||
}
|
||||
|
||||
export interface IBlockDefinition<T> {
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
},
|
||||
"scripts": {
|
||||
"dev": "concurrently 'vuedx-typecheck --no-pretty --watch ./lib' 'vite'",
|
||||
"build": "vuedx-typecheck --no-pretty ./lib && vite build"
|
||||
"build": "vuedx-typecheck --no-pretty ./lib && vite build",
|
||||
"typecheck": "vuedx-typecheck --no-pretty ./lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"@schlechtenburg/core": "^0.0.0",
|
||||
|
|
|
@ -13,6 +13,11 @@ import {
|
|||
useActivation,
|
||||
SbToolbar,
|
||||
SbSelect,
|
||||
OnUpdateSelfCb,
|
||||
OnAppendBlockCb,
|
||||
OnRemoveSelfCb,
|
||||
OnActivateNextCb,
|
||||
OnActivatePreviousCb,
|
||||
} from '@schlechtenburg/core';
|
||||
import {
|
||||
getDefaultData,
|
||||
|
@ -33,11 +38,26 @@ export default defineComponent({
|
|||
type: (null as unknown) as PropType<IHeadingData>,
|
||||
default: getDefaultData,
|
||||
},
|
||||
onUpdate: { type: Function, default: () => {} },
|
||||
onAppendBlock: { type: Function, default: () => {} },
|
||||
onRemoveSelf: { type: Function, default: () => {} },
|
||||
onActivateNext: { type: Function, default: () => {} },
|
||||
onActivatePrevious: { type: Function, default: () => {} },
|
||||
onUpdate: {
|
||||
type: (null as unknown) as PropType<OnUpdateSelfCb<IHeadingData>>,
|
||||
default: () => {},
|
||||
},
|
||||
onAppendBlock: {
|
||||
type: (null as unknown) as PropType<OnAppendBlockCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onRemoveSelf: {
|
||||
type: (null as unknown) as PropType<OnRemoveSelfCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onActivateNext: {
|
||||
type: (null as unknown) as PropType<OnActivateNextCb>,
|
||||
default: () => {},
|
||||
},
|
||||
onActivatePrevious: {
|
||||
type: (null as unknown) as PropType<OnActivatePreviousCb>,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
SbButton,
|
||||
SbBlock,
|
||||
IBlockData,
|
||||
OnUpdateSelfCb,
|
||||
} from '@schlechtenburg/core';
|
||||
import { IParagraphData } from '@schlechtenburg/paragraph';
|
||||
import {
|
||||
|
@ -27,7 +28,10 @@ export default defineComponent({
|
|||
model,
|
||||
|
||||
props: {
|
||||
onUpdate: { type: Function, default: () => {} },
|
||||
onUpdate: {
|
||||
type: (null as unknown) as PropType<OnUpdateSelfCb<IImageData>>,
|
||||
default: () => {},
|
||||
},
|
||||
data: {
|
||||
type: (null as unknown) as PropType<IImageData>,
|
||||
default: getDefaultData,
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
import {
|
||||
model,
|
||||
IBlockData,
|
||||
OnUpdateSelfCb,
|
||||
useActivation,
|
||||
|
||||
SbBlock,
|
||||
|
@ -30,7 +31,10 @@ export default defineComponent({
|
|||
model,
|
||||
|
||||
props: {
|
||||
onUpdate: { type: Function, default: () => {} },
|
||||
onUpdate: {
|
||||
type: (null as unknown) as PropType<OnUpdateSelfCb<ILayoutData>>,
|
||||
default: () => {},
|
||||
},
|
||||
data: {
|
||||
type: (null as unknown) as PropType<ILayoutData>,
|
||||
default: getDefaultData,
|
||||
|
|
|
@ -32,11 +32,26 @@ export default defineComponent({
|
|||
type: (null as unknown) as PropType<IParagraphData>,
|
||||
default: getDefaultData,
|
||||
},
|
||||
onUpdate: { type: Function, default: () => {} },
|
||||
onAppendBlock: { type: Function, default: () => {} },
|
||||
onRemoveSelf: { type: Function, default: () => {} },
|
||||
onActivateNext: { type: Function, default: () => {} },
|
||||
onActivatePrevious: { type: Function, default: () => {} },
|
||||
onUpdate: {
|
||||
type: (null as unknown) as PropType<((block?: Partial<IParagraphData>) => void)>,
|
||||
default: () => {},
|
||||
},
|
||||
onAppendBlock: {
|
||||
type: (null as unknown) as PropType<((block?: any) => void)>,
|
||||
default: () => {},
|
||||
},
|
||||
onRemoveSelf: {
|
||||
type: (null as unknown) as PropType<() => void>,
|
||||
default: () => {},
|
||||
},
|
||||
onActivateNext: {
|
||||
type: (null as unknown) as PropType<() => void>,
|
||||
default: () => {},
|
||||
},
|
||||
onActivatePrevious: {
|
||||
type: (null as unknown) as PropType<() => void>,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
|
|
Loading…
Reference in a new issue