Skip to content

fix: Use text area for alternative text and captions (visual editor) #644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions apps/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Use `QUARTO_VISUAL_EDITOR_CONFIRMED` > `PW_TEST` > `CI` to bypass (`true`) or force (`false`) the Visual Editor confirmation dialogue (<https://github.com/quarto-dev/quarto/pull/654>).
- Fix behavior in Positron when running a cell containing invalid/incomplete code (<https://github.com/quarto-dev/quarto/pull/664>).
- Visual Editor: uses a text box for alternative text and captions in callouts, images, and tables interface. (<https://github.com/quarto-dev/quarto/pull/644>)
- Fix `language` typos throughout the codebase (<https://github.com/quarto-dev/quarto/pull/650>)

## 1.118.0 (Release on 2024-11-26)
Expand Down
47 changes: 31 additions & 16 deletions packages/editor-ui/src/dialogs/edit-callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@

import React, { useRef, useState } from "react"

import { Button, Checkbox, Field, Input, Select, SelectTabData, SelectTabEvent, Tab, TabValue, makeStyles } from "@fluentui/react-components"
import {
Button,
Checkbox,
Field,
Select,
SelectTabData,
SelectTabEvent,
Tab,
TabValue,
makeStyles,
Textarea,
} from "@fluentui/react-components";

import { AttrEditInput, CalloutEditProps, CalloutEditResult, CalloutProps, PandocAttr, UIToolsAttr } from "editor-types";

Expand All @@ -32,10 +43,10 @@ import { useEffect } from "react";

export function editCallout(attrUITools: UIToolsAttr) {
return async (props: CalloutEditProps, removeEnabled: boolean): Promise<CalloutEditResult | null> => {
const values: EditCalloutDialogValues = {
values: {...attrUITools.propsToInput(props.attr), ...props.callout},
action: "edit"

const values: EditCalloutDialogValues = {
values: {...attrUITools.propsToInput(props.attr), ...props.callout},
action: "edit"
};

const result = await showValueEditorDialog(EditCalloutDialog, values, {
Expand Down Expand Up @@ -65,7 +76,7 @@ interface EditCalloutDialogOptions {
removeEnabled: boolean;
}

const EditCalloutDialog: React.FC<{
const EditCalloutDialog: React.FC<{
values: EditCalloutDialogValues,
options: EditCalloutDialogOptions,
onClosed: (values?: EditCalloutDialogValues) => void }
Expand Down Expand Up @@ -93,7 +104,7 @@ const EditCalloutDialog: React.FC<{
}
}

const removeButton =
const removeButton =
<Button onClick={() => close({ ...props.values, action: 'remove' })}>
{t("Unwrap Div")}
</Button>;
Expand Down Expand Up @@ -128,32 +139,36 @@ const EditCalloutDialog: React.FC<{
</Field>
</div>
<Field label={t("Caption")} placeholder={t("(Optional)")}>
<Input value={caption} onChange={(_ev, data) => setCaption(data.value)}/>
<Textarea
value={caption}
onChange={(_ev, data) => setCaption(data.value)}
resize="vertical"
/>
</Field>
<Checkbox label={t("Display icon alongside callout")} checked={icon} onChange={(_ev, data) => setIcon(!!data.checked)}/>
<Checkbox label={t("Display icon alongside callout")} checked={icon} onChange={(_ev, data) => setIcon(!!data.checked)}/>
</EditAttrPanel>;

const attributesPanel =
const attributesPanel =
<EditAttrPanel>
<EditAttr value={attr} onChange={setAttr} />
</EditAttrPanel>;

return (
<ModalDialog
title={t("Callout")}
title={t("Callout")}
theme={fluentTheme()}
isOpen={isOpen}
isOpen={isOpen}
leftButtons={props.options.removeEnabled ? removeButton : undefined}
onOK={() => close({ values: { ...attr, type, appearance, caption, icon}, action: 'edit'})}
onCancel={() => close() }
>
<ModalDialogTabList
id="edit-callout"
selectedValue={selectedTab}
id="edit-callout"
selectedValue={selectedTab}
onTabSelect={onTabSelect}
>
<Tab id="callout" value="callout">{t("Callout")}</Tab>
<Tab id="attributes" value="attributes">{t("Attributes")}</Tab>
<Tab id="attributes" value="attributes">{t("Attributes")}</Tab>
</ModalDialogTabList>
<div>
{selectedTab === "callout" && calloutPanel}
Expand All @@ -173,4 +188,4 @@ const useStyles = makeStyles({
width: '50%'
}
},
})
})
14 changes: 7 additions & 7 deletions packages/editor-ui/src/dialogs/edit-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
useId,
RadioGroup,
Label,
Radio
Radio,
Textarea
} from "@fluentui/react-components";

import { ModalDialog, ModalDialogTabList, showValueEditorDialog} from "ui-widgets";
Expand Down Expand Up @@ -153,19 +154,21 @@ const imagePanel =
: null
}
<Field label={t("Caption")}>
<Input
<Textarea
value={caption}
onChange={(_ev, data) => setCaption(data.value)}
placeholder={t("(Optional)")}
resize="vertical"
/>
</Field>

{alt !== undefined
? <Field label={t("Alternative text")}>
<Input
value={alt}
<Textarea
value={alt}
onChange={(_ev, data) => setAlt(data.value)}
placeholder={t("(Optional)")}
resize="vertical"
/>
</Field>
: null
Expand Down Expand Up @@ -288,6 +291,3 @@ const useStyles = makeStyles({
gridRowGap: tokens.spacingVerticalS,
}
})



11 changes: 8 additions & 3 deletions packages/editor-ui/src/dialogs/insert-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import React, { useState } from "react";

import { Checkbox, Field, Input, makeStyles } from "@fluentui/react-components";
import { Checkbox, Field, Input, makeStyles, Textarea } from "@fluentui/react-components";

import {
ModalDialog,
Expand Down Expand Up @@ -91,7 +91,12 @@ const InsertTableDialog: React.FC<{

{props.options.captions ? (
<Field label={t("Caption")}>
<Input value={caption} onChange={(_ev, data) => setCaption(data.value)} placeholder={t("(Optional)")}/>
<Textarea
value={caption}
onChange={(_ev, data) => setCaption(data.value)}
placeholder={t("(Optional)")}
resize="vertical"
/>
</Field>
) : null}

Expand All @@ -111,4 +116,4 @@ const useStyles = makeStyles({
width: '50%'
}
},
})
})