aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgeireann <60007097+geireann@users.noreply.github.com>2021-08-24 09:31:32 -0400
committergeireann <60007097+geireann@users.noreply.github.com>2021-08-24 09:31:32 -0400
commit7bad6629a38f2e338be2150d86248d06a4fddda5 (patch)
treea1ec86c9820e02c11adf8a16a14fae4aa41ab8e1 /src
parent44a2517ca0f153e63a75bfdef5e624ac24acaa28 (diff)
create text document
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts2
-rw-r--r--src/client/util/CurrentUserUtils.ts19
-rw-r--r--src/client/views/EditableView.tsx1
-rw-r--r--src/client/views/nodes/button/FontIconBox.tsx81
4 files changed, 81 insertions, 22 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 57015e241..9ba31da3b 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1151,6 +1151,8 @@ export namespace DocUtils {
description: ":" + StrCast(note.title),
event: undoBatch((args: { x: number, y: number }) => {
const textDoc = Docs.Create.TextDocument("", {
+ _fontFamily: StrCast(Doc.UserDoc()._fontFamily),
+ _fontSize: StrCast(Doc.UserDoc()._fontSize),
_width: 200, x, y, _autoHeight: note._autoHeight !== false,
title: StrCast(note.title) + "#" + (note.aliasCount = NumCast(note.aliasCount) + 1)
});
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index c305a495c..8abac9975 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -37,7 +37,7 @@ import { ColorScheme } from "./SettingsManager";
import { SharingManager } from "./SharingManager";
import { SnappingManager } from "./SnappingManager";
import { UndoManager } from "./UndoManager";
-import { ButtonType } from "../views/nodes/button/FontIconBox";
+import { ButtonType, NumButtonType } from "../views/nodes/button/FontIconBox";
import { IconName } from "@fortawesome/fontawesome-svg-core";
interface Button {
@@ -46,6 +46,7 @@ interface Button {
icon?: string;
btnType?: ButtonType;
click?: string;
+ numType?: NumButtonType;
switchToggle?: boolean;
script?: string;
width?: number;
@@ -939,7 +940,7 @@ export class CurrentUserUtils {
"Comic Sans MS", "Tahoma", "Impact", "Crimson Text"],
script: 'changeFont'
},
- { title: "Font size", toolTip: "Font size", btnType: ButtonType.NumberButton, script: 'changeFontSize'},
+ { title: "Font size", toolTip: "Font size", btnType: ButtonType.NumberButton, numType: NumButtonType.DropdownOptions, script: 'changeFontSize'},
{ title: "Bold", toolTip: "Bold (Ctrl+B)", btnType: ButtonType.ToggleButton, icon: "bold", click: 'toggleBold()', script: 'toggleBold' },
{ title: "Italic", toolTip: "Italic (Ctrl+I)", btnType: ButtonType.ToggleButton, icon: "italic", click: 'toggleItalic()', script: 'toggleItalic' },
{ title: "Underline", toolTip: "Underline (Ctrl+U)", btnType: ButtonType.ToggleButton, icon: "underline", click: 'toggleUnderline()', script: 'toggleUnderline' },
@@ -958,11 +959,12 @@ export class CurrentUserUtils {
static inkTools(doc: Doc) {
const tools:Button[] = [
- { title: "Pen", toolTip: "Pen (Ctrl+P)", btnType: ButtonType.ToggleButton, icon: "pen", click: 'togglePen()', script: 'togglePen' },
- { title: "Highlighter", toolTip: "Highlighter (Ctrl+H)", btnType: ButtonType.ToggleButton, icon: "highlighter", click: 'setHighlighter()', script: 'toggleHighlighter' },
- { title: "Circle", toolTip: "Circle (Ctrl+Shift+C)", btnType: ButtonType.ToggleButton, icon: "circle", click: 'toggleCircle()', script: 'toggleCircle' },
- { title: "Square", toolTip: "Square (Ctrl+Shift+S)", btnType: ButtonType.ToggleButton, icon: "square", click: 'toggleSquare()', script: 'toggleSquare' },
- { title: "Line", toolTip: "Line (Ctrl+Shift+L)", btnType: ButtonType.ToggleButton, icon: "fill-drip", click: 'toggleLine()', script: 'toggleLine' },
+ { title: "Pen", toolTip: "Pen (Ctrl+P)", btnType: ButtonType.ToggleButton, icon: "pen", click: 'setActiveInkTool("pen")'},
+ { title: "Highlighter", toolTip: "Highlighter (Ctrl+H)", btnType: ButtonType.ToggleButton, icon: "highlighter", click: 'setActiveInkTool("highlighter")' },
+ { title: "Circle", toolTip: "Circle (Ctrl+Shift+C)", btnType: ButtonType.ToggleButton, icon: "circle", click: 'setActiveInkTool("circle")' },
+ { title: "Square", toolTip: "Square (Ctrl+Shift+S)", btnType: ButtonType.ToggleButton, icon: "square", click: 'setActiveInkTool("square")' },
+ { title: "Line", toolTip: "Line (Ctrl+Shift+L)", btnType: ButtonType.ToggleButton, icon: "fill-drip", click: 'setActiveInkTool("line")' },
+ { title: "Stroke width", toolTip: "Stroke width", btnType: ButtonType.NumberButton, numType: NumButtonType.Slider, script: 'setLineWidth'},
];
return tools;
}
@@ -1044,7 +1046,7 @@ export class CurrentUserUtils {
default:
break;
}
- tools.map(({ title, toolTip, icon, btnType, click, script, width, list, ignoreClick }) => {
+ tools.map(({ title, toolTip, icon, btnType, numType, click, script, width, list, ignoreClick }) => {
menuDocList.push(Docs.Create.FontIconDocument({
_nativeWidth: width ? width : 25,
_nativeHeight: 25,
@@ -1052,6 +1054,7 @@ export class CurrentUserUtils {
_height: 25,
icon,
toolTip,
+ numType,
script,
btnType: btnType,
btnList: new List<string>(list),
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 03d9efff3..d5f8d3fcf 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -156,6 +156,7 @@ export class EditableView extends React.Component<EditableProps> {
}
renderEditor() {
+ console.log("render editor", this.props.autosuggestProps);
return this.props.autosuggestProps
? <Autosuggest
{...this.props.autosuggestProps.autosuggestProps}
diff --git a/src/client/views/nodes/button/FontIconBox.tsx b/src/client/views/nodes/button/FontIconBox.tsx
index 054e55c56..7ff3e388f 100644
--- a/src/client/views/nodes/button/FontIconBox.tsx
+++ b/src/client/views/nodes/button/FontIconBox.tsx
@@ -93,23 +93,75 @@ export class FontIconBox extends DocComponent<ButtonProps, FontIconDocument>(Fon
* - Number button
**/
+ _batch: UndoManager.Batch | undefined = undefined;
/**
* Number button
*/
@computed get numberButton() {
- const numType: string = StrCast(this.rootDoc.numButtonType);
+ const numType: string = StrCast(this.rootDoc.numType);
+ const setValue = (value: number) => {
+ // Script for running the toggle
+ const script: string = StrCast(this.rootDoc.script) + "(" + value + ")";
+ ScriptField.MakeScript(script)?.script.run();
+ };
+
+ // Script for checking the outcome of the toggle
+ const checkScript: string = StrCast(this.rootDoc.script) + "(true)";
+ const checkResult: number = ScriptField.MakeScript(checkScript)?.script.run().result;
- const dropdown = numType ?
- <div className="menuButton-dropdownBox"
- style={{ left: 0 }}>
+ const dropdown =
+ <div
+ className="menuButton-dropdownBox"
+ style={{ left: 0 }}
+ >
{/* DROPDOWN BOX CONTENTS */}
- </div> : null;
+ </div>;
+
+ if (numType === NumButtonType.Slider) {
+ return (
+ <div
+ className={`menuButton ${this.type} ${numType}`}
+ >
+ <input type="range" step="1" min="0" max="100" value={checkResult}
+ className={"toolbar-slider"} id="duration-slider"
+ onPointerDown={() => { this._batch = UndoManager.StartBatch("presDuration"); }}
+ onPointerUp={() => { if (this._batch) this._batch.end(); }}
+ onChange={(e: React.ChangeEvent<HTMLInputElement>) => { e.stopPropagation(); setValue(Number(e.target.value)); }}
+ />
+ </div>
+ );
+ } else if (numType === NumButtonType.DropdownOptions) {
+ return (
+ <div
+ className={`menuButton ${this.type} ${numType}`}
+ onDoubleClick={action(() => this.rootDoc.dropDownOpen = !this.rootDoc.dropDownOpen)}
+ >
+ <div className="numBtn-subtract">
+ <FontAwesomeIcon className={`fontIconBox-icon-${this.type}`} icon={"plus"} />
+ </div>
+ <div>
+ <input
+ className="input"
+ type="number"
+ value={checkResult}
+ onChange={action((e) => setValue(Number(e.target.value)))}
+ />
+ </div>
+ <div className="numBtn-plus">
+ <FontAwesomeIcon className={`fontIconBox-icon-${this.type}`} icon={"plus"} />
+ </div>
+ {this.rootDoc.dropDownOpen ? dropdown : null}
+ </div>
+ );
+ } else {
+ return (
+ <div>
+
+ </div>
+ );
+ }
+
- return (
- <div className={`menuButton ${this.type} ${numType}`}>
- {this.rootDoc.dropDownOpen ? dropdown : null}
- </div>
- );
}
/**
@@ -172,7 +224,9 @@ export class FontIconBox extends DocComponent<ButtonProps, FontIconDocument>(Fon
if (selected && StrCast(selected.Document.type) === DocumentType.RTF) {
text = StrCast(selected.Document._fontFamily);
} else {
- text = StrCast(Doc.UserDoc()._fontFamily);
+ const fontFamily = StrCast(Doc.UserDoc()._fontFamily);
+ console.log(fontFamily);
+ text = fontFamily;
}
noviceList = ["Roboto", "Times New Roman", "Arial", "Georgia",
"Comic Sans MS", "Tahoma", "Impact", "Crimson Text"];
@@ -485,9 +539,8 @@ Scripting.addGlobal(function toggleOverlay(checkResult?: boolean) {
// toggle: Set overlay status of selected document
Scripting.addGlobal(function changeFont(font: string) {
SelectionManager.Views().map(dv => dv.props.Document._fontFamily = font);
- console.log("[changeFont]: ", font);
- console.log(RichTextMenu.Instance.getActiveMarksOnSelection());
Doc.UserDoc()._fontFamily = font;
+ console.log(Doc.UserDoc()._fontFamily);
return Doc.UserDoc()._fontFamily;
});
@@ -555,7 +608,7 @@ Scripting.addGlobal(function toggleItalic(checkResult?: boolean) {
return Doc.UserDoc().italic;
});
-Scripting.addGlobal(function setActiveInkTool(checkResult?: boolean, tool?: InkTool) {
+Scripting.addGlobal(function setActiveInkTool(tool: InkTool, checkResult?: boolean) {
if (checkResult) {
return Doc.UserDoc().activeInkTool === tool;
}