import {CATS} from "@fiduswriter/document/schema/i18n" import {escapeText, infoTooltip} from "fwtoolkit" interface InternalTarget { id: string text: string } interface AllowedContent { cross_reference?: boolean link?: boolean } interface LinkDialogOptions { defaultLink: string internalTargets: InternalTarget[] linkType: string title: string target: string allowedContent: AllowedContent } export const linkDialogTemplate = ({ defaultLink, internalTargets, linkType, title, target, allowedContent }: LinkDialogOptions): string => `${ allowedContent.cross_reference && internalTargets.length ? `

` : "" }${ allowedContent.link && internalTargets.length ? `

` : "" }${ allowedContent.link ? `

` : "" }` /** Dialog to add a note to a revision before saving. */ export const revisionDialogTemplate = ({dir}: {dir: string}): string => `

` export const pdfExportDialogTemplate = (): string => `

${gettext("Tracked changes")}

${infoTooltip( gettext( "Applies all tracked changes so the PDF shows the document as if every change had already been accepted." ), "pdf-track-resolve-help" )}
${infoTooltip( gettext( "Prints the tracked changes so reviewers can see what was added, removed or altered." ), "pdf-track-include-help" )}

${infoTooltip( gettext( "Embeds the editable Fidus Writer document inside the PDF so it can be reopened for editing." ), "pdf-embed-fidus-help" )}

${gettext("Figures and tables")}

${infoTooltip( gettext( "Moves figures to the top of the page instead of interrupting the text flow. A custom document style can override this." ), "pdf-figure-page-floats-help" )}
${infoTooltip( gettext( "Moves tables to the top of the page instead of interrupting the text flow. A custom document style can override this." ), "pdf-table-page-floats-help" )}

${gettext("Print production")}

${infoTooltip( gettext("Small lines at the corners of the page that show printers where to cut the paper."), "pdf-crop-marks-help" )}
${infoTooltip( gettext("Marks the final size of the page after it has been cut."), "pdf-trim-box-help" )}
${infoTooltip( gettext("Marks the area beyond the final page size where images and colors must extend so no white edges appear after cutting."), "pdf-bleed-box-help" )}
${infoTooltip( gettext("How far, in millimeters, images and colors extend beyond the edge of the page."), "pdf-bleed-mm-help" )}
${infoTooltip( gettext("Draws a visible border around hyperlinks in the PDF so they are easier to find."), "pdf-link-borders-help" )}
${infoTooltip( gettext("Converts SVG images to bitmap images in the PDF, which can help when PDF viewers or printers do not render SVG images correctly."), "pdf-rasterize-svgs-help" )}

` /** * Radio group for choosing whether tracked changes are resolved (accepted) or * kept in the exported file. `name` must be unique per dialog; the chosen value * is read back with {@link getExportTrackChangesValue}. */ export const exportTrackChangesTemplate = (name: string): string => `

${gettext("Tracked changes")}

${infoTooltip( gettext( "Applies all tracked changes so the exported file shows the document as if every change had already been accepted." ), `${name}-resolve-help` )}
${infoTooltip( gettext( "Keeps the tracked changes so reviewers can see what was added, removed or altered." ), `${name}-include-help` )}
` /** Read the tracked-changes radio group value ("resolve" or "include"). */ export const getExportTrackChangesValue = ( dialogEl: Element, name: string ): string => { return ( dialogEl.querySelector( `input[name="${name}"]:checked` ) as HTMLInputElement | null )?.value || "resolve" } export const htmlExportDialogTemplate = (): string => ` ${exportTrackChangesTemplate("html-track-changes")}

${infoTooltip( gettext( "SVG renders consistently across browsers; MathML keeps formulas as text that can be searched and copied, but only newer browsers support it." ), "html-svg-math-help" )}

` export const epubExportDialogTemplate = (): string => ` ${exportTrackChangesTemplate("epub-track-changes")}

${infoTooltip( gettext( "SVG renders consistently across browsers; MathML keeps formulas as text that can be searched and copied, but only newer browsers support it." ), "epub-svg-math-help" )}

` export const tableInsertTemplate = (): string => `
         
         
         
         
         
         
         
` export const tableConfigurationTemplate = ({ language }: { language: string }): string => `

${gettext("Alignment")}

${gettext("Width")}

${gettext("Column style")}

${gettext("Listed as")}

${gettext("Caption")}

` export const orderedListStartTemplate = ({order}: {order: number}): string => `

` export const mathDialogTemplate = (): string => `
` interface FigureImageItem { id: number | string cats: string[] image: string thumbnail?: string title: string } export const figureImageItemTemplate = ({ id, cats, image, thumbnail, title }: FigureImageItem): string => ` ${ thumbnail === undefined ? `` : `` } ${escapeText(title)} ` interface ImageDB { [id: number]: FigureImageItem } /** A template to select images inside the figure configuration dialog in the editor. */ export const figureImageTemplate = ({imageDB}: {imageDB: ImageDB}): string => `
${Object.values(imageDB).map(image => figureImageItemTemplate(image)).join("")}
${gettext("Image")} ${gettext("Title")}
` /** A template to configure the display of a figure in the editor. */ export const configureFigureTemplate = ({language}: {language: string}): string => `

${gettext("Alignment")}

${gettext("Width")}

 

${gettext("Listed as")}

${gettext("Caption")}

` /** A template to configure citations in the editor */ export const configureCitationTemplate = ({ citedItemsHTML, citeFormat }: { citedItemsHTML: string citeFormat: string }): string => `

${gettext("My sources")}

${gettext("Citation format")}

${citedItemsHTML}
${gettext("Title")} ${gettext("Author")} ${gettext("Year")} ${gettext("Order")} ${gettext("Remove")}
` /** A template for each selected citation item inside the citation configuration dialog of the editor. */ export const selectedCitationTemplate = ({ title, author, year, id, db, prefix, locator }: { title: string author: string year: string id: number | string db: string prefix: string locator: string }): string => `
${escapeText(title)} ${escapeText(author)} ${escapeText(year)}
` interface Contributor { firstname?: string lastname?: string email?: string institution?: string id_type?: string id_value?: string } interface IdType { label: string } export const contributorTemplate = ({ contributor, idTypes = [] }: { contributor: Contributor idTypes?: IdType[] }): string => { const showIdFields = idTypes && idTypes.length > 0 let idTypeField = "" if (showIdFields) { if (idTypes.length === 1) { const type = idTypes[0] idTypeField = `${escapeText(type.label)}:` } else { idTypeField = `` } } return ` ${ showIdFields ? `
${idTypeField}
` : "" } ` } export const languageTemplate = ({ currentLanguage, allowedLanguages }: { currentLanguage: string allowedLanguages: [string, string, string][] }): string => ``