-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(fluent-editor): add formula demo #2516
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<div> | ||
<tiny-fluent-editor v-model="content" :options="options" ref="editorRef"></tiny-fluent-editor> | ||
内容:<br /> | ||
{{ content }} | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { onMounted, ref } from 'vue' | ||
import { TinyFluentEditor } from '@opentiny/vue' | ||
|
||
// 引入 mathlive 模块和样式 | ||
import 'mathlive' | ||
import 'mathlive/static.css' | ||
import 'mathlive/fonts.css' | ||
|
||
const editorRef = ref() | ||
|
||
const content = ref('{"ops":[{"insert":{"mathlive":{"value":"\\sum_{i=1}^{n} i^2","mode":"dialog"}}},{"insert":"\n"}]}') | ||
|
||
const options = ref({ | ||
modules: { | ||
// 工具栏 | ||
toolbar: ['formula'], | ||
// 可编辑公式 | ||
mathlive: true | ||
} | ||
}) | ||
|
||
onMounted(() => { | ||
editorRef.value.state.quill.setContents({ | ||
'ops': [{ 'insert': { 'mathlive': { 'value': '\\sum_{i=1}^{n} i^2', 'mode': 'dialog' } } }, { 'insert': '\n' }] | ||
}) | ||
}) | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<div> | ||
<tiny-fluent-editor v-model="content" :options="options" ref="editorRef"></tiny-fluent-editor> | ||
内容:<br /> | ||
{{ content }} | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { TinyFluentEditor } from '@opentiny/vue' | ||
|
||
// 引入 mathlive 模块和样式 | ||
import 'mathlive' | ||
import 'mathlive/static.css' | ||
import 'mathlive/fonts.css' | ||
|
||
export default { | ||
components: { | ||
TinyFluentEditor | ||
}, | ||
data() { | ||
return { | ||
content: '{"ops":[{"insert":{"mathlive":{"value":"\\sum_{i=1}^{n} i^2","mode":"dialog"}}},{"insert":"\n"}]}', | ||
options: { | ||
modules: { | ||
// 工具栏 | ||
toolbar: ['formula'], | ||
// 可编辑公式 | ||
mathlive: true | ||
} | ||
} | ||
} | ||
}, | ||
mounted() { | ||
this.$refs.editorRef.state.quill.setContents({ | ||
'ops': [{ 'insert': { 'mathlive': { 'value': '\\sum_{i=1}^{n} i^2', 'mode': 'dialog' } } }, { 'insert': '\n' }] | ||
}) | ||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
"//postversion": "pnpm build" | ||
}, | ||
"dependencies": { | ||
"@opentiny/fluent-editor": "~3.20.0", | ||
"@opentiny/fluent-editor": "~3.22.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Version bump is compatible but MathLive dependency is missing The version bump to ~3.22.0 is compatible, but there's an implementation concern:
🔗 Analysis chainVerify compatibility with the new fluent-editor version The version bump from ~3.20.0 to ~3.22.0 appears to be related to adding formula support. Let's verify this version contains the required features. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check the changelog or release notes for version 3.22.0 to confirm formula support
# and verify no breaking changes were introduced
# Search for changelog files
fd -t f -e md -e txt -i "changelog|release|history"
# Check package.json in fluent-editor dependency for peer dependencies
curl -s https://registry.npmjs.org/@opentiny/fluent-editor/3.22.0 | jq '.peerDependencies'
Length of output: 549 Script: #!/bin/bash
# Let's check the actual usage of mathlive in the formula-related files
rg -A 5 "mathlive" examples/sites/demos/pc/app/fluent-editor/options-formula.vue
rg -A 5 "mathlive" examples/sites/demos/pc/app/fluent-editor/options-formula-composition-api.vue
# Check if there are any formula-related features in the fluent-editor component
rg -l "formula" packages/vue/src/fluent-editor/
# Check the package.json in examples to see how mathlive is declared
cat examples/sites/package.json | jq '.dependencies["mathlive"]'
Length of output: 1436 |
||
"@opentiny/vue-common": "workspace:~", | ||
"@opentiny/vue-icon": "workspace:~", | ||
"@opentiny/vue-image-viewer": "workspace:~", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove redundant content initialization
The initial content is already set via v-model binding. The manual initialization in
onMounted
is redundant and could lead to race conditions.Additionally, if you need to programmatically update the content, consider exposing a proper method through the TinyFluentEditor component instead of accessing the Quill instance directly.
📝 Committable suggestion