diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-12-03 15:32:57 -0500 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-12-03 15:32:57 -0500 |
commit | 24f89a276005e25b1907f9236c5434f6c2e69746 (patch) | |
tree | 151302ef29d4fa43b5822ab8512f5009492ff180 | |
parent | 6b29c8177dae43f5d6a4ccdc2ca5dfc6f60e83eb (diff) | |
parent | 9a0787aafb623ce0aa043419533b51378f56e070 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
-rw-r--r-- | src/client/util/RichTextRules.ts | 2 | ||||
-rw-r--r-- | src/client/util/RichTextSchema.tsx | 23 | ||||
-rw-r--r-- | src/client/util/TooltipTextMenu.tsx | 3 | ||||
-rw-r--r-- | src/client/views/Main.scss | 2 | ||||
-rw-r--r-- | src/client/views/nodes/FormattedTextBox.tsx | 3 | ||||
-rw-r--r-- | src/server/Initialization.ts | 2 | ||||
-rw-r--r-- | src/server/RouteManager.ts | 2 | ||||
-rw-r--r-- | src/server/authentication/config/passport.ts | 2 |
8 files changed, 26 insertions, 13 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts index 1a637df32..bf365579a 100644 --- a/src/client/util/RichTextRules.ts +++ b/src/client/util/RichTextRules.ts @@ -147,7 +147,7 @@ export const inpRules = { new InputRule( new RegExp(/##\s$/), (state, match, start, end) => { - const target = Docs.Create.TextDocument({ width: 75, height: 35, autoHeight: true, fontSize: 9, title: "inline comment" }); + const target = Docs.Create.TextDocument({ width: 75, height: 35, backgroundColor: "yellow", autoHeight: true, fontSize: 9, title: "inline comment" }); const node = (state.doc.resolve(start) as any).nodeAfter; const newNode = schema.nodes.dashComment.create({ docid: target[Id] }); const dashDoc = schema.nodes.dashDoc.create({ width: 75, height: 35, title: "dashDoc", docid: target[Id], float: "right" }); diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx index cb03892f3..3b786e61d 100644 --- a/src/client/util/RichTextSchema.tsx +++ b/src/client/util/RichTextSchema.tsx @@ -18,6 +18,7 @@ import { Transform } from "./Transform"; import React = require("react"); import { BoolCast, NumCast } from "../../new_fields/Types"; import { FormattedTextBox } from "../views/nodes/FormattedTextBox"; +import { any } from "bluebird"; const pDOM: DOMOutputSpecArray = ["p", 0], blockquoteDOM: DOMOutputSpecArray = ["blockquote", 0], hrDOM: DOMOutputSpecArray = ["hr"], preDOM: DOMOutputSpecArray = ["pre", ["code", 0]], brDOM: DOMOutputSpecArray = ["br"], ulDOM: DOMOutputSpecArray = ["ul", 0]; @@ -670,20 +671,29 @@ export class DashDocCommentView { this._collapsed.className = "formattedTextBox-inlineComment"; this._collapsed.id = "DashDocCommentView-" + node.attrs.docid; this._view = view; + let targetNode = () => { + for (let i = getPos() + 1; i < view.state.doc.nodeSize; i++) { + let m = view.state.doc.nodeAt(i); + if (m && m.type === view.state.schema.nodes.dashDoc && m.attrs.docid === node.attrs.docid) { + return { node: m, pos: i } as { node: any, pos: number }; + } + } + return undefined; + } this._collapsed.onpointerdown = (e: any) => { - const node = view.state.doc.nodeAt(getPos() + 1); - view.dispatch(view.state.tr. - setNodeMarkup(getPos() + 1, undefined, { ...node.attrs, hidden: node.attrs.hidden ? false : true })); // update the attrs - setTimeout(() => node.attrs.hidden && DocServer.GetRefField(node.attrs.docid).then(async dashDoc => dashDoc instanceof Doc && Doc.linkFollowHighlight(dashDoc)), 100); + const target = targetNode(); + if (target) { + view.dispatch(view.state.tr. + setNodeMarkup(target.pos, undefined, { ...target.node.attrs, hidden: target.node.attrs.hidden ? false : true })); // update the attrs + setTimeout(() => node.attrs.hidden && DocServer.GetRefField(node.attrs.docid).then(async dashDoc => dashDoc instanceof Doc && Doc.linkFollowHighlight(dashDoc)), 100); + } }; this._collapsed.onpointerenter = (e: any) => { - const node = view.state.doc.nodeAt(getPos() + 1); DocServer.GetRefField(node.attrs.docid).then(async dashDoc => dashDoc instanceof Doc && Doc.linkFollowHighlight(dashDoc)); e.preventDefault(); e.stopPropagation(); }; this._collapsed.onpointerleave = (e: any) => { - const node = view.state.doc.nodeAt(getPos() + 1); DocServer.GetRefField(node.attrs.docid).then(async dashDoc => dashDoc instanceof Doc && Doc.linkFollowUnhighlight()); e.preventDefault(); e.stopPropagation(); @@ -720,7 +730,6 @@ export class DashDocView { this._dashSpan.style.height = node.attrs.height; this._dashSpan.style.position = "absolute"; this._dashSpan.style.display = "inline-block"; - this._dashSpan.style.borderWidth = "4"; const removeDoc = () => { const pos = getPos(); const ns = new NodeSelection(view.state.doc.resolve(pos)); diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx index 5e777cef9..35a099c48 100644 --- a/src/client/util/TooltipTextMenu.tsx +++ b/src/client/util/TooltipTextMenu.tsx @@ -184,6 +184,9 @@ export class TooltipTextMenu { } initFontSizes() { + this.fontSizes.push(schema.marks.pFontSize.create({ fontSize: 7 })); + this.fontSizes.push(schema.marks.pFontSize.create({ fontSize: 8 })); + this.fontSizes.push(schema.marks.pFontSize.create({ fontSize: 9 })); this.fontSizes.push(schema.marks.pFontSize.create({ fontSize: 10 })); this.fontSizes.push(schema.marks.pFontSize.create({ fontSize: 12 })); this.fontSizes.push(schema.marks.pFontSize.create({ fontSize: 14 })); diff --git a/src/client/views/Main.scss b/src/client/views/Main.scss index f435821df..4709e7ef2 100644 --- a/src/client/views/Main.scss +++ b/src/client/views/Main.scss @@ -38,7 +38,7 @@ p { ::-webkit-scrollbar { -webkit-appearance: none; height: 8px; - width: 20px; + width: 8px; } ::-webkit-scrollbar-thumb { diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index a9f8ea315..88c0c5a2e 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -813,8 +813,9 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps & if (selectOnLoad) { FormattedTextBox.SelectOnLoad = ""; this.props.select(false); - this._editorView!.focus(); } + const rtf = doc ? Cast(doc[fieldKey], RichTextField) : undefined; + (selectOnLoad || (rtf && !rtf.Text)) && this._editorView!.focus(); // add user mark for any first character that was typed since the user mark that gets set in KeyPress won't have been called yet. this._editorView!.state.storedMarks = [...(this._editorView!.state.storedMarks ? this._editorView!.state.storedMarks : []), schema.marks.user_mark.create({ userid: Doc.CurrentUserEmail, modified: Math.round(Date.now() / 1000 / 5) })]; } diff --git a/src/server/Initialization.ts b/src/server/Initialization.ts index 1fb949221..a41e2fea0 100644 --- a/src/server/Initialization.ts +++ b/src/server/Initialization.ts @@ -40,7 +40,7 @@ export default async function InitializeServer(options: InitializationOptions) { app.use("*", ({ user, originalUrl }, _res, next) => { if (!originalUrl.includes("Heartbeat")) { - const userEmail = user?.email; + const userEmail = user && ("email" in user) ? user["email"] : undefined; if (userEmail) { timeMap[userEmail] = Date.now(); } diff --git a/src/server/RouteManager.ts b/src/server/RouteManager.ts index 347be1952..41204964e 100644 --- a/src/server/RouteManager.ts +++ b/src/server/RouteManager.ts @@ -92,7 +92,7 @@ export default class RouteManager { try { await toExecute(args); } catch (e) { - console.log(red(target), user?.email ?? "<user logged out>"); + console.log(red(target), user && ("email" in user) ? "<user logged out>" : undefined); if (onError) { onError({ ...core, error: e }); } else { diff --git a/src/server/authentication/config/passport.ts b/src/server/authentication/config/passport.ts index 2271109a5..0ced99b0d 100644 --- a/src/server/authentication/config/passport.ts +++ b/src/server/authentication/config/passport.ts @@ -40,7 +40,7 @@ export let isAuthenticated = (req: Request, res: Response, next: NextFunction) = export let isAuthorized = (req: Request, res: Response, next: NextFunction) => { const provider = req.path.split("/").slice(-1)[0]; - if (_.find(req.user?.tokens, { kind: provider })) { + if (_.find(req.user && "tokens" in req.user ? req.user["tokens"] : undefined, { kind: provider })) { next(); } else { res.redirect(`/auth/${provider}`); |