aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/util/CurrentUserUtils.ts9
-rw-r--r--src/client/views/MainView.tsx2
-rw-r--r--src/client/views/nodes/button/FontIconBox.tsx53
-rw-r--r--src/client/views/nodes/formattedText/RichTextMenu.tsx32
4 files changed, 72 insertions, 24 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 8f75947d1..4975b749c 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -962,6 +962,9 @@ export class CurrentUserUtils {
{ title: "Bold", toolTip: "Bold (Ctrl+B)", btnType: ButtonType.ToggleButton, icon: "bold", click: 'toggleBold()', checkResult: 'toggleBold(true)' },
{ title: "Italic", toolTip: "Italic (Ctrl+I)", btnType: ButtonType.ToggleButton, icon: "italic", click: 'toggleItalic()', checkResult: 'toggleItalic(true)' },
{ title: "Underline", toolTip: "Underline (Ctrl+U)", btnType: ButtonType.ToggleButton, icon: "underline", click: 'toggleUnderline()', checkResult: 'toggleUnderline(true)' },
+ { title: "Bullet List", toolTip: "Bullet", btnType: ButtonType.ToggleButton, icon: "list", click: 'setBulletList("bullet")', checkResult: 'setBulletList("bullet", true)' },
+ { title: "Number List", toolTip: "Number", btnType: ButtonType.ToggleButton, icon: "list-ol", click: 'setBulletList("decimal")', checkResult: 'setBulletList("decimal", true)' },
+
// { title: "Strikethrough", tooltip: "Strikethrough", btnType: ButtonType.ToggleButton, icon: "strikethrough", click: 'toggleStrikethrough()'},
// { title: "Superscript", tooltip: "Superscript", btnType: ButtonType.ToggleButton, icon: "superscript", click: 'toggleSuperscript()'},
// { title: "Subscript", tooltip: "Subscript", btnType: ButtonType.ToggleButton, icon: "subscript", click: 'toggleSubscript()'},
@@ -992,11 +995,9 @@ export class CurrentUserUtils {
title: "Show preview",
toolTip: "Show preview of selected document",
btnType: ButtonType.ToggleButton,
- width: 50,
- switchToggle: true,
icon: "eye",
- click: 'toggleSchemaShow()',
- checkResult: 'toggleSchemaShow(true)'
+ click: 'toggleSchemaPreview()',
+ checkResult: 'toggleSchemaPreview(true)'
},
];
return tools;
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 52dbd451c..c95e56584 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -173,7 +173,7 @@ export class MainView extends React.Component {
fa.faArrowAltCircleDown, fa.faArrowAltCircleUp, fa.faArrowAltCircleLeft, fa.faArrowAltCircleRight, fa.faStopCircle, fa.faCheckCircle, fa.faGripVertical,
fa.faSortUp, fa.faSortDown, fa.faTable, fa.faTh, fa.faThList, fa.faProjectDiagram, fa.faSignature, fa.faColumns, fa.faChevronCircleUp, fa.faUpload, fa.faBorderAll,
fa.faBraille, fa.faChalkboard, fa.faPencilAlt, fa.faEyeSlash, fa.faSmile, fa.faIndent, fa.faOutdent, fa.faChartBar, fa.faBan, fa.faPhoneSlash, fa.faGripLines,
- fa.faSave, fa.faBookmark);
+ fa.faSave, fa.faBookmark, fa.faList, fa.faListOl);
this.initAuthenticationRouters();
}
diff --git a/src/client/views/nodes/button/FontIconBox.tsx b/src/client/views/nodes/button/FontIconBox.tsx
index 5d82fe123..745a85b21 100644
--- a/src/client/views/nodes/button/FontIconBox.tsx
+++ b/src/client/views/nodes/button/FontIconBox.tsx
@@ -164,7 +164,7 @@ export class FontIconBox extends DocComponent<ButtonProps, FontIconDocument>(Fon
e.stopPropagation();
e.preventDefault();
}}
- onDoubleClick={action(() => this.rootDoc.dropDownOpen = !this.rootDoc.dropDownOpen)}
+ onClick={action(() => this.rootDoc.dropDownOpen = !this.rootDoc.dropDownOpen)}
>
<input
style={{ width: 30 }}
@@ -641,6 +641,25 @@ Scripting.addGlobal(function setAlignment(align: "left" | "right" | "center", ch
Doc.UserDoc().textAlign = align;
});
+Scripting.addGlobal(function setBulletList(mapStyle: "bullet" | "decimal", checkResult?:boolean){
+ const editorView = RichTextMenu.Instance?.TextView?.EditorView;
+ if (checkResult){
+ const active = editorView?.state && RichTextMenu.Instance.getActiveListStyle();
+ console.log(active, mapStyle);
+ if (active === mapStyle) return Colors.MEDIUM_BLUE;
+ else return "transparent";
+ }
+ if (editorView){
+ const active = editorView?.state && RichTextMenu.Instance.getActiveListStyle();
+ if (active === mapStyle) {
+ console.log("set bullet list");
+ editorView?.state && RichTextMenu.Instance.changeListType(editorView.state.schema.nodes.ordered_list.create({ mapStyle: "" }));
+ } else {
+ editorView?.state && RichTextMenu.Instance.changeListType(editorView.state.schema.nodes.ordered_list.create({ mapStyle: mapStyle }));
+ }
+ }
+});
+
// toggle: Set overlay status of selected document
Scripting.addGlobal(function setFontColor(color?: string, checkResult?: boolean) {
const selected = SelectionManager.Views().length ? SelectionManager.Views()[0] : undefined;
@@ -707,7 +726,7 @@ Scripting.addGlobal(function toggleBold(checkResult?: boolean) {
const editorView = RichTextMenu.Instance.TextView?.EditorView;
if (editorView){
console.log("editorView");
- editorView?.state && RichTextMenu.Instance.toggleBold(editorView);
+ editorView?.state && RichTextMenu.Instance.toggleBold(editorView, true);
}
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;
@@ -720,7 +739,10 @@ Scripting.addGlobal(function toggleUnderline(checkResult?: boolean) {
else return "transparent";
}
const editorView = RichTextMenu.Instance.TextView?.EditorView;
-
+ if (editorView){
+ console.log("editorView");
+ editorView?.state && RichTextMenu.Instance.toggleUnderline(editorView, true);
+ }
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;
@@ -732,7 +754,10 @@ Scripting.addGlobal(function toggleItalic(checkResult?: boolean) {
else return "transparent";
}
const editorView = RichTextMenu.Instance.TextView?.EditorView;
-
+ if (editorView){
+ console.log("editorView");
+ editorView?.state && RichTextMenu.Instance.toggleItalic(editorView, true);
+ }
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;
@@ -815,4 +840,24 @@ Scripting.addGlobal(function webSetURL(url: string, checkResult?: boolean) {
else if (selected && selected.type === DocumentType.WEB){
selected.data = url;
}
+});
+
+
+/** Schema
+ * toggleSchemaPreview
+ **/
+ Scripting.addGlobal(function toggleSchemaPreview(checkResult?: boolean) {
+ const selected = SelectionManager.Views().length ? SelectionManager.Views()[0].rootDoc : undefined;
+ if (checkResult && selected){
+ const result:boolean = NumCast(selected.schemaPreviewWidth) > 0;
+ if (result) return Colors.MEDIUM_BLUE;
+ else return "transparent";
+ }
+ else if (selected){
+ if (NumCast(selected.schemaPreviewWidth) > 0){
+ selected.schemaPreviewWidth = 200;
+ } else {
+ selected.schemaPreviewWidth = 0;
+ }
+ }
}); \ No newline at end of file
diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx
index 4f40b59f2..3d9d9543d 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -280,14 +280,21 @@ 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);
- }
+ const mark = view.state.schema.mark(view.state.schema.marks.strong, {strong: forceBool});
+ this.setMark(mark, view.state, view.dispatch, false);
+ view.focus();
+ }
+
+ toggleUnderline = (view: EditorView, forceBool?:boolean) => {
+ const mark = view.state.schema.mark(view.state.schema.marks.underline, {underline: forceBool});
+ this.setMark(mark, view.state, view.dispatch, false);
+ view.focus();
+ }
+
+ toggleItalic = (view: EditorView, forceBool?:boolean) => {
+ const mark = view.state.schema.mark(view.state.schema.marks.em, {em: forceBool});
+ this.setMark(mark, view.state, view.dispatch, false);
+ view.focus();
}
@@ -323,7 +330,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
}
// TODO: remove doesn't work
- //remove all node type and apply the passed-in one to the selected text
+ // remove all node type and apply the passed-in one to the selected text
changeListType = (nodeType: Node | undefined) => {
if (!this.view || (nodeType as any)?.attrs.mapStyle === "") return;
@@ -653,6 +660,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
}
render() {
+ return null;
// TraceMobx();
// const row1 = <div className="antimodeMenu-row" key="row 1" style={{ display: this.collapsed ? "none" : undefined }}>{[
// //!this.collapsed ? this.getDragger() : (null),
@@ -715,12 +723,6 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
// </button>
// </div> */}
// </div>;
-
- return (
- <div className="richTextMenu">
- {/* {this.getElementWithRows([row1, row2], 2, false)} */}
- </div>
- );
}
}