Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frontend/common/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
deutsch,
ellinika,
english,
farsi,
french,
nederlands,
norsk_bokmål,
Expand All @@ -31,6 +32,9 @@ i18next.use(LanguageDetector).init({
en: {
translation: without_empty_keys(english),
},
fa: {
translation: without_empty_keys(farsi),
},
fi: {
translation: without_empty_keys(suomi),
},
Expand Down Expand Up @@ -90,6 +94,10 @@ export const getCurrentLanguage = () => {
return i18next.language
}

export const getWritingDirection = () => {
return t("t_language_direction") === "rtl" ? "rtl" : "ltr"
}

/**
* Like t, but you can interpolate Preact elements.
* @param {string} key
Expand Down
1 change: 1 addition & 0 deletions frontend/common/lang_imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export { default as deutsch } from "../lang/deutsch.json" with { type: "json" }
export { default as ellinika } from "../lang/ellinika.json" with { type: "json" }
export { default as english } from "../lang/english.json" with { type: "json" }
export { default as farsi } from "../lang/farsi.json" with { type: "json" }
export { default as french } from "../lang/french.json" with { type: "json" }
export { default as nederlands } from "../lang/nederlands.json" with { type: "json" }
export { default as norsk_bokmål } from "../lang/norsk_bokmål.json" with { type: "json" }
Expand Down
8 changes: 7 additions & 1 deletion frontend/components/CellInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,13 @@ const InputContextMenu = ({
>
${open
? html`<ul onMouseenter=${mouseenter}>
<${InputContextMenuItem} tag="delete" contents=${t("t_delete_cell_action")} title=${t("t_delete_cell_action")} onClick=${on_delete} setOpen=${setOpen} />
<${InputContextMenuItem}
tag="delete"
contents=${t("t_delete_cell_action")}
title=${t("t_delete_cell_action")}
onClick=${on_delete}
setOpen=${setOpen}
/>

<${InputContextMenuItem}
title=${running_disabled ? t("t_enable_and_run_cell") : t("t_disable_this_cell_and_all_cells_that_depend_on_it")}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/CellOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export let RawHTMLContainer = ({ body, className = "", persist_js_state = false,
}
}, [body, last_run_timestamp, pluto_actions, sanitize_html])

return html`<div class="raw-html-wrapper ${className}" ref=${container_ref}></div>`
return html`<div dir="auto" class="raw-html-wrapper ${className}" ref=${container_ref}></div>`
}

// https://github.com/fonsp/Pluto.jl/issues/1692
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { SafePreviewUI } from "./SafePreviewUI.js"
import { open_pluto_popup } from "../common/open_pluto_popup.js"
import { get_included_external_source } from "../common/external_source.js"
import { LanguagePicker } from "./LanguagePicker.js"
import { getCurrentLanguage, t, th } from "../common/lang.js"
import { getCurrentLanguage, getWritingDirection, t, th } from "../common/lang.js"

// This is imported asynchronously - uncomment for development
// import environment from "../common/Environment.js"
Expand Down Expand Up @@ -1469,7 +1469,8 @@ ${t("t_key_autosave_description")}`
updateLang() {
const lang = this.state.notebook.metadata?.frontmatter?.language
document.documentElement.lang = lang ?? getCurrentLanguage()
console.error("Updated lang to", document.documentElement.lang)
document.documentElement.dir = getWritingDirection()
console.error("Updated lang to", document.documentElement.lang, document.documentElement.dir)
}

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,5 @@ const LogViewAnsiUp = (/** @type {{value: string}} */ { value }) => {
node_ref.current.innerHTML = ansi_to_html(value)
}, [node_ref.current, value])

return html`<pre ref=${node_ref}></pre>`
return html`<pre dir="auto" ref=${node_ref}></pre>`
}
2 changes: 1 addition & 1 deletion frontend/components/PkgTerminalView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const TerminalViewAnsiUp = ({ value }) => {
}, [node_ref.current, value])

return !!value
? html`<pkg-terminal
? html`<pkg-terminal dir="ltr"
><div class="scroller" tabindex="0"><pre ref=${node_ref} class="pkg-terminal"></pre></div
></pkg-terminal>`
: null
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/welcome/Open.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Open = ({ client, connected, CustomPicker, show_samples, on_start_n

return html`<${PasteHandler} on_start_navigation=${on_start_navigation} />
<h2>${picker.text}</h2>
<div id="new" class=${!!window.plutoDesktop ? "desktop_opener" : ""}>
<div dir="ltr" id="new" class=${!!window.plutoDesktop ? "desktop_opener" : ""}>
<${FilePicker}
key=${picker.placeholder}
client=${client}
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/welcome/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const Welcome = ({ launch_params }) => {
/>
</div>
</section>
<section id="featured">
<section id="featured" dir="ltr">
<div>
<${Featured} sources=${featured_sources} direct_html_links=${launch_params.featured_direct_html_links} />
</div>
Expand Down
40 changes: 23 additions & 17 deletions frontend/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pluto-editor {
min-width: 0;
container-type: inline-size;
container-name: editor;
overflow-x: clip;
}

main {
Expand Down Expand Up @@ -104,6 +105,7 @@ pluto-editor main {
/* Second part: push away from the right to take up all free space */ min((100% - (700px + 25px + 6px)), /* but don't do this more than */ 500px)
);
position: relative;
margin-left: auto;
}

pluto-notebook {
Expand Down Expand Up @@ -626,7 +628,7 @@ dialog#export div#container {
flex-direction: row;
display: flex;
max-width: 1000px;
padding-right: 10em;
padding-inline-end: 10em;
margin: 0 auto;
position: relative;
height: var(--header-height);
Expand Down Expand Up @@ -684,7 +686,7 @@ dialog#export .export_small_btns {
padding: 0.9em;
border-radius: 0.9em;
position: absolute;
right: 0.8em;
inset-inline-end: 0.8em;
top: 0em;
background: var(--export-bg-color);
}
Expand Down Expand Up @@ -789,9 +791,9 @@ nav#at_the_top > div.desktop_picker span {
color: var(--nav-filepicker-color);
border: 2px solid var(--footer-input-border-color);
border-radius: 3px;
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-inline-end: none;
border-end-end-radius: 0;
border-start-end-radius: 0;
}

pluto-filepicker .cm-scroller {
Expand Down Expand Up @@ -924,7 +926,7 @@ nav#at_the_top:after {
nav#at_the_top > pluto-filepicker .cm-editor,
nav#at_the_top > div.desktop_picker span {
border: 2px solid transparent;
border-right: none;
border-inline-end: none;
transition: border 0.15s ease-in-out;
}
nav#at_the_top > pluto-filepicker button,
Expand All @@ -937,7 +939,7 @@ nav#at_the_top:after {
header:hover > nav#at_the_top > div.desktop_picker span,
header:focus-within > nav#at_the_top > div.desktop_picker span {
border: 2px solid var(--footer-input-border-color);
border-right: none;
border-inline-end: none;
}
header:hover > nav#at_the_top > pluto-filepicker button,
header:focus-within > nav#at_the_top > pluto-filepicker button,
Expand Down Expand Up @@ -1474,6 +1476,7 @@ pluto-input .cm-editor {
/* Make sure that scrolling an editor into view gives some breathing room */
scroll-margin-block: 20vh;
min-height: 25px;
direction: ltr;
}
pluto-input:focus-within .cm-editor {
/* z-index increased by 1 to make sure that the autocomplete window shows above all other editors, see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context */
Expand Down Expand Up @@ -1539,7 +1542,6 @@ pluto-shoulder {
--invisible-border: calc(0.5 * var(--pluto-cell-spacing));
--shoulder-width: calc(28px + var(--invisible-border));
--border-radius: calc(5px + var(--invisible-border));

left: calc(0px - var(--shoulder-width));
width: var(--shoulder-width);
border-radius: var(--border-radius) 0px 0px var(--border-radius);
Expand All @@ -1553,6 +1555,7 @@ pluto-shoulder {
bottom: calc(0px - var(--invisible-border));
border: var(--invisible-border) solid rgba(0, 0, 0, 0);
border-right: none;
direction: ltr;
}
pluto-editor.fullscreen pluto-shoulder {
--shoulder-width: 2000px;
Expand Down Expand Up @@ -1934,9 +1937,8 @@ pluto-input > .input_context_menu li button {
margin-top: 1px;
background-size: var(--size) var(--size);
background-position: center;
margin-right: calc(var(--size) / 3);
margin-inline-end: calc(var(--size) / 3);
}

.ctx_icon {
filter: var(--image-filters);
}
Expand Down Expand Up @@ -2533,7 +2535,7 @@ pluto-helpbox > header > button.helpbox-tab-key > .tabicon {
background-size: var(--size);
margin-bottom: calc(-0.15 * var(--size));
filter: var(--image-filters);
margin-right: 0.6em;
margin-inline-end: 0.6em;
display: inline-block;
}
pluto-helpbox > header > button.helpbox-docs > .tabicon {
Expand Down Expand Up @@ -2686,7 +2688,7 @@ button.helpbox-tab-key {
}

button.helpbox-tab-key.helpbox-process {
margin-right: auto;
margin-inline-end: auto;
}

button.helpbox-process.busy {
Expand Down Expand Up @@ -3094,7 +3096,7 @@ footer form > label {
}

footer form > label {
margin-right: 1em;
margin-inline-end: 1em;
flex: 0 1 auto;
overflow: hidden;
text-overflow: ellipsis;
Expand Down Expand Up @@ -3124,16 +3126,20 @@ footer input {
background: var(--white);
font-family: inherit;
font-size: inherit;
border-radius: 3px 0 0 3px;
border-radius: 3px;
border-end-end-radius: 0;
border-start-end-radius: 0;
padding: 3px;
border-right: none;
border-inline-end: none;
}

header#pluto-nav pluto-filepicker button,
footer button {
margin: 0px;
background: var(--footer-filepicker-focus-color);
border-radius: 0 3px 3px 0;
border-radius: 3px;
border-start-start-radius: 0;
border-end-start-radius: 0;
border: 3px solid var(--footer-filepicker-focus-color);
color: var(--footer-filepicker-button-color);
/* border: none; */
Expand Down Expand Up @@ -3161,7 +3167,7 @@ footer #info {
display: flex;
align-items: center;
gap: 0.5rem;
margin-right: 1rem;
margin-inline-end: 1rem;
font-size: 0.75rem;
flex: 0 0 auto;
}
Expand Down
14 changes: 7 additions & 7 deletions frontend/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ p {
}

ul {
padding-left: 0;
padding-inline-start: 0;
list-style: none;
}

Expand Down Expand Up @@ -105,9 +105,9 @@ pluto-filepicker .cm-editor {
color: var(--nav-filepicker-color);
border: 2px solid var(--footer-filepicker-focus-color);
border-radius: 3px;
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-inline-end: none;
border-end-end-radius: 0;
border-start-end-radius: 0;
flex: 1 1 auto;
width: 0px;
/* min-width: 0px; */
Expand Down Expand Up @@ -151,8 +151,8 @@ pluto-filepicker button,

pluto-filepicker button {
cursor: pointer;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-start-start-radius: 0;
border-end-start-radius: 0;
flex: 0 1 auto;
}

Expand Down Expand Up @@ -257,7 +257,7 @@ body.nosessions ul#new ~ * {

#recent button {
margin: 0px;
margin-right: 0.2em;
margin-inline-end: 0.2em;
padding: 1px;
opacity: 0.6;
border: none;
Expand Down
4 changes: 4 additions & 0 deletions frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { html, render } from "./imports/Preact.js"
import "./common/NodejsCompatibilityPolyfill.js"

import { Welcome } from "./components/welcome/Welcome.js"
import { getCurrentLanguage, getWritingDirection } from "./common/lang.js"

const url_params = new URLSearchParams(window.location.search)

Expand Down Expand Up @@ -29,5 +30,8 @@ const launch_params = {

console.log("Launch parameters: ", launch_params)

document.documentElement.lang = getCurrentLanguage()
document.documentElement.dir = getWritingDirection()

// @ts-ignore
render(html`<${Welcome} launch_params=${launch_params} />`, document.querySelector("#app"))
1 change: 1 addition & 0 deletions frontend/lang/english.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"t_language_name": "English",
"t_language_direction": "ltr",
"t_my_work": "My work",
"t_newnotebook": "Create a <strong>new notebook</strong>",
"t_welcome_to_pluto": "welcome to {{pluto}}",
Expand Down
Loading
Loading