aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/button/FontIconBox.tsx
diff options
context:
space:
mode:
authorgeireann <60007097+geireann@users.noreply.github.com>2021-08-22 16:05:57 -0400
committergeireann <60007097+geireann@users.noreply.github.com>2021-08-22 16:05:57 -0400
commitbc0a3eabf5a7a5d6c2944e4c6f99a4fd50563b82 (patch)
tree5bc2782f7a7c0423b2359cc80679f6da8e7e34a5 /src/client/views/nodes/button/FontIconBox.tsx
parent3275fa5b5cfb9cc3837acdbb44d292ca85e26591 (diff)
more updates
Diffstat (limited to 'src/client/views/nodes/button/FontIconBox.tsx')
-rw-r--r--src/client/views/nodes/button/FontIconBox.tsx31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/client/views/nodes/button/FontIconBox.tsx b/src/client/views/nodes/button/FontIconBox.tsx
index bc4b56a2d..aa3a1ada4 100644
--- a/src/client/views/nodes/button/FontIconBox.tsx
+++ b/src/client/views/nodes/button/FontIconBox.tsx
@@ -8,7 +8,7 @@ import { ColorState, SketchPicker } from 'react-color';
import { Doc, StrListCast } from '../../../../fields/Doc';
import { createSchema, makeInterface } from '../../../../fields/Schema';
import { ScriptField } from '../../../../fields/ScriptField';
-import { BoolCast, Cast, StrCast } from '../../../../fields/Types';
+import { BoolCast, Cast, NumCast, StrCast } from '../../../../fields/Types';
import { DocumentType } from '../../../documents/DocumentTypes';
import { Scripting } from "../../../util/Scripting";
import { SelectionManager } from '../../../util/SelectionManager';
@@ -277,15 +277,8 @@ export class FontIconBox extends DocComponent<ButtonProps, FontIconDocument>(Fon
}
@computed get toggleButton() {
- const numSelected = SelectionManager.Views().length;
- const selectedDoc = numSelected > 0 ? SelectionManager.Views()[0].Document : undefined;
-
const script: string = StrCast(this.rootDoc.script) + "(true)";
- console.log(script);
- const boolResult = ScriptField.MakeScript(script)?.script.run().success;
- if (script.includes("toggleOverlay")) {
- console.log("boolResult: " + boolResult);
- }
+ const boolResult = ScriptField.MakeScript(script)?.script.run().result;
const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color);
const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor);
@@ -426,15 +419,15 @@ Scripting.addGlobal(function changeBackgroundColor(color?: string, checkResult?:
// toggle: Set overlay status of selected document
Scripting.addGlobal(function toggleOverlay(checkResult?: boolean) {
const selected = SelectionManager.Views().length ? SelectionManager.Views()[0] : undefined;
- if (checkResult) {
- return selected && selected.Document.z == 1;
+ if (checkResult && selected) {
+ console.log("z: ", NumCast(selected.Document.z) === 1);
+ return NumCast(selected.Document.z) === 1;
}
selected ? selected.props.CollectionFreeFormDocumentView?.().float() : console.log("[FontIconBox.tsx] toggleOverlay failed");
});
// toggle: Set overlay status of selected document
Scripting.addGlobal(function changeFont(font: string) {
- // TODO: glr check if font selected and change selected font
SelectionManager.Views().map(dv => dv.props.Document._fontFamily = font);
console.log(font);
Doc.UserDoc()._fontFamily = font;
@@ -443,40 +436,38 @@ Scripting.addGlobal(function changeFont(font: string) {
// toggle: Set overlay status of selected document
Scripting.addGlobal(function changeFontColor(color: string) {
- // TODO: glr check if font selected and change selected font
console.log(color);
Doc.UserDoc()._fontColor = color;
});
// toggle: Set overlay status of selected document
Scripting.addGlobal(function changeFontSize(size: string) {
- // TODO: glr check if font selected and change selected font
console.log(size);
Doc.UserDoc()._fontSize = size;
});
Scripting.addGlobal(function toggleBold(checkResult?: boolean) {
if (checkResult) {
- console.log("got here");
return Doc.UserDoc().bold;
}
- // TODO: glr check if font selected and change selected font
SelectionManager.Views().map(dv => dv.props.Document.bold = !dv.props.Document.bold);
Doc.UserDoc().bold = !Doc.UserDoc().bold;
return Doc.UserDoc().bold;
});
Scripting.addGlobal(function toggleUnderline(checkResult?: boolean) {
- if (checkResult) return Doc.UserDoc().underline;
- // TODO: glr check if font selected and change selected font
+ if (checkResult) {
+ return Doc.UserDoc().underline;
+ }
SelectionManager.Views().map(dv => dv.props.Document.underline = !dv.props.Document.underline);
Doc.UserDoc().bold = !Doc.UserDoc().underline;
return Doc.UserDoc().underline;
});
Scripting.addGlobal(function toggleItalic(checkResult?: boolean) {
- if (checkResult) return Doc.UserDoc().italic;
- // TODO: glr check if font selected and change selected font
+ if (checkResult) {
+ return Doc.UserDoc().italic;
+ }
SelectionManager.Views().map(dv => dv.props.Document.italic = !dv.props.Document.italic);
Doc.UserDoc().bold = !Doc.UserDoc().italic;
return Doc.UserDoc().italic;