aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-03-16 21:33:59 -0400
committerbobzel <zzzman@gmail.com>2025-03-16 21:33:59 -0400
commit35f7b94e59f72463a30a52dd0fd8b57288b79016 (patch)
tree66ed024d42a63844837f1f27a0cb3c8e5273b7fb /src/client/views/collections
parent1ffa8a8fb3e16bd5a3338d18782ddda0c2ffca03 (diff)
parent920fb858854ca4866edc838b1db458ec7645f021 (diff)
Merge branch 'master' into DocCreatorMenu-work
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionStackedTimeline.tsx11
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx2
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx1
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.scss12
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx6
-rw-r--r--src/client/views/collections/collectionSchema/SchemaCellField.tsx58
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx20
7 files changed, 69 insertions, 41 deletions
diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx
index c3047e5fb..a7a9f2114 100644
--- a/src/client/views/collections/CollectionStackedTimeline.tsx
+++ b/src/client/views/collections/CollectionStackedTimeline.tsx
@@ -187,13 +187,12 @@ export class CollectionStackedTimeline extends CollectionSubView<CollectionStack
@computed get rangeClick() {
// prettier-ignore
return ScriptField.MakeFunction('stackedTimeline.clickAnchor(this, clientX)',
- { stackedTimeline: 'any', clientX: 'number' }, { stackedTimeline: 'string' /* should be CollectionStackedTimeline */ }
- )!;
+ { stackedTimeline: 'any', clientX: 'number' }, { stackedTimeline: this as unknown as string })!; // NOTE: scripts can't serialize a run-time React component as captured variable BUT this script will not be serialized so we can "stuff" anything we want in the capture variable
}
@computed get rangePlay() {
// prettier-ignore
return ScriptField.MakeFunction('stackedTimeline.playOnClick(this, clientX)',
- { stackedTimeline: 'any', clientX: 'number' }, { stackedTimeline: 'string' /* should be CollectionStackedTimeline */})!;
+ { stackedTimeline: 'any', clientX: 'number' }, { stackedTimeline: this as unknown as string })!; // NOTE: scripts can't serialize a run-time React component as captured variable BUT this script will not be serialized so we can "stuff" anything we want in the capture variable
}
rangeClickScript = () => this.rangeClick;
rangePlayScript = () => this.rangePlay;
@@ -268,13 +267,13 @@ export class CollectionStackedTimeline extends CollectionSubView<CollectionStack
setupMoveUpEvents(
this,
e,
- action(() => {
+ action(movEv => {
if (!wasSelecting) {
this._markerStart = this._markerEnd = this.toTimeline(clientX - rect.x, rect.width);
wasSelecting = true;
this._timelineWrapper && (this._timelineWrapper.style.cursor = 'ew-resize');
}
- this._markerEnd = this.toTimeline(e.clientX - rect.x, rect.width);
+ this._markerEnd = this.toTimeline(movEv.clientX - rect.x, rect.width);
return false;
}),
action((upEvent, movement, isClick) => {
@@ -844,7 +843,7 @@ class StackedTimelineAnchor extends ObservableReactComponent<StackedTimelineAnch
styleProvider={this._props.styleProvider}
renderDepth={this._props.renderDepth + 1}
LayoutTemplate={undefined}
- LayoutTemplateString={LabelBox.LayoutString('data')}
+ LayoutTemplateString={LabelBox.LayoutString('title')}
isDocumentActive={this._props.isDocumentActive}
PanelWidth={width}
PanelHeight={height}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
index 241a56a88..4ea1de680 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
@@ -107,7 +107,7 @@ export function computePassLayout(poolData: Map<string, PoolData>, pivotDoc: Doc
}
function toNumber(val: FieldResult<FieldType>) {
- return val === undefined ? undefined : DateCast(val) ? DateCast(val).date.getMilliseconds() : NumCast(val, Number(StrCast(val)));
+ return val === undefined ? undefined : DateCast(val) ? DateCast(val).date.getTime() : NumCast(val, Number(StrCast(val)));
}
export function computeStarburstLayout(poolData: Map<string, PoolData>, pivotDoc: Doc, childPairs: { layout: Doc; data?: Doc }[], panelDim: number[], viewDefsToJSX: (views: ViewDefBounds[]) => ViewDefResult[] /* , engineProps: any */) {
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 00d7ea451..ad52db496 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -113,6 +113,7 @@ export class MarqueeView extends ObservableReactComponent<SubCollectionViewProps
// tslint:disable-next-line:prefer-const
const cm = ContextMenu.Instance;
const [x, y] = this.Transform.transformPoint(this._downX, this._downY);
+
if (e.key === '?') {
cm.setDefaultItem('?', (str: string) =>
this._props.addDocTab(Docs.Create.WebDocument(`https://wikipedia.org/wiki/${str}`, { _width: 400, x, y, _height: 512, _nativeWidth: 850, title: `wiki:${str}`, data_useCors: true }), OpenWhere.addRight)
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
index 0bf78f57c..53c0823ea 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
@@ -224,6 +224,7 @@
display: none;
}
+.schema-table-cell-selected,
.schema-table-cell,
.row-menu {
border: 1px solid global.$medium-gray;
@@ -232,6 +233,14 @@
display: inline-flex;
padding: 0;
align-items: center;
+ input[type='text'] {
+ border: unset;
+ }
+}
+.schema-table-cell-selected {
+ input[type='text'] {
+ background: lightgray;
+ }
}
.schemaRTFCell {
@@ -310,4 +319,7 @@
.schemaField-editing {
outline: none;
height: 100%;
+ cursor: text;
+ outline: none;
+ overflow: auto;
}
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 8e9e8e1cc..05670562e 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -252,7 +252,8 @@ export class CollectionSchemaView extends CollectionSubView() {
@action
onKeyDown = (e: KeyboardEvent) => {
if (this._selectedDocs.length > 0) {
- switch (e.key) {
+ switch (e.key + (e.shiftKey ? 'Shift' : '')) {
+ case 'Enter':
case 'ArrowDown':
{
const lastDoc = this._selectedDocs.lastElement();
@@ -272,6 +273,7 @@ export class CollectionSchemaView extends CollectionSubView() {
e.preventDefault();
}
break;
+ case 'EnterShift':
case 'ArrowUp':
{
const firstDoc = this._selectedDocs.lastElement();
@@ -291,6 +293,7 @@ export class CollectionSchemaView extends CollectionSubView() {
e.preventDefault();
}
break;
+ case 'Tab':
case 'ArrowRight':
if (this._selectedCells) {
this._selectedCol = Math.min(this._colEles.length - 1, this._selectedCol + 1);
@@ -298,6 +301,7 @@ export class CollectionSchemaView extends CollectionSubView() {
this.selectCell(this._selectedDocs[0], 0, false, false);
}
break;
+ case 'TabShift':
case 'ArrowLeft':
if (this._selectedCells) {
this._selectedCol = Math.max(0, this._selectedCol - 1);
diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
index e6acff061..e89822b4c 100644
--- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
@@ -86,15 +86,6 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
editing => {
if (editing) {
this.setupRefSelect(this.refSelectConditionMet);
- setTimeout(() => {
- if (this._inputref?.innerText.startsWith('=') || this._inputref?.innerText.startsWith(':=')) {
- this._overlayDisposer?.();
- this._overlayDisposer = OverlayView.Instance.addElement(<DocumentIconContainer />, { x: 0, y: 0 });
- this._props.highlightCells?.(this._unrenderedContent);
- this.setContent(this._unrenderedContent);
- setTimeout(() => this.setCursorPosition(this._unrenderedContent.length));
- }
- });
} else {
this._overlayDisposer?.();
this._overlayDisposer = undefined;
@@ -192,6 +183,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
setIsFocused = (value: boolean) => {
const wasFocused = this._editing;
this._editing = value;
+ this._editing && setTimeout(() => this._inputref?.focus());
return wasFocused !== this._editing;
};
@@ -272,8 +264,6 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
@action
onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
- if (e.nativeEvent.defaultPrevented) return; // hack .. DashFieldView grabs native events, but react ignores stoppedPropagation and preventDefault, so we need to check it here
-
switch (e.key) {
case 'Tab':
e.stopPropagation();
@@ -284,9 +274,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
break;
case 'Enter':
e.stopPropagation();
- if (!e.ctrlKey) {
- this.finalizeEdit(e.shiftKey, false, true);
- }
+ !e.ctrlKey && this.finalizeEdit(e.shiftKey, false, true);
break;
case 'Escape':
e.stopPropagation();
@@ -297,7 +285,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
case 'ArrowLeft':
case 'ArrowRight': // prettier-ignore
e.stopPropagation();
- setTimeout(() => this.setupRefSelect(this.refSelectConditionMet), 0);
+ setTimeout(() => this.setupRefSelect(this.refSelectConditionMet));
break;
case ' ':
{
@@ -306,18 +294,14 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
setTimeout(() => {
this.setContent(this._unrenderedContent);
setTimeout(() => this.setCursorPosition(cursorPos));
- }, 0);
+ });
}
break;
- case 'u': // for some reason 'u' otherwise exits the editor
- e.stopPropagation();
- break;
case 'Shift':
case 'Alt':
case 'Meta':
case 'Control':
- case ':': // prettier-ignore
- break;
+ case ':':
default:
break;
}
@@ -361,12 +345,9 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
<div
contentEditable
className="schemaField-editing"
- ref={r => {
- this._inputref = r;
- }}
- style={{ cursor: 'text', outline: 'none', overflow: 'auto', minHeight: `min(100%, ${(this._props.GetValue()?.split('\n').length || 1) * 15})`, minWidth: 20 }}
+ ref={r => (this._inputref = r)}
+ style={{ minHeight: `min(100%, ${(this._props.GetValue()?.split('\n').length || 1) * 15})`, minWidth: 20 }}
onBlur={() => (this._props.refSelectModeInfo.enabled ? setTimeout(() => this.setIsFocused(true), 1000) : this.finalizeEdit(false, true, false))}
- autoFocus
onInput={this.onChange}
onKeyDown={this.onKeyDown}
onPointerDown={e => {
@@ -383,14 +364,37 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
);
};
+ onFocus = () => {
+ if (this._inputref?.innerText.startsWith('=') || this._inputref?.innerText.startsWith(':=')) {
+ this._overlayDisposer?.();
+ this._overlayDisposer = OverlayView.Instance.addElement(<DocumentIconContainer />, { x: 0, y: 0 });
+ this._props.highlightCells?.(this._unrenderedContent);
+ this.setContent(this._unrenderedContent);
+ setTimeout(() => this.setCursorPosition(this._unrenderedContent.length));
+ }
+ };
+
+ onBlur = action(() => {
+ this._editing = false;
+ });
+
render() {
const gval = this._props.GetValue()?.replace(/\n/g, '\\r\\n');
if (this._editing && gval !== undefined) {
- return <div className={`editableView-container-editing${this._props.oneLine ? '-oneLine' : ''}`}>{this.renderEditor()}</div>;
+ return (
+ <div
+ className={`editableView-container-editing${this._props.oneLine ? '-oneLine' : ''}`} //
+ onFocus={this.onFocus}
+ onBlur={this.onBlur}>
+ {this.renderEditor()}
+ </div>
+ );
} else
return this._props.contents instanceof ObjectField ? null : (
<div
className={`editableView-container-editing${this._props.oneLine ? '-oneLine' : ''}`}
+ onFocus={this.onFocus}
+ onBlur={this.onBlur}
style={{
minHeight: '10px',
whiteSpace: this._props.oneLine ? 'nowrap' : 'pre-line',
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 941402d6d..1b4f200a3 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -102,8 +102,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
return true;
};
public static renderProps(props: SchemaTableCellProps) {
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { Document, fieldKey, getFinfo, columnWidth, isRowActive } = props;
+ const { Document, fieldKey, /* getFinfo,*/ columnWidth, isRowActive } = props;
let protoCount = 0;
let doc: Doc | undefined = Document;
while (doc) {
@@ -187,7 +186,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
return (
<div
className="schemacell-edit-wrapper"
- // onContextMenu={}
+ tabIndex={1}
style={{
color,
textDecoration,
@@ -261,7 +260,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
render() {
return (
<div
- className="schema-table-cell"
+ className={`schema-table-cell${selectedCell(this._props) ? '-selected' : ''}`}
onContextMenu={e => StopEvent(e)}
onPointerDown={action(e => {
if (this.lockedInteraction) {
@@ -397,10 +396,10 @@ export class SchemaDateCell extends ObservableReactComponent<SchemaTableCellProp
const { pointerEvents } = SchemaTableCell.renderProps(this._props);
return (
<>
- <div style={{ pointerEvents: 'none' }}>
+ <div style={{ pointerEvents: 'none' }} tabIndex={1}>
<DatePicker dateFormat="Pp" selected={this.date?.date ?? Date.now()} onChange={emptyFunction} />
</div>
- {pointerEvents === 'none' ? null : (
+ {pointerEvents === 'none' || !selectedCell(this._props) ? null : (
<Popup
icon={<FontAwesomeIcon size="xs" icon="caret-down" />}
size={Size.XSMALL}
@@ -495,14 +494,22 @@ export class SchemaEnumerationCell extends ObservableReactComponent<SchemaTableC
<div style={{ width: '100%' }}>
<Select
styles={{
+ dropdownIndicator: base => ({
+ ...base,
+ display: selectedCell(this._props) ? 'unset' : 'none',
+ }),
container: base => ({
...base,
height: 20,
+ border: 'unset !important',
+ pointerEvents: selectedCell(this._props) ? 'all' : 'none',
}),
control: base => ({
...base,
height: 20,
minHeight: 20,
+ border: 'unset !important',
+ background: selectedCell(this._props) ? 'lightgray' : undefined,
}),
placeholder: base => ({
...base,
@@ -518,6 +525,7 @@ export class SchemaEnumerationCell extends ObservableReactComponent<SchemaTableC
...base,
height: 20,
transform: 'scale(0.75)',
+ border: 'unset !important',
}),
menuPortal: base => ({
...base,