@webwriter/geogebra 1.0.1 → 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/.github/workflows/publish.yml +8 -0
- package/LICENSE +6 -6
- package/README.md +785 -0
- package/custom-elements.json +11514 -0
- 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 +23 -1880
- package/dist/widgets/webwriter-geogebra-classic.js +22 -1879
- package/dist/widgets/webwriter-geogebra-geometry.js +22 -1879
- package/dist/widgets/webwriter-geogebra-notes.js +22 -1879
- package/dist/widgets/webwriter-geogebra-scientific.js +22 -1879
- package/dist/widgets/webwriter-geogebra.js +34 -1887
- package/editing-config.json +856 -0
- package/lit-localize.json +111 -0
- package/localization/af.xlf +290 -0
- package/localization/am.xlf +290 -0
- package/localization/ar.xlf +295 -0
- package/localization/az.xlf +290 -0
- package/localization/be.xlf +290 -0
- package/localization/bg.xlf +295 -0
- 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 +295 -0
- package/localization/cy.xlf +290 -0
- package/localization/da.xlf +295 -0
- package/localization/de-AT.xlf +294 -0
- package/localization/de-CH.xlf +294 -0
- package/localization/de.xlf +294 -0
- package/localization/el.xlf +295 -0
- package/localization/es.xlf +295 -0
- package/localization/et.xlf +295 -0
- package/localization/eu.xlf +290 -0
- package/localization/fa.xlf +290 -0
- package/localization/fi.xlf +295 -0
- package/localization/fr.xlf +295 -0
- 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 +16 -0
- package/localization/generated/az.ts +16 -0
- package/localization/generated/be.ts +16 -0
- package/localization/generated/bg.ts +16 -0
- 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 +16 -0
- package/localization/generated/cy.ts +16 -0
- package/localization/generated/da.ts +16 -0
- package/localization/generated/de-AT.ts +16 -0
- package/localization/generated/de-CH.ts +16 -0
- package/localization/generated/de.ts +16 -0
- package/localization/generated/el.ts +16 -0
- 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 +16 -0
- package/localization/generated/et.ts +16 -0
- package/localization/generated/eu.ts +16 -0
- package/localization/generated/fa.ts +16 -0
- package/localization/generated/fi.ts +16 -0
- package/localization/generated/fr.ts +16 -0
- 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 +16 -0
- package/localization/generated/hy.ts +16 -0
- package/localization/generated/id.ts +16 -0
- package/localization/generated/index.js +3 -0
- package/localization/generated/is.ts +16 -0
- package/localization/generated/it.ts +16 -0
- package/localization/generated/ja.ts +16 -0
- 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 +16 -0
- 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 +16 -0
- package/localization/generated/lv.ts +16 -0
- 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 +16 -0
- package/localization/generated/ne.ts +16 -0
- package/localization/generated/nl.ts +16 -0
- 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 +16 -0
- package/localization/generated/pt-BR.ts +16 -0
- package/localization/generated/pt-PT.ts +16 -0
- package/localization/generated/pt.ts +16 -0
- package/localization/generated/ro.ts +16 -0
- package/localization/generated/ru.ts +16 -0
- package/localization/generated/si.ts +16 -0
- package/localization/generated/sk.ts +16 -0
- package/localization/generated/sl.ts +16 -0
- 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 +16 -0
- 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 +16 -0
- package/localization/generated/uk.ts +16 -0
- 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 +295 -0
- package/localization/hy.xlf +290 -0
- package/localization/id.xlf +295 -0
- package/localization/is.xlf +290 -0
- package/localization/it.xlf +295 -0
- package/localization/ja.xlf +295 -0
- 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 +295 -0
- package/localization/ky.xlf +290 -0
- package/localization/la.xlf +290 -0
- package/localization/lb.xlf +290 -0
- package/localization/lt.xlf +295 -0
- package/localization/lv.xlf +295 -0
- 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 +295 -0
- package/localization/ne.xlf +290 -0
- package/localization/nl.xlf +295 -0
- 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/pkg/ar.xliff +6 -0
- package/localization/pkg/bg.xliff +6 -0
- package/localization/pkg/cs.xliff +6 -0
- package/localization/pkg/da.xliff +6 -0
- package/localization/pkg/de.xliff +6 -0
- package/localization/pkg/el.xliff +6 -0
- package/localization/pkg/es.xliff +6 -0
- package/localization/pkg/et.xliff +6 -0
- package/localization/pkg/fi.xliff +6 -0
- package/localization/pkg/fr.xliff +6 -0
- package/localization/pkg/hu.xliff +6 -0
- package/localization/pkg/id.xliff +6 -0
- package/localization/pkg/it.xliff +6 -0
- package/localization/pkg/ja.xliff +6 -0
- package/localization/pkg/ko.xliff +6 -0
- package/localization/pkg/lt.xliff +6 -0
- package/localization/pkg/lv.xliff +6 -0
- package/localization/pkg/nb.xliff +6 -0
- package/localization/pkg/nl.xliff +6 -0
- package/localization/pkg/pl.xliff +6 -0
- package/localization/pkg/pt-BR.xliff +6 -0
- package/localization/pkg/pt-PT.xliff +6 -0
- package/localization/pkg/ro.xliff +6 -0
- package/localization/pkg/ru.xliff +6 -0
- package/localization/pkg/sk.xliff +6 -0
- package/localization/pkg/sl.xliff +6 -0
- package/localization/pkg/sv.xliff +6 -0
- package/localization/pkg/tr.xliff +6 -0
- package/localization/pkg/uk.xliff +6 -0
- package/localization/pkg/zh-Hans.xliff +6 -0
- package/localization/pkg/zh-Hant.xliff +6 -0
- package/localization/pl.xlf +295 -0
- package/localization/pt-BR.xlf +295 -0
- package/localization/pt-PT.xlf +295 -0
- package/localization/pt.xlf +295 -0
- package/localization/ro.xlf +295 -0
- package/localization/ru.xlf +295 -0
- package/localization/si.xlf +290 -0
- package/localization/sk.xlf +295 -0
- package/localization/sl.xlf +295 -0
- package/localization/snippets/ar.xliff +4 -0
- package/localization/snippets/bg.xliff +4 -0
- package/localization/snippets/cs.xliff +4 -0
- package/localization/snippets/da.xliff +4 -0
- package/localization/snippets/de.xliff +4 -0
- package/localization/snippets/el.xliff +4 -0
- package/localization/snippets/es.xliff +4 -0
- package/localization/snippets/et.xliff +4 -0
- package/localization/snippets/fi.xliff +4 -0
- package/localization/snippets/fr.xliff +4 -0
- package/localization/snippets/hu.xliff +4 -0
- package/localization/snippets/id.xliff +4 -0
- package/localization/snippets/it.xliff +4 -0
- package/localization/snippets/ja.xliff +4 -0
- package/localization/snippets/ko.xliff +4 -0
- package/localization/snippets/lt.xliff +4 -0
- package/localization/snippets/lv.xliff +4 -0
- package/localization/snippets/nb.xliff +4 -0
- package/localization/snippets/nl.xliff +4 -0
- package/localization/snippets/pl.xliff +4 -0
- package/localization/snippets/pt-BR.xliff +4 -0
- package/localization/snippets/pt-PT.xliff +4 -0
- package/localization/snippets/ro.xliff +4 -0
- package/localization/snippets/ru.xliff +4 -0
- package/localization/snippets/sk.xliff +4 -0
- package/localization/snippets/sl.xliff +4 -0
- package/localization/snippets/sv.xliff +4 -0
- package/localization/snippets/tr.xliff +4 -0
- package/localization/snippets/uk.xliff +4 -0
- package/localization/snippets/zh-Hans.xliff +4 -0
- package/localization/snippets/zh-Hant.xliff +4 -0
- package/localization/so.xlf +290 -0
- package/localization/sq.xlf +290 -0
- package/localization/sr.xlf +290 -0
- package/localization/sv.xlf +295 -0
- 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 +295 -0
- package/localization/uk.xlf +295 -0
- 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 +272 -166
- package/src/components/geogebra-app.styles.ts +47 -0
- package/src/components/geogebra-app.ts +651 -0
- package/src/model/boolean-attribute-converter.ts +8 -0
- 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/src/widgets/webwriter-geogebra-3d.ts +15 -0
- package/{widgets → src/widgets}/webwriter-geogebra-classic.ts +14 -8
- package/{widgets → src/widgets}/webwriter-geogebra-geometry.ts +14 -8
- package/{widgets → src/widgets}/webwriter-geogebra-notes.ts +14 -8
- package/{widgets → src/widgets}/webwriter-geogebra-scientific.ts +14 -8
- package/src/widgets/webwriter-geogebra.ts +28 -0
- 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 +4 -8
- package/components/geogebra-app.ts +0 -417
- package/custom.d.ts +0 -180
- package/widgets/webwriter-geogebra-3d.ts +0 -9
- package/widgets/webwriter-geogebra-evaluator.ts +0 -9
- package/widgets/webwriter-geogebra.ts +0 -20
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export interface GeogebraAPI {
|
|
2
|
+
evalCommand(cmdString: string): boolean
|
|
3
|
+
evalLaTex(input: string): boolean
|
|
4
|
+
evalCommandGetLabels(cmdString: string): string
|
|
5
|
+
evalCommandCAS(text: string): string
|
|
6
|
+
insertEmbed(type: string, uri: string): void
|
|
7
|
+
deleteObject(objName: string): void
|
|
8
|
+
setAuxiliary(geo: any, status: boolean): void
|
|
9
|
+
setValue(objName: string, value: number): void
|
|
10
|
+
setTextValue(objName: string, value: string): void
|
|
11
|
+
setListValue(objName: string, i: number, value: number): void
|
|
12
|
+
setCoords(objName: string, x: number, y: number, z?: number): void
|
|
13
|
+
setCaption(objName: string, caption: string): void
|
|
14
|
+
setColor(objName: string, red: number, green: number, blue: number): void
|
|
15
|
+
setVisible(objName: string, visible: boolean): void
|
|
16
|
+
setLabelVisible(objName: string, visible: boolean): void
|
|
17
|
+
setLabelStyle(objName: string, style: 0 | 1 | 2 | 3): void
|
|
18
|
+
setFixed(objName: string, fixed: boolean, selectionAllowed: boolean): void
|
|
19
|
+
setTrace(objName: string, flag: boolean): void
|
|
20
|
+
renameObject(oldObjName: string, newObjName: string): boolean
|
|
21
|
+
setLayer(objName: string, layer: number): void
|
|
22
|
+
setLayerVisible(objName: string, visible: boolean): void
|
|
23
|
+
setLineStyle(objName: string, style: 0 | 1 | 2 | 3 | 4): void
|
|
24
|
+
setLineThickness(objName: string, thickness: -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13): void
|
|
25
|
+
setPointStyle(objName: string, size: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): void
|
|
26
|
+
setPointSize(objName: string, size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): void
|
|
27
|
+
setDisplayStyle(objName: string, style: string): void
|
|
28
|
+
setFilling(objName: string, filling: number): void
|
|
29
|
+
getPNGBase64(exportScale: number, transparent?: boolean, dpi?: number): string
|
|
30
|
+
exportSVG(filename: string): void
|
|
31
|
+
exportSVG(callback: CallableFunction): void
|
|
32
|
+
exportPDF(scale: number, filename: string, sliderLabel?: string): void
|
|
33
|
+
exportPDF(scale: number, callback: CallableFunction, sliderLabel?: string): void
|
|
34
|
+
getScreenshotBase64(callback: CallableFunction): void
|
|
35
|
+
writePNGtoFile(fileName: string, exportScale?: number, transparent?: boolean, dpi?: number): boolean
|
|
36
|
+
isIndependent(objName: string): boolean
|
|
37
|
+
isMovable(objName: string): boolean
|
|
38
|
+
showAllObjects(): void
|
|
39
|
+
registerEmbedResolver(type: string, callback: CallableFunction): void
|
|
40
|
+
setAnimating(objName: string, animate: boolean): void
|
|
41
|
+
setAnimationSpeed(objName: string, speed: number): void
|
|
42
|
+
startAnimation(): void
|
|
43
|
+
stopAnimation(): void
|
|
44
|
+
isAnimationRunning(): boolean
|
|
45
|
+
getXcoord(objName: string): number
|
|
46
|
+
getYcoord(objName: string): number
|
|
47
|
+
getZcoord(objName: string): number
|
|
48
|
+
getValue(objName: string): number
|
|
49
|
+
getListValue(objName: string, index: number): number
|
|
50
|
+
getColor(objName: string): string
|
|
51
|
+
getVisible(objName: string): boolean
|
|
52
|
+
getValueString(objName: string, useLocalizedInput?: boolean): string
|
|
53
|
+
getDefinitionString(objName: string): string
|
|
54
|
+
getCommandString(objName: string, useLocalizedInput?: boolean): string
|
|
55
|
+
getLaTeXString(objName: string, value: boolean): string
|
|
56
|
+
getObjectType(objName: string): string
|
|
57
|
+
exists(objName: string): boolean
|
|
58
|
+
isDefined(objName: string): boolean
|
|
59
|
+
getAllObjectNames(type?: string): string[]
|
|
60
|
+
getObjectNumber(): number
|
|
61
|
+
getCASObjectNumber(): number
|
|
62
|
+
getObjectName(i: number): string
|
|
63
|
+
getLayer(objName: string): string
|
|
64
|
+
getLineStyle(objName: string): 0 | 1 | 2 | 3 | 4
|
|
65
|
+
getLineThickness(objName: string): -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
|
|
66
|
+
getPointStyle(objName: string): -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
67
|
+
getPointSize(objName: string): 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
68
|
+
getFilling(objName: string): number
|
|
69
|
+
getCaption(objName: string, substitutePlaceholders?: boolean): string
|
|
70
|
+
getLabelStyle(objName: string): 0 | 1 | 2 | 3
|
|
71
|
+
getLabelVisible(): boolean
|
|
72
|
+
isInteractive(objName: string): boolean
|
|
73
|
+
setMode(mode: number): void
|
|
74
|
+
getMode(): number
|
|
75
|
+
reset(): void
|
|
76
|
+
newConstruction(): void
|
|
77
|
+
refreshViews(): void
|
|
78
|
+
setOnTheFlyPointCreationActive(flag: boolean): void
|
|
79
|
+
setPointCapture(view: -1 | 1 | 2, mode: 0 | 1 | 2 | 3): void
|
|
80
|
+
setRounding(round: string): void
|
|
81
|
+
hideCursorWhenDragging(flag: boolean): void
|
|
82
|
+
setRepaintingActive(flag: boolean): void
|
|
83
|
+
setErrorDialogsActive(flag: boolean): void
|
|
84
|
+
setCoordSystem(xmin: number, xmax: number, ymin: number, ymax: number, zmin?: number, zmax?: number, yVertical?: boolean): void
|
|
85
|
+
setAxesVisible(xAxis: boolean, yAxis: boolean, zAxis?: boolean): void
|
|
86
|
+
setUndoPoint(): void
|
|
87
|
+
setAxisLabels(viewNumber: number, xAxis: string, yAxis: string, zAxis: string): void
|
|
88
|
+
setAxisSteps(viewNumber: number, xAxis: number, yAxis: number, zAxis: number): void
|
|
89
|
+
setAxisUnits(viewNumber: number, xAxis: string, yAxis: string, zAxis: string): void
|
|
90
|
+
setGridVisible(flag: boolean): void
|
|
91
|
+
setGridVisible(viewNumber: number, flag: boolean): void
|
|
92
|
+
getGridVisible(viewNumber: number): boolean
|
|
93
|
+
getPerspectiveXML(): string
|
|
94
|
+
undo(): void
|
|
95
|
+
redo(): void
|
|
96
|
+
showToolBar(show: boolean): void
|
|
97
|
+
setCustomToolBar(toolbar: string): void
|
|
98
|
+
addCustomTool(iconURL: string, name: string, category?: string, callback?: CallableFunction): void
|
|
99
|
+
showMenuBar(show: boolean): void
|
|
100
|
+
showAlgebraInput(show: boolean): void
|
|
101
|
+
showResetIcon(show: boolean): void
|
|
102
|
+
enableRightClick(enable: boolean): void
|
|
103
|
+
enableLabelDrags(enable: boolean): void
|
|
104
|
+
enableShiftDragZoom(enable: boolean): void
|
|
105
|
+
enableCAS(enable: boolean): void
|
|
106
|
+
enable3D(enable: boolean): void
|
|
107
|
+
setPerspective(perspective: string): void
|
|
108
|
+
setWidth(width: number): void
|
|
109
|
+
setHeight(height: number): void
|
|
110
|
+
setSize(width: number, height: number): void
|
|
111
|
+
recalculateEnvironments(): void
|
|
112
|
+
getEditorState(): any
|
|
113
|
+
setEditorState(state: any): void
|
|
114
|
+
getGraphicsOptions(viewId: number): any
|
|
115
|
+
setGraphicsOptions(viewID: number, options: any): void
|
|
116
|
+
setAlgebraOptions(options: any): void
|
|
117
|
+
registerAddListener(func: CallableFunction): void
|
|
118
|
+
unregisterAddListener(func: CallableFunction): void
|
|
119
|
+
registerRemoveListener(func: CallableFunction): void
|
|
120
|
+
unregisterRemoveListener(func: CallableFunction): void
|
|
121
|
+
registerUpdateListener(func: CallableFunction): void
|
|
122
|
+
unregisterUpdateListener(func: CallableFunction): void
|
|
123
|
+
registerClickListener(func: CallableFunction): void
|
|
124
|
+
unregisterClickListener(func: CallableFunction): void
|
|
125
|
+
registerObjectUpdateListener(objName: string, func: CallableFunction): void
|
|
126
|
+
unregisterObjectUpdateListener(objName: string): void
|
|
127
|
+
registerObjectClickListener(objName: string, func: CallableFunction): void
|
|
128
|
+
unregisterObjectClickListener(objName: string): void
|
|
129
|
+
registerRenameListener(func: CallableFunction): void
|
|
130
|
+
unregisterRenameListener(func: CallableFunction): void
|
|
131
|
+
registerClearListener(func: CallableFunction): void
|
|
132
|
+
unregisterClearListener(func: CallableFunction): void
|
|
133
|
+
registerStoreUndoListener(func: CallableFunction): void
|
|
134
|
+
unregisterStoreUndoListener(func: CallableFunction): void
|
|
135
|
+
registerClientListener(func: CallableFunction): void
|
|
136
|
+
unregisterClientListener(func: CallableFunction): void
|
|
137
|
+
evalXML(xmlString: string): void
|
|
138
|
+
setXML(xmlString: string): void
|
|
139
|
+
getXML(objName?: string): string
|
|
140
|
+
getAlgorithmXML(objName: string): string
|
|
141
|
+
getFileJSON(): any
|
|
142
|
+
setFileJSON(content: any): void
|
|
143
|
+
getBase64(callback?: CallableFunction): string
|
|
144
|
+
setBase64(value: string, callback?: CallableFunction): void
|
|
145
|
+
debug(str: string): void
|
|
146
|
+
getVersion(): string
|
|
147
|
+
remove(): void
|
|
148
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
type Labelled = {msg: (source: string) => string}
|
|
2
|
+
|
|
3
|
+
/** Editor option declarations of the GeoGebra widgets. */
|
|
4
|
+
export const geogebraOptions = {
|
|
5
|
+
type: {type: "select" as const, control: "select" as const, label: (widget: Labelled) => ({_: widget.msg("Type")}), options: [
|
|
6
|
+
{value: "classic", label: (widget: Labelled) => ({_: widget.msg("Classic")})},
|
|
7
|
+
{value: "geometry", label: (widget: Labelled) => ({_: widget.msg("Geometry")})},
|
|
8
|
+
{value: "3d", label: (widget: Labelled) => ({_: widget.msg("3D")})},
|
|
9
|
+
{value: "suite", label: (widget: Labelled) => ({_: widget.msg("Calculator Suite")})},
|
|
10
|
+
{value: "evaluator", label: (widget: Labelled) => ({_: widget.msg("Evaluator")})},
|
|
11
|
+
{value: "scientific", label: (widget: Labelled) => ({_: widget.msg("Scientific")})},
|
|
12
|
+
{value: "notes", label: (widget: Labelled) => ({_: widget.msg("Notes")})},
|
|
13
|
+
]},
|
|
14
|
+
borderColor: {type: String, label: (widget: Labelled) => ({_: widget.msg("Border color")})},
|
|
15
|
+
borderRadius: {type: Number, label: (widget: Labelled) => ({_: widget.msg("Border radius")})},
|
|
16
|
+
enableRightClick: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Enable right click")})},
|
|
17
|
+
enableLabelDrags: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Allow dragging labels")})},
|
|
18
|
+
enableShiftDragZoom: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Enable Shift-drag zoom")})},
|
|
19
|
+
showZoomButtons: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show zoom buttons")})},
|
|
20
|
+
errorDialogsActive: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show error dialogs")})},
|
|
21
|
+
showMenuBar: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show menu bar")})},
|
|
22
|
+
showToolBar: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show toolbar")})},
|
|
23
|
+
showToolBarHelp: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show toolbar help")})},
|
|
24
|
+
customToolBar: {type: String, label: (widget: Labelled) => ({_: widget.msg("Custom toolbar")})},
|
|
25
|
+
showAlgebraInput: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show algebra input")})},
|
|
26
|
+
showResetIcon: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show reset icon")})},
|
|
27
|
+
language: {type: String, label: (widget: Labelled) => ({_: widget.msg("Language")})},
|
|
28
|
+
country: {type: String, label: (widget: Labelled) => ({_: widget.msg("Country")})},
|
|
29
|
+
appletId: {type: String, label: (widget: Labelled) => ({_: widget.msg("Applet ID")})},
|
|
30
|
+
allowStyleBar: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Allow style bar")})},
|
|
31
|
+
randomize: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Randomize")})},
|
|
32
|
+
randomSeed: {type: Number, label: (widget: Labelled) => ({_: widget.msg("Random seed")})},
|
|
33
|
+
useBrowserForJs: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Use browser for JavaScript")})},
|
|
34
|
+
showLogging: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show log messages")})},
|
|
35
|
+
capturingThreshold: {type: Number, label: (widget: Labelled) => ({_: widget.msg("Point capture threshold")})},
|
|
36
|
+
enableFileFeatures: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Enable file features")})},
|
|
37
|
+
enableUndoRedo: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Enable undo and redo")})},
|
|
38
|
+
perspective: {type: String, label: (widget: Labelled) => ({_: widget.msg("Perspective")})},
|
|
39
|
+
enable3d: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Enable 3D")})},
|
|
40
|
+
enableCAS: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Enable CAS")})},
|
|
41
|
+
algebraInputPosition: {type: "select" as const, label: (widget: Labelled) => ({_: widget.msg("Algebra input position")}), options: [
|
|
42
|
+
{value: "algebra", label: (widget: Labelled) => ({_: widget.msg("Algebra")})},
|
|
43
|
+
{value: "top", label: (widget: Labelled) => ({_: widget.msg("Top")})},
|
|
44
|
+
{value: "bottom", label: (widget: Labelled) => ({_: widget.msg("Bottom")})},
|
|
45
|
+
]},
|
|
46
|
+
preventFocus: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Prevent focus")})},
|
|
47
|
+
scaleContainerClass: {type: String, label: (widget: Labelled) => ({_: widget.msg("Scale container CSS class")})},
|
|
48
|
+
autoHeight: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Automatic height")})},
|
|
49
|
+
allowUpscale: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Allow upscaling")})},
|
|
50
|
+
playButton: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Play button")})},
|
|
51
|
+
scale: {type: Number, label: (widget: Labelled) => ({_: widget.msg("Scale")})},
|
|
52
|
+
showAnimationButton: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show animation button")})},
|
|
53
|
+
showFullscreenButton: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show fullscreen button")})},
|
|
54
|
+
showSuggestionButtons: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show suggestion buttons")})},
|
|
55
|
+
showStartTooltip: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show startup tooltip")})},
|
|
56
|
+
rounding: {type: String, label: (widget: Labelled) => ({_: widget.msg("Rounding")})},
|
|
57
|
+
buttonShadows: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Button shadows")})},
|
|
58
|
+
buttonRounding: {type: Number, label: (widget: Labelled) => ({_: widget.msg("Button corner rounding")})},
|
|
59
|
+
buttonBorderColor: {type: String, label: (widget: Labelled) => ({_: widget.msg("Button border color")})},
|
|
60
|
+
editorBackgroundColor: {type: String, label: (widget: Labelled) => ({_: widget.msg("Editor background color")})},
|
|
61
|
+
editorForegroundColor: {type: String, label: (widget: Labelled) => ({_: widget.msg("Editor foreground color")})},
|
|
62
|
+
textmode: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Text mode")})},
|
|
63
|
+
showKeyboardOnFocus: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Show keyboard on focus")})},
|
|
64
|
+
keyboardType: {type: "select" as const, label: (widget: Labelled) => ({_: widget.msg("Keyboard type")}), options: [
|
|
65
|
+
{value: "scientific", label: (widget: Labelled) => ({_: widget.msg("Scientific")})},
|
|
66
|
+
{value: "normal", label: (widget: Labelled) => ({_: widget.msg("Normal")})},
|
|
67
|
+
{value: "notes", label: (widget: Labelled) => ({_: widget.msg("Notes")})},
|
|
68
|
+
]},
|
|
69
|
+
transparentGraphics: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Transparent graphics")})},
|
|
70
|
+
disabledJavaScript: {type: Boolean, label: (widget: Labelled) => ({_: widget.msg("Disable JavaScript")})},
|
|
71
|
+
detachedKeyboardParent: {type: String, label: (widget: Labelled) => ({_: widget.msg("Detached keyboard parent")})},
|
|
72
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Properties of the widget that are handed to the applet as they are.
|
|
2
|
+
export const passThroughParameters = [
|
|
3
|
+
"width", "height", "borderColor", "borderRadius", "enableRightClick", "enableLabelDrags", "enableShiftDragZoom",
|
|
4
|
+
"showZoomButtons", "errorDialogsActive", "showMenuBar", "showToolBar", "showToolBarHelp", "customToolBar",
|
|
5
|
+
"showAlgebraInput", "showResetIcon",
|
|
6
|
+
] as const
|
|
7
|
+
|
|
8
|
+
export const passThroughParametersAfterLocale = [
|
|
9
|
+
"allowStyleBar", "randomize", "randomSeed", "useBrowserForJs", "showLogging", "capturingThreshold",
|
|
10
|
+
"enableFileFeatures", "perspective", "enable3d", "enableCAS", "algebraInputPosition", "preventFocus",
|
|
11
|
+
"scaleContainerClass", "autoHeight", "allowUpscale", "playButton", "scale", "showAnimationButton",
|
|
12
|
+
"showFullscreenButton", "showSuggestionButtons", "showStartTooltip", "rounding", "buttonShadows",
|
|
13
|
+
"buttonRounding", "buttonBorderColor", "editorBackgroundColor", "editorForegroundColor", "textmode",
|
|
14
|
+
"showKeyboardOnFocus", "keyboardType", "transparentGraphics", "disabledJavaScript", "detachedKeyboardParent",
|
|
15
|
+
] as const
|
|
16
|
+
|
|
17
|
+
type Source = {
|
|
18
|
+
appletId?: string
|
|
19
|
+
type: string
|
|
20
|
+
src?: string
|
|
21
|
+
language?: string
|
|
22
|
+
country?: string
|
|
23
|
+
} & Record<(typeof passThroughParameters)[number] | (typeof passThroughParametersAfterLocale)[number], unknown>
|
|
24
|
+
|
|
25
|
+
/** Maps the widget's properties to the parameters of the GeoGebra applet (deployggb.js). */
|
|
26
|
+
export function appletParameters(source: Source, lang: string, sourceLocale: string) {
|
|
27
|
+
let locale: Intl.Locale
|
|
28
|
+
try {
|
|
29
|
+
locale = new Intl.Locale(lang.trim() || sourceLocale)
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (!(error instanceof RangeError)) throw error
|
|
32
|
+
locale = new Intl.Locale(sourceLocale)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let filename: string | undefined, material_id: string | undefined, ggbBase64: string | undefined
|
|
36
|
+
const {src, language} = source
|
|
37
|
+
if (src?.startsWith("data:")) ggbBase64 = src.split(",").at(-1)
|
|
38
|
+
else if (src?.startsWith("ggbid:")) material_id = src.slice("ggbid:".length)
|
|
39
|
+
else if (src) filename = src
|
|
40
|
+
|
|
41
|
+
const pick = (keys: readonly (keyof Source)[]) => Object.fromEntries(keys.map(key => [key, source[key]]))
|
|
42
|
+
return {
|
|
43
|
+
id: source.appletId,
|
|
44
|
+
appName: source.type,
|
|
45
|
+
filename,
|
|
46
|
+
material_id,
|
|
47
|
+
ggbBase64,
|
|
48
|
+
...pick(passThroughParameters),
|
|
49
|
+
language: language ?? locale.language,
|
|
50
|
+
country: source.country ?? (language ? undefined : locale.region ?? (locale.script ? locale.maximize().region : undefined)),
|
|
51
|
+
...pick(passThroughParametersAfterLocale),
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const GGB_MEDIA_TYPE = "application/vnd.geogebra.file"
|
|
2
|
+
|
|
3
|
+
const ZIP_MAGIC = [0x50, 0x4b, 0x03, 0x04]
|
|
4
|
+
|
|
5
|
+
/** True when the bytes start like a zip archive, which every .ggb file is. */
|
|
6
|
+
export function isGgbArchive(bytes: Uint8Array): boolean {
|
|
7
|
+
return bytes.length > ZIP_MAGIC.length && ZIP_MAGIC.every((value, index) => bytes[index] === value)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function bytesToBase64(bytes: Uint8Array): string {
|
|
11
|
+
let binary = ""
|
|
12
|
+
for (let index = 0; index < bytes.length; index += 0x8000) {
|
|
13
|
+
binary += String.fromCharCode(...bytes.subarray(index, index + 0x8000))
|
|
14
|
+
}
|
|
15
|
+
return btoa(binary)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function base64ToBytes(base64: string): Uint8Array {
|
|
19
|
+
const binary = atob(base64)
|
|
20
|
+
const bytes = new Uint8Array(binary.length)
|
|
21
|
+
for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index)
|
|
22
|
+
return bytes
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const ggbDataUrl = (base64: string) => `data:${GGB_MEDIA_TYPE};base64,${base64}`
|
|
26
|
+
|
|
27
|
+
/** The base64 payload of a data URL, or undefined for any other source (a file URL or "ggbid:" material). */
|
|
28
|
+
export function dataUrlPayload(src: string | undefined): string | undefined {
|
|
29
|
+
return src?.startsWith("data:") ? src.split(",").at(-1) : undefined
|
|
30
|
+
}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {customElement} from "lit/decorators.js"
|
|
2
|
+
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A GeoGebra 3D Graphing Calculator widget.
|
|
6
|
+
*/
|
|
7
|
+
@customElement("webwriter-geogebra-3d")
|
|
8
|
+
export class WebwriterGeogebra3d extends GeogebraApp {
|
|
9
|
+
constructor() {
|
|
10
|
+
super()
|
|
11
|
+
this.type = "3d" as const
|
|
12
|
+
this.showZoomButtons = true
|
|
13
|
+
this.showFullscreenButton = true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {customElement} from "lit/decorators.js"
|
|
2
|
-
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {customElement} from "lit/decorators.js"
|
|
2
|
+
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A GeoGebra Classic widget.
|
|
6
|
+
*/
|
|
7
|
+
@customElement("webwriter-geogebra-classic")
|
|
8
|
+
export class WebwriterGeogebraClassic extends GeogebraApp {
|
|
9
|
+
constructor() {
|
|
10
|
+
super()
|
|
11
|
+
this.type = "classic" as const
|
|
12
|
+
this.showZoomButtons = true
|
|
13
|
+
this.showFullscreenButton = true
|
|
14
|
+
}
|
|
9
15
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {customElement} from "lit/decorators.js"
|
|
2
|
-
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {customElement} from "lit/decorators.js"
|
|
2
|
+
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A GeoGebra Geometry widget.
|
|
6
|
+
*/
|
|
7
|
+
@customElement("webwriter-geogebra-geometry")
|
|
8
|
+
export class WebwriterGeogebraGeometry extends GeogebraApp {
|
|
9
|
+
constructor() {
|
|
10
|
+
super()
|
|
11
|
+
this.type = "geometry" as const
|
|
12
|
+
this.showZoomButtons = true
|
|
13
|
+
this.showFullscreenButton = true
|
|
14
|
+
}
|
|
9
15
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {customElement} from "lit/decorators.js"
|
|
2
|
-
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {customElement} from "lit/decorators.js"
|
|
2
|
+
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A GeoGebra Notes widget.
|
|
6
|
+
*/
|
|
7
|
+
@customElement("webwriter-geogebra-notes")
|
|
8
|
+
export class WebwriterGeogebraNotes extends GeogebraApp {
|
|
9
|
+
constructor() {
|
|
10
|
+
super()
|
|
11
|
+
this.type = "notes" as const
|
|
12
|
+
this.showZoomButtons = true
|
|
13
|
+
this.showFullscreenButton = true
|
|
14
|
+
}
|
|
9
15
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {customElement} from "lit/decorators.js"
|
|
2
|
-
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {customElement} from "lit/decorators.js"
|
|
2
|
+
import { GeogebraApp } from "../components/geogebra-app"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A GeoGebra Scientific Calculator widget.
|
|
6
|
+
*/
|
|
7
|
+
@customElement("webwriter-geogebra-scientific")
|
|
8
|
+
export class WebwriterGeogebraScientific extends GeogebraApp {
|
|
9
|
+
constructor() {
|
|
10
|
+
super()
|
|
11
|
+
this.type = "scientific" as const
|
|
12
|
+
this.showZoomButtons = true
|
|
13
|
+
this.showFullscreenButton = true
|
|
14
|
+
}
|
|
9
15
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {css} from "lit"
|
|
2
|
+
import {customElement} from "lit/decorators.js"
|
|
3
|
+
import { GeogebraApp } from "../components/geogebra-app"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A GeoGebra Calculator Suite widget.
|
|
7
|
+
*/
|
|
8
|
+
@customElement("webwriter-geogebra")
|
|
9
|
+
export class WebwriterGeogebra extends GeogebraApp {
|
|
10
|
+
constructor() {
|
|
11
|
+
super()
|
|
12
|
+
this.type = "suite" as const
|
|
13
|
+
this.showZoomButtons = true
|
|
14
|
+
this.showFullscreenButton = true
|
|
15
|
+
this.enableFileFeatures = false
|
|
16
|
+
this.enableUndoRedo = false
|
|
17
|
+
|
|
18
|
+
this.ggbStyles = css`
|
|
19
|
+
.button.undo, .button.redo {
|
|
20
|
+
display: none !important;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.GeoGebraFrame .toolbar .header-open-landscape .center, .GeoGebraFrame .toolbar .header-close-landscape .center {
|
|
24
|
+
top: 0 !important;
|
|
25
|
+
}
|
|
26
|
+
`.cssText
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/// <reference types="mocha" />
|
|
2
|
+
import "mocha/mocha.js";
|
|
3
|
+
import { assert } from "chai";
|
|
4
|
+
import { getMochaConfig } from "@webwriter/build/test";
|
|
5
|
+
import "../src/widgets/webwriter-geogebra-classic";
|
|
6
|
+
import { mountIn, unmountAll, SRC_A, SRC_B } from "./helpers";
|
|
7
|
+
import { bytesToBase64, base64ToBytes, isGgbArchive } from "../src/model/ggb-file";
|
|
8
|
+
|
|
9
|
+
mocha.setup(getMochaConfig());
|
|
10
|
+
|
|
11
|
+
const TAG = "webwriter-geogebra-classic";
|
|
12
|
+
const zip = new Uint8Array([0x50, 0x4b, 0x03, 0x04, 1, 2, 3, 4]);
|
|
13
|
+
const ggbFile = (bytes: Uint8Array, name = "valid.ggb") => new File([bytes as BlobPart], name, {type: ""});
|
|
14
|
+
|
|
15
|
+
describe("conversions", function () {
|
|
16
|
+
afterEach(unmountAll);
|
|
17
|
+
|
|
18
|
+
it("declares the same file keys in the runtime maps", function () {
|
|
19
|
+
const widget = customElements.get(TAG) as any;
|
|
20
|
+
assert.deepEqual(Object.keys(widget.convertFrom), [".ggb"]);
|
|
21
|
+
assert.deepEqual(Object.keys(widget.convertTo), [".ggb", "image/png", "image/svg+xml"]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("encodes and decodes the bytes of a construction", function () {
|
|
25
|
+
assert.equal(bytesToBase64(zip), btoa("PK\x03\x04\x01\x02\x03\x04"));
|
|
26
|
+
assert.deepEqual([...base64ToBytes(bytesToBase64(zip))], [...zip]);
|
|
27
|
+
assert.isFalse(isGgbArchive(new Uint8Array([1, 2, 3, 4, 5])));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("imports a .ggb file only when the apply function runs", async function () {
|
|
31
|
+
const widget = await mountIn(`<${TAG} src="https://example.org/a.ggb"></${TAG}>`, TAG);
|
|
32
|
+
const apply = await widget.importGgb(ggbFile(zip));
|
|
33
|
+
assert.equal(widget.src, "https://example.org/a.ggb");
|
|
34
|
+
apply();
|
|
35
|
+
assert.equal(widget.src, `data:application/vnd.geogebra.file;base64,${bytesToBase64(zip)}`);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("refuses a file that is no zip archive without touching the widget", async function () {
|
|
39
|
+
const widget = await mountIn(`<${TAG}></${TAG}>`, TAG);
|
|
40
|
+
let message = "";
|
|
41
|
+
try { await widget.importGgb(ggbFile(new TextEncoder().encode("not a zip"), "bad.ggb")) }
|
|
42
|
+
catch (error) { message = (error as Error).message }
|
|
43
|
+
assert.match(message, /GeoGebra construction/);
|
|
44
|
+
assert.isUndefined(widget.src);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("exports the construction as .ggb and round-trips it", async function () {
|
|
48
|
+
const widget = await mountIn(`<${TAG}></${TAG}>`, TAG);
|
|
49
|
+
assert.isNull(widget.exportGgb());
|
|
50
|
+
widget.src = SRC_A;
|
|
51
|
+
const fromSrc = widget.exportGgb() as File;
|
|
52
|
+
assert.equal(fromSrc.name, "construction.ggb");
|
|
53
|
+
assert.equal(new TextDecoder().decode(await fromSrc.arrayBuffer()), "AAAA");
|
|
54
|
+
widget.api = {getBase64: () => SRC_B.split(",")[1]};
|
|
55
|
+
const live = widget.exportGgb() as File;
|
|
56
|
+
assert.equal(new TextDecoder().decode(await live.arrayBuffer()), "BBBB");
|
|
57
|
+
// Round trip: the exported bytes are a valid import for a second widget.
|
|
58
|
+
const again = await mountIn(`<${TAG}></${TAG}>`, TAG);
|
|
59
|
+
widget.api = {getBase64: () => bytesToBase64(zip)};
|
|
60
|
+
(await again.importGgb(await widget.exportGgb()))();
|
|
61
|
+
assert.equal(again.src, `data:application/vnd.geogebra.file;base64,${bytesToBase64(zip)}`);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("exports the picture through the applet and declines without an applet", async function () {
|
|
65
|
+
const widget = await mountIn(`<${TAG}></${TAG}>`, TAG);
|
|
66
|
+
assert.isNull(widget.exportPng());
|
|
67
|
+
assert.isNull(widget.exportSvg());
|
|
68
|
+
widget.api = {
|
|
69
|
+
getPNGBase64: () => btoa("png"),
|
|
70
|
+
exportSVG: (callback: (svg: string) => void) => callback("<svg xmlns='http://www.w3.org/2000/svg'/>"),
|
|
71
|
+
};
|
|
72
|
+
const png = widget.exportPng() as File;
|
|
73
|
+
assert.equal(png.type, "image/png");
|
|
74
|
+
const svg = await widget.exportSvg() as File;
|
|
75
|
+
assert.equal(svg.type, "image/svg+xml");
|
|
76
|
+
assert.include(await svg.text(), "<svg");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
mocha.run();
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/// <reference types="mocha" />
|
|
2
|
+
import "mocha/mocha.js";
|
|
3
|
+
import { assert } from "chai";
|
|
4
|
+
import { getMochaConfig } from "@webwriter/build/test";
|
|
5
|
+
import "../src/widgets/webwriter-geogebra";
|
|
6
|
+
import { SRC_A, SRC_B, json, wait, until, mount, unmountAll, dataBlock } from "./helpers";
|
|
7
|
+
|
|
8
|
+
mocha.setup(getMochaConfig());
|
|
9
|
+
|
|
10
|
+
for (const mode of ["read", "edit"] as const) {
|
|
11
|
+
describe(`<webwriter-geogebra> data block (${mode} mode)`, function () {
|
|
12
|
+
const attrs = mode === "edit" ? ` contenteditable=""` : "";
|
|
13
|
+
|
|
14
|
+
beforeEach(function () {
|
|
15
|
+
document.designMode = mode === "edit" ? "on" : "off";
|
|
16
|
+
});
|
|
17
|
+
afterEach(unmountAll);
|
|
18
|
+
|
|
19
|
+
it("reads the data block on connect", async function () {
|
|
20
|
+
const el = await mount(`<webwriter-geogebra${attrs}><script type="application/json" slot="data">${json(SRC_A)}</script></webwriter-geogebra>`);
|
|
21
|
+
assert.isTrue(await until(() => el.src === SRC_A), `src is ${el.src}`);
|
|
22
|
+
assert.isFalse(el.hasAttribute("src"), "a data URL must not be reflected as an attribute");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("creates the data block when src is set", async function () {
|
|
26
|
+
const el = await mount(`<webwriter-geogebra${attrs}></webwriter-geogebra>`);
|
|
27
|
+
assert.isNull(dataBlock(el), "no block before a construction");
|
|
28
|
+
el.src = SRC_B;
|
|
29
|
+
assert.isTrue(await until(() => dataBlock(el)), "block was not created");
|
|
30
|
+
const block = dataBlock(el)!;
|
|
31
|
+
assert.equal(block.type, "application/json");
|
|
32
|
+
assert.equal(block.slot, "data");
|
|
33
|
+
assert.equal(JSON.parse(block.textContent!).src, SRC_B);
|
|
34
|
+
assert.isFalse(el.hasAttribute("src"), "a data URL must not be reflected as an attribute");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("replaces the value in the same block on a later src", async function () {
|
|
38
|
+
const el = await mount(`<webwriter-geogebra${attrs}><script type="application/json" slot="data">${json(SRC_A)}</script></webwriter-geogebra>`);
|
|
39
|
+
assert.isTrue(await until(() => el.src === SRC_A));
|
|
40
|
+
const block = dataBlock(el)!;
|
|
41
|
+
el.src = SRC_B;
|
|
42
|
+
assert.isTrue(await until(() => JSON.parse(block.textContent!).src === SRC_B), block.textContent!);
|
|
43
|
+
assert.strictEqual(dataBlock(el), block);
|
|
44
|
+
assert.equal(el.querySelectorAll("script").length, 1, "one block is kept");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("updates the widget when the block changes", async function () {
|
|
48
|
+
const el = await mount(`<webwriter-geogebra${attrs}><script type="application/json" slot="data">${json(SRC_A)}</script></webwriter-geogebra>`);
|
|
49
|
+
assert.isTrue(await until(() => el.src === SRC_A));
|
|
50
|
+
dataBlock(el)!.textContent = json(SRC_B);
|
|
51
|
+
assert.isTrue(await until(() => el.src === SRC_B), `src is ${el.src}`);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("keeps a file URL as an attribute and not in the block", async function () {
|
|
55
|
+
const el = await mount(`<webwriter-geogebra${attrs}></webwriter-geogebra>`);
|
|
56
|
+
el.src = "https://example.org/a.ggb";
|
|
57
|
+
assert.isTrue(await until(() => el.getAttribute("src") === "https://example.org/a.ggb"), "attribute");
|
|
58
|
+
await wait(300);
|
|
59
|
+
assert.isNull(dataBlock(el), "no block for a URL");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("keeps unknown keys in the block", async function () {
|
|
63
|
+
const el = await mount(`<webwriter-geogebra${attrs}><script type="application/json" slot="data">{"src":"${SRC_A}","other":1}</script></webwriter-geogebra>`);
|
|
64
|
+
assert.isTrue(await until(() => el.src === SRC_A));
|
|
65
|
+
el.src = SRC_B;
|
|
66
|
+
assert.isTrue(await until(() => JSON.parse(dataBlock(el)!.textContent!).src === SRC_B));
|
|
67
|
+
assert.equal(JSON.parse(dataBlock(el)!.textContent!).other, 1, dataBlock(el)!.textContent!);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
mocha.run();
|
package/tests/helpers.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const SRC_A = "data:application/vnd.geogebra.file;base64,QUFBQQ=="
|
|
2
|
+
export const SRC_B = "data:application/vnd.geogebra.file;base64,QkJCQg=="
|
|
3
|
+
|
|
4
|
+
export const json = (src: string) => JSON.stringify({src})
|
|
5
|
+
|
|
6
|
+
export const wait = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms))
|
|
7
|
+
|
|
8
|
+
export async function until(condition: () => unknown, ms = 20000) {
|
|
9
|
+
const end = performance.now() + ms
|
|
10
|
+
while (performance.now() < end) {
|
|
11
|
+
if (await condition()) return true
|
|
12
|
+
await wait(50)
|
|
13
|
+
}
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function mount<T extends HTMLElement = any>(html: string): Promise<T> {
|
|
18
|
+
const host = document.createElement("div")
|
|
19
|
+
host.className = "test-mount"
|
|
20
|
+
document.body.append(host)
|
|
21
|
+
host.innerHTML = html
|
|
22
|
+
const el = host.firstElementChild as any
|
|
23
|
+
await Promise.race([
|
|
24
|
+
customElements.whenDefined(el.localName),
|
|
25
|
+
wait(5000).then(() => { throw new Error(el.localName + " is not defined") })
|
|
26
|
+
])
|
|
27
|
+
await el.updateComplete
|
|
28
|
+
return el
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function unmountAll() {
|
|
32
|
+
document.querySelectorAll(".test-mount").forEach(host => host.remove())
|
|
33
|
+
document.designMode = "off"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const dataBlock = (el: Element) =>
|
|
37
|
+
el.querySelector<HTMLScriptElement>(':scope > script[type="application/json"][slot="data"]')
|
|
38
|
+
|
|
39
|
+
export async function mountIn<T extends HTMLElement = any>(html: string, selector: string): Promise<T> {
|
|
40
|
+
const host = document.createElement("div")
|
|
41
|
+
host.className = "test-mount"
|
|
42
|
+
document.body.append(host)
|
|
43
|
+
host.innerHTML = html
|
|
44
|
+
const el = host.querySelector(selector) as any
|
|
45
|
+
await customElements.whenDefined(selector)
|
|
46
|
+
await el.updateComplete
|
|
47
|
+
return el
|
|
48
|
+
}
|