From e847215964bc02cf402eace30d6c9e19f5f0f0cf Mon Sep 17 00:00:00 2001
From: bobzel
Date: Thu, 7 Sep 2023 01:28:27 -0400
Subject: truncate link descriptions over link lines. Fix schema view issues
with multiline inputs. fix '#' field assignment for title bar of docs.
fixed dashFieldView to read fields from texstbox by fixing FindDocByTitle to
not match undefind. Don't end link_description input on Enter to allow
multiline inputs.
---
src/client/DocServer.ts | 8 +++--
src/client/views/EditableView.scss | 4 ++-
src/client/views/EditableView.tsx | 40 +++++++++++-----------
src/client/views/PropertiesView.tsx | 8 ++---
.../CollectionFreeFormLinkView.tsx | 4 +--
.../collectionLinear/CollectionLinearView.tsx | 10 +++---
src/client/views/linking/LinkMenuItem.tsx | 2 +-
src/client/views/nodes/DocumentView.tsx | 5 ++-
.../views/nodes/formattedText/RichTextRules.ts | 2 +-
9 files changed, 42 insertions(+), 41 deletions(-)
(limited to 'src')
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts
index 5fdea131b..fc8a9f3d6 100644
--- a/src/client/DocServer.ts
+++ b/src/client/DocServer.ts
@@ -32,9 +32,11 @@ export namespace DocServer {
let _cache: { [id: string]: RefField | Promise> } = {};
export function FindDocByTitle(title: string) {
- const foundDocId = Array.from(Object.keys(_cache))
- .filter(key => _cache[key] instanceof Doc)
- .find(key => (_cache[key] as Doc).title === title);
+ const foundDocId =
+ title &&
+ Array.from(Object.keys(_cache))
+ .filter(key => _cache[key] instanceof Doc)
+ .find(key => (_cache[key] as Doc).title === title);
return foundDocId ? (_cache[foundDocId] as Doc) : undefined;
}
diff --git a/src/client/views/EditableView.scss b/src/client/views/EditableView.scss
index 0955ba8ff..f7c03caf9 100644
--- a/src/client/views/EditableView.scss
+++ b/src/client/views/EditableView.scss
@@ -3,7 +3,8 @@
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
- overflow: hidden;
+ overflow: auto;
+ height: 100%;
min-width: 20;
text-overflow: ellipsis;
}
@@ -11,6 +12,7 @@
.editableView-container-editing-oneLine {
width: 100%;
height: max-content;
+ overflow: hidden;
span {
p {
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 147921596..ca4ffaf3a 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -231,7 +231,7 @@ export class EditableView extends React.Component {
onChange: this.props.autosuggestProps.onChange,
}}
/>
- ) : (
+ ) : this.props.oneLine !== false && this.props.GetValue()?.toString().indexOf('\n') === -1 ? (
(this._inputref = r)}
@@ -247,31 +247,31 @@ export class EditableView extends React.Component {
onClick={this.stopPropagation}
onPointerUp={this.stopPropagation}
/>
+ ) : (
+
- {!this.props.linkDoc.link_description ? null : {StrCast(this.props.linkDoc.link_description)}
}
+ {!this.props.linkDoc.link_description ? null : {StrCast(this.props.linkDoc.link_description).split('\n')[0].substring(0, 50)}
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index dcb2d9d51..ae9977d7a 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -1149,14 +1149,13 @@ export class DocumentViewInternal extends DocComponent {
- this.props.select(false);
return showTitle.split(';').length === 1 ? showTitle + '=' + Field.toString(targetDoc[showTitle.split(';')[0]] as any as Field) : '#' + showTitle;
}}
SetValue={undoBatch((input: string) => {
if (input?.startsWith('#')) {
- if (this.props.layout_showTitle) {
+ if (this.rootDoc.layout_showTitle) {
this.rootDoc._layout_showTitle = input?.substring(1) ? input.substring(1) : undefined;
- } else {
+ } else if (!this.props.layout_showTitle) {
Doc.UserDoc().layout_showTitle = input?.substring(1) ? input.substring(1) : 'author_date';
}
} else {
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts
index 8bafc2cef..5d92f63ef 100644
--- a/src/client/views/nodes/formattedText/RichTextRules.ts
+++ b/src/client/views/nodes/formattedText/RichTextRules.ts
@@ -279,7 +279,7 @@ export class RichTextRules {
const num = value.match(/^[0-9.]$/);
this.Document[DocData][fieldKey] = value === 'true' ? true : value === 'false' ? false : num ? Number(value) : value;
}
- const target = DocServer.FindDocByTitle(docTitle);
+ const target = DocServer.FindDocByTitle(docTitle) ?? this.Document;
if (target) {
const fieldView = state.schema.nodes.dashField.create({ fieldKey, docId: target[Id], hideKey: false });
return state.tr.setSelection(new TextSelection(state.doc.resolve(start), state.doc.resolve(end))).replaceSelectionWith(fieldView, true);
--
cgit v1.2.3-70-g09d2