md代码段预览执行可编辑 - #320
Open
xuqiu wants to merge 2 commits into
Open
Conversation
Contributor
|
代码先整理一下,console 信息用于本地调试,不建议提交 |
yvonneyx
reviewed
May 15, 2025
|
|
||
| ```js | ||
| ## 原代码块格式 支持编辑 | ||
| ```js | ob {editable:true} |
Contributor
There was a problem hiding this comment.
编辑能力目前还不够成熟,这个 PR 要不优先「编译」相关的代码?编辑的可以先不提
1. 不显示错误信息 2. 执行错误后, 修正代码后, 演示画布消失
yvonneyx
reviewed
May 19, 2025
| const { meta } = node.data; | ||
| if (!meta) return; | ||
| return meta.match(/\|\s*eb\s*(\|.*)?{*/); | ||
| } |
Contributor
There was a problem hiding this comment.
我看示例还是 | ob 没看到有 | eb 的地方呢?这块逻辑用在哪里了
| }) => { | ||
| const locale = useLocale(); | ||
| const exampleTitle = (typeof title === 'object' ? title[locale.id as 'zh' | 'en'] : title) as string; | ||
| // const locale = useLocale(); |
| `; | ||
| // 追加图表容器 | ||
| node.innerHTML = container || `<div id=${replaceId} class="playgroundCodeContainer" />`; | ||
| node.innerHTML = container || `<div id=${replaceId} class="playgroundCodeContainer" style="max-height:400px"/>`; |
Contributor
There was a problem hiding this comment.
这里 style 的改动会不会影响到示例页的编辑框样式?
| // 执行代码 | ||
| useEffect(() => { | ||
| execute(source); | ||
| //execute(source); |
| return cloned.textContent; | ||
| const preElement = cloned.querySelector('pre'); | ||
| preElement.childNodes.forEach((c) => source += c.textContent + '\n'); | ||
| return source; |
| console.log(22223) | ||
|
|
||
| root.render(<Preview source={source} code={block} {...options} />); | ||
| // root.render(<><CodeBlockRunner /><Preview source={source} code={block} {...options} /></>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
支持markdown的代码段预览模式下通过参数支持编辑并即时渲染
如:
详细参考示例文件 example/docs/manual/codeblock.md