aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2020-02-21 13:31:21 -0500
committerbob <bcz@cs.brown.edu>2020-02-21 13:31:21 -0500
commitcc2ebdf4c19b2cc9065f3860807aa85e2576df22 (patch)
treec67a813630a8d87792509f8d48d68d30053e5354
parent34ff0e9445b810690a334f3ae6744ff09009e285 (diff)
fixed crash with following link in text. made link anchor size smaller to be less obnoxious. publishing docs without custom titles switches them to cusom and removes the '-'
-rw-r--r--src/client/util/RichTextRules.ts2
-rw-r--r--src/client/views/DocumentDecorations.tsx9
-rw-r--r--src/client/views/nodes/DocuLinkBox.scss4
-rw-r--r--src/client/views/nodes/DocuLinkBox.tsx2
-rw-r--r--src/client/views/nodes/FormattedTextBoxComment.tsx6
5 files changed, 15 insertions, 8 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts
index a4f1ff22c..af3b1a81e 100644
--- a/src/client/util/RichTextRules.ts
+++ b/src/client/util/RichTextRules.ts
@@ -81,7 +81,7 @@ export class RichTextRules {
// create a text display of a metadata field on this or another document, or create a hyperlink portal to another document [[ <fieldKey> : <Doc>]] // [[:Doc]] => hyperlink [[fieldKey]] => show field [[fieldKey:Doc]] => show field of doc
new InputRule(
- new RegExp(/\[\[([a-zA-Z_ \-0-9]*)(:[a-zA-Z_ \-0-9]+)?\]\]$/),
+ new RegExp(/\[\[([a-zA-Z_#@\? \-0-9]*)(:[a-zA-Z_#@\? \-0-9]+)?\]\]$/),
(state, match, start, end) => {
const fieldKey = match[1];
const docid = match[2]?.substring(1);
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index dcd8dd113..a01f32152 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -414,7 +414,14 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
<input ref={this._keyinput} className="documentDecorations-title" type="text" name="dynbox" autoComplete="on" value={this._accumulatedTitle} style={{ width: "calc(100% - 20px)" }}
onBlur={e => this.titleBlur(true)} onChange={action(e => this._accumulatedTitle = e.target.value)} onKeyPress={this.titleEntered} />
<div className="publishBox" title="make document referenceable by its title"
- onPointerDown={e => DocUtils.Publish(seldoc.props.Document, this._accumulatedTitle, seldoc.props.addDocument, seldoc.props.removeDocument)}>
+ onPointerDown={action(e => {
+ if (!seldoc.props.Document.customTitle) {
+ seldoc.props.Document.customTitle = true;
+ StrCast(Doc.GetProto(seldoc.props.Document).title).startsWith("-") && (Doc.GetProto(seldoc.props.Document).title = StrCast(seldoc.props.Document.title).substring(1));
+ this._accumulatedTitle = StrCast(seldoc.props.Document.title);
+ }
+ DocUtils.Publish(seldoc.props.Document, this._accumulatedTitle, seldoc.props.addDocument, seldoc.props.removeDocument);
+ })}>
<FontAwesomeIcon size="lg" color={SelectionManager.SelectedDocuments()[0].props.Document.title === SelectionManager.SelectedDocuments()[0].props.Document[Id] ? "green" : undefined} icon="sticky-note"></FontAwesomeIcon>
</div>
</> :
diff --git a/src/client/views/nodes/DocuLinkBox.scss b/src/client/views/nodes/DocuLinkBox.scss
index 7b91b4f36..286033475 100644
--- a/src/client/views/nodes/DocuLinkBox.scss
+++ b/src/client/views/nodes/DocuLinkBox.scss
@@ -1,8 +1,8 @@
.docuLinkBox-cont {
cursor: default;
position: absolute;
- width: 25px;
- height: 25px;
+ width: 15;
+ height: 15;
border-radius: 20px;
pointer-events: all;
user-select: none;
diff --git a/src/client/views/nodes/DocuLinkBox.tsx b/src/client/views/nodes/DocuLinkBox.tsx
index 336b030f4..aa620658c 100644
--- a/src/client/views/nodes/DocuLinkBox.tsx
+++ b/src/client/views/nodes/DocuLinkBox.tsx
@@ -141,7 +141,7 @@ export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(Doc
);
return <div className="docuLinkBox-cont" onPointerDown={this.onPointerDown} onClick={this.onClick} title={targetTitle} onContextMenu={this.specificContextMenu}
ref={this._ref} style={{
- background: c, left: `calc(${x}% - 12.5px)`, top: `calc(${y}% - 12.5px)`,
+ background: c, left: `calc(${x}% - 7.5px)`, top: `calc(${y}% - 7.5px)`,
transform: `scale(${anchorScale / this.props.ContentScaling()})`
}} >
{!this._editing && !this._forceOpen ? (null) :
diff --git a/src/client/views/nodes/FormattedTextBoxComment.tsx b/src/client/views/nodes/FormattedTextBoxComment.tsx
index 1174110e7..ec51a2080 100644
--- a/src/client/views/nodes/FormattedTextBoxComment.tsx
+++ b/src/client/views/nodes/FormattedTextBoxComment.tsx
@@ -189,8 +189,8 @@ export class FormattedTextBoxComment {
pinToPres={returnFalse}
dontRegisterView={true}
renderDepth={1}
- PanelWidth={() => Math.min(350, NumCast(target.width, 350))}
- PanelHeight={() => Math.min(250, NumCast(target.height, 250))}
+ PanelWidth={() => Math.min(350, NumCast(target._width, 350))}
+ PanelHeight={() => Math.min(250, NumCast(target._height, 250))}
focus={emptyFunction}
whenActiveChanged={returnFalse}
/>, FormattedTextBoxComment.tooltipText);
@@ -211,7 +211,7 @@ export class FormattedTextBoxComment {
// let start = view.coordsAtPos(state.selection.from), end = view.coordsAtPos(state.selection.to);
const start = view.coordsAtPos(state.selection.from - nbef), end = view.coordsAtPos(state.selection.from - nbef);
// The box in which the tooltip is positioned, to use as base
- const box = (document.getElementById("mainView-container") as any).getBoundingClientRect();
+ const box = (document.getElementsByClassName("mainView-container") as any)[0].getBoundingClientRect();
// Find a center-ish x position from the selection endpoints (when
// crossing lines, end may be more to the left)
const left = Math.max((start.left + end.left) / 2, start.left + 3);