Skip to content

Commit

Permalink
feat: add react-at & fix loadJsForceUmd deps
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Apr 19, 2020
1 parent eda6b7d commit 48b0ee7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions public/code/index.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- hello-world.jsx
- react-at.jsx
- vue-at.js
- vue-render-h.js
- vue-string-template.js
Expand Down
35 changes: 35 additions & 0 deletions public/code/react-at.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//// hack for current version of react-at
await loadJs('https://unpkg.com/[email protected]/prop-types.min.js')
React.PropTypes = PropTypes

// await loadJs('https://unpkg.com/react-at')
await loadJsForceUmd({
url: 'https://unpkg.com/[email protected]/dist/index.js',
name: 'ReactAt',
deps: { react: 'React' },
})
////

let { default: At } = ReactAt

appendCss(`
.editor { margin-top:20px; padding:4px 8px; height:120px; border:solid 1px gray; white-space:pre-wrap }
`)

let members = ['fritx', 'linguokang', 'huangruichang']

let App = () => {
return (
<div style={{ padding: 20 }}>
<h1>react-at</h1>
<a target="_blank" href="https://github.com/fritx/react-at">
https://github.com/fritx/react-at
</a>
<At members={members}>
<div style={{ height: 100 }}>
<div class="editor" contentEditable>@fritx @huangruichang&nbsp;</div>
</div>
</At>
</div>
)
}
Binary file added public/code/react-at.jsx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion public/code/react-editor-sizing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ let { DragSizing } = ReactDragSizing
let MyCard = styled.div`
margin-top: 20px;
`

let MyEditor = styled(Editor)`
border: solid 1px gray; padding: 4px 10px; overflow: auto;
`
Expand All @@ -16,6 +15,9 @@ let App = () => {
return (
<div style={{ padding: 20 }}>
<h1>react-editor-sizing</h1>
<a target="_blank" href="https://github.com/fritx/react-drag-sizing">
https://github.com/fritx/react-drag-sizing
</a>

<MyCard>
<DragSizing border="bottom" style={{ minHeight: 32, height: 100 }}>
Expand Down
4 changes: 3 additions & 1 deletion public/code/react-editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ let { Editor } = ReactEditor
let MyCard = styled.div`
margin-top: 20px;
`

let MyEditor = styled(Editor)`
border: solid 1px gray; padding: 4px 10px; overflow: auto;
`
Expand All @@ -14,6 +13,9 @@ let App = () => {
return (
<div style={{ padding: 20 }}>
<h1>react-editor</h1>
<a target="_blank" href="https://github.com/fritx/react-editor">
https://github.com/fritx/react-editor
</a>

<MyCard>
<div style={{ height: 100 }}>
Expand Down
4 changes: 3 additions & 1 deletion public/code/vue-at.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ await loadJs('https://unpkg.com/[email protected]/dist/vue.min.js')
await loadJsForceUmd({
url: 'https://unpkg.com/[email protected]/dist/vue-at.js',
name: 'VueAt',
deps: { vue: Vue },
})

appendCss(`
Expand All @@ -18,6 +17,9 @@ let App = {
template: `
<div class="container">
<h1>Vue At</h1>
<a target="_blank" href="https://github.com/fritx/vue-at">
https://github.com/fritx/vue-at
</a>
<at :members="members" v-model="input">
<div class="editor" contenteditable></div>
</at>
Expand Down
2 changes: 1 addition & 1 deletion src/playground/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export let loadJsForceUmd = async ({
let module = { exports: {} }
let require = k => {
${Object.keys(deps)
.map(k => `if (k === ${k}) return ${deps[k]}`)
.map(k => `if (k === ${JSON.stringify(k)}) return ${deps[k]}`)
.join('\n')}
throw new Error(\`module '\${k}' not found\`)
}
Expand Down

0 comments on commit 48b0ee7

Please sign in to comment.