aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes')
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx3
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx38
-rw-r--r--src/client/views/nodes/trails/PresBox.tsx98
-rw-r--r--src/client/views/nodes/trails/SlideEffect.tsx2
4 files changed, 62 insertions, 79 deletions
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index b178d6554..15baebae1 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -192,6 +192,7 @@ export class DocumentContentsView extends ObservableReactComponent<DocumentConte
return { bindings, layoutFrame };
}
+ blacklistedAttrs = [];
render() {
TraceMobx();
const { bindings, layoutFrame } = this.renderData;
@@ -199,7 +200,7 @@ export class DocumentContentsView extends ObservableReactComponent<DocumentConte
return this._props.renderDepth > 12 || !layoutFrame || !this.layoutDoc || GetEffectiveAcl(this.layoutDoc) === AclPrivate ? null : (
<ObserverJsxParser
key={42}
- blacklistedAttrs={emptyPath}
+ blacklistedAttrs={this.blacklistedAttrs}
renderInWrapper={false}
components={DocumentContentsView.Components}
bindings={bindings}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 478039ffa..e21902fdd 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -59,7 +59,7 @@ import { LinkInfo } from '../LinkDocPreview';
import { OpenWhere } from '../OpenWhere';
import './FormattedTextBox.scss';
import { findLinkMark, FormattedTextBoxComment } from './FormattedTextBoxComment';
-import { buildKeymap, KeyMap, updateBullets } from './ProsemirrorExampleTransfer';
+import { buildKeymap, updateBullets } from './ProsemirrorExampleTransfer';
import { removeMarkWithAttrs } from './prosemirrorPatches';
import { RichTextMenu, RichTextMenuPlugin } from './RichTextMenu';
import { RichTextRules } from './RichTextRules';
@@ -75,6 +75,21 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
public static LayoutString(fieldStr: string) {
return FieldView.LayoutString(FormattedTextBox, fieldStr);
}
+ public static MakeConfig(rules?: RichTextRules, props?: FormattedTextBoxProps) {
+ const keymapping = buildKeymap(schema, props ?? {});
+ return {
+ schema,
+ plugins: [
+ inputRules(rules?.inpRules ?? { rules: [] }),
+ ...(props ? [FormattedTextBox.richTextMenuPlugin(props)] : []),
+ history(),
+ keymap(keymapping),
+ keymap(baseKeymap),
+ new Plugin({ props: { attributes: { class: 'ProseMirror-example-setup-style' } } }),
+ new Plugin({ view: () => new FormattedTextBoxComment() }),
+ ],
+ };
+ }
private static nodeViews: (self: FormattedTextBox) => { [key: string]: NodeViewConstructor };
/**
* Initialize the class with all the plugin node view components
@@ -108,7 +123,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
private _recordingStart: number = 0;
private _ignoreScroll = false;
private _focusSpeed: Opt<number>;
- private _keymap: KeyMap | undefined = undefined;
private _rules: RichTextRules | undefined;
private _forceUncollapse = true; // if the cursor doesn't move between clicks, then the selection will disappear for some reason. This flags the 2nd click as happening on a selection which allows bullet points to toggle
private _break = true;
@@ -128,20 +142,8 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
@computed get titleHeight() { return this._props.styleProvider?.(this.layoutDoc, this._props, StyleProp.HeaderMargin) as number || 0; } // prettier-ignore
@computed get layout_autoHeightMargins() { return this.titleHeight + NumCast(this.layoutDoc._layout_autoHeightMargins); } // prettier-ignore
@computed get config() {
- this._keymap = buildKeymap(schema, this._props);
this._rules = new RichTextRules(this.Document, this);
- return {
- schema,
- plugins: [
- inputRules(this._rules.inpRules),
- this.richTextMenuPlugin(),
- history(),
- keymap(this._keymap),
- keymap(baseKeymap),
- new Plugin({ props: { attributes: { class: 'ProseMirror-example-setup-style' } } }),
- new Plugin({ view: () => new FormattedTextBoxComment() }),
- ],
- };
+ return FormattedTextBox.MakeConfig(this._rules, this._props);
}
public get EditorView() {
@@ -1380,11 +1382,11 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB
return true;
}
- richTextMenuPlugin() {
+ static richTextMenuPlugin(props: FormattedTextBoxProps) {
return new Plugin({
view: action((newView: EditorView) => {
- this._props.rootSelected?.() && RichTextMenu.Instance && (RichTextMenu.Instance.view = newView);
- return new RichTextMenuPlugin({ editorProps: this._props });
+ props?.rootSelected?.() && RichTextMenu.Instance && (RichTextMenu.Instance.view = newView);
+ return new RichTextMenuPlugin({ editorProps: props });
}),
});
}
diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index 0c73400a9..c403f9415 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -1,5 +1,3 @@
-/* eslint-disable jsx-a11y/no-static-element-interactions */
-/* eslint-disable jsx-a11y/click-events-have-key-events */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Tooltip } from '@mui/material';
import Slider from '@mui/material/Slider';
@@ -32,7 +30,7 @@ import { dropActionType } from '../../../util/DropActionTypes';
import { ScriptingGlobals } from '../../../util/ScriptingGlobals';
import { SerializationHelper } from '../../../util/SerializationHelper';
import { SnappingManager } from '../../../util/SnappingManager';
-import { undoBatch, UndoManager } from '../../../util/UndoManager';
+import { undoable, undoBatch, UndoManager } from '../../../util/UndoManager';
import { CollectionFreeFormView } from '../../collections/collectionFreeForm';
import { CollectionFreeFormPannableContents } from '../../collections/collectionFreeForm/CollectionFreeFormPannableContents';
import { CollectionView } from '../../collections/CollectionView';
@@ -191,7 +189,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
@computed
get isTreeOrStack() {
- return [CollectionViewType.Tree, CollectionViewType.Stacking].includes(StrCast(this.layoutDoc._type_collection) as any);
+ return [CollectionViewType.Tree, CollectionViewType.Stacking].includes(StrCast(this.layoutDoc._type_collection) as CollectionViewType);
}
@computed get isTree() {
return this.layoutDoc._type_collection === CollectionViewType.Tree;
@@ -304,7 +302,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// 'Play on next' for audio or video therefore first navigate to the audio/video before it should be played
startTempMedia = (targetDoc: Doc, activeItem: Doc) => {
const duration: number = NumCast(activeItem.config_clipEnd) - NumCast(activeItem.config_clipStart);
- if ([DocumentType.VID, DocumentType.AUDIO].includes(targetDoc.type as any)) {
+ if ([DocumentType.VID, DocumentType.AUDIO].includes(targetDoc.type as DocumentType)) {
const targMedia = DocumentView.getDocumentView(targetDoc);
targMedia?.ComponentView?.playFrom?.(NumCast(activeItem.config_clipStart), NumCast(activeItem.config_clipStart) + duration);
}
@@ -312,7 +310,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
stopTempMedia = (targetDocField: FieldResult) => {
const targetDoc = DocCast(DocCast(targetDocField).annotationOn) ?? DocCast(targetDocField);
- if ([DocumentType.VID, DocumentType.AUDIO].includes(targetDoc.type as any)) {
+ if ([DocumentType.VID, DocumentType.AUDIO].includes(targetDoc.type as DocumentType)) {
const targMedia = DocumentView.getDocumentView(targetDoc);
targMedia?.ComponentView?.Pause?.();
}
@@ -364,7 +362,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
this.setIsRecording(false);
this.setIsLoading(true);
- const currSlideProperties: { [key: string]: any } = {};
+ const currSlideProperties: { [key: string]: FieldResult } = {};
gptSlideProperties.forEach(key => {
if (this.activeItem[key]) {
currSlideProperties[key] = this.activeItem[key];
@@ -554,7 +552,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
});
static pinDataTypes(target?: Doc): dataTypes {
- const targetType = target?.type as any;
+ const targetType = target?.type as DocumentType;
const inkable = [DocumentType.INK].includes(targetType);
const scrollable = [DocumentType.PDF, DocumentType.RTF, DocumentType.WEB].includes(targetType) || target?._type_collection === CollectionViewType.Stacking;
const pannable = [DocumentType.IMG, DocumentType.PDF].includes(targetType) || (targetType === DocumentType.COL && target?._type_collection === CollectionViewType.Freeform);
@@ -759,8 +757,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
const doc = DocCast(DocServer.GetCachedRefField(data.id));
if (doc) {
transitioned.add(doc);
- const field = !data.data ? undefined : await SerializationHelper.Deserialize(data.data);
- const tfield = !data.text ? undefined : await SerializationHelper.Deserialize(data.text);
+ const field = !data.data ? undefined : ((await SerializationHelper.Deserialize(data.data)) as FieldType);
+ const tfield = !data.text ? undefined : ((await SerializationHelper.Deserialize(data.text)) as FieldType);
doc._dataTransition = `all ${transTime}ms`;
doc.x = data.x;
doc.y = data.y;
@@ -858,7 +856,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
effect: activeItem,
noSelect: true,
openLocation: targetDoc.type === DocumentType.PRES ? ((OpenWhere.replace + ':' + PresBox.PanelName) as OpenWhere) : OpenWhere.addLeft,
- easeFunc: StrCast(activeItem.presentation_easeFunc, 'ease') as any,
+ easeFunc: StrCast(activeItem.presentation_easeFunc, 'ease') as 'linear' | 'ease',
zoomTextSelections: BoolCast(activeItem.presentation_zoomText),
playAudio: BoolCast(activeItem.presentation_playAudio),
playMedia: activeItem.presentation_mediaStart === 'auto',
@@ -1101,7 +1099,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
*/
@undoBatch
viewChanged = action((e: React.ChangeEvent) => {
- const typeCollection = (e.target as any).selectedOptions[0].value as CollectionViewType;
+ const typeCollection = (e.target as HTMLSelectElement).selectedOptions[0].value as CollectionViewType;
this.layoutDoc.presFieldKey = this.fieldKey + (typeCollection === CollectionViewType.Tree ? '-linearized' : '');
// pivot field may be set by the user in timeline view (or some other way) -- need to reset it here
[CollectionViewType.Tree || CollectionViewType.Stacking].includes(typeCollection) && (this.Document._pivotField = undefined);
@@ -1111,30 +1109,8 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
}
});
- /**
- * Called when the user changes the view type
- * Either 'List' (stacking) or 'Slides' (carousel)
- */
- // @undoBatch
- mediaStopChanged = action((e: React.ChangeEvent) => {
- const { activeItem } = this;
- const stopDoc = (e.target as any).selectedOptions[0].value as string;
- const stopDocIndex = Number(stopDoc[0]);
- activeItem.mediaStopDoc = stopDocIndex;
- if (this.childDocs[stopDocIndex - 1].mediaStopTriggerList) {
- const list = DocListCast(this.childDocs[stopDocIndex - 1].mediaStopTriggerList);
- list.push(activeItem);
- // this.childDocs[stopDocIndex - 1].mediaStopTriggerList = list;\
- } else {
- this.childDocs[stopDocIndex - 1].mediaStopTriggerList = new List<Doc>();
- const list = DocListCast(this.childDocs[stopDocIndex - 1].mediaStopTriggerList);
- list.push(activeItem);
- // this.childDocs[stopDocIndex - 1].mediaStopTriggerList = list;
- }
- });
-
movementName = action((activeItem: Doc) => {
- if (![PresMovement.Zoom, PresMovement.Pan, PresMovement.Center, PresMovement.Jump, PresMovement.None].includes(StrCast(activeItem.presentation_movement) as any)) {
+ if (![PresMovement.Zoom, PresMovement.Pan, PresMovement.Center, PresMovement.Jump, PresMovement.None].includes(StrCast(activeItem.presentation_movement) as PresMovement)) {
return PresMovement.Zoom;
}
return StrCast(activeItem.presentation_movement);
@@ -1185,7 +1161,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
* Method to get the list of selected items in the order in which they have been selected
*/
@computed get listOfSelected() {
- return Array.from(this.selectedArray).map((doc: Doc, index: any) => {
+ return Array.from(this.selectedArray).map((doc, index) => {
const curDoc = Cast(doc, Doc, null);
const tagDoc = Cast(curDoc.presentation_targetDoc, Doc, null);
if (curDoc && curDoc === this.activeItem)
@@ -1193,7 +1169,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// eslint-disable-next-line react/no-array-index-key
<div key={index} className="selectedList-items">
<b>
- {index + 1}. {curDoc.title}
+ {index + 1}. {StrCast(curDoc.title)})
</b>
</div>
);
@@ -1201,14 +1177,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
return (
// eslint-disable-next-line react/no-array-index-key
<div key={index} className="selectedList-items">
- {index + 1}. {curDoc.title}
+ {index + 1}. {StrCast(curDoc.title)}
</div>
);
if (curDoc)
return (
// eslint-disable-next-line react/no-array-index-key
<div key={index} className="selectedList-items">
- {index + 1}. {curDoc.title}
+ {index + 1}. {StrCast(curDoc.title)}
</div>
);
return null;
@@ -1301,13 +1277,14 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
switch (e.key) {
case 'Backspace':
if (this.layoutDoc.presentation_status === 'edit') {
- undoBatch(
+ undoable(
action(() => {
Array.from(this.selectedArray).forEach(doc => this.removeDocument(doc));
this.clearSelectedArray();
this._eleArray.length = 0;
this._dragArray.length = 0;
- })
+ }),
+ 'delete slides'
)();
handled = true;
}
@@ -1488,7 +1465,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
);
};
// Converts seconds to ms and updates presentation_transition
- public static SetTransitionTime = (number: String, setter: (timeInMS: number) => void, change?: number) => {
+ public static SetTransitionTime = (number: string, setter: (timeInMS: number) => void, change?: number) => {
let timeInMS = Number(number) * 1000;
if (change) timeInMS += change;
if (timeInMS < 100) timeInMS = 100;
@@ -1497,7 +1474,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
@undoBatch
- updateTransitionTime = (number: String, change?: number) => {
+ updateTransitionTime = (number: string, change?: number) => {
PresBox.SetTransitionTime(
number,
(timeInMS: number) =>
@@ -1510,7 +1487,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
// Converts seconds to ms and updates presentation_transition
@undoBatch
- updateZoom = (number: String, change?: number) => {
+ updateZoom = (number: string, change?: number) => {
let scale = Number(number) / 100;
if (change) scale += change;
if (scale < 0.01) scale = 0.01;
@@ -1524,7 +1501,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
* Converts seconds to ms and updates presentation_duration
*/
@undoBatch
- updateDurationTime = (number: String, change?: number) => {
+ updateDurationTime = (number: string, change?: number) => {
let timeInMS = Number(number) * 1000;
if (change) timeInMS += change;
if (timeInMS < 100) timeInMS = 100;
@@ -1608,9 +1585,9 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
});
};
- static _sliderBatch: any;
+ static _sliderBatch: UndoManager.Batch | undefined;
static endBatch = () => {
- PresBox._sliderBatch.end();
+ PresBox._sliderBatch?.end();
document.removeEventListener('pointerup', PresBox.endBatch, true);
};
public static inputter = (min: string, step: string, max: string, value: number, active: boolean, change: (val: string) => void, hmargin?: number) => (
@@ -1704,7 +1681,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
</div>
</Tooltip>
</div>
- {[DocumentType.AUDIO, DocumentType.VID].includes(targetType as any as DocumentType) ? null : (
+ {[DocumentType.AUDIO, DocumentType.VID].includes(targetType as DocumentType) ? null : (
<>
<div className="ribbon-doubleButton">
<div className="presBox-subheading">Slide Duration</div>
@@ -1847,7 +1824,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
if (activeItem && this.targetDoc) {
const transitionSpeed = activeItem.presentation_transition ? NumCast(activeItem.presentation_transition) / 1000 : 0.5;
const zoom = NumCast(activeItem.config_zoom, 1) * 100;
- const effect = StrCast(activeItem.presentation_effect) ? (StrCast(activeItem.presentation_effect) as any as PresEffect) : PresEffect.None;
+ const effect = StrCast(activeItem.presentation_effect) ? (StrCast(activeItem.presentation_effect) as PresEffect) : PresEffect.None;
const direction = StrCast(activeItem.presentation_effectDirection) as PresEffectDirection;
return (
@@ -2660,24 +2637,26 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<div className={`dropdown-play ${this._presentTools ? 'active' : ''}`} onClick={e => e.stopPropagation()} onPointerUp={e => e.stopPropagation()} onPointerDown={e => e.stopPropagation()}>
<div
className="dropdown-play-button"
- onClick={undoBatch(
+ onClick={undoable(
action(() => {
this.enterMinimize();
this.turnOffEdit(true);
this.gotoDocument(this.itemIndex, this.activeItem);
- })
+ }),
+ 'minimze presentation'
)}>
Mini-player
</div>
<div
className="dropdown-play-button"
- onClick={undoBatch(
+ onClick={undoable(
action(() => {
this.layoutDoc.presentation_status = 'manual';
this.initializePresState(this.itemIndex);
this.turnOffEdit(true);
this.gotoDocument(this.itemIndex, this.activeItem);
- })
+ }),
+ 'make presentation manual'
)}>
Sidebar player
</div>
@@ -2773,13 +2752,13 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
<span className={`presBox-button ${this.layoutDoc.presentation_status === PresStatus.Edit ? 'present' : ''}`}>
<div
className="presBox-button-left"
- onClick={undoBatch(() => {
+ onClick={undoable(() => {
if (this.childDocs.length) {
this.layoutDoc.presentation_status = 'manual';
this.initializePresState(this.itemIndex);
this.gotoDocument(this.itemIndex, this.activeItem);
}
- })}>
+ }, 'start presentation')}>
<FontAwesomeIcon icon="play-circle" />
<div style={{ display: this._props.PanelWidth() > 200 ? 'inline-flex' : 'none' }}>&nbsp; Present</div>
</div>
@@ -2911,11 +2890,12 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
{this._props.PanelWidth() > 250 ? (
<div
className="presPanel-button-text"
- onClick={undoBatch(
+ onClick={undoable(
action(() => {
this.layoutDoc.presentation_status = PresStatus.Edit;
clearTimeout(this._presTimer);
- })
+ }),
+ 'edit presetnation'
)}>
EXIT
</div>
@@ -2988,7 +2968,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
};
sort = (treeViewMap: Map<Doc, number>) => [...treeViewMap.entries()].sort((a: [Doc, number], b: [Doc, number]) => (a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0)).map(kv => kv[0]);
-
+ emptyHierarchy = [];
render() {
// needed to ensure that the childDocs are loaded for looking up fields
this.childDocs.slice();
@@ -3086,7 +3066,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
ScreenToLocalTransform={this.getTransform}
AddToMap={this.AddToMap}
RemFromMap={this.RemFromMap}
- hierarchyIndex={emptyPath}
+ hierarchyIndex={this.emptyHierarchy}
/>
) : null}
</div>
diff --git a/src/client/views/nodes/trails/SlideEffect.tsx b/src/client/views/nodes/trails/SlideEffect.tsx
index 00039e3cb..a114c231f 100644
--- a/src/client/views/nodes/trails/SlideEffect.tsx
+++ b/src/client/views/nodes/trails/SlideEffect.tsx
@@ -103,7 +103,7 @@ export default function SpringAnimation({ doc, dir, springSettings, presEffect,
api.start({ loop: infinite, delay: infinite ? 500 : 0 });
}
}, [inView]);
- const animatedDiv = (style: any) => (
+ const animatedDiv = (style: object) => (
<animated.div ref={ref} style={{ ...style, opacity: to(springs.opacity, val => `${val}`) }}>
{children}
</animated.div>