@webwriter/geogebra 1.1.0 → 2.0.2
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-ANJTU3IB.js +203 -0
- package/dist/chunks/chunk-BSUFUO7E.js +65 -0
- package/dist/chunks/chunk-RYZMQM25.js +789 -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 +237 -332
- 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 +114 -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,80 @@
|
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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, passThroughParameters, passThroughParametersAfterLocale } from "../model/geogebra-parameters"
|
|
15
|
+
import { base64ToBytes, bytesToBase64, dataUrlPayload, ggbDataUrl, GGB_MEDIA_TYPE, isGgbArchive } from "../model/ggb-file"
|
|
16
|
+
|
|
17
|
+
const appletSettings = new Set<PropertyKey>([
|
|
18
|
+
...passThroughParameters,
|
|
19
|
+
...passThroughParametersAfterLocale,
|
|
20
|
+
"appletId", "type", "lang", "language", "country", "ggbStyles",
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
export type { GeogebraAPI }
|
|
24
|
+
|
|
25
|
+
declare global {
|
|
26
|
+
interface HTMLElementEventMap {
|
|
27
|
+
"ggb-load": CustomEvent<{api: GeogebraAPI}>
|
|
28
|
+
}
|
|
162
29
|
}
|
|
163
30
|
|
|
164
31
|
/**
|
|
32
|
+
* 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):
|
|
33
|
+
* the applet fills the iframe (16:9, at least 18rem high), so `width` and `height` only set its size before the first resize.
|
|
34
|
+
*
|
|
35
|
+
* 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.
|
|
36
|
+
*
|
|
37
|
+
* Conversions: a `.ggb` file replaces the construction (import) and the current construction downloads as `.ggb` (export).
|
|
38
|
+
* `image/png` and `image/svg+xml` export the picture of the graphics view; both need the loaded applet and are lossy
|
|
39
|
+
* (no construction steps, no algebra view). A file that is no zip archive is refused before the widget changes.
|
|
40
|
+
*
|
|
41
|
+
* @part applet - The iframe that holds the GeoGebra applet.
|
|
165
42
|
* @fires focus - Fired when the GeoGebra applet gains focus.
|
|
166
43
|
* @fires ggb-load - Fired when the GeoGebra API is ready. The event detail contains the API instance.
|
|
167
44
|
*/
|
|
168
|
-
@localized()
|
|
169
45
|
export class GeogebraApp extends LitElementWw {
|
|
170
|
-
|
|
46
|
+
static styles = geogebraAppStyles
|
|
171
47
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
48
|
+
static options = geogebraOptions
|
|
49
|
+
|
|
50
|
+
static actions = {
|
|
51
|
+
importConstruction: {
|
|
52
|
+
label: (widget: {msg: MsgFn}) => ({_: widget.msg("Import construction")}),
|
|
53
|
+
input: {type: "file" as const, accept: ".ggb", multiple: false},
|
|
54
|
+
},
|
|
176
55
|
}
|
|
177
56
|
|
|
178
|
-
static
|
|
57
|
+
static convertFrom = {".ggb": "importGgb"}
|
|
58
|
+
|
|
59
|
+
static convertTo = {".ggb": "exportGgb", "image/png": "exportPng", "image/svg+xml": "exportSvg"}
|
|
60
|
+
|
|
61
|
+
// The labels of the options are computed with msg, so the editor reads them again after a language change.
|
|
62
|
+
protected readonly localize = localizer(this, {
|
|
63
|
+
sourceLocale,
|
|
64
|
+
targetLocales,
|
|
65
|
+
load: (locale) => import(`../../localization/generated/${locale}.ts`),
|
|
66
|
+
drawer: true,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
readonly msg: MsgFn = this.localize.msg
|
|
70
|
+
|
|
71
|
+
// The embedded construction is the "src" key of the JSON data block.
|
|
72
|
+
#data = jsonData<{src?: string}>(this, {
|
|
73
|
+
defaults: {},
|
|
74
|
+
changed: ({src}) => {
|
|
75
|
+
if (typeof src === "string" && src.startsWith("data:")) this.src = src
|
|
76
|
+
},
|
|
77
|
+
})
|
|
179
78
|
|
|
180
79
|
/**
|
|
181
80
|
* Custom CSS styles to apply to the GeoGebra applet.
|
|
@@ -208,8 +107,11 @@ export class GeogebraApp extends LitElementWw {
|
|
|
208
107
|
/**
|
|
209
108
|
* Source of the GeoGebra file to load (base64-encoded string, material ID prefixed with "ggbid:", or file URL)
|
|
210
109
|
*/
|
|
211
|
-
@property({type: String, attribute: true, reflect: true
|
|
212
|
-
|
|
110
|
+
@property({type: String, attribute: true, reflect: true, converter: {
|
|
111
|
+
fromAttribute: (value: string | null) => value,
|
|
112
|
+
toAttribute: (value: string | null) => value?.startsWith("data:") ? null : value,
|
|
113
|
+
}})
|
|
114
|
+
accessor src: string | undefined
|
|
213
115
|
|
|
214
116
|
/**
|
|
215
117
|
* Color of the border line drawn around the applet panel (as hex rgb string). Default: gray
|
|
@@ -275,7 +177,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
275
177
|
* 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
178
|
*/
|
|
277
179
|
@property({type: String, attribute: true, reflect: true})
|
|
278
|
-
accessor customToolBar: string
|
|
180
|
+
accessor customToolBar: string | undefined
|
|
279
181
|
|
|
280
182
|
/**
|
|
281
183
|
* States whether the algebra input line (with input field, greek letters and command list) should be shown in the applet. Default: false
|
|
@@ -293,19 +195,19 @@ export class GeogebraApp extends LitElementWw {
|
|
|
293
195
|
* 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
196
|
*/
|
|
295
197
|
@property({type: String, attribute: true, reflect: true})
|
|
296
|
-
accessor language:
|
|
198
|
+
accessor language: string | undefined
|
|
297
199
|
|
|
298
200
|
/**
|
|
299
201
|
* ISO country string. This parameter only makes sense if you use it together with the language parameter.
|
|
300
202
|
*/
|
|
301
203
|
@property({type: String, attribute: true, reflect: true})
|
|
302
|
-
accessor country:
|
|
204
|
+
accessor country: string | undefined
|
|
303
205
|
|
|
304
206
|
/**
|
|
305
207
|
* 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
208
|
*/
|
|
307
209
|
@property({type: String, attribute: true, reflect: true})
|
|
308
|
-
accessor appletId:
|
|
210
|
+
accessor appletId: string | undefined
|
|
309
211
|
|
|
310
212
|
/**
|
|
311
213
|
* Determines whether the Style Bar can be shown (or will be shown if just Graphics View 1 is showing). Default: false
|
|
@@ -323,7 +225,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
323
225
|
* 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
226
|
*/
|
|
325
227
|
@property({type: Number, attribute: true, reflect: true})
|
|
326
|
-
accessor randomSeed: number
|
|
228
|
+
accessor randomSeed: number | undefined
|
|
327
229
|
|
|
328
230
|
/**
|
|
329
231
|
* 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 +261,25 @@ export class GeogebraApp extends LitElementWw {
|
|
|
359
261
|
* 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
262
|
*/
|
|
361
263
|
@property({type: String, attribute: true, reflect: true})
|
|
362
|
-
accessor perspective:
|
|
264
|
+
accessor perspective: string | undefined
|
|
363
265
|
|
|
364
266
|
/**
|
|
365
267
|
* Whether 3D should be enabled (for exam mode).
|
|
366
268
|
*/
|
|
367
269
|
@property({type: Boolean, attribute: true, reflect: true, converter: booleanAttributeConverter})
|
|
368
|
-
accessor enable3d: boolean
|
|
270
|
+
accessor enable3d: boolean | undefined
|
|
369
271
|
|
|
370
272
|
/**
|
|
371
273
|
* Whether CAS should be enabled (for exam mode).
|
|
372
274
|
*/
|
|
373
275
|
@property({type: Boolean, attribute: true, reflect: true, converter: booleanAttributeConverter})
|
|
374
|
-
accessor enableCAS: boolean
|
|
276
|
+
accessor enableCAS: boolean | undefined
|
|
375
277
|
|
|
376
278
|
/**
|
|
377
279
|
* 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
280
|
*/
|
|
379
281
|
@property({type: String, attribute: true, reflect: true})
|
|
380
|
-
accessor algebraInputPosition: "algebra" | "top" | "bottom"
|
|
282
|
+
accessor algebraInputPosition: "algebra" | "top" | "bottom" | undefined
|
|
381
283
|
|
|
382
284
|
/**
|
|
383
285
|
* When set to true, this prevents the applet from getting focus automatically at the start. Default: false
|
|
@@ -389,7 +291,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
389
291
|
* Name of CSS class that is used as container; applet will scale to fit into the container.
|
|
390
292
|
*/
|
|
391
293
|
@property({type: String, attribute: true, reflect: true})
|
|
392
|
-
accessor scaleContainerClass: string
|
|
294
|
+
accessor scaleContainerClass: string | undefined
|
|
393
295
|
|
|
394
296
|
/**
|
|
395
297
|
* `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 +345,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
443
345
|
* 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
346
|
*/
|
|
445
347
|
@property({type: String, attribute: true, reflect: true})
|
|
446
|
-
accessor rounding: string
|
|
348
|
+
accessor rounding: string | undefined
|
|
447
349
|
|
|
448
350
|
/**
|
|
449
351
|
* Whether buttons should have shadow
|
|
@@ -455,25 +357,25 @@ export class GeogebraApp extends LitElementWw {
|
|
|
455
357
|
* 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
358
|
*/
|
|
457
359
|
@property({type: Number, attribute: true, reflect: true})
|
|
458
|
-
accessor buttonRounding
|
|
360
|
+
accessor buttonRounding = 0.2
|
|
459
361
|
|
|
460
362
|
/**
|
|
461
363
|
* 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
364
|
*/
|
|
463
365
|
@property({type: String, attribute: true, reflect: true})
|
|
464
|
-
accessor buttonBorderColor: string
|
|
366
|
+
accessor buttonBorderColor: string | undefined
|
|
465
367
|
|
|
466
368
|
/**
|
|
467
369
|
* Background color of the evaluator app
|
|
468
370
|
*/
|
|
469
371
|
@property({type: String, attribute: true, reflect: true})
|
|
470
|
-
accessor editorBackgroundColor: string
|
|
372
|
+
accessor editorBackgroundColor: string | undefined
|
|
471
373
|
|
|
472
374
|
/**
|
|
473
375
|
* Foreground (text) color of the equation editor (appname = "evaluator")
|
|
474
376
|
*/
|
|
475
377
|
@property({type: String, attribute: true, reflect: true})
|
|
476
|
-
accessor editorForegroundColor: string
|
|
378
|
+
accessor editorForegroundColor: string | undefined
|
|
477
379
|
|
|
478
380
|
/**
|
|
479
381
|
* Whether editor is in text mode or not (appname = "evaluator"). Default: false
|
|
@@ -485,13 +387,13 @@ export class GeogebraApp extends LitElementWw {
|
|
|
485
387
|
* 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
388
|
*/
|
|
487
389
|
@property({type: Boolean, attribute: true, reflect: true, converter: booleanAttributeConverter})
|
|
488
|
-
accessor showKeyboardOnFocus: boolean
|
|
390
|
+
accessor showKeyboardOnFocus: boolean | undefined
|
|
489
391
|
|
|
490
392
|
/**
|
|
491
393
|
* Which keyboard is shown for equation editor (appname = "evaluator")
|
|
492
394
|
*/
|
|
493
395
|
@property({type: String, attribute: true, reflect: true})
|
|
494
|
-
accessor keyboardType: "scientific" | "normal" | "notes"
|
|
396
|
+
accessor keyboardType: "scientific" | "normal" | "notes" | undefined
|
|
495
397
|
|
|
496
398
|
/**
|
|
497
399
|
* Whether the Graphics View and Graphics View 2 should be transparent
|
|
@@ -509,7 +411,7 @@ export class GeogebraApp extends LitElementWw {
|
|
|
509
411
|
* When set, the keyboard should be attached to the first element in DOM that fits the selector.
|
|
510
412
|
*/
|
|
511
413
|
@property({type: String, attribute: true, reflect: true})
|
|
512
|
-
accessor detachedKeyboardParent: string
|
|
414
|
+
accessor detachedKeyboardParent: string | undefined
|
|
513
415
|
|
|
514
416
|
/**
|
|
515
417
|
* Used to force reset of the applet. Increment this property to reset the applet.
|
|
@@ -518,149 +420,92 @@ export class GeogebraApp extends LitElementWw {
|
|
|
518
420
|
protected accessor resetKey: number = 0
|
|
519
421
|
|
|
520
422
|
// 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
|
-
}
|
|
546
|
-
|
|
547
|
-
if (config.type === Boolean || typeof currentValue === "boolean") {
|
|
548
|
-
propConfig.type = "boolean"
|
|
549
|
-
} else if (config.type === Number || typeof currentValue === "number") {
|
|
550
|
-
propConfig.type = "number"
|
|
551
|
-
} else if (config.type === String || typeof currentValue === "string") {
|
|
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
|
-
}
|
|
423
|
+
private paramUpdateMap?: Map<string, (value: never) => void>
|
|
563
424
|
|
|
564
|
-
|
|
565
|
-
|
|
425
|
+
private api?: GeogebraAPI
|
|
426
|
+
private listeners?: AbortController
|
|
427
|
+
private srcFrame = 0
|
|
428
|
+
@state()
|
|
429
|
+
private accessor ready = false
|
|
566
430
|
|
|
567
|
-
|
|
568
|
-
|
|
431
|
+
private resizer?: ResizeObserver
|
|
432
|
+
private resizeFrame = 0
|
|
433
|
+
private updatingGgb = false
|
|
569
434
|
|
|
570
435
|
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
|
-
}
|
|
436
|
+
return appletParameters(this, this.lang, sourceLocale)
|
|
592
437
|
}
|
|
593
438
|
|
|
594
439
|
connectedCallback(): void {
|
|
595
440
|
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
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
private handlePropertyChange(e: CustomEvent) {
|
|
628
|
-
const {name, value} = e.detail;
|
|
629
|
-
(this as any)[name] = value
|
|
441
|
+
this.listeners = new AbortController()
|
|
442
|
+
this.addEventListener("ggb-load", (e) => {
|
|
443
|
+
const api = e.detail.api
|
|
444
|
+
this.api = api
|
|
445
|
+
this.ready = true
|
|
446
|
+
this.observeSize()
|
|
447
|
+
api.registerAddListener(this.updateSrc)
|
|
448
|
+
api.registerClearListener(this.updateSrc)
|
|
449
|
+
api.registerUpdateListener(this.updateSrc)
|
|
450
|
+
api.registerRenameListener(this.updateSrc)
|
|
451
|
+
api.registerRemoveListener(this.updateSrc)
|
|
452
|
+
|
|
453
|
+
// showMenuBar is not updated live, because showMenuBar(false) does not work.
|
|
454
|
+
this.paramUpdateMap = new Map<string, (value: never) => void>([
|
|
455
|
+
["width", api.setWidth],
|
|
456
|
+
["height", api.setHeight],
|
|
457
|
+
["enableRightClick", api.enableRightClick],
|
|
458
|
+
["enableLabelDrags", api.enableLabelDrags],
|
|
459
|
+
["enableShiftDragZoom", api.enableShiftDragZoom],
|
|
460
|
+
["errorDialogsActive", api.setErrorDialogsActive],
|
|
461
|
+
["showToolBar", api.showToolBar],
|
|
462
|
+
["customToolBar", api.setCustomToolBar],
|
|
463
|
+
["showAlgebraInput", api.showAlgebraInput],
|
|
464
|
+
["showResetIcon", api.showResetIcon],
|
|
465
|
+
["perspective", api.setPerspective],
|
|
466
|
+
["enable3d", api.enable3D],
|
|
467
|
+
["enableCAS", api.enableCAS],
|
|
468
|
+
["rounding", api.setRounding],
|
|
469
|
+
])
|
|
470
|
+
}, {signal: this.listeners.signal})
|
|
630
471
|
}
|
|
631
472
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
this.
|
|
473
|
+
disconnectedCallback(): void {
|
|
474
|
+
super.disconnectedCallback()
|
|
475
|
+
this.listeners?.abort()
|
|
476
|
+
this.resizer?.disconnect()
|
|
477
|
+
this.resizer = undefined
|
|
478
|
+
cancelAnimationFrame(this.resizeFrame)
|
|
479
|
+
this.resizeFrame = 0
|
|
480
|
+
this.ready = false
|
|
481
|
+
if (this.srcFrame) {
|
|
482
|
+
cancelAnimationFrame(this.srcFrame)
|
|
483
|
+
this.writeSrc()
|
|
484
|
+
}
|
|
485
|
+
this.api = undefined
|
|
635
486
|
}
|
|
636
487
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
protected updated(changed: PropertyValues): void {
|
|
640
|
-
console.log("GeogebraApp updated:", changed)
|
|
488
|
+
protected updated(changed: PropertyValues<this>): void {
|
|
641
489
|
super.updated(changed)
|
|
642
490
|
|
|
643
|
-
if(
|
|
491
|
+
if (changed.has("src")) this.#data.set({src: this.src?.startsWith("data:") ? this.src : undefined})
|
|
492
|
+
|
|
493
|
+
const api = this.api
|
|
494
|
+
if(!api) {
|
|
644
495
|
this.resetIFrame()
|
|
645
496
|
return
|
|
646
497
|
}
|
|
647
498
|
if (this.paramUpdateMap) {
|
|
648
499
|
let needFullReload = false
|
|
649
500
|
|
|
650
|
-
changed.forEach((_, key
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
if(
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
const updateFunc = this.paramUpdateMap.get(propName)
|
|
658
|
-
if(updateFunc) {
|
|
659
|
-
updateFunc.call(this.api, (this as any)[propName])
|
|
660
|
-
console.log(`Updated GeoGebra property ${propName} to value ${(this as any)[propName]}`)
|
|
661
|
-
}
|
|
501
|
+
changed.forEach((_, key) => {
|
|
502
|
+
// Saving a construction changes WebWriter's reactive data property. Only applet
|
|
503
|
+
// settings can require reinitialization. Construction changes are handled below.
|
|
504
|
+
if (!appletSettings.has(key)) return
|
|
505
|
+
const updateFunc = this.paramUpdateMap?.get(key.toString())
|
|
506
|
+
if(updateFunc) {
|
|
507
|
+
updateFunc.call(api, this[key as keyof this] as never)
|
|
662
508
|
} else {
|
|
663
|
-
console.log(`No update function found for property: ${propName}, reloading entire applet...`)
|
|
664
509
|
needFullReload = true
|
|
665
510
|
}
|
|
666
511
|
})
|
|
@@ -670,32 +515,78 @@ export class GeogebraApp extends LitElementWw {
|
|
|
670
515
|
return
|
|
671
516
|
}
|
|
672
517
|
}
|
|
673
|
-
|
|
674
518
|
|
|
675
|
-
if(!changed.has("src")
|
|
519
|
+
if(!changed.has("src")) {
|
|
676
520
|
return
|
|
677
521
|
}
|
|
678
|
-
|
|
522
|
+
const base64 = this.src?.split(",").at(-1)
|
|
523
|
+
if(this.src && base64 !== api.getBase64()) {
|
|
679
524
|
this.updatingGgb = true
|
|
680
|
-
|
|
525
|
+
api.setBase64(base64 ?? "", () => {
|
|
681
526
|
this.updatingGgb = false
|
|
682
527
|
})
|
|
683
528
|
}
|
|
684
529
|
else if(!this.src) {
|
|
685
530
|
this.updatingGgb = true
|
|
686
|
-
|
|
531
|
+
api.setBase64("", () => {
|
|
687
532
|
this.updatingGgb = false
|
|
688
533
|
})
|
|
689
534
|
}
|
|
690
535
|
}
|
|
691
536
|
|
|
692
|
-
|
|
693
|
-
|
|
537
|
+
async importConstruction(files: File[]) {
|
|
538
|
+
const file = files[0]
|
|
539
|
+
if (!file || !this.isConnected) return
|
|
540
|
+
this.src = ggbDataUrl(bytesToBase64(new Uint8Array(await file.arrayBuffer())))
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
async importGgb(file: File) {
|
|
544
|
+
const bytes = new Uint8Array(await file.arrayBuffer())
|
|
545
|
+
if (!isGgbArchive(bytes)) throw new Error(this.msg("The file is not a GeoGebra construction (.ggb)."))
|
|
546
|
+
const src = ggbDataUrl(bytesToBase64(bytes))
|
|
547
|
+
return () => { this.src = src }
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
exportGgb() {
|
|
551
|
+
const base64 = this.api?.getBase64() || dataUrlPayload(this.src)
|
|
552
|
+
if (!base64) return null
|
|
553
|
+
return new File([base64ToBytes(base64) as BlobPart], "construction.ggb", {type: GGB_MEDIA_TYPE})
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
exportPng() {
|
|
557
|
+
const base64 = this.api?.getPNGBase64(1, false, 72)
|
|
558
|
+
if (!base64) return null
|
|
559
|
+
return new File([base64ToBytes(base64) as BlobPart], "construction.png", {type: "image/png"})
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
exportSvg() {
|
|
563
|
+
const api = this.api
|
|
564
|
+
if (!api) return null
|
|
565
|
+
return new Promise<File | null>(resolve => {
|
|
566
|
+
const timeout = setTimeout(() => resolve(null), 8000)
|
|
567
|
+
api.exportSVG((svg: string) => {
|
|
568
|
+
clearTimeout(timeout)
|
|
569
|
+
resolve(svg ? new File([svg], "construction.svg", {type: "image/svg+xml"}) : null)
|
|
570
|
+
})
|
|
571
|
+
})
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// Serializing the construction is costly and the applet reports every change of a drag, so it runs once per frame.
|
|
575
|
+
private updateSrc = () => {
|
|
576
|
+
if (this.updatingGgb || !this.api || this.srcFrame) return
|
|
577
|
+
this.srcFrame = requestAnimationFrame(this.writeSrc)
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
private writeSrc = () => {
|
|
581
|
+
this.srcFrame = 0
|
|
582
|
+
if(!this.updatingGgb && this.api) {
|
|
583
|
+
this.src = `data:application/vnd.geogebra.file;base64,${this.api.getBase64()}`
|
|
584
|
+
}
|
|
585
|
+
}
|
|
694
586
|
|
|
695
587
|
private initializeIFrame(iframe: HTMLIFrameElement) {
|
|
696
588
|
const doc = iframe.contentDocument
|
|
697
|
-
|
|
698
|
-
if (doc.getElementById("ggb-element")) {
|
|
589
|
+
if (!doc || doc.getElementById("ggb-element")) {
|
|
699
590
|
return
|
|
700
591
|
}
|
|
701
592
|
doc.body.style.margin = "0"
|
|
@@ -716,37 +607,51 @@ export class GeogebraApp extends LitElementWw {
|
|
|
716
607
|
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
608
|
applet.inject("ggb-element")
|
|
718
609
|
`
|
|
719
|
-
doc.addEventListener("ggb-load", (e
|
|
610
|
+
doc.addEventListener("ggb-load", (e) => this.dispatchEvent(new CustomEvent("ggb-load", {bubbles: true, composed: true, detail: (e as CustomEvent<{api: GeogebraAPI}>).detail})))
|
|
720
611
|
doc.body.append(createScript)
|
|
721
612
|
})
|
|
722
613
|
doc.body.append(deployScript)
|
|
723
614
|
}
|
|
724
615
|
|
|
616
|
+
// The applet follows the size of the iframe, which follows the container; one resize per frame avoids loops.
|
|
617
|
+
private observeSize() {
|
|
618
|
+
const iframe = this.renderRoot.querySelector("iframe")
|
|
619
|
+
if (!iframe) return
|
|
620
|
+
this.resizer?.disconnect()
|
|
621
|
+
let last = ""
|
|
622
|
+
this.resizer = new ResizeObserver(() => {
|
|
623
|
+
cancelAnimationFrame(this.resizeFrame)
|
|
624
|
+
this.resizeFrame = requestAnimationFrame(() => {
|
|
625
|
+
const {width, height} = iframe.getBoundingClientRect()
|
|
626
|
+
const size = `${Math.round(width)}x${Math.round(height)}`
|
|
627
|
+
if (!this.api || !iframe.isConnected || width < 1 || size === last) return
|
|
628
|
+
last = size
|
|
629
|
+
this.api.setSize(Math.round(width), Math.round(height))
|
|
630
|
+
})
|
|
631
|
+
})
|
|
632
|
+
this.resizer.observe(iframe)
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
focus(options?: FocusOptions) {
|
|
636
|
+
this.renderRoot.querySelector("iframe")?.focus(options)
|
|
637
|
+
}
|
|
638
|
+
|
|
725
639
|
private resetIFrame() {
|
|
726
640
|
if(!this.api) {
|
|
727
641
|
return
|
|
728
642
|
}
|
|
729
643
|
|
|
730
644
|
this.api = undefined
|
|
731
|
-
this.
|
|
732
|
-
this.addEventListener("ggb-load", (e: any) => {
|
|
733
|
-
r(e.detail.api)
|
|
734
|
-
}, {once: true})
|
|
735
|
-
})
|
|
736
|
-
|
|
645
|
+
this.ready = false
|
|
737
646
|
this.resetKey++
|
|
738
647
|
}
|
|
739
648
|
|
|
740
649
|
render() {
|
|
741
650
|
return html`
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
.properties=${this.getConfigurableProperties()}
|
|
747
|
-
@property-change=${this.handlePropertyChange}
|
|
748
|
-
@import-file=${this.handleFileImport}
|
|
749
|
-
></geogebra-options-panel>
|
|
651
|
+
<div class="applet" ?data-ready=${this.ready}>
|
|
652
|
+
${keyed(this.resetKey, html`<iframe id="ggb" part="applet" title=${this.msg("GeoGebra applet")} @load=${(e: Event) => this.initializeIFrame(e.target as HTMLIFrameElement)}></iframe>`)}
|
|
653
|
+
<p class="print-note">${this.msg("Interactive content: open the document online to use the GeoGebra applet.")}</p>
|
|
654
|
+
</div>
|
|
750
655
|
`
|
|
751
656
|
}
|
|
752
|
-
}
|
|
657
|
+
}
|