aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/button/FontIconBox.tsx17
-rw-r--r--src/client/views/nodes/formattedText/RichTextMenu.tsx12
2 files changed, 23 insertions, 6 deletions
diff --git a/src/client/views/nodes/button/FontIconBox.tsx b/src/client/views/nodes/button/FontIconBox.tsx
index e09e15a60..5d82fe123 100644
--- a/src/client/views/nodes/button/FontIconBox.tsx
+++ b/src/client/views/nodes/button/FontIconBox.tsx
@@ -591,10 +591,6 @@ Scripting.addGlobal(function toggleOverlay(checkResult?: boolean) {
* toggleItalic
* toggleUnderline
**/
-Scripting.addGlobal(function toggleBold(){
- const editorView = RichTextMenu.Instance.TextView?.EditorView;
-});
-
// toggle: Set overlay status of selected document
Scripting.addGlobal(function setFont(font: string, checkResult?: boolean) {
@@ -708,7 +704,12 @@ Scripting.addGlobal(function toggleBold(checkResult?: boolean) {
if (Doc.UserDoc().bold) return Colors.MEDIUM_BLUE;
else return "transparent";
}
- SelectionManager.Views().filter(i => StrCast(i.rootDoc.type) === DocumentType.RTF).map(dv => dv.props.Document.italic = !dv.props.Document.italic);
+ const editorView = RichTextMenu.Instance.TextView?.EditorView;
+ if (editorView){
+ console.log("editorView");
+ editorView?.state && RichTextMenu.Instance.toggleBold(editorView);
+ }
+ SelectionManager.Views().filter(i => StrCast(i.rootDoc.type) === DocumentType.RTF).map(dv => dv.props.Document.bold = !dv.props.Document.bold);
Doc.UserDoc().bold = !Doc.UserDoc().bold;
return Doc.UserDoc().bold;
});
@@ -718,7 +719,9 @@ Scripting.addGlobal(function toggleUnderline(checkResult?: boolean) {
if (Doc.UserDoc().underline) return Colors.MEDIUM_BLUE;
else return "transparent";
}
- SelectionManager.Views().filter(i => StrCast(i.rootDoc.type) === DocumentType.RTF).map(dv => dv.props.Document.italic = !dv.props.Document.italic);
+ const editorView = RichTextMenu.Instance.TextView?.EditorView;
+
+ SelectionManager.Views().filter(i => StrCast(i.rootDoc.type) === DocumentType.RTF).map(dv => dv.props.Document.underline = !dv.props.Document.underline);
Doc.UserDoc().underline = !Doc.UserDoc().underline;
return Doc.UserDoc().underline;
});
@@ -728,6 +731,8 @@ Scripting.addGlobal(function toggleItalic(checkResult?: boolean) {
if (Doc.UserDoc().italic) return Colors.MEDIUM_BLUE;
else return "transparent";
}
+ const editorView = RichTextMenu.Instance.TextView?.EditorView;
+
SelectionManager.Views().filter(i => StrCast(i.rootDoc.type) === DocumentType.RTF).map(dv => dv.props.Document.italic = !dv.props.Document.italic);
Doc.UserDoc().italic = !Doc.UserDoc().italic;
return Doc.UserDoc().italic;
diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx
index e32eccb62..4f40b59f2 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -279,6 +279,17 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
});
}
+ toggleBold = (view: EditorView, forceBool?:boolean) => {
+ if (forceBool) {
+ const mark = view.state.schema.marks.bold.create({bold: true});
+ this.setMark(mark, view.state, view.dispatch, true);
+ }
+ else {
+ console.log(toggleMark);
+ toggleMark(view.state.schema.marks.bold);
+ }
+ }
+
setFontSize = (size:number, view: EditorView) => {
const fmark = view.state.schema.marks.pFontSize.create({ fontSize: size });
@@ -378,6 +389,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
view.focus();
return true;
});
+ view.focus();
dispatch?.(tr);
return true;
}