Skip to content

Commit 48b0ee7

Browse files
committed
feat: add react-at & fix loadJsForceUmd deps
1 parent eda6b7d commit 48b0ee7

File tree

7 files changed

+46
-4
lines changed

7 files changed

+46
-4
lines changed

public/code/index.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- hello-world.jsx
2+
- react-at.jsx
23
- vue-at.js
34
- vue-render-h.js
45
- vue-string-template.js

public/code/react-at.jsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//// hack for current version of react-at
2+
await loadJs('https://unpkg.com/[email protected]/prop-types.min.js')
3+
React.PropTypes = PropTypes
4+
5+
// await loadJs('https://unpkg.com/react-at')
6+
await loadJsForceUmd({
7+
url: 'https://unpkg.com/[email protected]/dist/index.js',
8+
name: 'ReactAt',
9+
deps: { react: 'React' },
10+
})
11+
////
12+
13+
let { default: At } = ReactAt
14+
15+
appendCss(`
16+
.editor { margin-top:20px; padding:4px 8px; height:120px; border:solid 1px gray; white-space:pre-wrap }
17+
`)
18+
19+
let members = ['fritx', 'linguokang', 'huangruichang']
20+
21+
let App = () => {
22+
return (
23+
<div style={{ padding: 20 }}>
24+
<h1>react-at</h1>
25+
<a target="_blank" href="https://github.com/fritx/react-at">
26+
https://github.com/fritx/react-at
27+
</a>
28+
<At members={members}>
29+
<div style={{ height: 100 }}>
30+
<div class="editor" contentEditable>@fritx @huangruichang&nbsp;</div>
31+
</div>
32+
</At>
33+
</div>
34+
)
35+
}

public/code/react-at.jsx.png

52.7 KB
Loading

public/code/react-editor-sizing.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ let { DragSizing } = ReactDragSizing
77
let MyCard = styled.div`
88
margin-top: 20px;
99
`
10-
1110
let MyEditor = styled(Editor)`
1211
border: solid 1px gray; padding: 4px 10px; overflow: auto;
1312
`
@@ -16,6 +15,9 @@ let App = () => {
1615
return (
1716
<div style={{ padding: 20 }}>
1817
<h1>react-editor-sizing</h1>
18+
<a target="_blank" href="https://github.com/fritx/react-drag-sizing">
19+
https://github.com/fritx/react-drag-sizing
20+
</a>
1921

2022
<MyCard>
2123
<DragSizing border="bottom" style={{ minHeight: 32, height: 100 }}>

public/code/react-editor.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ let { Editor } = ReactEditor
55
let MyCard = styled.div`
66
margin-top: 20px;
77
`
8-
98
let MyEditor = styled(Editor)`
109
border: solid 1px gray; padding: 4px 10px; overflow: auto;
1110
`
@@ -14,6 +13,9 @@ let App = () => {
1413
return (
1514
<div style={{ padding: 20 }}>
1615
<h1>react-editor</h1>
16+
<a target="_blank" href="https://github.com/fritx/react-editor">
17+
https://github.com/fritx/react-editor
18+
</a>
1719

1820
<MyCard>
1921
<div style={{ height: 100 }}>

public/code/vue-at.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ await loadJs('https://unpkg.com/[email protected]/dist/vue.min.js')
55
await loadJsForceUmd({
66
url: 'https://unpkg.com/[email protected]/dist/vue-at.js',
77
name: 'VueAt',
8-
deps: { vue: Vue },
98
})
109

1110
appendCss(`
@@ -18,6 +17,9 @@ let App = {
1817
template: `
1918
<div class="container">
2019
<h1>Vue At</h1>
20+
<a target="_blank" href="https://github.com/fritx/vue-at">
21+
https://github.com/fritx/vue-at
22+
</a>
2123
<at :members="members" v-model="input">
2224
<div class="editor" contenteditable></div>
2325
</at>

src/playground/util.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export let loadJsForceUmd = async ({
2929
let module = { exports: {} }
3030
let require = k => {
3131
${Object.keys(deps)
32-
.map(k => `if (k === ${k}) return ${deps[k]}`)
32+
.map(k => `if (k === ${JSON.stringify(k)}) return ${deps[k]}`)
3333
.join('\n')}
3434
throw new Error(\`module '\${k}' not found\`)
3535
}

0 commit comments

Comments
 (0)