@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,49 @@
|
|
|
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/widgets/webwriter-geogebra-geometry";
|
|
7
|
+
import { until, mount, mountIn, unmountAll } from "./helpers";
|
|
8
|
+
|
|
9
|
+
mocha.setup(getMochaConfig());
|
|
10
|
+
|
|
11
|
+
describe("language and declarations", function () {
|
|
12
|
+
afterEach(unmountAll);
|
|
13
|
+
|
|
14
|
+
it("lang on an ancestor selects the catalog and the drawer text", async function () {
|
|
15
|
+
const widget = await mountIn(`<div lang="de"><webwriter-geogebra></webwriter-geogebra></div>`, "webwriter-geogebra");
|
|
16
|
+
await widget.updateComplete;
|
|
17
|
+
let changed = 0;
|
|
18
|
+
widget.addEventListener("optionschange", () => changed++, true);
|
|
19
|
+
assert.isTrue(await until(() => widget.localize.getLocale() === "de"), `locale ${widget.localize.getLocale()}`);
|
|
20
|
+
assert.isTrue(await until(() => widget.options.enableRightClick.label._ !== "Enable right click"), "label stays English");
|
|
21
|
+
const german = widget.options.enableRightClick.label._;
|
|
22
|
+
widget.parentElement.setAttribute("lang", "fr");
|
|
23
|
+
assert.isTrue(await until(() => widget.localize.getLocale() === "fr"), "locale fr");
|
|
24
|
+
assert.isTrue(await until(() => widget.options.enableRightClick.label._ !== german), "label did not change with the language");
|
|
25
|
+
assert.isAbove(changed, 0, "optionschange was not sent");
|
|
26
|
+
assert.isFalse(widget.hasAttribute("lang"), "an inherited language must not be written to the widget");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("the applet language follows the tag and a bad tag falls back", async function () {
|
|
30
|
+
const widget = await mountIn(`<div lang="de-AT"><webwriter-geogebra-geometry></webwriter-geogebra-geometry></div>`, "webwriter-geogebra-geometry");
|
|
31
|
+
await widget.updateComplete;
|
|
32
|
+
assert.equal(widget.ggbProperties.language, "de");
|
|
33
|
+
assert.equal(widget.ggbProperties.country, "AT");
|
|
34
|
+
widget.parentElement.setAttribute("lang", "not a tag");
|
|
35
|
+
await widget.updateComplete;
|
|
36
|
+
assert.equal(widget.ggbProperties.language, "en");
|
|
37
|
+
assert.equal(widget.localize.getLocale(), "en");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("still declares the options and actions", async function () {
|
|
41
|
+
const el = await mount(`<webwriter-geogebra></webwriter-geogebra>`);
|
|
42
|
+
assert.equal(el.options.type.control, "select");
|
|
43
|
+
assert.equal(el.options.enableRightClick.type, Boolean);
|
|
44
|
+
assert.isOk(el.options.showToolBar);
|
|
45
|
+
assert.equal(el.actions.importConstruction.input.accept, ".ggb");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
mocha.run();
|
|
@@ -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, until, wait } from "./helpers";
|
|
7
|
+
|
|
8
|
+
mocha.setup(getMochaConfig());
|
|
9
|
+
|
|
10
|
+
describe("presentation", function () {
|
|
11
|
+
afterEach(unmountAll);
|
|
12
|
+
|
|
13
|
+
it("takes font and color from the theme and keeps the host size limits", async function () {
|
|
14
|
+
const widget = await mountIn(
|
|
15
|
+
`<div style="--ww-text-color: rgb(1, 2, 3); --ww-font-family: Georgia"><webwriter-geogebra-classic></webwriter-geogebra-classic></div>`,
|
|
16
|
+
"webwriter-geogebra-classic",
|
|
17
|
+
);
|
|
18
|
+
const host = getComputedStyle(widget);
|
|
19
|
+
assert.equal(host.color, "rgb(1, 2, 3)");
|
|
20
|
+
assert.include(host.fontFamily, "Georgia");
|
|
21
|
+
assert.equal(host.display, "block");
|
|
22
|
+
assert.equal(host.minWidth, "300px");
|
|
23
|
+
assert.equal(host.maxWidth, "2100px");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("exposes the applet as a named, labelled part", async function () {
|
|
27
|
+
const widget = await mountIn(`<webwriter-geogebra-classic></webwriter-geogebra-classic>`, "webwriter-geogebra-classic");
|
|
28
|
+
const frame = widget.shadowRoot.querySelector("iframe");
|
|
29
|
+
assert.equal(frame.getAttribute("part"), "applet");
|
|
30
|
+
assert.ok(frame.title);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("keeps its runtime state out of the authored attributes and focuses the applet", async function () {
|
|
34
|
+
const widget = await mountIn(`<webwriter-geogebra-classic></webwriter-geogebra-classic>`, "webwriter-geogebra-classic");
|
|
35
|
+
widget.focus();
|
|
36
|
+
assert.equal(widget.shadowRoot.activeElement, widget.shadowRoot.querySelector("iframe"));
|
|
37
|
+
assert.deepEqual([...widget.attributes].map((attribute: Attr) => attribute.name).filter((name: string) => name.startsWith("data-")), []);
|
|
38
|
+
});
|
|
39
|
+
const fakeApi = (calls: number[][]) => new Proxy({setSize: (width: number, height: number) => calls.push([width, height])} as Record<string, unknown>, {
|
|
40
|
+
get: (target, key: string) => key in target ? target[key] : () => undefined,
|
|
41
|
+
});
|
|
42
|
+
const connect = (widget: any, api: unknown) => widget.dispatchEvent(new CustomEvent("ggb-load", {detail: {api}}));
|
|
43
|
+
|
|
44
|
+
it("sizes the applet to the container at 300 and 2100 px", async function () {
|
|
45
|
+
this.timeout(15000);
|
|
46
|
+
const widget = await mountIn(`<div style="width: 300px"><webwriter-geogebra-classic></webwriter-geogebra-classic></div>`, "webwriter-geogebra-classic");
|
|
47
|
+
const calls: number[][] = [];
|
|
48
|
+
connect(widget, fakeApi(calls));
|
|
49
|
+
assert.isTrue(await until(() => calls.length > 0, 3000));
|
|
50
|
+
assert.equal(calls.at(-1)![0], 300);
|
|
51
|
+
assert.isAtLeast(calls.at(-1)![1], 288);
|
|
52
|
+
(widget.parentElement as HTMLElement).style.width = "2100px";
|
|
53
|
+
assert.isTrue(await until(() => calls.at(-1)![0] === 2100, 3000));
|
|
54
|
+
assert.isAtLeast(calls.at(-1)![1], 1100);
|
|
55
|
+
const count = calls.length;
|
|
56
|
+
await wait(300);
|
|
57
|
+
assert.equal(calls.length, count, "no further resize without a size change");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("shows the print note only when no applet is loaded, and only on paper", async function () {
|
|
61
|
+
const widget = await mountIn(`<webwriter-geogebra-classic></webwriter-geogebra-classic>`, "webwriter-geogebra-classic");
|
|
62
|
+
const applet = widget.shadowRoot.querySelector(".applet");
|
|
63
|
+
const note = widget.shadowRoot.querySelector(".print-note");
|
|
64
|
+
assert.isFalse(applet.hasAttribute("data-ready"));
|
|
65
|
+
assert.equal(getComputedStyle(note).display, "none");
|
|
66
|
+
const frame = widget.shadowRoot.querySelector("iframe");
|
|
67
|
+
connect(widget, fakeApi([]));
|
|
68
|
+
await widget.updateComplete;
|
|
69
|
+
await wait(200);
|
|
70
|
+
assert.isTrue(applet.hasAttribute("data-ready"), "loading the applet must not trigger a reload");
|
|
71
|
+
assert.strictEqual(widget.shadowRoot.querySelector("iframe"), frame);
|
|
72
|
+
const rules = widget.shadowRoot.adoptedStyleSheets.flatMap((sheet: CSSStyleSheet) => [...sheet.cssRules]).filter((rule: CSSRule) => rule instanceof CSSMediaRule && rule.media.mediaText === "print");
|
|
73
|
+
const text = rules.map((rule: CSSMediaRule) => rule.cssText).join("\n");
|
|
74
|
+
assert.include(text, ".applet:not([data-ready]) .print-note");
|
|
75
|
+
assert.include(text, ".applet:not([data-ready]) iframe");
|
|
76
|
+
assert.include(text, "break-inside: avoid");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
mocha.run();
|
package/tsconfig.json
CHANGED
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import {LitElement, html, css, PropertyValues} from "lit"
|
|
2
|
-
import {LitElementWw, option} from "@webwriter/lit"
|
|
3
|
-
import {customElement, property, query, queryAsync} from "lit/decorators.js"
|
|
4
|
-
|
|
5
|
-
export interface GeogebraAPI {
|
|
6
|
-
evalCommand(cmdString: string): boolean
|
|
7
|
-
evalLaTex(input: string): boolean
|
|
8
|
-
evalCommandGetLabels(cmdString: string): string
|
|
9
|
-
evalCommandCAS(text: string): string
|
|
10
|
-
insertEmbed(type: string, uri: string): void
|
|
11
|
-
deleteObject(objName: string): void
|
|
12
|
-
setAuxiliary(geo: any, status: boolean): void
|
|
13
|
-
setValue(objName: string, value: number): void
|
|
14
|
-
setTextValue(objName: string, value: string): void
|
|
15
|
-
setListValue(objName: string, i: number, value: number): void
|
|
16
|
-
setCoords(objName: string, x: number, y: number, z?: number): void
|
|
17
|
-
setCaption(objName: string, caption: string): void
|
|
18
|
-
setColor(objName: string, red: number, green: number, blue: number): void
|
|
19
|
-
setVisible(objName: string, visible: boolean): void
|
|
20
|
-
setLabelVisible(objName: string, visible: boolean): void
|
|
21
|
-
setLabelStyle(objName: string, style: 0 | 1 | 2 | 3): void
|
|
22
|
-
setFixed(objName: string, fixed: boolean, selectionAllowed: boolean): void
|
|
23
|
-
setTrace(objName: string, flag: boolean): void
|
|
24
|
-
renameObject(oldObjName: string, newObjName: string): boolean
|
|
25
|
-
setLayer(objName: string, layer: number): void
|
|
26
|
-
setLayerVisible(objName: string, visible: boolean): void
|
|
27
|
-
setLineStyle(objName: string, style: 0 | 1 | 2 | 3 | 4): void
|
|
28
|
-
setLineThickness(objName: string, thickness: -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13): void
|
|
29
|
-
setPointStyle(objName: string, size: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): void
|
|
30
|
-
setPointSize(objName: string, size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): void
|
|
31
|
-
setDisplayStyle(objName: string, style: string): void
|
|
32
|
-
setFilling(objName: string, filling: number): void
|
|
33
|
-
getPNGBase64(exportScale: number, transparent?: boolean, dpi?: number): string
|
|
34
|
-
exportSVG(filename: string): void
|
|
35
|
-
exportSVG(callback: CallableFunction): void
|
|
36
|
-
exportPDF(scale: number, filename: string, sliderLabel?: string): void
|
|
37
|
-
exportPDF(scale: number, callback: CallableFunction, sliderLabel?: string): void
|
|
38
|
-
getScreenshotBase64(callback: CallableFunction): void
|
|
39
|
-
writePNGtoFile(fileName: string, exportScale?: number, transparent?: boolean, dpi?: number): boolean
|
|
40
|
-
isIndependent(objName: string): boolean
|
|
41
|
-
isMovable(objName: string): boolean
|
|
42
|
-
showAllObjects(): void
|
|
43
|
-
registerEmbedResolver(type: string, callback: CallableFunction): void
|
|
44
|
-
setAnimating(objName: string, animate: boolean): void
|
|
45
|
-
setAnimationSpeed(objName: string, speed: number): void
|
|
46
|
-
startAnimation(): void
|
|
47
|
-
stopAnimation(): void
|
|
48
|
-
isAnimationRunning(): boolean
|
|
49
|
-
getXcoord(objName: string): number
|
|
50
|
-
getYcoord(objName: string): number
|
|
51
|
-
getZcoord(objName: string): number
|
|
52
|
-
getValue(objName: string): number
|
|
53
|
-
getListValue(objName: string, index: number): number
|
|
54
|
-
getColor(objName: string): string
|
|
55
|
-
getVisible(objName: string): boolean
|
|
56
|
-
getValueString(objName: string, useLocalizedInput?: boolean): string
|
|
57
|
-
getDefinitionString(objName: string): string
|
|
58
|
-
getCommandString(objName: string, useLocalizedInput?: boolean): string
|
|
59
|
-
getLaTeXString(objName: string, value: boolean): string
|
|
60
|
-
getObjectType(objName: string): string
|
|
61
|
-
exists(objName: string): boolean
|
|
62
|
-
isDefined(objName: string): boolean
|
|
63
|
-
getAllObjectNames(type?: string): string[]
|
|
64
|
-
getObjectNumber(): number
|
|
65
|
-
getCASObjectNumber(): number
|
|
66
|
-
getObjectName(i: number): string
|
|
67
|
-
getLayer(objName: string): string
|
|
68
|
-
getLineStyle(objName: string): 0 | 1 | 2 | 3 | 4
|
|
69
|
-
getLineThickness(objName: string): -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
|
|
70
|
-
getPointStyle(objName: string): -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
71
|
-
getPointSize(objName: string): 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
72
|
-
getFilling(objName: string): number
|
|
73
|
-
getCaption(objName: string, substitutePlaceholders?: boolean): string
|
|
74
|
-
getLabelStyle(objName: string): 0 | 1 | 2 | 3
|
|
75
|
-
getLabelVisible(): boolean
|
|
76
|
-
isInteractive(objName: string): boolean
|
|
77
|
-
setMode(mode: number): void
|
|
78
|
-
getMode(): number
|
|
79
|
-
reset(): void
|
|
80
|
-
newConstruction(): void
|
|
81
|
-
refreshViews(): void
|
|
82
|
-
setOnTheFlyPointCreationActive(flag: boolean): void
|
|
83
|
-
setPointCapture(view: -1 | 1 | 2, mode: 0 | 1 | 2 | 3): void
|
|
84
|
-
setRounding(round: string): void
|
|
85
|
-
hideCursorWhenDragging(flag: boolean): void
|
|
86
|
-
setRepaintingActive(flag: boolean): void
|
|
87
|
-
setErrorDialogsActive(flag: boolean): void
|
|
88
|
-
setCoordSystem(xmin: number, xmax: number, ymin: number, ymax: number, zmin?: number, zmax?: number, yVertical?: boolean): void
|
|
89
|
-
setAxesVisible(xAxis: boolean, yAxis: boolean, zAxis?: boolean): void
|
|
90
|
-
setUndoPoint(): void
|
|
91
|
-
setAxisLabels(viewNumber: number, xAxis: string, yAxis: string, zAxis: string): void
|
|
92
|
-
setAxisSteps(viewNumber: number, xAxis: number, yAxis: number, zAxis: number): void
|
|
93
|
-
setAxisUnits(viewNumber: number, xAxis: string, yAxis: string, zAxis: string): void
|
|
94
|
-
setGridVisible(flag: boolean): void
|
|
95
|
-
setGridVisible(viewNumber: number, flag: boolean): void
|
|
96
|
-
getGridVisible(viewNumber: number): boolean
|
|
97
|
-
getPerspectiveXML(): string
|
|
98
|
-
undo(): void
|
|
99
|
-
redo(): void
|
|
100
|
-
showToolBar(show: boolean): void
|
|
101
|
-
setCustomToolBar(toolbar: string): void
|
|
102
|
-
addCustomTool(iconURL: string, name: string, category?: string, callback?: CallableFunction): void
|
|
103
|
-
showMenuBar(show: boolean): void
|
|
104
|
-
showAlgebraInput(show: boolean): void
|
|
105
|
-
showResetIcon(show: boolean): void
|
|
106
|
-
enableRightClick(enable: boolean): void
|
|
107
|
-
enableLabelDrags(enable: boolean): void
|
|
108
|
-
enableShiftDragZoom(enable: boolean): void
|
|
109
|
-
enableCAS(enable: boolean): void
|
|
110
|
-
enable3D(enable: boolean): void
|
|
111
|
-
setPerspective(perspective: string): void
|
|
112
|
-
setWidth(width: number): void
|
|
113
|
-
setHeight(height: number): void
|
|
114
|
-
setSize(width: number, height: number): void
|
|
115
|
-
recalculateEnvironments(): void
|
|
116
|
-
getEditorState(): any
|
|
117
|
-
setEditorState(state: any): void
|
|
118
|
-
getGraphicsOptions(viewId: number): any
|
|
119
|
-
setGraphicsOptions(viewID: number, options: any): void
|
|
120
|
-
setAlgebraOptions(options: any): void
|
|
121
|
-
registerAddListener(func: CallableFunction): void
|
|
122
|
-
unregisterAddListener(func: CallableFunction): void
|
|
123
|
-
registerRemoveListener(func: CallableFunction): void
|
|
124
|
-
unregisterRemoveListener(func: CallableFunction): void
|
|
125
|
-
registerUpdateListener(func: CallableFunction): void
|
|
126
|
-
unregisterUpdateListener(func: CallableFunction): void
|
|
127
|
-
registerClickListener(func: CallableFunction): void
|
|
128
|
-
unregisterClickListener(func: CallableFunction): void
|
|
129
|
-
registerObjectUpdateListener(objName: string, func: CallableFunction): void
|
|
130
|
-
unregisterObjectUpdateListener(objName: string): void
|
|
131
|
-
registerObjectClickListener(objName: string, func: CallableFunction): void
|
|
132
|
-
unregisterObjectClickListener(objName: string): void
|
|
133
|
-
registerRenameListener(func: CallableFunction): void
|
|
134
|
-
unregisterRenameListener(func: CallableFunction): void
|
|
135
|
-
registerClearListener(func: CallableFunction): void
|
|
136
|
-
unregisterClearListener(func: CallableFunction): void
|
|
137
|
-
registerStoreUndoListener(func: CallableFunction): void
|
|
138
|
-
unregisterStoreUndoListener(func: CallableFunction): void
|
|
139
|
-
registerClientListener(func: CallableFunction): void
|
|
140
|
-
unregisterClientListener(func: CallableFunction): void
|
|
141
|
-
evalXML(xmlString: string): void
|
|
142
|
-
setXML(xmlString: string): void
|
|
143
|
-
getXML(objName?: string): string
|
|
144
|
-
getAlgorithmXML(objName: string): string
|
|
145
|
-
getFileJSON(): any
|
|
146
|
-
setFileJSON(content: any): void
|
|
147
|
-
getBase64(callback?: CallableFunction): string
|
|
148
|
-
setBase64(value: string, callback?: CallableFunction): void
|
|
149
|
-
debug(str: string): void
|
|
150
|
-
getVersion(): string
|
|
151
|
-
remove(): void
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export class GeogebraApp extends LitElementWw {
|
|
155
|
-
|
|
156
|
-
static styles = css`
|
|
157
|
-
iframe {
|
|
158
|
-
border: none;
|
|
159
|
-
width: 100%;
|
|
160
|
-
aspect-ratio: 16/9;
|
|
161
|
-
}
|
|
162
|
-
`
|
|
163
|
-
|
|
164
|
-
@property({type: String})
|
|
165
|
-
ggbStyles: string
|
|
166
|
-
|
|
167
|
-
@property({reflect: true})
|
|
168
|
-
type: "classic" | "geometry" | "3d" | "suite" | "evaluator" | "scientific" | "notes" = "classic"
|
|
169
|
-
|
|
170
|
-
@property({type: Number, reflect: true})
|
|
171
|
-
width: number = 800
|
|
172
|
-
|
|
173
|
-
@property({type: Number, reflect: true})
|
|
174
|
-
height: number = 450
|
|
175
|
-
|
|
176
|
-
@property({type: String, attribute: true, reflect: true}) // base64, material ID, file url
|
|
177
|
-
accessor src: string
|
|
178
|
-
|
|
179
|
-
@property({type: String, reflect: true})
|
|
180
|
-
borderColor: string = "gray"
|
|
181
|
-
|
|
182
|
-
@property({type: Number, reflect: true})
|
|
183
|
-
borderRadius: number = 1
|
|
184
|
-
|
|
185
|
-
@property({type: Boolean, reflect: true})
|
|
186
|
-
enableRightClick = true
|
|
187
|
-
|
|
188
|
-
@property({type: Boolean, reflect: true})
|
|
189
|
-
enableLabelDrags = true
|
|
190
|
-
|
|
191
|
-
@property({type: Boolean, reflect: true})
|
|
192
|
-
enableShiftDragZoom = true
|
|
193
|
-
|
|
194
|
-
@property({type: Boolean, reflect: true})
|
|
195
|
-
showZoomButtons = false
|
|
196
|
-
|
|
197
|
-
@property({type: Boolean, reflect: true})
|
|
198
|
-
errorDialogsActive = true
|
|
199
|
-
|
|
200
|
-
@property({type: Boolean, reflect: true})
|
|
201
|
-
showMenuBar = false
|
|
202
|
-
|
|
203
|
-
@property({type: Boolean, reflect: true})
|
|
204
|
-
showToolBar = false
|
|
205
|
-
|
|
206
|
-
@property({type: Boolean, reflect: true})
|
|
207
|
-
showToolBarHelp = false
|
|
208
|
-
|
|
209
|
-
@property({type: String, reflect: true})
|
|
210
|
-
customToolBar: string
|
|
211
|
-
|
|
212
|
-
@property({type: Boolean, reflect: true})
|
|
213
|
-
showAlgebraInput = true
|
|
214
|
-
|
|
215
|
-
@property({type: Boolean, reflect: true})
|
|
216
|
-
showResetIcon = false
|
|
217
|
-
|
|
218
|
-
@property({type: String, reflect: true})
|
|
219
|
-
language: String
|
|
220
|
-
|
|
221
|
-
@property({type: String, reflect: true})
|
|
222
|
-
country: String
|
|
223
|
-
|
|
224
|
-
@property({type: String, reflect: true})
|
|
225
|
-
appletId: String
|
|
226
|
-
|
|
227
|
-
@property({type: Boolean, reflect: true})
|
|
228
|
-
allowStyleBar = false
|
|
229
|
-
|
|
230
|
-
@property({type: Boolean, reflect: true})
|
|
231
|
-
randomize = true
|
|
232
|
-
|
|
233
|
-
@property({type: Number, reflect: true})
|
|
234
|
-
randomSeed: number
|
|
235
|
-
|
|
236
|
-
@property({type: Boolean, reflect: true})
|
|
237
|
-
useBrowserForJs = false
|
|
238
|
-
|
|
239
|
-
@property({type: Boolean, reflect: true})
|
|
240
|
-
showLogging = false
|
|
241
|
-
|
|
242
|
-
@property({type: Number, reflect: true})
|
|
243
|
-
capturingThreshold = 3
|
|
244
|
-
|
|
245
|
-
@property({type: Boolean, reflect: true})
|
|
246
|
-
enableFileFeatures = true
|
|
247
|
-
|
|
248
|
-
@property({type: Boolean, reflect: true})
|
|
249
|
-
enableUndoRedo = true
|
|
250
|
-
|
|
251
|
-
@property({type: String, reflect: true})
|
|
252
|
-
perspective: String
|
|
253
|
-
|
|
254
|
-
@property({type: Boolean, reflect: true})
|
|
255
|
-
enable3d: boolean
|
|
256
|
-
|
|
257
|
-
@property({type: Boolean, reflect: true})
|
|
258
|
-
enableCAS: boolean
|
|
259
|
-
|
|
260
|
-
@property({type: String, reflect: true})
|
|
261
|
-
algebraInputPosition: "algebra" | "top" | "bottom"
|
|
262
|
-
|
|
263
|
-
@property({type: Boolean, reflect: true})
|
|
264
|
-
preventFocus = false
|
|
265
|
-
|
|
266
|
-
@property({type: String, reflect: true})
|
|
267
|
-
scaleContainerClass: string
|
|
268
|
-
|
|
269
|
-
@property({type: Boolean, reflect: true})
|
|
270
|
-
autoHeight = true
|
|
271
|
-
|
|
272
|
-
@property({type: Boolean, reflect: true})
|
|
273
|
-
allowUpscale = false
|
|
274
|
-
|
|
275
|
-
@property({type: Boolean, reflect: true})
|
|
276
|
-
playButton = false
|
|
277
|
-
|
|
278
|
-
@property({type: Number, reflect: true})
|
|
279
|
-
scale = 1
|
|
280
|
-
|
|
281
|
-
@property({type: Boolean, reflect: true})
|
|
282
|
-
showAnimationButton = false
|
|
283
|
-
|
|
284
|
-
@property({type: Boolean, reflect: true})
|
|
285
|
-
showFullscreenButton = false
|
|
286
|
-
|
|
287
|
-
@property({type: Boolean, reflect: true})
|
|
288
|
-
showSuggestionButtons = false
|
|
289
|
-
|
|
290
|
-
@property({type: Boolean, reflect: true})
|
|
291
|
-
showStartTooltip = false
|
|
292
|
-
|
|
293
|
-
@property({type: String, reflect: true})
|
|
294
|
-
rounding: string
|
|
295
|
-
|
|
296
|
-
@property({type: Boolean, reflect: true})
|
|
297
|
-
buttonShadows = false
|
|
298
|
-
|
|
299
|
-
@property({type: Number, reflect: true})
|
|
300
|
-
buttonRounding: Number = 0.2
|
|
301
|
-
|
|
302
|
-
@property({type: String, reflect: true})
|
|
303
|
-
buttonBorderColor: string
|
|
304
|
-
|
|
305
|
-
@property({type: String, reflect: true})
|
|
306
|
-
editorBackgroundColor: string
|
|
307
|
-
|
|
308
|
-
@property({type: String, reflect: true})
|
|
309
|
-
editorForegroundColor: string
|
|
310
|
-
|
|
311
|
-
@property({type: Boolean, reflect: true})
|
|
312
|
-
textmode = false
|
|
313
|
-
|
|
314
|
-
@property({type: Boolean, reflect: true})
|
|
315
|
-
showKeyboardOnFocus: boolean
|
|
316
|
-
|
|
317
|
-
@property({type: String, reflect: true})
|
|
318
|
-
keyboardType: "scientific" | "normal" | "notes"
|
|
319
|
-
|
|
320
|
-
@property({type: Boolean, reflect: true})
|
|
321
|
-
transparentGraphics = false
|
|
322
|
-
|
|
323
|
-
@property({type: Boolean, reflect: true})
|
|
324
|
-
disabledJavaScript = false
|
|
325
|
-
|
|
326
|
-
@property({type: String, reflect: true})
|
|
327
|
-
detachedKeyboardParent: string
|
|
328
|
-
|
|
329
|
-
private get ggbProperties() {
|
|
330
|
-
const {appletId: id, type: appName, width, height, borderColor, borderRadius, enableLabelDrags, enableShiftDragZoom, showZoomButtons, errorDialogsActive, showMenuBar, showToolBar, showToolBarHelp, customToolBar, showAlgebraInput, showResetIcon, language, 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} = this
|
|
331
|
-
|
|
332
|
-
let filename: string, material_id: string, ggbBase64: string
|
|
333
|
-
if(this.src && this.src.startsWith("data:")) {
|
|
334
|
-
ggbBase64 = this.src.split(",").at(-1)
|
|
335
|
-
}
|
|
336
|
-
else if(this.src && this.src.startsWith("ggbid:")) {
|
|
337
|
-
material_id = this.src.slice("ggbid:".length)
|
|
338
|
-
}
|
|
339
|
-
else if(this.src) {
|
|
340
|
-
filename = this.src
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
return {id, appName, filename, material_id, ggbBase64, width, height, borderColor, borderRadius, 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}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
updateSrc = () => {
|
|
347
|
-
if(!this.updatingGgb) {
|
|
348
|
-
this.src = `data:application/vnd.geogebra.file;base64,${this.api.getBase64()}`
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
connectedCallback(): void {
|
|
353
|
-
super.connectedCallback()
|
|
354
|
-
this.apiReady = new Promise(r => {
|
|
355
|
-
this.addEventListener("ggb-load", (e: any) => {
|
|
356
|
-
r(e.detail.api)
|
|
357
|
-
this.api = e.detail.api
|
|
358
|
-
this.api.registerAddListener(this.updateSrc)
|
|
359
|
-
this.api.registerClearListener(this.updateSrc)
|
|
360
|
-
this.api.registerUpdateListener(this.updateSrc)
|
|
361
|
-
this.api.registerRenameListener(this.updateSrc)
|
|
362
|
-
this.api.registerRemoveListener(this.updateSrc)
|
|
363
|
-
})
|
|
364
|
-
})
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
updatingGgb = false
|
|
368
|
-
|
|
369
|
-
protected updated(changed: PropertyValues): void {
|
|
370
|
-
|
|
371
|
-
if(changed.has("src") && this.src && this.src.split(",").at(-1) !== this?.api?.getBase64()) {
|
|
372
|
-
this.updatingGgb = true
|
|
373
|
-
this?.api?.setBase64(this.src.split(",").at(-1), () => this.updatingGgb = false)
|
|
374
|
-
}
|
|
375
|
-
else if(changed.has("src") && !this.src) {
|
|
376
|
-
this.updatingGgb = true
|
|
377
|
-
this?.api?.setBase64("", () => this.updatingGgb = false)
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
apiReady: Promise<GeogebraAPI>
|
|
382
|
-
api?: GeogebraAPI
|
|
383
|
-
|
|
384
|
-
initializeIFrame(e: Event) {
|
|
385
|
-
const iframe = e.target as HTMLIFrameElement
|
|
386
|
-
const doc = iframe.contentDocument
|
|
387
|
-
const win = iframe.contentWindow
|
|
388
|
-
doc.body.style.margin = "0"
|
|
389
|
-
if(this.ggbStyles) {
|
|
390
|
-
const style = doc.createElement("style")
|
|
391
|
-
style.textContent = this.ggbStyles
|
|
392
|
-
doc.head.append(style)
|
|
393
|
-
}
|
|
394
|
-
doc.body.addEventListener("focusin", () => this.dispatchEvent(new FocusEvent("focus", {bubbles: true, composed: true})))
|
|
395
|
-
const ggbEl = doc.createElement("div")
|
|
396
|
-
ggbEl.id = "ggb-element"
|
|
397
|
-
doc.body.append(ggbEl);
|
|
398
|
-
const deployScript = doc.createElement("script")
|
|
399
|
-
deployScript.src = "https://www.geogebra.org/apps/deployggb.js"
|
|
400
|
-
deployScript.addEventListener("load", () => {
|
|
401
|
-
const createScript = doc.createElement("script")
|
|
402
|
-
createScript.textContent = `
|
|
403
|
-
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}}))})
|
|
404
|
-
applet.inject("ggb-element")
|
|
405
|
-
`
|
|
406
|
-
doc.addEventListener("ggb-load", (e: any) => this.dispatchEvent(new CustomEvent("ggb-load", {bubbles: true, composed: true, detail: e.detail})))
|
|
407
|
-
doc.body.append(createScript)
|
|
408
|
-
})
|
|
409
|
-
doc.body.append(deployScript)
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
render() {
|
|
413
|
-
return html`
|
|
414
|
-
<iframe id="ggb" @load=${this.initializeIFrame}></iframe>
|
|
415
|
-
`
|
|
416
|
-
}
|
|
417
|
-
}
|