用 react 来写 scriptable 脚本的插件。
来自 scriptable-jsx 的启发,觉得这个小工具挺有意思的。希望自己也能实现一个。
本项目和原项目在思路上有点不同,所以如果提 PR 的话改动太大,所以干脆就直接重写了。
npm install -D scriptable-transform// .babelrc
{
...
"plugins": [
...
[
"@babel/plugin-transform-react-jsx",
{
"throwIfNamespace": false,
"runtime": "automatic",
"importSource": "scriptable-transform"
}
]
]
}
import{render}from'scriptable-transform';constroot=newListWidget();functionApp(){return(<><textonCreate={(text: WidgetText)=>text.textColor=Color.cyan()}text={'AAAA'}/><texttext={'BBBB'}/><stack><texttext={'CCC'}/><texttext={'DDD'}/></stack><stackonCreate={(stack: WidgetText)=>stack.url='https://github.com/kyuuseiryuu'}><texttext={'EEEE'}/><datedate={newDate()}/></stack></>);}render(<App/>,root);root.presentMedium().then();