Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
KieSun committed Apr 18, 2023
2 parents 922bcbc + ec18ff9 commit 81306da
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-pears-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"solive-docusaurus-theme-code": patch
---

fix match props error
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
'class-methods-use-this': 'off',
radix: 'off',
'guard-for-in': 'off',
'max-len': ['error', { code: 150 }],
'max-len': ['error', { code: 250 }],

// TypeScript 相关
'@typescript-eslint/explicit-function-return-type': 'off',
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/relesae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
paths-ignore:
- 'apps/**'

concurrency: ${{ github.workflow }}-${{ github.ref }}

Expand Down
3 changes: 2 additions & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17",
"tty-browserify": "^0.0.1",
"url": "^0.11.0",
"util": "^0.12.5"
"util": "^0.12.5",
"webpack-node-externals": "^3.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
title: Docusaurus 插件
title: 引导
hide_title: true
slug: /docusaurus-plugins
---


## Docusaurus 插件

> 你可以使用 `solive-docusaurus-theme-code` 插件快速集成一个轻量级Solidity Editor嵌入你的文档.
> 你可以使用 `solive-docusaurus-theme-code` 插件快速集成一个轻量级Solidity Editor嵌入你的文档. (完善中)
### 安装

Expand All @@ -27,22 +29,22 @@ module.exports = {
### 快速使用

1. 你需要注意在代码块标记solive,和配置solive的属性:
```md
```solidity solive height=300px
````md
```solidity solive height=500px
// your code
```\
```
```
````

2. 你可以在代码块中配置solive相关属性 `height`(具体参考[属性表](/docs/solive-props)):
```md
2. 你可以在代码块中配置solive相关属性 `height`(具体参考[属性表](/docs/docusaurus-plugins/props)):
````md
```solidity solive height=300px
// your code
```\
```
```
````

3. 配置代码块文件名(可多文件):
```md
```solidity solive height=300px
````md
```solidity solive height=500px
/**
* @filename Storage.sol
*/
Expand All @@ -54,12 +56,12 @@ module.exports = {
*/

// your code
```\
```
```
````

3. 完整的代码块示例:
````md
```solidity solive height=300px
```solidity solive height=500px
/**
* @filename Storage.sol
*/
Expand Down Expand Up @@ -94,12 +96,12 @@ contract Storage {
return number;
}
}
```\
```
````

### 展示结果:

```solidity solive height=300px
```solidity solive height=500px
/**
* @filename Storage.sol
*/
Expand Down
21 changes: 21 additions & 0 deletions apps/doc/docs/expansion/docusaurus-plugins/props.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: 属性
slug: /docusaurus-plugins/props
hide_title: true
---

## 属性

> 注意:考虑对参数匹配的准确性和文档UI适应性,部分Solive的属性默认值有所变动,并增加和变动一些新的属性
| 属性 | 类型 | 默认值 | 说明 |
| --- | --- | --- | --- |
| width | string | 90% | 容器宽度 |
| height | string | 500px | 容器高度 |
| consoleOpen | boolean | true | 是否显示控制台 |
| consoleTriggerControl | boolean | false | 是否显示控制台触发按钮 |
| consoleDefaultVisible | boolean | false | 控制台默认是否可见 |
| deployOpen | boolean | true | 是否显示部署 |
| deployDefaultVisible | boolean | false | 部署默认是否可见 |
| fileNavOpen | boolean | true | 是否显示文件导航栏 |
| fileNavDefaultVisible | boolean | false | 文件导航栏默认是否可见 |
7 changes: 7 additions & 0 deletions apps/doc/docs/expansion/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ title: 扩展
sidebar_position: 3
hide_title: true
---

## 扩展

import DocCardList from '@theme/DocCardList';

<DocCardList />

6 changes: 3 additions & 3 deletions apps/doc/docs/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ import TabItem from '@theme/TabItem';
<TabItem value="npm" label="Npm">

```sh
npm install solive
npm install solive-core
```

</TabItem>
<TabItem value="Yarn" label="Yarn">

```sh
yarn add solive
yarn add solive-core
```

</TabItem>
<TabItem value="Pnpm" label="Pnpm">

```sh
pnpm install solive
pnpm install solive-core
```

</TabItem>
Expand Down
25 changes: 14 additions & 11 deletions apps/next_demo/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import dynamic from "next/dynamic";
import dynamic from 'next/dynamic';

import "solive-core/dist/index.css";
import 'solive-core/dist/index.css';

const Editor = dynamic(
() => {
return import("solive-core");
},
{ ssr: false }
() => import('solive-core'),
{ ssr: false },
);

export default function Home() {
return (
<main>
<Editor id="1" modelInfos={
<Editor
id="1"
modelInfos={
[
{
filename: '_Storage.sol',
// eslint-disable-next-line max-len
value: "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Storage\n * @dev Store & retrieve value in a variable\n * @custom:dev-run-script ./scripts/deploy_with_ethers.ts\n */\ncontract Storage {\n\n uint256 number;\n\n /**\n * @dev Store value in variable\n * @param num value to store\n */\n function store(uint256 num) public {\n number = num;\n }\n\n /**\n * @dev Return value \n * @return value of 'number'\n */\n function retrieve() public view returns (uint256){\n return number;\n }\n}",
language: "solidity" as any,
}
language: 'solidity' as any,
},
]
} height="500px" />
}
height="500px"
/>
</main>
)
);
}
15 changes: 9 additions & 6 deletions packages/docusaurus-plugin/src/theme/utils/match-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ export const coerceValue = (value: string, type: TPropType) => {
};

export const matchProps = (metaString: string, propsInfo: TPropsInfo): TResultProps => {
const dynamicRex = /(?<key>[^=]+)="(?<value>[^"]*)"/g;
const props: any = {};
const dynamicRex = /(?<key>[^=\s]+)=(?:"(?<value1>[^"]*)"|'(?<value2>[^']*)'|(?<value3>[^\s]*))/g;
const props: TResultProps = {};
let match;
// eslint-disable-next-line no-cond-assign
while ((match = dynamicRex.exec(metaString)) !== null) {
const { key, value } = match.groups as any;
const keyName = key.trim();
if (propsInfo[keyName]) {
props[keyName] = coerceValue(value, propsInfo[keyName].type);
const { groups } = match;
if (groups) {
const key = groups.key.trim();
const value = groups.value1 || groups.value2 || groups.value3;
if (propsInfo[key]) {
props[key] = value;
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 81306da

Please sign in to comment.