Skip to content

Commit ac998d0

Browse files
ntachevadimodi
andauthored
chore(Editor): fix examples (#2646)
* chore(Editor): fix examples * Update editor-add-icons.md --------- Co-authored-by: Dimo Dimov <[email protected]>
1 parent 139d5c7 commit ac998d0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

knowledge-base/editor-add-icons.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,14 @@ This means that you need to inject the icons stylesheet into the `<iframe>`, so
5151
@inject IJSRuntime js
5252
5353
<TelerikEditor @bind-Value="@EditorValue"
54-
Tools="@EditorTools"
54+
Tools="@EditorToolSets.All"
5555
Schema="schemaProvider"
5656
Height="300px">
5757
</TelerikEditor>
5858
5959
@code {
6060
private string EditorValue { get; set; } = @"<p>Here is an example icon in the Editor content <i class='fa fa-info-circle'></i></p>";
6161
62-
private List<IEditorTool> EditorTools { get; set; } = new List<IEditorTool>() { new ViewHtml() };
63-
6462
protected override async Task OnAfterRenderAsync(bool firstRender)
6563
{
6664
if (firstRender)
@@ -103,9 +101,13 @@ This means that you need to inject the icons stylesheet into the `<iframe>`, so
103101
const schema = args.getSchema();
104102
const Schema = args.ProseMirror.Schema
105103
104+
// remove the default i mark that does not support the class attribute
105+
let marks = schema.spec.marks.remove("i");
106+
107+
// add the modified i as a node
106108
let nodes = schema.spec.nodes.addToEnd("i", iconNode);
107109
108-
const newSchema = new Schema({ nodes });
110+
const newSchema = new Schema({ nodes, marks });
109111
return newSchema;
110112
}
111113
@@ -155,7 +157,7 @@ Make sure to use the correct way and resources for your actual project *@
155157
@code {
156158
private string EditorValue { get; set; } = @"Here is an example icon in the Editor content <i class='fa fa-info-circle'></i>";
157159
158-
private List<IEditorTool> EditorTools { get; set; } = new List<IEditorTool>() { new ViewHtml() };
160+
private List<IEditorTool> EditorTools { get; set; } = EditorToolSets.All;
159161
}
160162
161163
@* Move JavaScript code to a separate JS file in production *@
@@ -185,16 +187,19 @@ Make sure to use the correct way and resources for your actual project *@
185187
return ["i", attrs];
186188
},
187189
};
188-
debugger
189190
190191
//add the icon node to the Editor ProseMirror schema
191192
window.schemaProvider = (args) => {
192193
const schema = args.getSchema();
193194
const Schema = args.ProseMirror.Schema
194195
196+
// remove the default i mark that does not support the class attribute
197+
let marks = schema.spec.marks.remove("i");
198+
199+
// add the modified i as a node
195200
let nodes = schema.spec.nodes.addToEnd("i", iconNode);
196201
197-
const newSchema = new Schema({ nodes });
202+
const newSchema = new Schema({ nodes, marks });
198203
return newSchema;
199204
}
200205
@@ -204,4 +209,4 @@ Make sure to use the correct way and resources for your actual project *@
204209
## See Also
205210

206211
* [Custom Editor Tools]({%slug editor-custom-tools%})
207-
* [Modify the ProseMirror Schema]({%slug editor-modify-default-schema%})
212+
* [Modify the ProseMirror Schema]({%slug editor-modify-default-schema%})

0 commit comments

Comments
 (0)