From 25d3933db0123bacad14b0af71fbc946fcbd6a45 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Fri, 22 May 2020 22:18:29 -0400 Subject: ifxed text style when ctrl or alt entering --- .../nodes/formattedText/ProsemirrorExampleTransfer.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/client/views/nodes/formattedText') diff --git a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts index 2f7d23021..0e3e7f91e 100644 --- a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts +++ b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts @@ -154,15 +154,12 @@ export default function buildKeymap>(schema: S, props: any const originalDoc = layoutDoc.rootDocument || layoutDoc; if (originalDoc instanceof Doc) { const layoutKey = StrCast(originalDoc.layoutKey); - const newDoc = Docs.Create.TextDocument("", { - layout: Cast(originalDoc.layout, Doc, null) || FormattedTextBox.DefaultLayout, - layoutKey, - _singleLine: BoolCast(originalDoc._singleLine), - x: NumCast(originalDoc.x), y: NumCast(originalDoc.y) + NumCast(originalDoc._height) + 10, _width: NumCast(layoutDoc._width), _height: NumCast(layoutDoc._height) - }); + const newDoc = Doc.MakeCopy(originalDoc, true); + newDoc.y = NumCast(originalDoc.y) + NumCast(originalDoc._height) + 10; if (layoutKey !== "layout" && originalDoc[layoutKey] instanceof Doc) { newDoc[layoutKey] = originalDoc[layoutKey]; } + Doc.GetProto(newDoc).text = undefined; FormattedTextBox.SelectOnLoad = newDoc[Id]; props.addDocument(newDoc); } @@ -178,15 +175,12 @@ export default function buildKeymap>(schema: S, props: any const originalDoc = layoutDoc.rootDocument || layoutDoc; if (force || props.Document._singleLine) { const layoutKey = StrCast(originalDoc.layoutKey); - const newDoc = Docs.Create.TextDocument("", { - layout: Cast(originalDoc.layout, Doc, null) || FormattedTextBox.DefaultLayout, - layoutKey, - _singleLine: BoolCast(originalDoc._singleLine), - x: NumCast(originalDoc.x) + NumCast(originalDoc._width) + 10, y: NumCast(originalDoc.y), _width: NumCast(layoutDoc._width), _height: NumCast(layoutDoc._height) - }); + const newDoc = Doc.MakeCopy(originalDoc, true); + newDoc.x = NumCast(originalDoc.x) + NumCast(originalDoc._width) + 10; if (layoutKey !== "layout" && originalDoc[layoutKey] instanceof Doc) { newDoc[layoutKey] = originalDoc[layoutKey]; } + Doc.GetProto(newDoc).text = undefined; FormattedTextBox.SelectOnLoad = newDoc[Id]; props.addDocument(newDoc); return true; -- cgit v1.2.3-70-g09d2 From 3afdfa11e35bcb73dd4a871e5e4489b0dd3a3c95 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Tue, 16 Jun 2020 21:16:54 -0400 Subject: fixed problems with scriptingBox types & cleaned up code. --- src/client/views/nodes/ScriptingBox.scss | 25 ++- src/client/views/nodes/ScriptingBox.tsx | 224 +++++---------------- .../nodes/formattedText/DashDocCommentView.tsx | 22 +- 3 files changed, 84 insertions(+), 187 deletions(-) (limited to 'src/client/views/nodes/formattedText') diff --git a/src/client/views/nodes/ScriptingBox.scss b/src/client/views/nodes/ScriptingBox.scss index d7fb7ca88..a937364a8 100644 --- a/src/client/views/nodes/ScriptingBox.scss +++ b/src/client/views/nodes/ScriptingBox.scss @@ -35,14 +35,14 @@ max-height: calc(100%-30px); display: flex; flex-direction: row; - overflow: scroll; + overflow: auto; justify-content: center; .descriptor { overflow: hidden; } - .scriptingBox-textArea { + .scriptingBox-textArea, .scriptingBox-textArea-inputs { flex: 70; height: 100%; max-width: 95%; @@ -50,7 +50,7 @@ box-sizing: border-box; resize: none; padding: 7px; - overflow-y: scroll; + overflow-y: auto; overflow-x: hidden; body { @@ -63,7 +63,7 @@ width: 100%; height: 100%; margin-bottom: 60px !important; - overflow-y: scroll; + overflow-y: auto; overflow-x: hidden; overflow: hidden; } @@ -94,7 +94,7 @@ border-radius: 3px; box-shadow: 0 0 5px rgba(27, 31, 35, 0.1); list-style: none; - overflow-y: scroll; + overflow-y: auto; overflow-x: hidden; } @@ -103,7 +103,7 @@ width: 100%; text-align: left; outline: none; - overflow-y: scroll; + overflow-y: auto; } .rta__entity:hover { @@ -122,6 +122,17 @@ } } + .scriptingBox-textArea-inputs { + max-width: 100%; + height: 40%; + width: 100%; + resize: none; + } + .scriptingBox-textArea-script { + resize: none; + height: 100%; + } + .scriptingBox-plist { flex: 30; width: 30%; @@ -129,7 +140,7 @@ box-sizing: border-box; resize: none; padding: 2px; - overflow-y: scroll; + overflow-y: auto; .scriptingBox-pborder { background-color: rgb(241, 239, 235); diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx index 0ae57ca52..8912b113c 100644 --- a/src/client/views/nodes/ScriptingBox.tsx +++ b/src/client/views/nodes/ScriptingBox.tsx @@ -8,7 +8,7 @@ import { documentSchema } from "../../../fields/documentSchemas"; import { List } from "../../../fields/List"; import { createSchema, listSpec, makeInterface } from "../../../fields/Schema"; import { ScriptField } from "../../../fields/ScriptField"; -import { Cast, NumCast, ScriptCast, StrCast } from "../../../fields/Types"; +import { Cast, NumCast, ScriptCast, StrCast, BoolCast } from "../../../fields/Types"; import { returnEmptyString } from "../../../Utils"; import { DragManager } from "../../util/DragManager"; import { InteractionUtils } from "../../util/InteractionUtils"; @@ -21,6 +21,7 @@ import { FieldView, FieldViewProps } from "../nodes/FieldView"; import { OverlayView } from "../OverlayView"; import { DocumentIconContainer } from "./DocumentIcon"; import "./ScriptingBox.scss"; +import { TraceMobx } from "../../../fields/util"; const _global = (window /* browser */ || global /* node */) as any; const ScriptingSchema = createSchema({}); @@ -34,15 +35,14 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent void; + private _caretPos = 0; @observable private _errorMessage: string = ""; @observable private _applied: boolean = false; @observable private _function: boolean = false; - @observable private _hovered: boolean = false; @observable private _spaced: boolean = false; @observable private _scriptKeys: any = Scripting.getGlobals(); - @observable private _scriptGlobals: any = Scripting.getGlobalObj(); @observable private _scriptingDescriptions: any = Scripting.getDescriptions(); @observable private _scriptingParams: any = Scripting.getParameters(); @@ -57,7 +57,6 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent(value); } getValue(result: any, descrip: boolean) { - let value = ""; if (typeof result === "object") { - let text = ""; - if (descrip) { - text = result[1]; - } else { - text = result[2]; - } - if (text !== undefined) { - value = text; - } else { - value = ""; - } + const text = descrip ? result[1] : result[2]; + return text !== undefined ? text : ""; } else { - value = ""; + return ""; } - return value; } @action @@ -118,21 +106,18 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent (x + scriptWidth)) { const diff = (left + suggestionWidth) - (x + scriptWidth); left = left - diff; } - runInAction(() => { - this._suggestionBoxX = left; - this._suggestionBoxY = top; - }); + this._suggestionBoxX = left; + this._suggestionBoxY = top; } componentWillUnmount() { @@ -176,11 +161,7 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { - this._errorMessage = ""; if (this.functionName.length === 0) { @@ -246,7 +226,6 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent { //@ts-ignore - this.dataDoc[name] = e.target.selectedOptions[0].value; + const val = e.target.selectedOptions[0].value; + this.dataDoc[name] = val[0] === "S" ? val.substring(1) : val[0] === "N" ? parseInt(val.substring(1)) : val.substring(1) === "true"; } // creates a copy of the script document @@ -297,19 +277,17 @@ export class ScriptingBox extends ViewBoxAnnotatableComponent this.functionDescription = e.target.value} placeholder="enter description here" value={this.functionDescription} - style={{ maxWidth: "100%", height: "40%", width: "100%", resize: "none" }} />; const nameInput =