Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
Benjamin Bädorf | 44cef9309f | ||
Benjamin Bädorf | eec847ed92 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ dist
|
|||
dist-ssr
|
||||
*.local
|
||||
tags
|
||||
yarn-error.log
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
.sb-missing-block{flex-basis:100%}
|
|
@ -1,2 +0,0 @@
|
|||
import{y as a,m as s,z as e,D as t,e as l}from"./index.a48301fd.js";/* empty css */import"./vendor.a029424f.js";var d=a({name:"sb-image-display",model:s,props:{data:{type:null,default:e}},setup:a=>()=>t("figure",{class:"sb-image"},[t("img",{class:"sb-image__content",src:a.data.src,alt:a.data.alt},null),t(l,{block:a.data.description},null)])});export default d;
|
||||
//# sourceMappingURL=display.54a23f84.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"display.54a23f84.js","sources":["../../packages/image/lib/display.tsx"],"sourcesContent":["import { defineComponent, PropType } from 'vue';\nimport {\n model,\n SbBlock,\n} from '@schlechtenburg/core';\nimport {\n getDefaultData,\n ImageData,\n} from './util';\n\nimport './style.scss';\n\nexport default defineComponent({\n name: 'sb-image-display',\n\n model,\n\n props: {\n data: {\n type: (null as unknown) as PropType<ImageData>,\n default: getDefaultData,\n },\n },\n\n setup(props) {\n return () => <figure class=\"sb-image\">\n <img\n class=\"sb-image__content\"\n src={props.data.src}\n alt={props.data.alt}\n />\n <SbBlock block={props.data.description} />\n </figure>;\n },\n});\n"],"names":["defineComponent","name","model","props","data","type","default","getDefaultData","setup","src","alt","description"],"mappings":"6HAYA,MAAeA,EAAgB,CAC7BC,KAAM,mBAENC,MAAAA,EAEAC,MAAO,CACLC,KAAM,CACJC,KAAO,KACPC,QAASC,IAIbC,MAAML,GACG,sBAAoB,4BAEf,wBACDA,EAAMC,KAAKK,QACXN,EAAMC,KAAKM,sBAEFP,EAAMC,KAAKO"}
|
|
@ -1,2 +0,0 @@
|
|||
var e=Object.assign;import{G as t,m as a,H as n,I as s,J as l}from"./index.a48301fd.js";import"./vendor.a029424f.js";var o=t({name:"sb-missing-block",model:a,props:e(e({},n),{name:String,data:{type:null,default:null},eventUpdate:{type:Function,default:()=>{}},eventAppendBlock:{type:Function,default:()=>{}},eventRemoveBlock:{type:Function,default:()=>{}}}),setup:e=>()=>s("div",{class:"sb-missing-block"},[l("Missing block: "),e.name])});export default o;
|
||||
//# sourceMappingURL=display.82dfc9cb.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"display.82dfc9cb.js","sources":["../../packages/core/lib/components/MissingBlock/display.tsx"],"sourcesContent":["import { defineComponent, PropType } from 'vue';\nimport {\n model,\n blockProps,\n} from '../../block-helpers';\n\nimport './style.scss';\n\nexport default defineComponent({\n name: 'sb-missing-block',\n\n model,\n\n props: {\n ...blockProps,\n name: String,\n data: {\n type: (null as unknown) as PropType<any>,\n default: null,\n },\n eventUpdate: { type: Function, default: () => {} },\n eventAppendBlock: { type: Function, default: () => {} },\n eventRemoveBlock: { type: Function, default: () => {} },\n },\n\n setup(props) {\n return () => (\n <div class=\"sb-missing-block\">Missing block: {props.name}</div>\n );\n },\n});\n"],"names":["defineComponent","name","model","props","__assign","blockProps","String","data","type","default","eventUpdate","Function","eventAppendBlock","eventRemoveBlock","setup"],"mappings":"2HAQeA,EAAgB,CAC7BC,KAAM,mBAENC,MAAAA,EAEAC,MAAOC,OACFC,GADE,CAELJ,KAAMK,OACNC,KAAM,CACJC,KAAO,KACPC,QAAS,MAEXC,YAAa,CAAEF,KAAMG,SAAUF,QAAS,QACxCG,iBAAkB,CAAEJ,KAAMG,SAAUF,QAAS,QAC7CI,iBAAkB,CAAEL,KAAMG,SAAUF,QAAS,UAG/CK,MAAMX,GACG,mBACM,0CAAmCA,EAAMF"}
|
|
@ -1,2 +0,0 @@
|
|||
import{d as a,m as s,g as t,c as e,a as l,e as o}from"./index.a48301fd.js";/* empty css */import"./vendor.a029424f.js";var d=a({name:"sb-layout-display",model:s,props:{data:{type:null,default:t}},setup(a){const s=e((()=>({"sb-layout":!0,[`sb-layout_${a.data.orientation}`]:!0})));return()=>l("div",{class:s.value},[...a.data.children.map((a=>l(o,{key:a.id,block:a},null)))])}});export default d;
|
||||
//# sourceMappingURL=display.a9bb8ea2.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"display.a9bb8ea2.js","sources":["../../packages/layout/lib/display.tsx"],"sourcesContent":["import {\n defineComponent,\n computed,\n PropType,\n} from 'vue';\nimport {\n model,\n SbBlock,\n} from '@schlechtenburg/core';\nimport {\n LayoutData,\n getDefaultData,\n} from './util';\n\nimport './style.scss';\n\nexport default defineComponent({\n name: 'sb-layout-display',\n\n model,\n\n props: {\n data: {\n type: (null as unknown) as PropType<LayoutData>,\n default: getDefaultData,\n },\n },\n\n setup(props) {\n const classes = computed(() => ({\n 'sb-layout': true,\n [`sb-layout_${props.data.orientation}`]: true,\n }));\n\n return () => (\n <div class={classes.value}>\n {...props.data.children.map((child) => (\n <SbBlock\n key={child.id}\n block={child}\n />\n ))}\n </div>\n );\n },\n});\n"],"names":["defineComponent","name","model","props","data","type","default","getDefaultData","setup","classes","computed","orientation","value","children","map","child","id"],"mappings":"oIAgBA,MAAeA,EAAgB,CAC7BC,KAAM,oBAENC,MAAAA,EAEAC,MAAO,CACLC,KAAM,CACJC,KAAO,KACPC,QAASC,IAIbC,MAAML,SACEM,EAAUC,GAAS,KAAO,cACjB,GACX,aAAYP,EAAMC,KAAKO,gBAAgB,YAGpC,mBACOF,EAAQG,WACdT,EAAMC,KAAKS,SAASC,iBAEfC,EAAMC,SACJD"}
|
|
@ -1,2 +0,0 @@
|
|||
import{j as a,m as s,k as r,q as p,s as e,x as t}from"./index.a48301fd.js";/* empty css */import"./vendor.a029424f.js";var l=a({name:"sb-paragraph-display",model:s,props:{data:{type:Object,default:r}},setup(a){const s=p((()=>({"sb-paragraph":!0,[`sb-paragraph_align-${a.data.align}`]:!0})));return()=>e("p",t({class:s.value},{innerHTML:a.data.value}),null)}});export default l;
|
||||
//# sourceMappingURL=display.cf8b58ad.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"display.cf8b58ad.js","sources":["../../packages/paragraph/lib/display.tsx"],"sourcesContent":["import {\n defineComponent,\n computed,\n PropType,\n} from 'vue';\nimport {\n model,\n} from '@schlechtenburg/core';\nimport {\n getDefaultData,\n ParagraphData,\n} from './util';\n\nimport './style.scss';\n\nexport default defineComponent({\n name: 'sb-paragraph-display',\n\n model,\n\n props: {\n data: {\n type: Object as PropType<ParagraphData>,\n default: getDefaultData,\n },\n },\n\n setup(props) {\n const classes = computed(() => ({\n 'sb-paragraph': true,\n [`sb-paragraph_align-${props.data.align}`]: true,\n }));\n\n return () => <p\n class={classes.value}\n {...{\n innerHTML: props.data.value,\n }}\n ></p>;\n },\n});\n"],"names":["defineComponent","name","model","props","data","type","Object","default","getDefaultData","setup","classes","computed","align","value","innerHTML"],"mappings":"oIAeA,MAAeA,EAAgB,CAC7BC,KAAM,uBAENC,MAAAA,EAEAC,MAAO,CACLC,KAAM,CACJC,KAAMC,OACNC,QAASC,IAIbC,MAAMN,SACEO,EAAUC,GAAS,KAAO,iBACd,GACd,sBAAqBR,EAAMC,KAAKQ,UAAU,YAGvC,mBACEF,EAAQG,QAEbC,UAAWX,EAAMC,KAAKS"}
|
|
@ -1,2 +0,0 @@
|
|||
var a=Object.assign;import{y as t,m as e,z as l,A as s,B as n,C as i,D as d,S as r,b as o,E as c,F as u,e as p}from"./index.a48301fd.js";/* empty css */import"./vendor.a029424f.js";var f=t({name:"sb-image-edit",model:e,props:{onUpdate:{type:Function,default:()=>{}},data:{type:null,default:l}},setup(t){const e=s({src:t.data.src,alt:t.data.alt,description:t.data.description}),l=n(null);i((()=>t.data),(()=>{e.src=t.data.src,e.alt=t.data.alt,e.description=t.data.description}));const f=()=>{l.value&&l.value.click()},v=()=>{if(l.value&&l.value.files&&l.value.files.length){const a=new FileReader;a.addEventListener("load",(()=>{var e;const l=null==(e=null==a?void 0:a.result)?void 0:e.toString();if(!l)throw new Error("Couldn't load image src");t.onUpdate({src:l,alt:t.data.alt,description:t.data.description})})),a.readAsDataURL(l.value.files[0])}};return()=>d("figure",{class:"sb-image"},[d(r,null,{default:()=>[e.src?d(o,{onClick:f},{default:()=>[c("Select Image")]}):null,d("input",{type:"file",ref:l,style:"display: none;",onInput:v},null)]}),e.src?d(u,null,[d("img",{src:e.src,alt:e.alt,class:"sb-image__content"},null),d(p,{block:e.description,onUpdate:e=>{return l=e,void t.onUpdate(a(a({},t.data),{description:l}));var l}},null)]):d(o,{onClick:f},{default:()=>[c("Select Image")]})])}});export default f;
|
||||
//# sourceMappingURL=edit.79e9c821.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"edit.79e9c821.js","sources":["../../packages/image/lib/edit.tsx"],"sourcesContent":["import {\n defineComponent,\n reactive,\n ref,\n Ref,\n watch,\n PropType,\n} from 'vue';\nimport {\n model,\n SbToolbar,\n SbButton,\n SbBlock,\n BlockData,\n} from '@schlechtenburg/core';\nimport { ParagraphData } from '@schlechtenburg/paragraph';\nimport {\n getDefaultData,\n ImageData,\n} from './util';\n\nimport './style.scss';\n\nexport default defineComponent({\n name: 'sb-image-edit',\n\n model,\n\n props: {\n onUpdate: { type: Function, default: () => {} },\n data: {\n type: (null as unknown) as PropType<ImageData>,\n default: getDefaultData,\n },\n },\n\n setup(props) {\n const localData = reactive({\n src: props.data.src,\n alt: props.data.alt,\n description: props.data.description,\n });\n\n const fileInput: Ref<null|HTMLInputElement> = ref(null);\n\n watch(() => props.data, () => {\n localData.src = props.data.src;\n localData.alt = props.data.alt;\n localData.description = props.data.description;\n });\n\n const selectImage = () => {\n if (fileInput.value) {\n fileInput.value.click();\n }\n };\n\n const onImageSelect = () => {\n if (fileInput.value && fileInput.value.files && fileInput.value.files.length) {\n const reader = new FileReader();\n reader.addEventListener('load', () => {\n const src = reader?.result?.toString();\n if (!src) {\n throw new Error('Couldn\\'t load image src');\n }\n\n props.onUpdate({\n src,\n alt: props.data.alt,\n description: props.data.description,\n });\n });\n\n reader.readAsDataURL(fileInput.value.files[0]);\n }\n };\n\n const onDescriptionUpdate = (description: BlockData<ParagraphData>) => {\n props.onUpdate({\n ...props.data,\n description,\n });\n };\n\n return () => (\n <figure class=\"sb-image\">\n <SbToolbar>\n {localData.src\n ? <SbButton {...{ onClick: selectImage }}>Select Image</SbButton>\n : null}\n <input\n type=\"file\"\n ref={fileInput}\n style=\"display: none;\"\n onInput={onImageSelect}\n />\n </SbToolbar>\n {localData.src\n ? <>\n <img\n src={localData.src}\n alt={localData.alt}\n class=\"sb-image__content\"\n />\n <SbBlock\n block={localData.description}\n onUpdate={(updated: BlockData<ParagraphData>) => onDescriptionUpdate(updated)}\n />\n </>\n : <SbButton {...{ onClick: selectImage }}>Select Image</SbButton>\n }\n </figure>\n );\n },\n});\n"],"names":["defineComponent","name","model","props","onUpdate","type","Function","default","data","getDefaultData","setup","localData","reactive","src","alt","description","fileInput","ref","selectImage","value","click","onImageSelect","files","length","reader","FileReader","addEventListener","result","toString","Error","readAsDataURL","onClick","onDescriptionUpdate","updated","__assign"],"mappings":"kMAuBA,MAAeA,EAAgB,CAC7BC,KAAM,gBAENC,MAAAA,EAEAC,MAAO,CACLC,SAAU,CAAEC,KAAMC,SAAUC,QAAS,QACrCC,KAAM,CACJH,KAAO,KACPE,QAASE,IAIbC,MAAMP,SACEQ,EAAYC,EAAS,CACzBC,IAAKV,EAAMK,KAAKK,IAChBC,IAAKX,EAAMK,KAAKM,IAChBC,YAAaZ,EAAMK,KAAKO,cAGpBC,EAAwCC,EAAI,SAE5C,IAAMd,EAAMK,OAAM,OACZK,IAAMV,EAAMK,KAAKK,MACjBC,IAAMX,EAAMK,KAAKM,MACjBC,YAAcZ,EAAMK,KAAKO,qBAG/BG,EAAc,KACdF,EAAUG,SACFA,MAAMC,SAIdC,EAAgB,QAChBL,EAAUG,OAASH,EAAUG,MAAMG,OAASN,EAAUG,MAAMG,MAAMC,OAAQ,OACtEC,EAAS,IAAIC,aACZC,iBAAiB,QAAQ,iBACxBb,EAAMW,0BAAQG,iBAAQC,eACvBf,QACG,IAAIgB,MAAM,6BAGZzB,SAAS,CACbS,IAAAA,EACAC,IAAKX,EAAMK,KAAKM,IAChBC,YAAaZ,EAAMK,KAAKO,mBAIrBe,cAAcd,EAAUG,MAAMG,MAAM,YAWxC,sBACS,oCAETX,EAAUE,SACSkB,QAASb,sCACzB,qBAEG,WACAF,QACC,yBACGK,YAGZV,EAAUE,2BAGEF,EAAUE,QACVF,EAAUG,UACT,sCAGCH,EAAUI,yBACgCiB,SAAoBC,SA5BzE7B,SAAS8B,OACV/B,EAAMK,MADI,CAEbO,YAAAA,KAHyBA,qBAgCLgB,QAASb"}
|
|
@ -1,2 +0,0 @@
|
|||
var e=Object.assign;import{d as n,m as i,g as t,u as l,r as a,w as d,c as r,a as o,S as c,b as h,e as s,f as p,h as u,i as v}from"./index.a48301fd.js";/* empty css */import"./vendor.a029424f.js";var f=n({name:"sb-layout-edit",model:i,props:{onUpdate:{type:Function,default:()=>{}},data:{type:null,default:t}},setup(n){const{activate:i}=l(),t=a({orientation:n.data.orientation,children:[...n.data.children]});d((()=>n.data),(()=>{t.orientation=n.data.orientation,t.children=[...n.data.children]}));const f=r((()=>({"sb-layout":!0,[`sb-layout_${t.orientation}`]:!0}))),m=()=>{n.onUpdate({orientation:"vertical"===t.orientation?"horizontal":"vertical"})},U=e=>{t.children=[...t.children,e],n.onUpdate({children:[...t.children]}),i(e.id)},b=(e,l)=>{t.children=[...t.children.slice(0,e+1),l,...t.children.slice(e+1)],n.onUpdate({children:[...t.children]}),i(l.id)},y=e=>{t.children=[...t.children.slice(0,e),...t.children.slice(e+1)],n.onUpdate({children:[...t.children]});const l=Math.max(e-1,0);i(t.children[l].id)},k=e=>{const n=Math.max(Math.min(t.children.length-1,e),0);i(t.children[n].id)};return()=>o("div",{class:f.value},[o(c,null,{default:()=>[o(h,{type:"button",onClick:m},{default:()=>[t.orientation]})]}),...t.children.map(((i,l)=>o(s,p({key:i.id},{"data-order":l,block:i,onUpdate:l=>((i,l)=>{const a=t.children.indexOf(i);-1!==a&&n.onUpdate({children:[...t.children.slice(0,a),e(e({},i),l),...t.children.slice(a+1)]})})(i,l),onRemoveSelf:()=>y(l),onPrependBlock:e=>b(l-1,e),onAppendBlock:e=>b(l,e),onActivatePrevious:()=>k(l-1),onActivateNext:()=>k(l+1)}),{"context-toolbar":()=>o(u,{onMoveBackward:()=>(e=>{if(0===e)return;const i=t.children[e],l=t.children[e-1];t.children=[...t.children.slice(0,e-1),i,l,...t.children.slice(e+1)],n.onUpdate({children:[...t.children]})})(l),onMoveForward:()=>(e=>{if(e===t.children.length-1)return;const i=t.children[e],l=t.children[e+1];t.children=[...t.children.slice(0,e),l,i,...t.children.slice(e+2)],n.onUpdate({children:[...t.children]})})(l),onRemove:()=>y(l),orientation:t.orientation},null)}))),o(v,{onInsertBlock:U},null)])}});export default f;
|
||||
//# sourceMappingURL=edit.85b1500c.js.map
|
File diff suppressed because one or more lines are too long
|
@ -1,2 +0,0 @@
|
|||
import{j as a,m as e,k as n,l as t,n as l,u as o,o as u,p as i,q as s,s as r,S as d,t as p,v}from"./index.a48301fd.js";/* empty css */import"./vendor.a029424f.js";var c=a({name:"sb-paragraph-edit",model:e,props:{blockId:{type:String,required:!0},data:{type:null,default:n},onUpdate:{type:Function,default:()=>{}},onAppendBlock:{type:Function,default:()=>{}},onRemoveSelf:{type:Function,default:()=>{}},onActivateNext:{type:Function,default:()=>{}},onActivatePrevious:{type:Function,default:()=>{}}},setup(a){const e=t({value:a.data.value,align:a.data.align,focused:!1}),c=l(null),{isActive:f,activate:g}=o(a.blockId),y=()=>{c.value&&f.value&&c.value.focus()};u((()=>{y(),c.value&&(c.value.innerHTML=e.value)})),i(f,y),i((()=>a.data),(()=>{e.value=a.data.value,e.align=a.data.align,c.value&&(c.value.innerHTML=e.value)}));const h=a=>{e.value=a.target.innerHTML},b=s((()=>({"sb-paragraph":!0,"sb-paragraph_focused":e.focused,[`sb-paragraph_align-${e.align}`]:!0}))),m=n=>{a.onUpdate({value:e.value,align:n.target.value})},k=()=>{e.focused=!0,g()},A=()=>{e.focused=!1,a.onUpdate({value:e.value,align:e.align})},w=e=>{if("Enter"===e.key&&!e.shiftKey){const t=""+ +new Date;a.onAppendBlock({id:t,name:"sb-paragraph",data:n()}),g(t),e.preventDefault()}},F=n=>{var t;"Backspace"===n.key&&""===e.value&&a.onRemoveSelf();const l=window.getSelection(),o=null==l?void 0:l.focusNode,u=Array.from((null==(t=null==c?void 0:c.value)?void 0:t.childNodes)||[]),i=o?u.indexOf(o):-1;if(o===c.value||0===i||i===u.length-1)switch(n.key){case"ArrowDown":a.onActivateNext();break;case"ArrowUp":a.onActivatePrevious()}};return()=>r("div",{class:b.value},[r(d,null,{default:()=>[r(p,{value:e.align,onChange:m},{default:()=>[r("option",null,[v("left")]),r("option",null,[v("center")]),r("option",null,[v("right")])]})]}),r("p",{class:"sb-paragraph__input",ref:c,contenteditable:!0,onInput:h,onFocus:k,onBlur:A,onKeydown:w,onKeyup:F},null)])}});export default c;
|
||||
//# sourceMappingURL=edit.b0a76e09.js.map
|
File diff suppressed because one or more lines are too long
|
@ -1,2 +0,0 @@
|
|||
export default{};
|
||||
//# sourceMappingURL=edit.bd5075df.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"edit.bd5075df.js","sources":["../../packages/heading/lib/edit.tsx"],"sourcesContent":["export default {};\n"],"names":[],"mappings":"cAAe"}
|
|
@ -1 +0,0 @@
|
|||
@charset "UTF-8";.sb-button{border:0;padding:8px 12px;background-color:var(--grey-0);border:1px solid var(--grey-2)}.sb-button:hover{border:1px solid var(--interact)}.sb-context{position:relative}.sb-context-menu{display:none;flex-direction:column;background:var(--grey-0);border:1px solid var(--grey-3);top:100%;left:0;margin:0;z-index:var(--z-context-menu);max-height:70vh;max-width:100vw;overflow:auto}.sb-context-menu[open]{display:flex}.sb-tree-block-select__list{list-style:none;margin:0;padding:0}.sb-tree-block-select__list_base{padding-right:1rem}.sb-tree-block-select__block{padding:0;margin:0;padding-left:1rem}.sb-tree-block-select__block-name{display:block;background:0 0;border:0;font:inherit;color:inherit;padding:.5rem 1rem;width:100%;text-align:left}.sb-tree-block-select__block_active>.sb-tree-block-select__block-name{outline:1px solid var(--interact)}.sb-block{display:flex;align-items:stretch;justify-items:stretch;height:auto}.sb-block>*>.sb-toolbar{opacity:0;pointer-events:none}.sb-block>.sb-block-ordering{opacity:0;pointer-events:none}.sb-block_active{outline:4px solid var(--interact)}.sb-block_active>*>.sb-toolbar{opacity:1;pointer-events:all;outline:1px solid var(--grey-2)}.sb-block_active>.sb-block-ordering{opacity:1;pointer-events:all}.sb-block_highlighted{outline:2px solid var(--interact)}.sb-main{position:relative;background-color:var(--bg);padding:50px 40px}.sb-modal__overlay{background-color:var(--grey-3-t);position:fixed;z-index:10;top:0;left:0;bottom:0;right:0;padding:10vh 10vw;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none}.sb-modal__content{width:900px;max-width:100%;height:auto;max-height:100%;background-color:var(--grey-0);padding:24px 32px}.sb-modal_open .sb-modal__overlay{opacity:1;pointer-events:all}.sb-block-picker{display:flex;justify-content:center;align-items:center;height:100%;width:100%}.sb-block-picker__add-button{padding:24px 32px}.sb-block-ordering{display:flex;position:absolute;flex-direction:column}.sb-block-placeholder{width:100%;position:relative;overflow:visible}.sb-block-placeholder__add{background-color:var(--grey-1);width:100%}.sb-toolbar{position:absolute;width:auto;height:auto}.sb-select{background-color:var(--grey-0);border:1px solid var(--grey-2);position:relative}.sb-select:hover{border:1px solid var(--interact)}.sb-select::after{position:absolute;content:"⯆";top:6px;height:100%;right:12px;pointer-events:none}.sb-select__input{background:0 0;appearance:none;border:0;padding:8px 32px 8px 12px}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#2c3e50}*,::after,::before{box-sizing:border-box}html{--grey-0:white;--grey-1-t:rgba(0, 0, 0, 0.05);--grey-1:rgb(242, 242, 242);--grey-2-t:rgba(0, 0, 0, 0.1);--grey-2:rgb(230, 230, 230);--grey-3-t:rgba(0, 0, 0, 0.2);--grey-3:rgb(205, 205, 205);--grey-4-t:rgba(0, 0, 0, 0.4);--grey-4:rgb(155, 155, 155);--grey-5-t:rgba(0, 0, 0, 0.7);--grey-5:rgb(75, 75, 75);--black:rgba(0, 0, 0, 0.9);--bg:var(--grey-1);--fg:var(--black);--interact:#3f9cff;--z-context-menu:3000}body{margin:0;min-height:100vh}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
.sb-paragraph{flex-basis:100%}.sb-paragraph__input{display:block;flex-basis:100%}.sb-paragraph_align-left,.sb-paragraph_align-left .sb-paragraph__input{text-align:left}.sb-paragraph_align-right,.sb-paragraph_align-right .sb-paragraph__input{text-align:right}.sb-paragraph_align-center,.sb-paragraph_align-center .sb-paragraph__input{text-align:center}
|
|
@ -1 +0,0 @@
|
|||
.sb-layout{display:flex}.sb-layout_vertical{flex-direction:column}.sb-layout_horizontal{flex-direction:row}.sb-layout__item{position:relative}.sb-layout>*{flex-basis:auto;flex-grow:1;flex-shrink:1}
|
|
@ -1 +0,0 @@
|
|||
.sb-image{margin:0}.sb-image__content{width:100%;height:auto}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="./favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<script type="module" crossorigin src="./assets/index.a48301fd.js"></script>
|
||||
<link rel="modulepreload" href="./assets/vendor.a029424f.js">
|
||||
<link rel="stylesheet" href="./assets/index.62d1366f.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
19
package.json
19
package.json
|
@ -2,23 +2,8 @@
|
|||
"name": "schlechtenburg",
|
||||
"version": "0.0.0",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"dev": "concurrently 'vuedx-typecheck --no-pretty --watch ./src' 'vite'",
|
||||
"build": "vuedx-typecheck --no-pretty ./src && vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash-es": "^4.17.21",
|
||||
"vue": "^3.0.7"
|
||||
},
|
||||
"scripts": {},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue-jsx": "^1.1.2",
|
||||
"@vue/compiler-sfc": "^3.0.7",
|
||||
"@vuedx/typecheck": "^0.6.3",
|
||||
"@vuedx/typescript-plugin-vue": "^0.6.3",
|
||||
"concurrently": "^6.0.0",
|
||||
"lerna": "^3.22.1",
|
||||
"sass": "^1.32.8",
|
||||
"typescript": "^4.2.3",
|
||||
"vite": "^2.0.5"
|
||||
"lerna": "^3.22.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,11 @@ import {
|
|||
} from 'vue';
|
||||
import { BlockData } from '../types';
|
||||
import { SbMode } from '../mode';
|
||||
import { useResizeObserver, SymBlockDimensions } from '../use-resize-observer';
|
||||
import { useActivation } from '../use-activation';
|
||||
import { useBlockTree } from '../use-block-tree';
|
||||
import { useDynamicBlocks } from '../use-dynamic-blocks';
|
||||
|
||||
import SbMissingBlock from './MissingBlock';
|
||||
|
||||
import './Block.scss';
|
||||
|
||||
export const SbBlock = defineComponent({
|
||||
name: 'sb-block',
|
||||
|
||||
|
@ -40,17 +36,7 @@ export const SbBlock = defineComponent({
|
|||
setup(props, context) {
|
||||
const el: Ref<null|HTMLElement> = ref(null);
|
||||
const { mode, getBlock } = useDynamicBlocks();
|
||||
const {
|
||||
isActive,
|
||||
activate,
|
||||
} = useActivation(props.block.id);
|
||||
const classes = computed(() => ({
|
||||
'sb-block': true,
|
||||
'sb-block_active': isActive.value,
|
||||
}));
|
||||
|
||||
const { triggerSizeCalculation } = useResizeObserver(el, SymBlockDimensions);
|
||||
watch(() => props.block.data, triggerSizeCalculation);
|
||||
const classes = computed(() => ({ 'sb-block': true }));
|
||||
|
||||
const { register } = useBlockTree();
|
||||
register(props.block);
|
||||
|
@ -88,8 +74,6 @@ export const SbBlock = defineComponent({
|
|||
ref={el}
|
||||
class={classes.value}
|
||||
>
|
||||
<div class="sb-block__edit-cover"></div>
|
||||
{context.slots['context-toolbar'] ? context.slots['context-toolbar']() : null}
|
||||
<BlockComponent
|
||||
data={props.block.data}
|
||||
blockId={props.block.id}
|
||||
|
@ -103,7 +87,6 @@ export const SbBlock = defineComponent({
|
|||
{...{
|
||||
onClick: ($event: MouseEvent) => {
|
||||
$event.stopPropagation();
|
||||
activate();
|
||||
},
|
||||
...context.attrs,
|
||||
}}
|
||||
|
|
|
@ -21,14 +21,9 @@ import {
|
|||
SymBlockTreeUnregister,
|
||||
} from '../use-block-tree';
|
||||
import { SymEditorDimensions, useResizeObserver } from '../use-resize-observer';
|
||||
import { SymActiveBlock } from '../use-activation';
|
||||
|
||||
import { SbMainMenu } from './MainMenu';
|
||||
import { SbBlockToolbar } from './BlockToolbar';
|
||||
import { SbBlock } from './Block';
|
||||
|
||||
import './Main.scss';
|
||||
|
||||
export const SbMain = defineComponent({
|
||||
name: 'sb-main',
|
||||
|
||||
|
@ -60,9 +55,6 @@ export const SbMain = defineComponent({
|
|||
const mode = ref(props.mode);
|
||||
provide(Mode, mode);
|
||||
|
||||
const activeBlock = ref(null);
|
||||
provide(SymActiveBlock, activeBlock);
|
||||
|
||||
const blockTree: Ref<TreeNode|null> = ref(null);
|
||||
provide(SymBlockTree, blockTree);
|
||||
provide(SymBlockTreeRegister, (block: TreeNode) => { blockTree.value = block; });
|
||||
|
@ -82,14 +74,6 @@ export const SbMain = defineComponent({
|
|||
class="sb-main"
|
||||
ref={el}
|
||||
>
|
||||
{
|
||||
mode.value === SbMode.Edit
|
||||
? <>
|
||||
<SbMainMenu block={props.block} />
|
||||
<SbBlockToolbar />
|
||||
</>
|
||||
: null
|
||||
}
|
||||
<SbBlock
|
||||
block={props.block}
|
||||
onUpdate={props.onUpdate}
|
||||
|
|
1
packages/docs/.gitignore
vendored
Normal file
1
packages/docs/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/dist
|
11
packages/docs/README.md
Normal file
11
packages/docs/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# `@schlechtenburg/docs`
|
||||
|
||||
> TODO: description
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
const docs = require('@schlechtenburg/docs');
|
||||
|
||||
// TODO: DEMONSTRATE API
|
||||
```
|
7
packages/docs/__tests__/docs.test.js
Normal file
7
packages/docs/__tests__/docs.test.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const docs = require('..');
|
||||
|
||||
describe('@schlechtenburg/docs', () => {
|
||||
it('needs tests');
|
||||
});
|
|
@ -8,6 +8,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
<script type="module" src="/lib/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
41
packages/docs/lib/App.tsx
Normal file
41
packages/docs/lib/App.tsx
Normal file
|
@ -0,0 +1,41 @@
|
|||
import {
|
||||
onBeforeMount,
|
||||
defineComponent,
|
||||
reactive,
|
||||
} from 'vue';
|
||||
|
||||
import { SbMain, BlockData, SbMode } from '@schlechtenburg/core';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'App',
|
||||
|
||||
setup() {
|
||||
const block: BlockData<any> = reactive({
|
||||
name: 'none',
|
||||
id: '0',
|
||||
data: null,
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const res = await fetch('./initial-data.json');
|
||||
const data = await res.json();
|
||||
block.name = data.name;
|
||||
block.id = data.id;
|
||||
block.data = data.data;
|
||||
});
|
||||
|
||||
return () => {
|
||||
return <div id="app">
|
||||
<SbMain
|
||||
block={block}
|
||||
onUpdate={(newBlock: BlockData<any>) => {
|
||||
block.data = newBlock.data;
|
||||
}}
|
||||
customBlocks={[ ]}
|
||||
key="edit"
|
||||
mode={SbMode.Edit}
|
||||
/>
|
||||
</div>;
|
||||
};
|
||||
},
|
||||
});
|
7
packages/docs/lib/docs.js
Normal file
7
packages/docs/lib/docs.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = docs;
|
||||
|
||||
function docs() {
|
||||
// TODO
|
||||
}
|
46
packages/docs/package.json
Normal file
46
packages/docs/package.json
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "@schlechtenburg/docs",
|
||||
"version": "0.0.0",
|
||||
"description": "> TODO: description",
|
||||
"author": "Benjamin Bädorf <hello@benjaminbaedorf.eu>",
|
||||
"homepage": "",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"main": "lib/index.ts",
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@git.b12f.io:b12f/schlechtenburg.git"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "concurrently 'vuedx-typecheck --no-pretty --watch ./lib' 'vite'",
|
||||
"build": "vuedx-typecheck --no-pretty ./lib && vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@schlechtenburg/core": "^0.0.0",
|
||||
"@schlechtenburg/heading": "^0.0.0",
|
||||
"@schlechtenburg/image": "^0.0.0",
|
||||
"@schlechtenburg/layout": "^0.0.0",
|
||||
"@schlechtenburg/paragraph": "^0.0.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"vue": "^3.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue-jsx": "^1.1.2",
|
||||
"@vue/compiler-sfc": "^3.0.7",
|
||||
"@vuedx/typecheck": "^0.6.3",
|
||||
"@vuedx/typescript-plugin-vue": "^0.6.3",
|
||||
"concurrently": "^6.0.0",
|
||||
"sass": "^1.32.8",
|
||||
"typescript": "^4.2.3",
|
||||
"vite": "^2.0.5"
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
26
packages/docs/vite.config.js
Normal file
26
packages/docs/vite.config.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
|
||||
export default {
|
||||
base: './',
|
||||
resolve: {
|
||||
alias: {
|
||||
'@schlechtenburg/core': '../core/lib/index.ts',
|
||||
'@schlechtenburg/paragraph': '../paragraph/lib/index.ts',
|
||||
'@schlechtenburg/heading': '../heading/lib/index.ts',
|
||||
'@schlechtenburg/image': '../image/lib/index.ts',
|
||||
'@schlechtenburg/layout': '../layout/lib/index.ts',
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
vueJsx({}),
|
||||
],
|
||||
esbuild: {
|
||||
jsxFactory: 'h',
|
||||
jsxFragment: 'Fragment',
|
||||
},
|
||||
build: {
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
outDir: 'dist',
|
||||
},
|
||||
};
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
File diff suppressed because one or more lines are too long
87
src/App.tsx
87
src/App.tsx
|
@ -1,87 +0,0 @@
|
|||
import {
|
||||
onBeforeMount,
|
||||
computed,
|
||||
defineComponent,
|
||||
reactive,
|
||||
ref,
|
||||
} from 'vue';
|
||||
|
||||
import { SbMain, BlockData, SbMode } from '../packages/core/lib';
|
||||
|
||||
import SbLayout from '../packages/layout/lib';
|
||||
import SbHeading from '../packages/heading/lib';
|
||||
import SbParagraph from '../packages/paragraph/lib';
|
||||
import SbImage from '../packages/image/lib';
|
||||
|
||||
import './App.scss';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'App',
|
||||
|
||||
setup() {
|
||||
const activeTab = ref('edit');
|
||||
const block: BlockData<any> = reactive({
|
||||
name: 'none',
|
||||
id: '0',
|
||||
data: null,
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const res = await fetch('./initial-data.json');
|
||||
const data = await res.json();
|
||||
block.name = data.name;
|
||||
block.id = data.id;
|
||||
block.data = data.data;
|
||||
});
|
||||
|
||||
const displayedElement = computed(() => {
|
||||
switch (activeTab.value) {
|
||||
case SbMode.Edit:
|
||||
return <SbMain
|
||||
block={block}
|
||||
onUpdate={(newBlock: BlockData<any>) => {
|
||||
block.data = newBlock.data;
|
||||
}}
|
||||
customBlocks={[
|
||||
SbLayout,
|
||||
SbHeading,
|
||||
SbImage,
|
||||
SbParagraph,
|
||||
]}
|
||||
key="edit"
|
||||
mode={SbMode.Edit}
|
||||
/>;
|
||||
case SbMode.Display:
|
||||
return <SbMain
|
||||
block={block}
|
||||
customBlocks={[
|
||||
SbLayout,
|
||||
SbHeading,
|
||||
SbImage,
|
||||
SbParagraph,
|
||||
]}
|
||||
key="display"
|
||||
mode={SbMode.Display}
|
||||
/>;
|
||||
case 'data':
|
||||
return <pre><code>{ JSON.stringify(block, null, 2) }</code></pre>;
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
return <div id="app">
|
||||
<select
|
||||
value={activeTab.value}
|
||||
onChange={($event: Event) => {
|
||||
activeTab.value = ($event.target as HTMLSelectElement).value;
|
||||
}}
|
||||
>
|
||||
<option>edit</option>
|
||||
<option>display</option>
|
||||
<option>data</option>
|
||||
</select>
|
||||
{displayedElement.value}
|
||||
</div>;
|
||||
};
|
||||
},
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
|
||||
export default {
|
||||
base: './',
|
||||
plugins: [
|
||||
vueJsx({}),
|
||||
],
|
||||
esbuild: {
|
||||
jsxFactory: 'h',
|
||||
jsxFragment: 'Fragment',
|
||||
},
|
||||
build: {
|
||||
sourcemap: true,
|
||||
outDir: 'docs',
|
||||
},
|
||||
};
|
Loading…
Reference in a new issue