Skip to content

Commit 4cb96db

Browse files
authored
feat(Vditor): support edit form (#771)
* refactor: 调整 dom 结构支持表单内使用 * chore: bump version 10.0.2
1 parent 6a3742f commit 4cb96db

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/components/BootstrapBlazor.Vditor/BootstrapBlazor.Vditor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.0.1</Version>
4+
<Version>10.0.2</Version>
55
</PropertyGroup>
66

77
<PropertyGroup>

src/components/BootstrapBlazor.Vditor/Vditor.razor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
{
77
<BootstrapLabel required="@Required" for="@Id" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
88
}
9-
<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id"></div>
9+
<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id">
10+
<div class="bb-vditor-container"></div>
11+
</div>

src/components/BootstrapBlazor.Vditor/Vditor.razor.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addLink, addScript } from '../BootstrapBlazor/modules/utility.js';
1+
import { addLink, addScript } from '../BootstrapBlazor/modules/utility.js';
22
import Data from '../BootstrapBlazor/modules/data.js';
33

44
export async function init(id, invoke, options) {
@@ -10,8 +10,9 @@ export async function init(id, invoke, options) {
1010
await addLink('./_content/BootstrapBlazor.Vditor/css/vditor.css');
1111
await addScript('./_content/BootstrapBlazor.Vditor/js/vditor.js');
1212

13+
const root = el.querySelector('.bb-vditor-container');
1314
const { options: op, value } = options;
14-
const vditor = new Vditor(id, getOptions(invoke, { ...op, value }));
15+
const vditor = new Vditor(root, getOptions(invoke, { ...op, value }));
1516

1617
Data.set(id, { el, invoke, vditor });
1718
return vditor;
@@ -35,11 +36,12 @@ const getOptions = (invoke, options) => {
3536

3637
export async function reset(id, value, options) {
3738
const md = Data.get(id);
38-
const { invoke, vditor } = md;
39+
const { el, invoke, vditor } = md;
3940
if (vditor) {
4041
vditor.destroy();
4142

42-
md.vditor = new Vditor(id, getOptions(invoke, { ...options, value }));
43+
const root = el.querySelector('.bb-vditor-container');
44+
md.vditor = new Vditor(root, getOptions(invoke, { ...options, value }));
4345
}
4446
return md.vditor;
4547
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
@import url('index.css');
22

3-
.bb-vditor {
3+
.bb-vditor .vditor {
44
border-radius: var(--bs-border-radius);
55
overflow: hidden;
66
}
77

8-
.bb-vditor.is-invalid {
8+
.bb-vditor.is-invalid .vditor {
99
border-color: var(--bs-danger);
1010
}
1111

12-
.bb-vditor.is-valid {
12+
.bb-vditor.is-valid .vditor {
1313
border-color: var(--bs-success);
1414
}

0 commit comments

Comments
 (0)