@webwriter/geogebra 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/main.yml +8 -0
- package/LICENSE +6 -6
- package/README.md +629 -0
- package/assets/icons/file-earmark-arrow-up.svg +4 -0
- package/components/geogebra-app.styles.ts +10 -0
- package/components/geogebra-app.ts +751 -416
- package/components/geogebra-options.styles.ts +37 -0
- package/components/geogebra-options.ts +187 -0
- package/custom-elements.json +10518 -0
- package/custom.d.ts +179 -179
- package/dist/widgets/webwriter-geogebra-3d.css +444 -0
- package/dist/widgets/webwriter-geogebra-3d.js +25359 -1408
- package/dist/widgets/webwriter-geogebra-classic.css +444 -0
- package/dist/widgets/webwriter-geogebra-classic.js +25359 -1408
- package/dist/widgets/webwriter-geogebra-geometry.css +444 -0
- package/dist/widgets/webwriter-geogebra-geometry.js +25359 -1408
- package/dist/widgets/webwriter-geogebra-notes.css +444 -0
- package/dist/widgets/webwriter-geogebra-notes.js +25359 -1408
- package/dist/widgets/webwriter-geogebra-scientific.css +444 -0
- package/dist/widgets/webwriter-geogebra-scientific.js +25359 -1408
- package/dist/widgets/webwriter-geogebra.css +444 -0
- package/dist/widgets/webwriter-geogebra.js +25370 -1413
- package/editing-config.json +37 -0
- package/lit-localize.json +47 -0
- package/localization/ar.xlf +30 -0
- package/localization/bg.xlf +30 -0
- package/localization/cs.xlf +30 -0
- package/localization/da.xlf +30 -0
- package/localization/de.xlf +29 -0
- package/localization/el.xlf +30 -0
- package/localization/es.xlf +30 -0
- package/localization/et.xlf +30 -0
- package/localization/fi.xlf +30 -0
- package/localization/fr.xlf +30 -0
- package/localization/generated/ar.ts +22 -0
- package/localization/generated/bg.ts +22 -0
- package/localization/generated/cs.ts +22 -0
- package/localization/generated/da.ts +22 -0
- package/localization/generated/de.ts +21 -0
- package/localization/generated/el.ts +22 -0
- package/localization/generated/es.ts +22 -0
- package/localization/generated/et.ts +22 -0
- package/localization/generated/fi.ts +22 -0
- package/localization/generated/fr.ts +22 -0
- package/localization/generated/hu.ts +22 -0
- package/localization/generated/id.ts +22 -0
- package/localization/generated/index.js +3 -0
- package/localization/generated/it.ts +22 -0
- package/localization/generated/ja.ts +22 -0
- package/localization/generated/ko.ts +22 -0
- package/localization/generated/locale-codes.js +83 -0
- package/localization/generated/lt.ts +22 -0
- package/localization/generated/lv.ts +22 -0
- package/localization/generated/nb.ts +22 -0
- package/localization/generated/nl.ts +22 -0
- package/localization/generated/pl.ts +22 -0
- package/localization/generated/pt-BR.ts +22 -0
- package/localization/generated/pt-PT.ts +22 -0
- package/localization/generated/ro.ts +22 -0
- package/localization/generated/ru.ts +22 -0
- package/localization/generated/sk.ts +22 -0
- package/localization/generated/sl.ts +22 -0
- package/localization/generated/sv.ts +22 -0
- package/localization/generated/tr.ts +22 -0
- package/localization/generated/uk.ts +22 -0
- package/localization/generated/zh-hans.ts +20 -0
- package/localization/generated/zh-hant.ts +20 -0
- package/localization/hu.xlf +30 -0
- package/localization/id.xlf +30 -0
- package/localization/it.xlf +30 -0
- package/localization/ja.xlf +30 -0
- package/localization/ko.xlf +30 -0
- package/localization/lt.xlf +30 -0
- package/localization/lv.xlf +30 -0
- package/localization/nb.xlf +30 -0
- package/localization/nl.xlf +30 -0
- package/localization/pkg/ar.xliff +6 -0
- package/localization/pkg/bg.xliff +6 -0
- package/localization/pkg/cs.xliff +6 -0
- package/localization/pkg/da.xliff +6 -0
- package/localization/pkg/de.xliff +6 -0
- package/localization/pkg/el.xliff +6 -0
- package/localization/pkg/es.xliff +6 -0
- package/localization/pkg/et.xliff +6 -0
- package/localization/pkg/fi.xliff +6 -0
- package/localization/pkg/fr.xliff +6 -0
- package/localization/pkg/hu.xliff +6 -0
- package/localization/pkg/id.xliff +6 -0
- package/localization/pkg/it.xliff +6 -0
- package/localization/pkg/ja.xliff +6 -0
- package/localization/pkg/ko.xliff +6 -0
- package/localization/pkg/lt.xliff +6 -0
- package/localization/pkg/lv.xliff +6 -0
- package/localization/pkg/nb.xliff +6 -0
- package/localization/pkg/nl.xliff +6 -0
- package/localization/pkg/pl.xliff +6 -0
- package/localization/pkg/pt-BR.xliff +6 -0
- package/localization/pkg/pt-PT.xliff +6 -0
- package/localization/pkg/ro.xliff +6 -0
- package/localization/pkg/ru.xliff +6 -0
- package/localization/pkg/sk.xliff +6 -0
- package/localization/pkg/sl.xliff +6 -0
- package/localization/pkg/sv.xliff +6 -0
- package/localization/pkg/tr.xliff +6 -0
- package/localization/pkg/uk.xliff +6 -0
- package/localization/pkg/zh-hans.xliff +6 -0
- package/localization/pkg/zh-hant.xliff +6 -0
- package/localization/pl.xlf +30 -0
- package/localization/pt-BR.xlf +30 -0
- package/localization/pt-PT.xlf +30 -0
- package/localization/ro.xlf +30 -0
- package/localization/ru.xlf +30 -0
- package/localization/sk.xlf +30 -0
- package/localization/sl.xlf +30 -0
- package/localization/snippets/ar.xliff +4 -0
- package/localization/snippets/bg.xliff +4 -0
- package/localization/snippets/cs.xliff +4 -0
- package/localization/snippets/da.xliff +4 -0
- package/localization/snippets/de.xliff +4 -0
- package/localization/snippets/el.xliff +4 -0
- package/localization/snippets/es.xliff +4 -0
- package/localization/snippets/et.xliff +4 -0
- package/localization/snippets/fi.xliff +4 -0
- package/localization/snippets/fr.xliff +4 -0
- package/localization/snippets/hu.xliff +4 -0
- package/localization/snippets/id.xliff +4 -0
- package/localization/snippets/it.xliff +4 -0
- package/localization/snippets/ja.xliff +4 -0
- package/localization/snippets/ko.xliff +4 -0
- package/localization/snippets/lt.xliff +4 -0
- package/localization/snippets/lv.xliff +4 -0
- package/localization/snippets/nb.xliff +4 -0
- package/localization/snippets/nl.xliff +4 -0
- package/localization/snippets/pl.xliff +4 -0
- package/localization/snippets/pt-BR.xliff +4 -0
- package/localization/snippets/pt-PT.xliff +4 -0
- package/localization/snippets/ro.xliff +4 -0
- package/localization/snippets/ru.xliff +4 -0
- package/localization/snippets/sk.xliff +4 -0
- package/localization/snippets/sl.xliff +4 -0
- package/localization/snippets/sv.xliff +4 -0
- package/localization/snippets/tr.xliff +4 -0
- package/localization/snippets/uk.xliff +4 -0
- package/localization/snippets/zh-hans.xliff +4 -0
- package/localization/snippets/zh-hant.xliff +4 -0
- package/localization/sv.xlf +30 -0
- package/localization/tr.xlf +30 -0
- package/localization/uk.xlf +30 -0
- package/localization/zh-hans.xlf +30 -0
- package/localization/zh-hant.xlf +30 -0
- package/package.json +163 -165
- package/tsconfig.json +7 -7
- package/utils/boolean-attribute-converter.ts +8 -0
- package/widgets/webwriter-geogebra-3d.ts +14 -8
- package/widgets/webwriter-geogebra-classic.ts +14 -8
- package/widgets/webwriter-geogebra-evaluator.ts +14 -8
- package/widgets/webwriter-geogebra-geometry.ts +14 -8
- package/widgets/webwriter-geogebra-notes.ts +14 -8
- package/widgets/webwriter-geogebra-scientific.ts +14 -8
- package/widgets/webwriter-geogebra.ts +28 -19
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
|
|
3
|
+
export const geogebraOptionsStyles = css`
|
|
4
|
+
div {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 0.5em;
|
|
8
|
+
}
|
|
9
|
+
input {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
sl-button {
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
sl-button::part(label) {
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
}
|
|
20
|
+
sl-switch {
|
|
21
|
+
margin-left: 2px;
|
|
22
|
+
}
|
|
23
|
+
.hidden {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
sl-details,
|
|
27
|
+
sl-input::part(form-control-label),
|
|
28
|
+
sl-select::part(form-control-label),
|
|
29
|
+
sl-switch::part(label) {
|
|
30
|
+
font-size: 1rem;
|
|
31
|
+
}
|
|
32
|
+
sl-details::part(content) {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
gap: 0.5em;
|
|
36
|
+
}
|
|
37
|
+
`
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { msg } from "@lit/localize";
|
|
2
|
+
import { SlButton, SlChangeEvent, SlDetails, SlIcon, SlInput, SlOption, SlSelect, SlSwitch } from "@shoelace-style/shoelace";
|
|
3
|
+
import { LitElementWw } from "@webwriter/lit";
|
|
4
|
+
import { html } from "lit";
|
|
5
|
+
import FileEarmarkArrowUp from "../assets/icons/file-earmark-arrow-up.svg"
|
|
6
|
+
import { geogebraOptionsStyles } from "./geogebra-options.styles";
|
|
7
|
+
import { property } from "lit/decorators.js";
|
|
8
|
+
|
|
9
|
+
export interface PropertyConfig {
|
|
10
|
+
name: string
|
|
11
|
+
type: "boolean" | "number" | "string" | "select"
|
|
12
|
+
options?: string[]
|
|
13
|
+
value: number | string | boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class GeogebraOptions extends LitElementWw {
|
|
17
|
+
protected static get scopedElements() {
|
|
18
|
+
return {
|
|
19
|
+
"sl-button": SlButton,
|
|
20
|
+
"sl-icon": SlIcon,
|
|
21
|
+
"sl-switch": SlSwitch,
|
|
22
|
+
"sl-details": SlDetails,
|
|
23
|
+
"sl-select": SlSelect,
|
|
24
|
+
"sl-option": SlOption,
|
|
25
|
+
"sl-input": SlInput
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static styles = geogebraOptionsStyles
|
|
30
|
+
|
|
31
|
+
@property({type: Boolean})
|
|
32
|
+
accessor visible: boolean = false
|
|
33
|
+
|
|
34
|
+
@property({type: Array})
|
|
35
|
+
accessor properties: PropertyConfig[] = []
|
|
36
|
+
|
|
37
|
+
private formatLabel(name: string): string {
|
|
38
|
+
const customLabels: Map<string,string> = new Map([
|
|
39
|
+
["enable3d", "Enable 3D"],
|
|
40
|
+
["enableCAS", "Enable CAS"],
|
|
41
|
+
["useBrowserForJs", "Use Browser for JS"],
|
|
42
|
+
["disabledJavaScript", "Disable JavaScript"],
|
|
43
|
+
])
|
|
44
|
+
if(customLabels.has(name)) {
|
|
45
|
+
return customLabels.get(name)!
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return name
|
|
49
|
+
.replace(/([A-Z])/g, ' $1')
|
|
50
|
+
.replace(/^./, str => str.toUpperCase())
|
|
51
|
+
.trim()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private handleFileImport(e: SlChangeEvent) {
|
|
55
|
+
const input = e.target as HTMLInputElement
|
|
56
|
+
const file = input.files?.item(0)
|
|
57
|
+
if(!file) return
|
|
58
|
+
|
|
59
|
+
const reader = new FileReader()
|
|
60
|
+
reader.onload = () => {
|
|
61
|
+
const base64 = (reader.result as string).split(",").at(-1)
|
|
62
|
+
this.dispatchEvent(new CustomEvent("import-file", {
|
|
63
|
+
detail: {base64},
|
|
64
|
+
bubbles: true,
|
|
65
|
+
composed: true
|
|
66
|
+
}))
|
|
67
|
+
}
|
|
68
|
+
reader.readAsDataURL(file)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private handlePropertyChange(name: string, e: Event) {
|
|
72
|
+
const target = e.target as any
|
|
73
|
+
let newValue: string | boolean | number
|
|
74
|
+
|
|
75
|
+
const prop = this.properties.find(p => p.name === name)
|
|
76
|
+
if(!prop) return
|
|
77
|
+
|
|
78
|
+
switch(prop.type) {
|
|
79
|
+
case "boolean":
|
|
80
|
+
newValue = target.checked
|
|
81
|
+
break
|
|
82
|
+
case "number":
|
|
83
|
+
newValue = parseFloat(target.value)
|
|
84
|
+
break
|
|
85
|
+
default:
|
|
86
|
+
newValue = target.value
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.dispatchEvent(new CustomEvent("property-change", {
|
|
90
|
+
detail: {
|
|
91
|
+
name,
|
|
92
|
+
value: newValue
|
|
93
|
+
},
|
|
94
|
+
bubbles: true,
|
|
95
|
+
composed: true
|
|
96
|
+
}))
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private renderPropertyInput(prop) {
|
|
100
|
+
const label = this.formatLabel(prop.name)
|
|
101
|
+
|
|
102
|
+
switch(prop.type) {
|
|
103
|
+
case "boolean":
|
|
104
|
+
return html`
|
|
105
|
+
<sl-switch
|
|
106
|
+
?checked=${prop.value}
|
|
107
|
+
@sl-change=${(e: Event) => {this.handlePropertyChange(prop.name, e)}}
|
|
108
|
+
>
|
|
109
|
+
${label}
|
|
110
|
+
</sl-switch>
|
|
111
|
+
`
|
|
112
|
+
|
|
113
|
+
case "number":
|
|
114
|
+
return html`
|
|
115
|
+
<sl-input
|
|
116
|
+
type="number"
|
|
117
|
+
size="small"
|
|
118
|
+
label=${label}
|
|
119
|
+
value=${prop.value ?? ""}
|
|
120
|
+
@sl-change=${(e: Event) => this.handlePropertyChange(prop.name, e)}
|
|
121
|
+
></sl-input>
|
|
122
|
+
`
|
|
123
|
+
|
|
124
|
+
case "select":
|
|
125
|
+
return html`
|
|
126
|
+
<sl-select
|
|
127
|
+
label=${label}
|
|
128
|
+
size="small"
|
|
129
|
+
value=${prop.value ?? ""}
|
|
130
|
+
@sl-change=${(e: Event) => this.handlePropertyChange(prop.name, e)}
|
|
131
|
+
>
|
|
132
|
+
${prop.options?.map(opt => html`
|
|
133
|
+
<sl-option value=${opt}>${opt}</sl-option>
|
|
134
|
+
`)}
|
|
135
|
+
</sl-select>
|
|
136
|
+
`
|
|
137
|
+
|
|
138
|
+
case "string":
|
|
139
|
+
default:
|
|
140
|
+
return html`
|
|
141
|
+
<sl-input
|
|
142
|
+
type="text"
|
|
143
|
+
size="small"
|
|
144
|
+
label=${label}
|
|
145
|
+
value=${prop.value ?? ""}
|
|
146
|
+
@sl-change=${(e: Event) => this.handlePropertyChange(prop.name, e)}
|
|
147
|
+
></sl-input>
|
|
148
|
+
`
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private renderPropertyInputs() {
|
|
153
|
+
return html`${this.properties.map(prop => this.renderPropertyInput(prop))}`
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
render() {
|
|
157
|
+
return html`
|
|
158
|
+
<div class=${this.visible ? "" : "hidden"}>
|
|
159
|
+
<input type="file" accept=".ggb" id="ggb-upload" name="ggb-upload" @change=${this.handleFileImport}>
|
|
160
|
+
<sl-button @click=${
|
|
161
|
+
() => {
|
|
162
|
+
const input = this.renderRoot.querySelector("#ggb-upload") as HTMLInputElement
|
|
163
|
+
input.value = ""
|
|
164
|
+
input.click()
|
|
165
|
+
}
|
|
166
|
+
}>
|
|
167
|
+
<sl-icon src=${FileEarmarkArrowUp} slot="prefix"></sl-icon>
|
|
168
|
+
${msg("Import GeoGebra File")}
|
|
169
|
+
</sl-button>
|
|
170
|
+
|
|
171
|
+
<sl-details summary=${msg("Advanced Settings")}>
|
|
172
|
+
<p>
|
|
173
|
+
${msg("These settings are not relevant for most users and should not usually be changed. Changing them can completely break your applet.")}
|
|
174
|
+
${msg(html`See the
|
|
175
|
+
<a
|
|
176
|
+
href="https://geogebra.github.io/docs/reference/en/GeoGebra_App_Parameters/"
|
|
177
|
+
target="_blank">
|
|
178
|
+
GeoGebra docs</a>
|
|
179
|
+
for more information.`
|
|
180
|
+
)}
|
|
181
|
+
</p>
|
|
182
|
+
${this.renderPropertyInputs()}
|
|
183
|
+
</sl-details>
|
|
184
|
+
</div>
|
|
185
|
+
`
|
|
186
|
+
}
|
|
187
|
+
}
|