@webwriter/geogebra 1.1.0 → 2.0.1
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/README.md +280 -124
- package/custom-elements.json +2255 -1259
- package/dist/chunks/af-35CD6HFH.js +12 -0
- package/dist/chunks/am-JMDT5LI7.js +12 -0
- package/dist/chunks/ar-JL4QKYYL.js +12 -0
- package/dist/chunks/az-3SZS6WCY.js +12 -0
- package/dist/chunks/be-C4GWVHR2.js +12 -0
- package/dist/chunks/bg-6QGE5EQ4.js +12 -0
- package/dist/chunks/bn-UM2BV46R.js +12 -0
- package/dist/chunks/bs-XE2PWKCS.js +12 -0
- package/dist/chunks/ca-ZO2BQKPZ.js +12 -0
- package/dist/chunks/ca-balear-GJKWY5R7.js +12 -0
- package/dist/chunks/ca-valencia-CNQYSJSJ.js +12 -0
- package/dist/chunks/chunk-ACU6XINJ.js +781 -0
- package/dist/chunks/chunk-ANJTU3IB.js +203 -0
- package/dist/chunks/chunk-BSUFUO7E.js +65 -0
- package/dist/chunks/cnr-MCZGASOD.js +12 -0
- package/dist/chunks/cs-4Q7FRISG.js +12 -0
- package/dist/chunks/cy-7VXG3AYH.js +12 -0
- package/dist/chunks/da-VDMHGBXD.js +12 -0
- package/dist/chunks/de-AT-YM5GCI75.js +12 -0
- package/dist/chunks/de-CH-LQNHTGYT.js +12 -0
- package/dist/chunks/de-GJT7RSHT.js +12 -0
- package/dist/chunks/el-ZVUVWEQ3.js +12 -0
- package/dist/chunks/en-AU-PCIYYC4M.js +12 -0
- package/dist/chunks/en-CA-37T7YUIL.js +12 -0
- package/dist/chunks/en-GB-ZYCA2CIZ.js +12 -0
- package/dist/chunks/en-IN-EPHXLNO6.js +12 -0
- package/dist/chunks/en-US-ECSJ5HDL.js +12 -0
- package/dist/chunks/es-5VBYK2HE.js +12 -0
- package/dist/chunks/et-OFQRRTW6.js +12 -0
- package/dist/chunks/eu-7TNOYFB7.js +12 -0
- package/dist/chunks/fa-KZU6GKWU.js +12 -0
- package/dist/chunks/fi-THJEKJPW.js +12 -0
- package/dist/chunks/fr-MUVVTBQZ.js +12 -0
- package/dist/chunks/ga-UWUVCWOT.js +12 -0
- package/dist/chunks/gl-NHQ52YCN.js +12 -0
- package/dist/chunks/gu-HVDD4QHO.js +12 -0
- package/dist/chunks/ha-2BPTATOZ.js +12 -0
- package/dist/chunks/he-MDESCUHJ.js +12 -0
- package/dist/chunks/hi-C6BGPR4Y.js +12 -0
- package/dist/chunks/hr-77MP3ELT.js +12 -0
- package/dist/chunks/hu-7PRNX6NB.js +12 -0
- package/dist/chunks/hy-R3VEL63L.js +12 -0
- package/dist/chunks/id-O6B2T3Y2.js +12 -0
- package/dist/chunks/is-XLNS5CAZ.js +12 -0
- package/dist/chunks/it-NZODUGUP.js +12 -0
- package/dist/chunks/ja-FFK5WXSB.js +12 -0
- package/dist/chunks/jv-GS3IRAIB.js +12 -0
- package/dist/chunks/ka-NWIJAO54.js +12 -0
- package/dist/chunks/kk-WQFRFG44.js +12 -0
- package/dist/chunks/km-AUKBN3YT.js +12 -0
- package/dist/chunks/kn-PKZFPECM.js +12 -0
- package/dist/chunks/ko-XNGAWKQ4.js +12 -0
- package/dist/chunks/ky-AQTYDJIL.js +12 -0
- package/dist/chunks/la-ERS7V4N4.js +12 -0
- package/dist/chunks/lb-KU3DVPI4.js +12 -0
- package/dist/chunks/locale-codes-TGY5LMYX.js +11 -0
- package/dist/chunks/lt-6RI4HSG3.js +12 -0
- package/dist/chunks/lv-RGIUQVA7.js +12 -0
- package/dist/chunks/mk-JMAYXTCL.js +12 -0
- package/dist/chunks/ml-5ZAIPAYV.js +12 -0
- package/dist/chunks/mn-N2GZBVDP.js +12 -0
- package/dist/chunks/mr-2SRCJIBC.js +12 -0
- package/dist/chunks/ms-WHD5PUQM.js +12 -0
- package/dist/chunks/mt-EXRK5UO6.js +12 -0
- package/dist/chunks/my-D2COGDRI.js +12 -0
- package/dist/chunks/nb-3XNBS2DU.js +12 -0
- package/dist/chunks/ne-PA4KUBGU.js +12 -0
- package/dist/chunks/nl-QMM3PBPM.js +12 -0
- package/dist/chunks/nn-CLFEMF2K.js +12 -0
- package/dist/chunks/no-CV376NZG.js +12 -0
- package/dist/chunks/or-KP7CET7X.js +12 -0
- package/dist/chunks/pa-CH5JYVXT.js +12 -0
- package/dist/chunks/pl-DDW4HT7M.js +12 -0
- package/dist/chunks/pt-BR-CVNA2MRU.js +12 -0
- package/dist/chunks/pt-CRTRYTDJ.js +12 -0
- package/dist/chunks/pt-PT-IZMPF3BY.js +12 -0
- package/dist/chunks/ro-FUOGHWJA.js +12 -0
- package/dist/chunks/ru-KAT4X5EC.js +12 -0
- package/dist/chunks/si-GDAXEOBK.js +12 -0
- package/dist/chunks/sk-CDSK6MY5.js +12 -0
- package/dist/chunks/sl-TFJQYNA4.js +12 -0
- package/dist/chunks/so-TXI6JJPW.js +12 -0
- package/dist/chunks/sq-KMM2QIRU.js +12 -0
- package/dist/chunks/sr-OTZNEL5Z.js +12 -0
- package/dist/chunks/sv-7CANJ6CF.js +12 -0
- package/dist/chunks/sw-5JDMTJ5K.js +12 -0
- package/dist/chunks/ta-HT4SO7PD.js +12 -0
- package/dist/chunks/te-FECCLHOI.js +12 -0
- package/dist/chunks/tg-FJWFJWF2.js +12 -0
- package/dist/chunks/th-JEP434LN.js +12 -0
- package/dist/chunks/tl-GN35ZR2F.js +12 -0
- package/dist/chunks/tr-IPVLQUE4.js +12 -0
- package/dist/chunks/uk-LHWPGFRV.js +12 -0
- package/dist/chunks/ur-7FU4XRAY.js +12 -0
- package/dist/chunks/uz-RO7XCKFE.js +12 -0
- package/dist/chunks/vi-5PHPTVV4.js +12 -0
- package/dist/chunks/zh-Hans-UM7MUEDB.js +12 -0
- package/dist/chunks/zh-Hant-7M2P4G7R.js +12 -0
- package/dist/chunks/zh-LHCPWZN2.js +12 -0
- package/dist/widgets/webwriter-geogebra-3d.js +19 -25827
- package/dist/widgets/webwriter-geogebra-classic.js +18 -25826
- package/dist/widgets/webwriter-geogebra-geometry.js +18 -25826
- package/dist/widgets/webwriter-geogebra-notes.js +18 -25826
- package/dist/widgets/webwriter-geogebra-scientific.js +18 -25826
- package/dist/widgets/webwriter-geogebra.js +20 -25830
- package/editing-config.json +839 -20
- package/lit-localize.json +73 -9
- package/localization/af.xlf +290 -0
- package/localization/am.xlf +290 -0
- package/localization/ar.xlf +271 -6
- package/localization/az.xlf +290 -0
- package/localization/be.xlf +290 -0
- package/localization/bg.xlf +271 -6
- package/localization/bn.xlf +290 -0
- package/localization/bs.xlf +290 -0
- package/localization/ca-balear.xlf +290 -0
- package/localization/ca-valencia.xlf +290 -0
- package/localization/ca.xlf +290 -0
- package/localization/cnr.xlf +290 -0
- package/localization/cs.xlf +271 -6
- package/localization/cy.xlf +290 -0
- package/localization/da.xlf +271 -6
- package/localization/de-AT.xlf +294 -0
- package/localization/de-CH.xlf +294 -0
- package/localization/de.xlf +271 -6
- package/localization/el.xlf +271 -6
- package/localization/es.xlf +271 -6
- package/localization/et.xlf +271 -6
- package/localization/eu.xlf +290 -0
- package/localization/fa.xlf +290 -0
- package/localization/fi.xlf +271 -6
- package/localization/fr.xlf +271 -6
- package/localization/ga.xlf +290 -0
- package/localization/generated/af.ts +16 -0
- package/localization/generated/am.ts +16 -0
- package/localization/generated/ar.ts +6 -12
- package/localization/generated/az.ts +16 -0
- package/localization/generated/be.ts +16 -0
- package/localization/generated/bg.ts +6 -12
- package/localization/generated/bn.ts +16 -0
- package/localization/generated/bs.ts +16 -0
- package/localization/generated/ca-balear.ts +16 -0
- package/localization/generated/ca-valencia.ts +16 -0
- package/localization/generated/ca.ts +16 -0
- package/localization/generated/cnr.ts +16 -0
- package/localization/generated/cs.ts +6 -12
- package/localization/generated/cy.ts +16 -0
- package/localization/generated/da.ts +6 -12
- package/localization/generated/de-AT.ts +16 -0
- package/localization/generated/de-CH.ts +16 -0
- package/localization/generated/de.ts +6 -11
- package/localization/generated/el.ts +6 -12
- package/localization/generated/en-AU.ts +16 -0
- package/localization/generated/en-CA.ts +16 -0
- package/localization/generated/en-GB.ts +16 -0
- package/localization/generated/en-IN.ts +16 -0
- package/localization/generated/en-US.ts +16 -0
- package/localization/generated/es.ts +6 -12
- package/localization/generated/et.ts +6 -12
- package/localization/generated/eu.ts +16 -0
- package/localization/generated/fa.ts +16 -0
- package/localization/generated/fi.ts +6 -12
- package/localization/generated/fr.ts +6 -12
- package/localization/generated/ga.ts +16 -0
- package/localization/generated/gl.ts +16 -0
- package/localization/generated/gu.ts +16 -0
- package/localization/generated/ha.ts +16 -0
- package/localization/generated/he.ts +16 -0
- package/localization/generated/hi.ts +16 -0
- package/localization/generated/hr.ts +16 -0
- package/localization/generated/hu.ts +6 -12
- package/localization/generated/hy.ts +16 -0
- package/localization/generated/id.ts +6 -12
- package/localization/generated/is.ts +16 -0
- package/localization/generated/it.ts +6 -12
- package/localization/generated/ja.ts +6 -12
- package/localization/generated/jv.ts +16 -0
- package/localization/generated/ka.ts +16 -0
- package/localization/generated/kk.ts +16 -0
- package/localization/generated/km.ts +16 -0
- package/localization/generated/kn.ts +16 -0
- package/localization/generated/ko.ts +6 -12
- package/localization/generated/ky.ts +16 -0
- package/localization/generated/la.ts +16 -0
- package/localization/generated/lb.ts +16 -0
- package/localization/generated/locale-codes.ts +211 -0
- package/localization/generated/lt.ts +6 -12
- package/localization/generated/lv.ts +6 -12
- package/localization/generated/mk.ts +16 -0
- package/localization/generated/ml.ts +16 -0
- package/localization/generated/mn.ts +16 -0
- package/localization/generated/mr.ts +16 -0
- package/localization/generated/ms.ts +16 -0
- package/localization/generated/mt.ts +16 -0
- package/localization/generated/my.ts +16 -0
- package/localization/generated/nb.ts +6 -12
- package/localization/generated/ne.ts +16 -0
- package/localization/generated/nl.ts +6 -12
- package/localization/generated/nn.ts +16 -0
- package/localization/generated/no.ts +16 -0
- package/localization/generated/or.ts +16 -0
- package/localization/generated/pa.ts +16 -0
- package/localization/generated/pl.ts +6 -12
- package/localization/generated/pt-BR.ts +6 -12
- package/localization/generated/pt-PT.ts +6 -12
- package/localization/generated/pt.ts +16 -0
- package/localization/generated/ro.ts +6 -12
- package/localization/generated/ru.ts +6 -12
- package/localization/generated/si.ts +16 -0
- package/localization/generated/sk.ts +6 -12
- package/localization/generated/sl.ts +6 -12
- package/localization/generated/so.ts +16 -0
- package/localization/generated/sq.ts +16 -0
- package/localization/generated/sr.ts +16 -0
- package/localization/generated/sv.ts +6 -12
- package/localization/generated/sw.ts +16 -0
- package/localization/generated/ta.ts +16 -0
- package/localization/generated/te.ts +16 -0
- package/localization/generated/tg.ts +16 -0
- package/localization/generated/th.ts +16 -0
- package/localization/generated/tl.ts +16 -0
- package/localization/generated/tr.ts +6 -12
- package/localization/generated/uk.ts +6 -12
- package/localization/generated/ur.ts +16 -0
- package/localization/generated/uz.ts +16 -0
- package/localization/generated/vi.ts +16 -0
- package/localization/generated/zh-Hans.ts +16 -0
- package/localization/generated/zh-Hant.ts +16 -0
- package/localization/generated/zh.ts +16 -0
- package/localization/gl.xlf +290 -0
- package/localization/gu.xlf +290 -0
- package/localization/ha.xlf +290 -0
- package/localization/he.xlf +290 -0
- package/localization/hi.xlf +290 -0
- package/localization/hr.xlf +290 -0
- package/localization/hu.xlf +271 -6
- package/localization/hy.xlf +290 -0
- package/localization/id.xlf +271 -6
- package/localization/is.xlf +290 -0
- package/localization/it.xlf +271 -6
- package/localization/ja.xlf +271 -6
- package/localization/jv.xlf +290 -0
- package/localization/ka.xlf +290 -0
- package/localization/kk.xlf +290 -0
- package/localization/km.xlf +290 -0
- package/localization/kn.xlf +290 -0
- package/localization/ko.xlf +271 -6
- package/localization/ky.xlf +290 -0
- package/localization/la.xlf +290 -0
- package/localization/lb.xlf +290 -0
- package/localization/lt.xlf +271 -6
- package/localization/lv.xlf +271 -6
- package/localization/mk.xlf +290 -0
- package/localization/ml.xlf +290 -0
- package/localization/mn.xlf +290 -0
- package/localization/mr.xlf +290 -0
- package/localization/ms.xlf +290 -0
- package/localization/mt.xlf +290 -0
- package/localization/my.xlf +290 -0
- package/localization/nb.xlf +271 -6
- package/localization/ne.xlf +290 -0
- package/localization/nl.xlf +271 -6
- package/localization/nn.xlf +290 -0
- package/localization/no.xlf +295 -0
- package/localization/or.xlf +290 -0
- package/localization/pa.xlf +290 -0
- package/localization/pl.xlf +271 -6
- package/localization/pt-BR.xlf +271 -6
- package/localization/pt-PT.xlf +271 -6
- package/localization/pt.xlf +295 -0
- package/localization/ro.xlf +271 -6
- package/localization/ru.xlf +271 -6
- package/localization/si.xlf +290 -0
- package/localization/sk.xlf +271 -6
- package/localization/sl.xlf +271 -6
- package/localization/so.xlf +290 -0
- package/localization/sq.xlf +290 -0
- package/localization/sr.xlf +290 -0
- package/localization/sv.xlf +271 -6
- package/localization/sw.xlf +290 -0
- package/localization/ta.xlf +290 -0
- package/localization/te.xlf +290 -0
- package/localization/tg.xlf +290 -0
- package/localization/th.xlf +290 -0
- package/localization/tl.xlf +290 -0
- package/localization/tr.xlf +271 -6
- package/localization/uk.xlf +271 -6
- package/localization/ur.xlf +290 -0
- package/localization/uz.xlf +290 -0
- package/localization/vi.xlf +290 -0
- package/localization/zh-Hans.xlf +295 -0
- package/localization/zh-Hant.xlf +295 -0
- package/localization/zh.xlf +295 -0
- package/package.json +194 -86
- package/src/components/geogebra-app.styles.ts +47 -0
- package/{components → src/components}/geogebra-app.ts +229 -330
- package/src/model/geogebra-api.ts +148 -0
- package/src/model/geogebra-options.ts +72 -0
- package/src/model/geogebra-parameters.ts +53 -0
- package/src/model/ggb-file.ts +30 -0
- package/src/types.d.ts +3 -0
- package/{widgets → src/widgets}/webwriter-geogebra-3d.ts +1 -1
- package/{widgets → src/widgets}/webwriter-geogebra.ts +1 -2
- package/tests/conversions.test.ts +80 -0
- package/tests/data-block.test.ts +72 -0
- package/tests/helpers.ts +48 -0
- package/tests/language.test.ts +49 -0
- package/tests/presentation.test.ts +80 -0
- package/tsconfig.json +3 -7
- package/assets/icons/file-earmark-arrow-up.svg +0 -4
- package/components/geogebra-app.styles.ts +0 -10
- package/components/geogebra-options.styles.ts +0 -37
- package/components/geogebra-options.ts +0 -187
- package/custom.d.ts +0 -180
- package/dist/widgets/webwriter-geogebra-3d.css +0 -444
- package/dist/widgets/webwriter-geogebra-classic.css +0 -444
- package/dist/widgets/webwriter-geogebra-geometry.css +0 -444
- package/dist/widgets/webwriter-geogebra-notes.css +0 -444
- package/dist/widgets/webwriter-geogebra-scientific.css +0 -444
- package/dist/widgets/webwriter-geogebra.css +0 -444
- package/localization/generated/locale-codes.js +0 -83
- package/localization/generated/zh-hans.ts +0 -20
- package/localization/generated/zh-hant.ts +0 -20
- package/localization/zh-hans.xlf +0 -30
- package/localization/zh-hant.xlf +0 -30
- package/widgets/webwriter-geogebra-evaluator.ts +0 -15
- /package/.github/workflows/{main.yml → publish.yml} +0 -0
- /package/localization/pkg/{zh-hans.xliff → zh-Hans.xliff} +0 -0
- /package/localization/pkg/{zh-hant.xliff → zh-Hant.xliff} +0 -0
- /package/localization/snippets/{zh-hans.xliff → zh-Hans.xliff} +0 -0
- /package/localization/snippets/{zh-hant.xliff → zh-Hant.xliff} +0 -0
- /package/{utils → src/model}/boolean-attribute-converter.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-classic.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-geometry.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-notes.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-scientific.ts +0 -0
|
@@ -1,181 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { LitElementWw } from "@webwriter/lit"
|
|
2
|
+
import { localizer } from "@webwriter/lit/localize"
|
|
3
|
+
import { jsonData } from "@webwriter/lit/data"
|
|
4
|
+
import type { MsgFn } from "@lit/localize"
|
|
5
|
+
import { sourceLocale, targetLocales } from "../../localization/generated/locale-codes"
|
|
6
|
+
import {html, css, type PropertyValues} from "lit"
|
|
7
|
+
import {property, state} from "lit/decorators.js"
|
|
4
8
|
import {keyed} from "lit/directives/keyed.js"
|
|
5
9
|
|
|
6
|
-
import "@shoelace-style/shoelace/dist/themes/light.css"
|
|
7
|
-
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
import LOCALIZE from "../localization/generated"
|
|
10
|
-
import {localized, msg} from "@lit/localize"
|
|
11
10
|
import {geogebraAppStyles} from "./geogebra-app.styles"
|
|
12
|
-
import { booleanAttributeConverter } from "../
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
setTextValue(objName: string, value: string): void
|
|
25
|
-
setListValue(objName: string, i: number, value: number): void
|
|
26
|
-
setCoords(objName: string, x: number, y: number, z?: number): void
|
|
27
|
-
setCaption(objName: string, caption: string): void
|
|
28
|
-
setColor(objName: string, red: number, green: number, blue: number): void
|
|
29
|
-
setVisible(objName: string, visible: boolean): void
|
|
30
|
-
setLabelVisible(objName: string, visible: boolean): void
|
|
31
|
-
setLabelStyle(objName: string, style: 0 | 1 | 2 | 3): void
|
|
32
|
-
setFixed(objName: string, fixed: boolean, selectionAllowed: boolean): void
|
|
33
|
-
setTrace(objName: string, flag: boolean): void
|
|
34
|
-
renameObject(oldObjName: string, newObjName: string): boolean
|
|
35
|
-
setLayer(objName: string, layer: number): void
|
|
36
|
-
setLayerVisible(objName: string, visible: boolean): void
|
|
37
|
-
setLineStyle(objName: string, style: 0 | 1 | 2 | 3 | 4): void
|
|
38
|
-
setLineThickness(objName: string, thickness: -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13): void
|
|
39
|
-
setPointStyle(objName: string, size: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): void
|
|
40
|
-
setPointSize(objName: string, size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): void
|
|
41
|
-
setDisplayStyle(objName: string, style: string): void
|
|
42
|
-
setFilling(objName: string, filling: number): void
|
|
43
|
-
getPNGBase64(exportScale: number, transparent?: boolean, dpi?: number): string
|
|
44
|
-
exportSVG(filename: string): void
|
|
45
|
-
exportSVG(callback: CallableFunction): void
|
|
46
|
-
exportPDF(scale: number, filename: string, sliderLabel?: string): void
|
|
47
|
-
exportPDF(scale: number, callback: CallableFunction, sliderLabel?: string): void
|
|
48
|
-
getScreenshotBase64(callback: CallableFunction): void
|
|
49
|
-
writePNGtoFile(fileName: string, exportScale?: number, transparent?: boolean, dpi?: number): boolean
|
|
50
|
-
isIndependent(objName: string): boolean
|
|
51
|
-
isMovable(objName: string): boolean
|
|
52
|
-
showAllObjects(): void
|
|
53
|
-
registerEmbedResolver(type: string, callback: CallableFunction): void
|
|
54
|
-
setAnimating(objName: string, animate: boolean): void
|
|
55
|
-
setAnimationSpeed(objName: string, speed: number): void
|
|
56
|
-
startAnimation(): void
|
|
57
|
-
stopAnimation(): void
|
|
58
|
-
isAnimationRunning(): boolean
|
|
59
|
-
getXcoord(objName: string): number
|
|
60
|
-
getYcoord(objName: string): number
|
|
61
|
-
getZcoord(objName: string): number
|
|
62
|
-
getValue(objName: string): number
|
|
63
|
-
getListValue(objName: string, index: number): number
|
|
64
|
-
getColor(objName: string): string
|
|
65
|
-
getVisible(objName: string): boolean
|
|
66
|
-
getValueString(objName: string, useLocalizedInput?: boolean): string
|
|
67
|
-
getDefinitionString(objName: string): string
|
|
68
|
-
getCommandString(objName: string, useLocalizedInput?: boolean): string
|
|
69
|
-
getLaTeXString(objName: string, value: boolean): string
|
|
70
|
-
getObjectType(objName: string): string
|
|
71
|
-
exists(objName: string): boolean
|
|
72
|
-
isDefined(objName: string): boolean
|
|
73
|
-
getAllObjectNames(type?: string): string[]
|
|
74
|
-
getObjectNumber(): number
|
|
75
|
-
getCASObjectNumber(): number
|
|
76
|
-
getObjectName(i: number): string
|
|
77
|
-
getLayer(objName: string): string
|
|
78
|
-
getLineStyle(objName: string): 0 | 1 | 2 | 3 | 4
|
|
79
|
-
getLineThickness(objName: string): -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
|
|
80
|
-
getPointStyle(objName: string): -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
81
|
-
getPointSize(objName: string): 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
82
|
-
getFilling(objName: string): number
|
|
83
|
-
getCaption(objName: string, substitutePlaceholders?: boolean): string
|
|
84
|
-
getLabelStyle(objName: string): 0 | 1 | 2 | 3
|
|
85
|
-
getLabelVisible(): boolean
|
|
86
|
-
isInteractive(objName: string): boolean
|
|
87
|
-
setMode(mode: number): void
|
|
88
|
-
getMode(): number
|
|
89
|
-
reset(): void
|
|
90
|
-
newConstruction(): void
|
|
91
|
-
refreshViews(): void
|
|
92
|
-
setOnTheFlyPointCreationActive(flag: boolean): void
|
|
93
|
-
setPointCapture(view: -1 | 1 | 2, mode: 0 | 1 | 2 | 3): void
|
|
94
|
-
setRounding(round: string): void
|
|
95
|
-
hideCursorWhenDragging(flag: boolean): void
|
|
96
|
-
setRepaintingActive(flag: boolean): void
|
|
97
|
-
setErrorDialogsActive(flag: boolean): void
|
|
98
|
-
setCoordSystem(xmin: number, xmax: number, ymin: number, ymax: number, zmin?: number, zmax?: number, yVertical?: boolean): void
|
|
99
|
-
setAxesVisible(xAxis: boolean, yAxis: boolean, zAxis?: boolean): void
|
|
100
|
-
setUndoPoint(): void
|
|
101
|
-
setAxisLabels(viewNumber: number, xAxis: string, yAxis: string, zAxis: string): void
|
|
102
|
-
setAxisSteps(viewNumber: number, xAxis: number, yAxis: number, zAxis: number): void
|
|
103
|
-
setAxisUnits(viewNumber: number, xAxis: string, yAxis: string, zAxis: string): void
|
|
104
|
-
setGridVisible(flag: boolean): void
|
|
105
|
-
setGridVisible(viewNumber: number, flag: boolean): void
|
|
106
|
-
getGridVisible(viewNumber: number): boolean
|
|
107
|
-
getPerspectiveXML(): string
|
|
108
|
-
undo(): void
|
|
109
|
-
redo(): void
|
|
110
|
-
showToolBar(show: boolean): void
|
|
111
|
-
setCustomToolBar(toolbar: string): void
|
|
112
|
-
addCustomTool(iconURL: string, name: string, category?: string, callback?: CallableFunction): void
|
|
113
|
-
showMenuBar(show: boolean): void
|
|
114
|
-
showAlgebraInput(show: boolean): void
|
|
115
|
-
showResetIcon(show: boolean): void
|
|
116
|
-
enableRightClick(enable: boolean): void
|
|
117
|
-
enableLabelDrags(enable: boolean): void
|
|
118
|
-
enableShiftDragZoom(enable: boolean): void
|
|
119
|
-
enableCAS(enable: boolean): void
|
|
120
|
-
enable3D(enable: boolean): void
|
|
121
|
-
setPerspective(perspective: string): void
|
|
122
|
-
setWidth(width: number): void
|
|
123
|
-
setHeight(height: number): void
|
|
124
|
-
setSize(width: number, height: number): void
|
|
125
|
-
recalculateEnvironments(): void
|
|
126
|
-
getEditorState(): any
|
|
127
|
-
setEditorState(state: any): void
|
|
128
|
-
getGraphicsOptions(viewId: number): any
|
|
129
|
-
setGraphicsOptions(viewID: number, options: any): void
|
|
130
|
-
setAlgebraOptions(options: any): void
|
|
131
|
-
registerAddListener(func: CallableFunction): void
|
|
132
|
-
unregisterAddListener(func: CallableFunction): void
|
|
133
|
-
registerRemoveListener(func: CallableFunction): void
|
|
134
|
-
unregisterRemoveListener(func: CallableFunction): void
|
|
135
|
-
registerUpdateListener(func: CallableFunction): void
|
|
136
|
-
unregisterUpdateListener(func: CallableFunction): void
|
|
137
|
-
registerClickListener(func: CallableFunction): void
|
|
138
|
-
unregisterClickListener(func: CallableFunction): void
|
|
139
|
-
registerObjectUpdateListener(objName: string, func: CallableFunction): void
|
|
140
|
-
unregisterObjectUpdateListener(objName: string): void
|
|
141
|
-
registerObjectClickListener(objName: string, func: CallableFunction): void
|
|
142
|
-
unregisterObjectClickListener(objName: string): void
|
|
143
|
-
registerRenameListener(func: CallableFunction): void
|
|
144
|
-
unregisterRenameListener(func: CallableFunction): void
|
|
145
|
-
registerClearListener(func: CallableFunction): void
|
|
146
|
-
unregisterClearListener(func: CallableFunction): void
|
|
147
|
-
registerStoreUndoListener(func: CallableFunction): void
|
|
148
|
-
unregisterStoreUndoListener(func: CallableFunction): void
|
|
149
|
-
registerClientListener(func: CallableFunction): void
|
|
150
|
-
unregisterClientListener(func: CallableFunction): void
|
|
151
|
-
evalXML(xmlString: string): void
|
|
152
|
-
setXML(xmlString: string): void
|
|
153
|
-
getXML(objName?: string): string
|
|
154
|
-
getAlgorithmXML(objName: string): string
|
|
155
|
-
getFileJSON(): any
|
|
156
|
-
setFileJSON(content: any): void
|
|
157
|
-
getBase64(callback?: CallableFunction): string
|
|
158
|
-
setBase64(value: string, callback?: CallableFunction): void
|
|
159
|
-
debug(str: string): void
|
|
160
|
-
getVersion(): string
|
|
161
|
-
remove(): void
|
|
11
|
+
import { booleanAttributeConverter } from "../model/boolean-attribute-converter"
|
|
12
|
+
import type { GeogebraAPI } from "../model/geogebra-api"
|
|
13
|
+
import { geogebraOptions } from "../model/geogebra-options"
|
|
14
|
+
import { appletParameters } from "../model/geogebra-parameters"
|
|
15
|
+
import { base64ToBytes, bytesToBase64, dataUrlPayload, ggbDataUrl, GGB_MEDIA_TYPE, isGgbArchive } from "../model/ggb-file"
|
|
16
|
+
|
|
17
|
+
export type { GeogebraAPI }
|
|
18
|
+
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementEventMap {
|
|
21
|
+
"ggb-load": CustomEvent<{api: GeogebraAPI}>
|
|
22
|
+
}
|
|
162
23
|
}
|
|
163
24
|
|
|
164
25
|
/**
|
|
26
|
+
* The applet runs in an iframe and handles keyboard, pointer and touch input itself. The widget resizes it with its container (300 to 2100 px):
|
|
27
|
+
* the applet fills the iframe (16:9, at least 18rem high), so `width` and `height` only set its size before the first resize.
|
|
28
|
+
*
|
|
29
|
+
* Theme: the host takes `--ww-text-color` and `--ww-font-family`; the focus ring uses `--ww-link-color`. The applet's own content is not themed.
|
|
30
|
+
*
|
|
31
|
+
* Conversions: a `.ggb` file replaces the construction (import) and the current construction downloads as `.ggb` (export).
|
|
32
|
+
* `image/png` and `image/svg+xml` export the picture of the graphics view; both need the loaded applet and are lossy
|
|
33
|
+
* (no construction steps, no algebra view). A file that is no zip archive is refused before the widget changes.
|
|
34
|
+
*
|
|
35
|
+
* @part applet - The iframe that holds the GeoGebra applet.
|
|
165
36
|
* @fires focus - Fired when the GeoGebra applet gains focus.
|
|
166
37
|
* @fires ggb-load - Fired when the GeoGebra API is ready. The event detail contains the API instance.
|
|
167
38
|
*/
|
|
168
|
-
@localized()
|
|
169
39
|
export class GeogebraApp extends LitElementWw {
|
|
170
|
-
|
|
40
|
+
static styles = geogebraAppStyles
|
|
171
41
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
42
|
+
static options = geogebraOptions
|
|
43
|
+
|
|
44
|
+
static actions = {
|
|
45
|
+
importConstruction: {
|
|
46
|
+
label: (widget: {msg: MsgFn}) => ({_: widget.msg("Import construction")}),
|
|
47
|
+
input: {type: "file" as const, accept: ".ggb", multiple: false},
|
|
48
|
+
},
|
|
176
49
|
}
|
|
177
50
|
|
|
178
|
-
static
|
|
51
|
+
static convertFrom = {".ggb": "importGgb"}
|
|
52
|
+
|
|
53
|
+
static convertTo = {".ggb": "exportGgb", "image/png": "exportPng", "image/svg+xml": "exportSvg"}
|
|
54
|
+
|
|
55
|
+
// The labels of the options are computed with msg, so the editor reads them again after a language change.
|
|
56
|
+
protected readonly localize = localizer(this, {
|
|
57
|
+
sourceLocale,
|
|
58
|
+
targetLocales,
|
|
59
|
+
load: (locale) => import(`../../localization/generated/${locale}.ts`),
|
|
60
|
+
drawer: true,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
readonly msg: MsgFn = this.localize.msg
|
|
64
|
+
|
|
65
|
+
// The embedded construction is the "src" key of the JSON data block.
|
|
66
|
+
#data = jsonData<{src?: string}>(this, {
|
|
67
|
+
defaults: {},
|
|
68
|
+
changed: ({src}) => {
|
|
69
|
+
if (typeof src === "string" && src.startsWith("data:")) this.src = src
|
|
70
|
+
},
|
|
71
|
+
})
|
|
179
72
|
|
|
180
73
|
/**
|
|
181
74
|
* Custom CSS styles to apply to the GeoGebra applet.
|
|
@@ -208,8 +101,11 @@ export class GeogebraApp extends LitElementWw {
|
|
|
208
101
|
/**
|
|
209
102
|
* Source of the GeoGebra file to load (base64-encoded string, material ID prefixed with "ggbid:", or file URL)
|
|
210
103
|
*/
|
|
211
|
-
@property({type: String, attribute: true, reflect: true
|
|
212
|
-
|
|
104
|
+
@property({type: String, attribute: true, reflect: true, converter: {
|
|
105
|
+
fromAttribute: (value: string | null) => value,
|
|
106
|
+
toAttribute: (value: string | null) => value?.startsWith("data:") ? null : value,
|
|
107
|
+
}})
|
|
108
|
+
accessor src: string | undefined
|
|
213
109
|
|
|
214
110
|
/**
|
|
215
111
|
* Color of the border line drawn around the applet panel (as hex rgb string). Default: gray
|
|
@@ -275,7 +171,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
275
171
|
* Sets the toolbar according to a custom toolbar string where the int values are Toolbar Mode Values, `,` adds a separator within a menu, `|` starts a new menu and `||` adds a separator in the toolbar before starting a new menu. This will override the saved toolbar from the .ggb file / base64 string. Custom tools are numbered 100 001, 100 002, etc
|
|
276
172
|
*/
|
|
277
173
|
@property({type: String, attribute: true, reflect: true})
|
|
278
|
-
accessor customToolBar: string
|
|
174
|
+
accessor customToolBar: string | undefined
|
|
279
175
|
|
|
280
176
|
/**
|
|
281
177
|
* States whether the algebra input line (with input field, greek letters and command list) should be shown in the applet. Default: false
|
|
@@ -293,19 +189,19 @@ export class GeogebraApp extends LitElementWw {
|
|
|
293
189
|
* ISO language string. GeoGebra tries to set your local language automatically (if it is available among the supported languages, of course). The default language for unsupported languages is English. If you want to specify a certain language manually, please use this parameter.
|
|
294
190
|
*/
|
|
295
191
|
@property({type: String, attribute: true, reflect: true})
|
|
296
|
-
accessor language:
|
|
192
|
+
accessor language: string | undefined
|
|
297
193
|
|
|
298
194
|
/**
|
|
299
195
|
* ISO country string. This parameter only makes sense if you use it together with the language parameter.
|
|
300
196
|
*/
|
|
301
197
|
@property({type: String, attribute: true, reflect: true})
|
|
302
|
-
accessor country:
|
|
198
|
+
accessor country: string | undefined
|
|
303
199
|
|
|
304
200
|
/**
|
|
305
201
|
* This parameter allows you to specify the argument passed to the JavaScript function ggbOnInit(), which is called once the applet is fully initialised. This is useful when you have multiple applets on a page.
|
|
306
202
|
*/
|
|
307
203
|
@property({type: String, attribute: true, reflect: true})
|
|
308
|
-
accessor appletId:
|
|
204
|
+
accessor appletId: string | undefined
|
|
309
205
|
|
|
310
206
|
/**
|
|
311
207
|
* Determines whether the Style Bar can be shown (or will be shown if just Graphics View 1 is showing). Default: false
|
|
@@ -323,7 +219,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
323
219
|
* Specify seed for random numbers. Note that if you save a state of the app after user interacted with it and try to reload that state with the same randomSeed, you may get a different result. Use randomize for those use-cases.
|
|
324
220
|
*/
|
|
325
221
|
@property({type: Number, attribute: true, reflect: true})
|
|
326
|
-
accessor randomSeed: number
|
|
222
|
+
accessor randomSeed: number | undefined
|
|
327
223
|
|
|
328
224
|
/**
|
|
329
225
|
* When true, GeoGebra: runs ggbOnInit from HTML, ignores ggbOnInit from file, and ignores JS update scripts of objects in file. When false, GeoGebra: ignores ggbOnInit from HTML (use appletOnLoad parameter of GGBApplet instead), runs ggbOnInit from file, and runs JS update scripts of objects in file. Default: false
|
|
@@ -359,25 +255,25 @@ export class GeogebraApp extends LitElementWw {
|
|
|
359
255
|
* For values see SetPerspective_Command in the GeoGebra Manual. Just for a blank start ie shouldn't be used with material_id, filename or ggbBase64 parameters
|
|
360
256
|
*/
|
|
361
257
|
@property({type: String, attribute: true, reflect: true})
|
|
362
|
-
accessor perspective:
|
|
258
|
+
accessor perspective: string | undefined
|
|
363
259
|
|
|
364
260
|
/**
|
|
365
261
|
* Whether 3D should be enabled (for exam mode).
|
|
366
262
|
*/
|
|
367
263
|
@property({type: Boolean, attribute: true, reflect: true, converter: booleanAttributeConverter})
|
|
368
|
-
accessor enable3d: boolean
|
|
264
|
+
accessor enable3d: boolean | undefined
|
|
369
265
|
|
|
370
266
|
/**
|
|
371
267
|
* Whether CAS should be enabled (for exam mode).
|
|
372
268
|
*/
|
|
373
269
|
@property({type: Boolean, attribute: true, reflect: true, converter: booleanAttributeConverter})
|
|
374
|
-
accessor enableCAS: boolean
|
|
270
|
+
accessor enableCAS: boolean | undefined
|
|
375
271
|
|
|
376
272
|
/**
|
|
377
273
|
* Determines whether input bar should be shown in algebra, on top of the applet or under the applet. When left empty (default), the position depends on file.
|
|
378
274
|
*/
|
|
379
275
|
@property({type: String, attribute: true, reflect: true})
|
|
380
|
-
accessor algebraInputPosition: "algebra" | "top" | "bottom"
|
|
276
|
+
accessor algebraInputPosition: "algebra" | "top" | "bottom" | undefined
|
|
381
277
|
|
|
382
278
|
/**
|
|
383
279
|
* When set to true, this prevents the applet from getting focus automatically at the start. Default: false
|
|
@@ -389,7 +285,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
389
285
|
* Name of CSS class that is used as container; applet will scale to fit into the container.
|
|
390
286
|
*/
|
|
391
287
|
@property({type: String, attribute: true, reflect: true})
|
|
392
|
-
accessor scaleContainerClass: string
|
|
288
|
+
accessor scaleContainerClass: string | undefined
|
|
393
289
|
|
|
394
290
|
/**
|
|
395
291
|
* `true` to restrict the width of the applet and compute height automatically, add autoHeight: true. `false` if you want the applet to be restricted by both width and height of the container
|
|
@@ -443,7 +339,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
443
339
|
* String composed of number of decimal places and flags — valid flags are "s" for significant digits and "r" for rational numbers. Hence "10" means 10 decimal places, "10s" stands for 10 significant digits.
|
|
444
340
|
*/
|
|
445
341
|
@property({type: String, attribute: true, reflect: true})
|
|
446
|
-
accessor rounding: string
|
|
342
|
+
accessor rounding: string | undefined
|
|
447
343
|
|
|
448
344
|
/**
|
|
449
345
|
* Whether buttons should have shadow
|
|
@@ -455,25 +351,25 @@ export class GeogebraApp extends LitElementWw {
|
|
|
455
351
|
* Relative radius of button's rounded border. The border radius in pixels is buttonRounding * height /2, where height is the height of the button. Default: 0.2
|
|
456
352
|
*/
|
|
457
353
|
@property({type: Number, attribute: true, reflect: true})
|
|
458
|
-
accessor buttonRounding
|
|
354
|
+
accessor buttonRounding = 0.2
|
|
459
355
|
|
|
460
356
|
/**
|
|
461
357
|
* Border color of buttons on the graphics view. Default is black, if the button background is white, otherwise one shade darker than the background color
|
|
462
358
|
*/
|
|
463
359
|
@property({type: String, attribute: true, reflect: true})
|
|
464
|
-
accessor buttonBorderColor: string
|
|
360
|
+
accessor buttonBorderColor: string | undefined
|
|
465
361
|
|
|
466
362
|
/**
|
|
467
363
|
* Background color of the evaluator app
|
|
468
364
|
*/
|
|
469
365
|
@property({type: String, attribute: true, reflect: true})
|
|
470
|
-
accessor editorBackgroundColor: string
|
|
366
|
+
accessor editorBackgroundColor: string | undefined
|
|
471
367
|
|
|
472
368
|
/**
|
|
473
369
|
* Foreground (text) color of the equation editor (appname = "evaluator")
|
|
474
370
|
*/
|
|
475
371
|
@property({type: String, attribute: true, reflect: true})
|
|
476
|
-
accessor editorForegroundColor: string
|
|
372
|
+
accessor editorForegroundColor: string | undefined
|
|
477
373
|
|
|
478
374
|
/**
|
|
479
375
|
* Whether editor is in text mode or not (appname = "evaluator"). Default: false
|
|
@@ -485,13 +381,13 @@ export class GeogebraApp extends LitElementWw {
|
|
|
485
381
|
* Whether to show keyboard when input is focused. When set to true, keyboard is always shown, for false it never appears, for auto it's shown unless closed by user. Default: true in evaluator app, auto in other apps
|
|
486
382
|
*/
|
|
487
383
|
@property({type: Boolean, attribute: true, reflect: true, converter: booleanAttributeConverter})
|
|
488
|
-
accessor showKeyboardOnFocus: boolean
|
|
384
|
+
accessor showKeyboardOnFocus: boolean | undefined
|
|
489
385
|
|
|
490
386
|
/**
|
|
491
387
|
* Which keyboard is shown for equation editor (appname = "evaluator")
|
|
492
388
|
*/
|
|
493
389
|
@property({type: String, attribute: true, reflect: true})
|
|
494
|
-
accessor keyboardType: "scientific" | "normal" | "notes"
|
|
390
|
+
accessor keyboardType: "scientific" | "normal" | "notes" | undefined
|
|
495
391
|
|
|
496
392
|
/**
|
|
497
393
|
* Whether the Graphics View and Graphics View 2 should be transparent
|
|
@@ -509,7 +405,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
509
405
|
* When set, the keyboard should be attached to the first element in DOM that fits the selector.
|
|
510
406
|
*/
|
|
511
407
|
@property({type: String, attribute: true, reflect: true})
|
|
512
|
-
accessor detachedKeyboardParent: string
|
|
408
|
+
accessor detachedKeyboardParent: string | undefined
|
|
513
409
|
|
|
514
410
|
/**
|
|
515
411
|
* Used to force reset of the applet. Increment this property to reset the applet.
|
|
@@ -518,149 +414,92 @@ export class GeogebraApp extends LitElementWw {
|
|
|
518
414
|
protected accessor resetKey: number = 0
|
|
519
415
|
|
|
520
416
|
// A map of parameter names to their corresponding update functions in the GeoGebra API
|
|
521
|
-
private paramUpdateMap
|
|
522
|
-
|
|
523
|
-
private getConfigurableProperties() {
|
|
524
|
-
const properties: PropertyConfig[] = []
|
|
525
|
-
const ownProperties = (this.constructor as any).elementProperties as Map<string, PropertyDeclaration>
|
|
526
|
-
|
|
527
|
-
const excludedProperties = new Set([
|
|
528
|
-
"contentEditable",
|
|
529
|
-
"lang",
|
|
530
|
-
"src",
|
|
531
|
-
"width",
|
|
532
|
-
"height",
|
|
533
|
-
"ggbStyles",
|
|
534
|
-
"resetKey"
|
|
535
|
-
])
|
|
536
|
-
|
|
537
|
-
ownProperties.forEach((config, propName) => {
|
|
538
|
-
if (excludedProperties.has(propName)) return
|
|
539
|
-
|
|
540
|
-
const currentValue = (this as any)[propName]
|
|
541
|
-
let propConfig: PropertyConfig = {
|
|
542
|
-
name: propName,
|
|
543
|
-
type: "string",
|
|
544
|
-
value: currentValue
|
|
545
|
-
}
|
|
417
|
+
private paramUpdateMap?: Map<string, (value: never) => void>
|
|
546
418
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
const selectProps: Record<string, string[]> = {
|
|
553
|
-
"algebraInputPosition": ["algebra", "top", "bottom"],
|
|
554
|
-
"type": ["classic", "geometry", "3d", "suite", "evaluator", "scientific", "notes"],
|
|
555
|
-
"keyboardType": ["scientific", "normal", "notes"]
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
if (selectProps[propName]) {
|
|
559
|
-
propConfig.type = "select"
|
|
560
|
-
propConfig.options = selectProps[propName]
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
properties.push(propConfig)
|
|
565
|
-
})
|
|
419
|
+
private api?: GeogebraAPI
|
|
420
|
+
private listeners?: AbortController
|
|
421
|
+
private srcFrame = 0
|
|
422
|
+
@state()
|
|
423
|
+
private accessor ready = false
|
|
566
424
|
|
|
567
|
-
|
|
568
|
-
|
|
425
|
+
private resizer?: ResizeObserver
|
|
426
|
+
private resizeFrame = 0
|
|
427
|
+
private updatingGgb = false
|
|
569
428
|
|
|
570
429
|
private get ggbProperties() {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
let filename: string, material_id: string, ggbBase64: string
|
|
574
|
-
if(this.src && this.src.startsWith("data:")) {
|
|
575
|
-
ggbBase64 = this.src.split(",").at(-1)
|
|
576
|
-
}
|
|
577
|
-
else if(this.src && this.src.startsWith("ggbid:")) {
|
|
578
|
-
material_id = this.src.slice("ggbid:".length)
|
|
579
|
-
}
|
|
580
|
-
else if(this.src) {
|
|
581
|
-
filename = this.src
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
return {id, appName, filename, material_id, ggbBase64, width, height, borderColor, borderRadius, enableRightClick, enableLabelDrags, enableShiftDragZoom, showZoomButtons, errorDialogsActive, showMenuBar, showToolBar, showToolBarHelp, customToolBar, showAlgebraInput, showResetIcon, language: language ?? this.lang, country, allowStyleBar, randomize, randomSeed, useBrowserForJs, showLogging, capturingThreshold, enableFileFeatures, perspective, enable3d, enableCAS, algebraInputPosition, preventFocus, scaleContainerClass, autoHeight, allowUpscale, playButton, scale, showAnimationButton, showFullscreenButton, showSuggestionButtons, showStartTooltip, rounding, buttonShadows, buttonRounding, buttonBorderColor, editorBackgroundColor, editorForegroundColor, textmode, showKeyboardOnFocus, keyboardType, transparentGraphics, disabledJavaScript, detachedKeyboardParent}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
private updateSrc = (a) => {
|
|
588
|
-
console.log("updateSrc called", a)
|
|
589
|
-
if(!this.updatingGgb) {
|
|
590
|
-
this.src = `data:application/vnd.geogebra.file;base64,${this.api.getBase64()}`
|
|
591
|
-
}
|
|
430
|
+
return appletParameters(this, this.lang, sourceLocale)
|
|
592
431
|
}
|
|
593
432
|
|
|
594
433
|
connectedCallback(): void {
|
|
595
434
|
super.connectedCallback()
|
|
596
|
-
this.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
]
|
|
623
|
-
|
|
624
|
-
|
|
435
|
+
this.listeners = new AbortController()
|
|
436
|
+
this.addEventListener("ggb-load", (e) => {
|
|
437
|
+
const api = e.detail.api
|
|
438
|
+
this.api = api
|
|
439
|
+
this.ready = true
|
|
440
|
+
this.observeSize()
|
|
441
|
+
api.registerAddListener(this.updateSrc)
|
|
442
|
+
api.registerClearListener(this.updateSrc)
|
|
443
|
+
api.registerUpdateListener(this.updateSrc)
|
|
444
|
+
api.registerRenameListener(this.updateSrc)
|
|
445
|
+
api.registerRemoveListener(this.updateSrc)
|
|
446
|
+
|
|
447
|
+
// showMenuBar is not updated live, because showMenuBar(false) does not work.
|
|
448
|
+
this.paramUpdateMap = new Map<string, (value: never) => void>([
|
|
449
|
+
["width", api.setWidth],
|
|
450
|
+
["height", api.setHeight],
|
|
451
|
+
["enableRightClick", api.enableRightClick],
|
|
452
|
+
["enableLabelDrags", api.enableLabelDrags],
|
|
453
|
+
["enableShiftDragZoom", api.enableShiftDragZoom],
|
|
454
|
+
["errorDialogsActive", api.setErrorDialogsActive],
|
|
455
|
+
["showToolBar", api.showToolBar],
|
|
456
|
+
["customToolBar", api.setCustomToolBar],
|
|
457
|
+
["showAlgebraInput", api.showAlgebraInput],
|
|
458
|
+
["showResetIcon", api.showResetIcon],
|
|
459
|
+
["perspective", api.setPerspective],
|
|
460
|
+
["enable3d", api.enable3D],
|
|
461
|
+
["enableCAS", api.enableCAS],
|
|
462
|
+
["rounding", api.setRounding],
|
|
463
|
+
])
|
|
464
|
+
}, {signal: this.listeners.signal})
|
|
625
465
|
}
|
|
626
466
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
this.
|
|
467
|
+
disconnectedCallback(): void {
|
|
468
|
+
super.disconnectedCallback()
|
|
469
|
+
this.listeners?.abort()
|
|
470
|
+
this.resizer?.disconnect()
|
|
471
|
+
this.resizer = undefined
|
|
472
|
+
cancelAnimationFrame(this.resizeFrame)
|
|
473
|
+
this.resizeFrame = 0
|
|
474
|
+
this.ready = false
|
|
475
|
+
if (this.srcFrame) {
|
|
476
|
+
cancelAnimationFrame(this.srcFrame)
|
|
477
|
+
this.writeSrc()
|
|
478
|
+
}
|
|
479
|
+
this.api = undefined
|
|
635
480
|
}
|
|
636
481
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
protected updated(changed: PropertyValues): void {
|
|
640
|
-
console.log("GeogebraApp updated:", changed)
|
|
482
|
+
protected updated(changed: PropertyValues<this>): void {
|
|
641
483
|
super.updated(changed)
|
|
642
484
|
|
|
643
|
-
if(
|
|
485
|
+
if (changed.has("src")) this.#data.set({src: this.src?.startsWith("data:") ? this.src : undefined})
|
|
486
|
+
|
|
487
|
+
const api = this.api
|
|
488
|
+
if(!api) {
|
|
644
489
|
this.resetIFrame()
|
|
645
490
|
return
|
|
646
491
|
}
|
|
647
492
|
if (this.paramUpdateMap) {
|
|
648
493
|
let needFullReload = false
|
|
649
494
|
|
|
650
|
-
changed.forEach((_, key
|
|
651
|
-
|
|
652
|
-
console.log(`Property changed: ${propName}`)
|
|
653
|
-
if(propName === "src") {
|
|
495
|
+
changed.forEach((_, key) => {
|
|
496
|
+
if(key === "src" || key === "ready") {
|
|
654
497
|
return
|
|
655
498
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
updateFunc.call(this.api, (this as any)[propName])
|
|
660
|
-
console.log(`Updated GeoGebra property ${propName} to value ${(this as any)[propName]}`)
|
|
661
|
-
}
|
|
499
|
+
const updateFunc = this.paramUpdateMap?.get(key.toString())
|
|
500
|
+
if(updateFunc) {
|
|
501
|
+
updateFunc.call(api, this[key as keyof this] as never)
|
|
662
502
|
} else {
|
|
663
|
-
console.log(`No update function found for property: ${propName}, reloading entire applet...`)
|
|
664
503
|
needFullReload = true
|
|
665
504
|
}
|
|
666
505
|
})
|
|
@@ -670,32 +509,78 @@ export class GeogebraApp extends LitElementWw {
|
|
|
670
509
|
return
|
|
671
510
|
}
|
|
672
511
|
}
|
|
673
|
-
|
|
674
512
|
|
|
675
|
-
if(!changed.has("src")
|
|
513
|
+
if(!changed.has("src")) {
|
|
676
514
|
return
|
|
677
515
|
}
|
|
678
|
-
|
|
516
|
+
const base64 = this.src?.split(",").at(-1)
|
|
517
|
+
if(this.src && base64 !== api.getBase64()) {
|
|
679
518
|
this.updatingGgb = true
|
|
680
|
-
|
|
519
|
+
api.setBase64(base64 ?? "", () => {
|
|
681
520
|
this.updatingGgb = false
|
|
682
521
|
})
|
|
683
522
|
}
|
|
684
523
|
else if(!this.src) {
|
|
685
524
|
this.updatingGgb = true
|
|
686
|
-
|
|
525
|
+
api.setBase64("", () => {
|
|
687
526
|
this.updatingGgb = false
|
|
688
527
|
})
|
|
689
528
|
}
|
|
690
529
|
}
|
|
691
530
|
|
|
692
|
-
|
|
693
|
-
|
|
531
|
+
async importConstruction(files: File[]) {
|
|
532
|
+
const file = files[0]
|
|
533
|
+
if (!file || !this.isConnected) return
|
|
534
|
+
this.src = ggbDataUrl(bytesToBase64(new Uint8Array(await file.arrayBuffer())))
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
async importGgb(file: File) {
|
|
538
|
+
const bytes = new Uint8Array(await file.arrayBuffer())
|
|
539
|
+
if (!isGgbArchive(bytes)) throw new Error(this.msg("The file is not a GeoGebra construction (.ggb)."))
|
|
540
|
+
const src = ggbDataUrl(bytesToBase64(bytes))
|
|
541
|
+
return () => { this.src = src }
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
exportGgb() {
|
|
545
|
+
const base64 = this.api?.getBase64() || dataUrlPayload(this.src)
|
|
546
|
+
if (!base64) return null
|
|
547
|
+
return new File([base64ToBytes(base64) as BlobPart], "construction.ggb", {type: GGB_MEDIA_TYPE})
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
exportPng() {
|
|
551
|
+
const base64 = this.api?.getPNGBase64(1, false, 72)
|
|
552
|
+
if (!base64) return null
|
|
553
|
+
return new File([base64ToBytes(base64) as BlobPart], "construction.png", {type: "image/png"})
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
exportSvg() {
|
|
557
|
+
const api = this.api
|
|
558
|
+
if (!api) return null
|
|
559
|
+
return new Promise<File | null>(resolve => {
|
|
560
|
+
const timeout = setTimeout(() => resolve(null), 8000)
|
|
561
|
+
api.exportSVG((svg: string) => {
|
|
562
|
+
clearTimeout(timeout)
|
|
563
|
+
resolve(svg ? new File([svg], "construction.svg", {type: "image/svg+xml"}) : null)
|
|
564
|
+
})
|
|
565
|
+
})
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// Serializing the construction is costly and the applet reports every change of a drag, so it runs once per frame.
|
|
569
|
+
private updateSrc = () => {
|
|
570
|
+
if (this.updatingGgb || !this.api || this.srcFrame) return
|
|
571
|
+
this.srcFrame = requestAnimationFrame(this.writeSrc)
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
private writeSrc = () => {
|
|
575
|
+
this.srcFrame = 0
|
|
576
|
+
if(!this.updatingGgb && this.api) {
|
|
577
|
+
this.src = `data:application/vnd.geogebra.file;base64,${this.api.getBase64()}`
|
|
578
|
+
}
|
|
579
|
+
}
|
|
694
580
|
|
|
695
581
|
private initializeIFrame(iframe: HTMLIFrameElement) {
|
|
696
582
|
const doc = iframe.contentDocument
|
|
697
|
-
|
|
698
|
-
if (doc.getElementById("ggb-element")) {
|
|
583
|
+
if (!doc || doc.getElementById("ggb-element")) {
|
|
699
584
|
return
|
|
700
585
|
}
|
|
701
586
|
doc.body.style.margin = "0"
|
|
@@ -716,37 +601,51 @@ export class GeogebraApp extends LitElementWw {
|
|
|
716
601
|
const applet = new GGBApplet({${JSON.stringify(this.ggbProperties).slice(1, -1)}, appletOnLoad: api => document.dispatchEvent(new CustomEvent("ggb-load", {bubbles: true, composed: true, detail: {api}}))})
|
|
717
602
|
applet.inject("ggb-element")
|
|
718
603
|
`
|
|
719
|
-
doc.addEventListener("ggb-load", (e
|
|
604
|
+
doc.addEventListener("ggb-load", (e) => this.dispatchEvent(new CustomEvent("ggb-load", {bubbles: true, composed: true, detail: (e as CustomEvent<{api: GeogebraAPI}>).detail})))
|
|
720
605
|
doc.body.append(createScript)
|
|
721
606
|
})
|
|
722
607
|
doc.body.append(deployScript)
|
|
723
608
|
}
|
|
724
609
|
|
|
610
|
+
// The applet follows the size of the iframe, which follows the container; one resize per frame avoids loops.
|
|
611
|
+
private observeSize() {
|
|
612
|
+
const iframe = this.renderRoot.querySelector("iframe")
|
|
613
|
+
if (!iframe) return
|
|
614
|
+
this.resizer?.disconnect()
|
|
615
|
+
let last = ""
|
|
616
|
+
this.resizer = new ResizeObserver(() => {
|
|
617
|
+
cancelAnimationFrame(this.resizeFrame)
|
|
618
|
+
this.resizeFrame = requestAnimationFrame(() => {
|
|
619
|
+
const {width, height} = iframe.getBoundingClientRect()
|
|
620
|
+
const size = `${Math.round(width)}x${Math.round(height)}`
|
|
621
|
+
if (!this.api || !iframe.isConnected || width < 1 || size === last) return
|
|
622
|
+
last = size
|
|
623
|
+
this.api.setSize(Math.round(width), Math.round(height))
|
|
624
|
+
})
|
|
625
|
+
})
|
|
626
|
+
this.resizer.observe(iframe)
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
focus(options?: FocusOptions) {
|
|
630
|
+
this.renderRoot.querySelector("iframe")?.focus(options)
|
|
631
|
+
}
|
|
632
|
+
|
|
725
633
|
private resetIFrame() {
|
|
726
634
|
if(!this.api) {
|
|
727
635
|
return
|
|
728
636
|
}
|
|
729
637
|
|
|
730
638
|
this.api = undefined
|
|
731
|
-
this.
|
|
732
|
-
this.addEventListener("ggb-load", (e: any) => {
|
|
733
|
-
r(e.detail.api)
|
|
734
|
-
}, {once: true})
|
|
735
|
-
})
|
|
736
|
-
|
|
639
|
+
this.ready = false
|
|
737
640
|
this.resetKey++
|
|
738
641
|
}
|
|
739
642
|
|
|
740
643
|
render() {
|
|
741
644
|
return html`
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
.properties=${this.getConfigurableProperties()}
|
|
747
|
-
@property-change=${this.handlePropertyChange}
|
|
748
|
-
@import-file=${this.handleFileImport}
|
|
749
|
-
></geogebra-options-panel>
|
|
645
|
+
<div class="applet" ?data-ready=${this.ready}>
|
|
646
|
+
${keyed(this.resetKey, html`<iframe id="ggb" part="applet" title=${this.msg("GeoGebra applet")} @load=${(e: Event) => this.initializeIFrame(e.target as HTMLIFrameElement)}></iframe>`)}
|
|
647
|
+
<p class="print-note">${this.msg("Interactive content: open the document online to use the GeoGebra applet.")}</p>
|
|
648
|
+
</div>
|
|
750
649
|
`
|
|
751
650
|
}
|
|
752
|
-
}
|
|
651
|
+
}
|