aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesButtons.tsx
diff options
context:
space:
mode:
authorJoanne <zehan_ding@brown.edu>2025-05-12 20:58:01 -0400
committerJoanne <zehan_ding@brown.edu>2025-05-12 20:58:01 -0400
commitcd93c88b8fee83a99342eac4dc60f7b4373fa843 (patch)
treeb00d1f46c802752c90e54bb21be785a05e05195e /src/client/views/PropertiesButtons.tsx
parent4997c3de20a381eac30224a7a550afa66174f07d (diff)
parent3a733aa0fd24517e83649824dec0fc8bcc0bde43 (diff)
added tutorial tool, still need to integrate with metadatatool
Diffstat (limited to 'src/client/views/PropertiesButtons.tsx')
-rw-r--r--src/client/views/PropertiesButtons.tsx37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx
index 606fb17ed..28566ba1d 100644
--- a/src/client/views/PropertiesButtons.tsx
+++ b/src/client/views/PropertiesButtons.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable react/no-unused-class-component-methods */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Dropdown, DropdownType, IListItemProps, Toggle, ToggleType, Type } from '@dash/components';
import { action, computed, observable } from 'mobx';
@@ -14,7 +13,6 @@ import { RxWidth } from 'react-icons/rx';
import { TbEditCircle, TbEditCircleOff, TbHandOff, TbHandStop, TbHighlight, TbHighlightOff } from 'react-icons/tb';
import { TfiBarChart } from 'react-icons/tfi';
import { Doc, Opt } from '../../fields/Doc';
-import { DocData } from '../../fields/DocSymbols';
import { ScriptField } from '../../fields/ScriptField';
import { BoolCast, ScriptCast, StrCast } from '../../fields/Types';
import { ImageField } from '../../fields/URLField';
@@ -120,7 +118,7 @@ export class PropertiesButtons extends React.Component {
// select text
return this.propertyToggleBtn(
on => (on ? 'ALIGN TOP' : 'ALIGN CENTER'),
- '_layout_centered',
+ 'text_centered',
on => `${on ? 'Text is aligned with top of document' : 'Text is aligned with center of document'} `,
() => <MdTouchApp /> // 'eye'
);
@@ -133,9 +131,9 @@ export class PropertiesButtons extends React.Component {
on => `${on ? 'Flashcard enabled' : 'Flashcard disabled'} `,
() => <MdTouchApp />,
(dv, doc) => {
- const on = !!doc.onPaint;
- doc[DocData].onPaint = on ? undefined : ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, { documentView: 'any' });
- doc[DocData].layout_textPainted = on ? undefined : `<ComparisonBox {...props} fieldKey={'${dv?.LayoutFieldKey ?? 'text'}'}/>`;
+ const on = !!doc.$onPaint;
+ doc.$onPaint = on ? undefined : ScriptField.MakeScript(`toggleDetail(documentView, "textPainted")`, { documentView: 'any' });
+ doc.$layout_textPainted = on ? undefined : `<ComparisonBox {...props} fieldKey={'${dv?.LayoutFieldKey ?? 'text'}'}/>`;
}
);
}
@@ -295,7 +293,7 @@ export class PropertiesButtons extends React.Component {
@computed get onClickVal() {
const linkButton = IsFollowLinkScript(this.selectedDoc.onClick);
const followLoc = this.selectedDoc._followLinkLocation;
- const linkedToLightboxView = () => Doc.Links(this.selectedDoc).some(link => Doc.getOppositeAnchor(link, this.selectedDoc)?._isLightbox);
+ const linkedToLightboxView = () => Doc.Links(this.selectedDoc).some(link => Doc.getOppositeAnchor(link, this.selectedDoc)?.$isLightbox);
if (followLoc === OpenWhere.lightbox && !linkedToLightboxView()) return 'linkInPlace';
if (linkButton && followLoc === OpenWhere.addRight) return 'linkOnRight';
@@ -387,18 +385,19 @@ export class PropertiesButtons extends React.Component {
const followLoc = this.selectedDoc._followLinkLocation;
const linkedToLightboxView = () => Doc.Links(this.selectedDoc).some(link => Doc.getOppositeAnchor(link, this.selectedDoc)?._isLightbox);
- let active = false;
- // prettier-ignore
- switch (value[0]) {
- case 'linkInPlace': active = linkButton && followLoc === OpenWhere.lightbox && !linkedToLightboxView(); break;
- case 'linkOnRight': active = linkButton && followLoc === OpenWhere.addRight; break;
- case 'enterPortal': active = linkButton && this.selectedDoc._followLinkLocation === OpenWhere.lightbox && linkedToLightboxView(); break;
- case 'toggleDetail':active = ScriptCast(this.selectedDoc.onClick)?.script.originalScript.includes('toggleDetail'); break;
- case 'nothing': active = !linkButton && this.selectedDoc.onClick === undefined;break;
- default:
- }
+ const active = () => {
+ // prettier-ignore
+ switch (value[0]) {
+ case 'linkInPlace': return linkButton && followLoc === OpenWhere.lightbox && !linkedToLightboxView(); break;
+ case 'linkOnRight': return linkButton && followLoc === OpenWhere.addRight; break;
+ case 'enterPortal': return linkButton && this.selectedDoc._followLinkLocation === OpenWhere.lightbox && linkedToLightboxView(); break;
+ case 'toggleDetail':return ScriptCast(this.selectedDoc.onClick)?.script.originalScript.includes('toggleDetail'); break;
+ case 'nothing': return !linkButton && this.selectedDoc.onClick === undefined;break;
+ default: return false;
+ }
+ };
return (
- <div className="list-item" key={`${value}`} style={{ backgroundColor: active ? Colors.LIGHT_BLUE : undefined }} onClick={click}>
+ <div className="list-item" key={`${value}`} style={{ backgroundColor: active() ? Colors.LIGHT_BLUE : undefined }} onClick={click}>
{value[1]}
</div>
);
@@ -449,7 +448,7 @@ export class PropertiesButtons extends React.Component {
};
render() {
- const layoutField = this.selectedDoc?.[Doc.LayoutFieldKey(this.selectedDoc)];
+ const layoutField = this.selectedDoc?.[Doc.LayoutDataKey(this.selectedDoc)];
const isText = DocumentView.Selected().lastElement()?.ComponentView instanceof FormattedTextBox;
const isInk = this.selectedDoc?.layout_isSvg;
const isImage = layoutField instanceof ImageField;