From 702ba59ac0235e24121ffff9fcca7c35717867ab Mon Sep 17 00:00:00 2001 From: geireann Date: Thu, 26 Aug 2021 12:40:42 -0400 Subject: hopefully ready! --- src/client/util/CurrentUserUtils.ts | 9 ++-- src/client/views/MainView.tsx | 2 +- src/client/views/nodes/button/FontIconBox.tsx | 53 ++++++++++++++++++++-- .../views/nodes/formattedText/RichTextMenu.tsx | 32 +++++++------ 4 files changed, 72 insertions(+), 24 deletions(-) (limited to 'src') 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(Fon e.stopPropagation(); e.preventDefault(); }} - onDoubleClick={action(() => this.rootDoc.dropDownOpen = !this.rootDoc.dropDownOpen)} + onClick={action(() => this.rootDoc.dropDownOpen = !this.rootDoc.dropDownOpen)} > 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 { } 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 { } // 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 { } render() { + return null; // TraceMobx(); // const row1 =
{[ // //!this.collapsed ? this.getDragger() : (null), @@ -715,12 +723,6 @@ export class RichTextMenu extends AntimodeMenu { // //
*/} // ; - - return ( -
- {/* {this.getElementWithRows([row1, row2], 2, false)} */} -
- ); } } -- cgit v1.2.3-70-g09d2