@webwriter/geogebra 1.1.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -124
- package/custom-elements.json +2255 -1259
- package/dist/chunks/af-35CD6HFH.js +12 -0
- package/dist/chunks/am-JMDT5LI7.js +12 -0
- package/dist/chunks/ar-JL4QKYYL.js +12 -0
- package/dist/chunks/az-3SZS6WCY.js +12 -0
- package/dist/chunks/be-C4GWVHR2.js +12 -0
- package/dist/chunks/bg-6QGE5EQ4.js +12 -0
- package/dist/chunks/bn-UM2BV46R.js +12 -0
- package/dist/chunks/bs-XE2PWKCS.js +12 -0
- package/dist/chunks/ca-ZO2BQKPZ.js +12 -0
- package/dist/chunks/ca-balear-GJKWY5R7.js +12 -0
- package/dist/chunks/ca-valencia-CNQYSJSJ.js +12 -0
- package/dist/chunks/chunk-ANJTU3IB.js +203 -0
- package/dist/chunks/chunk-BSUFUO7E.js +65 -0
- package/dist/chunks/chunk-RYZMQM25.js +789 -0
- package/dist/chunks/cnr-MCZGASOD.js +12 -0
- package/dist/chunks/cs-4Q7FRISG.js +12 -0
- package/dist/chunks/cy-7VXG3AYH.js +12 -0
- package/dist/chunks/da-VDMHGBXD.js +12 -0
- package/dist/chunks/de-AT-YM5GCI75.js +12 -0
- package/dist/chunks/de-CH-LQNHTGYT.js +12 -0
- package/dist/chunks/de-GJT7RSHT.js +12 -0
- package/dist/chunks/el-ZVUVWEQ3.js +12 -0
- package/dist/chunks/en-AU-PCIYYC4M.js +12 -0
- package/dist/chunks/en-CA-37T7YUIL.js +12 -0
- package/dist/chunks/en-GB-ZYCA2CIZ.js +12 -0
- package/dist/chunks/en-IN-EPHXLNO6.js +12 -0
- package/dist/chunks/en-US-ECSJ5HDL.js +12 -0
- package/dist/chunks/es-5VBYK2HE.js +12 -0
- package/dist/chunks/et-OFQRRTW6.js +12 -0
- package/dist/chunks/eu-7TNOYFB7.js +12 -0
- package/dist/chunks/fa-KZU6GKWU.js +12 -0
- package/dist/chunks/fi-THJEKJPW.js +12 -0
- package/dist/chunks/fr-MUVVTBQZ.js +12 -0
- package/dist/chunks/ga-UWUVCWOT.js +12 -0
- package/dist/chunks/gl-NHQ52YCN.js +12 -0
- package/dist/chunks/gu-HVDD4QHO.js +12 -0
- package/dist/chunks/ha-2BPTATOZ.js +12 -0
- package/dist/chunks/he-MDESCUHJ.js +12 -0
- package/dist/chunks/hi-C6BGPR4Y.js +12 -0
- package/dist/chunks/hr-77MP3ELT.js +12 -0
- package/dist/chunks/hu-7PRNX6NB.js +12 -0
- package/dist/chunks/hy-R3VEL63L.js +12 -0
- package/dist/chunks/id-O6B2T3Y2.js +12 -0
- package/dist/chunks/is-XLNS5CAZ.js +12 -0
- package/dist/chunks/it-NZODUGUP.js +12 -0
- package/dist/chunks/ja-FFK5WXSB.js +12 -0
- package/dist/chunks/jv-GS3IRAIB.js +12 -0
- package/dist/chunks/ka-NWIJAO54.js +12 -0
- package/dist/chunks/kk-WQFRFG44.js +12 -0
- package/dist/chunks/km-AUKBN3YT.js +12 -0
- package/dist/chunks/kn-PKZFPECM.js +12 -0
- package/dist/chunks/ko-XNGAWKQ4.js +12 -0
- package/dist/chunks/ky-AQTYDJIL.js +12 -0
- package/dist/chunks/la-ERS7V4N4.js +12 -0
- package/dist/chunks/lb-KU3DVPI4.js +12 -0
- package/dist/chunks/locale-codes-TGY5LMYX.js +11 -0
- package/dist/chunks/lt-6RI4HSG3.js +12 -0
- package/dist/chunks/lv-RGIUQVA7.js +12 -0
- package/dist/chunks/mk-JMAYXTCL.js +12 -0
- package/dist/chunks/ml-5ZAIPAYV.js +12 -0
- package/dist/chunks/mn-N2GZBVDP.js +12 -0
- package/dist/chunks/mr-2SRCJIBC.js +12 -0
- package/dist/chunks/ms-WHD5PUQM.js +12 -0
- package/dist/chunks/mt-EXRK5UO6.js +12 -0
- package/dist/chunks/my-D2COGDRI.js +12 -0
- package/dist/chunks/nb-3XNBS2DU.js +12 -0
- package/dist/chunks/ne-PA4KUBGU.js +12 -0
- package/dist/chunks/nl-QMM3PBPM.js +12 -0
- package/dist/chunks/nn-CLFEMF2K.js +12 -0
- package/dist/chunks/no-CV376NZG.js +12 -0
- package/dist/chunks/or-KP7CET7X.js +12 -0
- package/dist/chunks/pa-CH5JYVXT.js +12 -0
- package/dist/chunks/pl-DDW4HT7M.js +12 -0
- package/dist/chunks/pt-BR-CVNA2MRU.js +12 -0
- package/dist/chunks/pt-CRTRYTDJ.js +12 -0
- package/dist/chunks/pt-PT-IZMPF3BY.js +12 -0
- package/dist/chunks/ro-FUOGHWJA.js +12 -0
- package/dist/chunks/ru-KAT4X5EC.js +12 -0
- package/dist/chunks/si-GDAXEOBK.js +12 -0
- package/dist/chunks/sk-CDSK6MY5.js +12 -0
- package/dist/chunks/sl-TFJQYNA4.js +12 -0
- package/dist/chunks/so-TXI6JJPW.js +12 -0
- package/dist/chunks/sq-KMM2QIRU.js +12 -0
- package/dist/chunks/sr-OTZNEL5Z.js +12 -0
- package/dist/chunks/sv-7CANJ6CF.js +12 -0
- package/dist/chunks/sw-5JDMTJ5K.js +12 -0
- package/dist/chunks/ta-HT4SO7PD.js +12 -0
- package/dist/chunks/te-FECCLHOI.js +12 -0
- package/dist/chunks/tg-FJWFJWF2.js +12 -0
- package/dist/chunks/th-JEP434LN.js +12 -0
- package/dist/chunks/tl-GN35ZR2F.js +12 -0
- package/dist/chunks/tr-IPVLQUE4.js +12 -0
- package/dist/chunks/uk-LHWPGFRV.js +12 -0
- package/dist/chunks/ur-7FU4XRAY.js +12 -0
- package/dist/chunks/uz-RO7XCKFE.js +12 -0
- package/dist/chunks/vi-5PHPTVV4.js +12 -0
- package/dist/chunks/zh-Hans-UM7MUEDB.js +12 -0
- package/dist/chunks/zh-Hant-7M2P4G7R.js +12 -0
- package/dist/chunks/zh-LHCPWZN2.js +12 -0
- package/dist/widgets/webwriter-geogebra-3d.js +19 -25827
- package/dist/widgets/webwriter-geogebra-classic.js +18 -25826
- package/dist/widgets/webwriter-geogebra-geometry.js +18 -25826
- package/dist/widgets/webwriter-geogebra-notes.js +18 -25826
- package/dist/widgets/webwriter-geogebra-scientific.js +18 -25826
- package/dist/widgets/webwriter-geogebra.js +20 -25830
- package/editing-config.json +839 -20
- package/lit-localize.json +73 -9
- package/localization/af.xlf +290 -0
- package/localization/am.xlf +290 -0
- package/localization/ar.xlf +271 -6
- package/localization/az.xlf +290 -0
- package/localization/be.xlf +290 -0
- package/localization/bg.xlf +271 -6
- package/localization/bn.xlf +290 -0
- package/localization/bs.xlf +290 -0
- package/localization/ca-balear.xlf +290 -0
- package/localization/ca-valencia.xlf +290 -0
- package/localization/ca.xlf +290 -0
- package/localization/cnr.xlf +290 -0
- package/localization/cs.xlf +271 -6
- package/localization/cy.xlf +290 -0
- package/localization/da.xlf +271 -6
- package/localization/de-AT.xlf +294 -0
- package/localization/de-CH.xlf +294 -0
- package/localization/de.xlf +271 -6
- package/localization/el.xlf +271 -6
- package/localization/es.xlf +271 -6
- package/localization/et.xlf +271 -6
- package/localization/eu.xlf +290 -0
- package/localization/fa.xlf +290 -0
- package/localization/fi.xlf +271 -6
- package/localization/fr.xlf +271 -6
- package/localization/ga.xlf +290 -0
- package/localization/generated/af.ts +16 -0
- package/localization/generated/am.ts +16 -0
- package/localization/generated/ar.ts +6 -12
- package/localization/generated/az.ts +16 -0
- package/localization/generated/be.ts +16 -0
- package/localization/generated/bg.ts +6 -12
- package/localization/generated/bn.ts +16 -0
- package/localization/generated/bs.ts +16 -0
- package/localization/generated/ca-balear.ts +16 -0
- package/localization/generated/ca-valencia.ts +16 -0
- package/localization/generated/ca.ts +16 -0
- package/localization/generated/cnr.ts +16 -0
- package/localization/generated/cs.ts +6 -12
- package/localization/generated/cy.ts +16 -0
- package/localization/generated/da.ts +6 -12
- package/localization/generated/de-AT.ts +16 -0
- package/localization/generated/de-CH.ts +16 -0
- package/localization/generated/de.ts +6 -11
- package/localization/generated/el.ts +6 -12
- package/localization/generated/en-AU.ts +16 -0
- package/localization/generated/en-CA.ts +16 -0
- package/localization/generated/en-GB.ts +16 -0
- package/localization/generated/en-IN.ts +16 -0
- package/localization/generated/en-US.ts +16 -0
- package/localization/generated/es.ts +6 -12
- package/localization/generated/et.ts +6 -12
- package/localization/generated/eu.ts +16 -0
- package/localization/generated/fa.ts +16 -0
- package/localization/generated/fi.ts +6 -12
- package/localization/generated/fr.ts +6 -12
- package/localization/generated/ga.ts +16 -0
- package/localization/generated/gl.ts +16 -0
- package/localization/generated/gu.ts +16 -0
- package/localization/generated/ha.ts +16 -0
- package/localization/generated/he.ts +16 -0
- package/localization/generated/hi.ts +16 -0
- package/localization/generated/hr.ts +16 -0
- package/localization/generated/hu.ts +6 -12
- package/localization/generated/hy.ts +16 -0
- package/localization/generated/id.ts +6 -12
- package/localization/generated/is.ts +16 -0
- package/localization/generated/it.ts +6 -12
- package/localization/generated/ja.ts +6 -12
- package/localization/generated/jv.ts +16 -0
- package/localization/generated/ka.ts +16 -0
- package/localization/generated/kk.ts +16 -0
- package/localization/generated/km.ts +16 -0
- package/localization/generated/kn.ts +16 -0
- package/localization/generated/ko.ts +6 -12
- package/localization/generated/ky.ts +16 -0
- package/localization/generated/la.ts +16 -0
- package/localization/generated/lb.ts +16 -0
- package/localization/generated/locale-codes.ts +211 -0
- package/localization/generated/lt.ts +6 -12
- package/localization/generated/lv.ts +6 -12
- package/localization/generated/mk.ts +16 -0
- package/localization/generated/ml.ts +16 -0
- package/localization/generated/mn.ts +16 -0
- package/localization/generated/mr.ts +16 -0
- package/localization/generated/ms.ts +16 -0
- package/localization/generated/mt.ts +16 -0
- package/localization/generated/my.ts +16 -0
- package/localization/generated/nb.ts +6 -12
- package/localization/generated/ne.ts +16 -0
- package/localization/generated/nl.ts +6 -12
- package/localization/generated/nn.ts +16 -0
- package/localization/generated/no.ts +16 -0
- package/localization/generated/or.ts +16 -0
- package/localization/generated/pa.ts +16 -0
- package/localization/generated/pl.ts +6 -12
- package/localization/generated/pt-BR.ts +6 -12
- package/localization/generated/pt-PT.ts +6 -12
- package/localization/generated/pt.ts +16 -0
- package/localization/generated/ro.ts +6 -12
- package/localization/generated/ru.ts +6 -12
- package/localization/generated/si.ts +16 -0
- package/localization/generated/sk.ts +6 -12
- package/localization/generated/sl.ts +6 -12
- package/localization/generated/so.ts +16 -0
- package/localization/generated/sq.ts +16 -0
- package/localization/generated/sr.ts +16 -0
- package/localization/generated/sv.ts +6 -12
- package/localization/generated/sw.ts +16 -0
- package/localization/generated/ta.ts +16 -0
- package/localization/generated/te.ts +16 -0
- package/localization/generated/tg.ts +16 -0
- package/localization/generated/th.ts +16 -0
- package/localization/generated/tl.ts +16 -0
- package/localization/generated/tr.ts +6 -12
- package/localization/generated/uk.ts +6 -12
- package/localization/generated/ur.ts +16 -0
- package/localization/generated/uz.ts +16 -0
- package/localization/generated/vi.ts +16 -0
- package/localization/generated/zh-Hans.ts +16 -0
- package/localization/generated/zh-Hant.ts +16 -0
- package/localization/generated/zh.ts +16 -0
- package/localization/gl.xlf +290 -0
- package/localization/gu.xlf +290 -0
- package/localization/ha.xlf +290 -0
- package/localization/he.xlf +290 -0
- package/localization/hi.xlf +290 -0
- package/localization/hr.xlf +290 -0
- package/localization/hu.xlf +271 -6
- package/localization/hy.xlf +290 -0
- package/localization/id.xlf +271 -6
- package/localization/is.xlf +290 -0
- package/localization/it.xlf +271 -6
- package/localization/ja.xlf +271 -6
- package/localization/jv.xlf +290 -0
- package/localization/ka.xlf +290 -0
- package/localization/kk.xlf +290 -0
- package/localization/km.xlf +290 -0
- package/localization/kn.xlf +290 -0
- package/localization/ko.xlf +271 -6
- package/localization/ky.xlf +290 -0
- package/localization/la.xlf +290 -0
- package/localization/lb.xlf +290 -0
- package/localization/lt.xlf +271 -6
- package/localization/lv.xlf +271 -6
- package/localization/mk.xlf +290 -0
- package/localization/ml.xlf +290 -0
- package/localization/mn.xlf +290 -0
- package/localization/mr.xlf +290 -0
- package/localization/ms.xlf +290 -0
- package/localization/mt.xlf +290 -0
- package/localization/my.xlf +290 -0
- package/localization/nb.xlf +271 -6
- package/localization/ne.xlf +290 -0
- package/localization/nl.xlf +271 -6
- package/localization/nn.xlf +290 -0
- package/localization/no.xlf +295 -0
- package/localization/or.xlf +290 -0
- package/localization/pa.xlf +290 -0
- package/localization/pl.xlf +271 -6
- package/localization/pt-BR.xlf +271 -6
- package/localization/pt-PT.xlf +271 -6
- package/localization/pt.xlf +295 -0
- package/localization/ro.xlf +271 -6
- package/localization/ru.xlf +271 -6
- package/localization/si.xlf +290 -0
- package/localization/sk.xlf +271 -6
- package/localization/sl.xlf +271 -6
- package/localization/so.xlf +290 -0
- package/localization/sq.xlf +290 -0
- package/localization/sr.xlf +290 -0
- package/localization/sv.xlf +271 -6
- package/localization/sw.xlf +290 -0
- package/localization/ta.xlf +290 -0
- package/localization/te.xlf +290 -0
- package/localization/tg.xlf +290 -0
- package/localization/th.xlf +290 -0
- package/localization/tl.xlf +290 -0
- package/localization/tr.xlf +271 -6
- package/localization/uk.xlf +271 -6
- package/localization/ur.xlf +290 -0
- package/localization/uz.xlf +290 -0
- package/localization/vi.xlf +290 -0
- package/localization/zh-Hans.xlf +295 -0
- package/localization/zh-Hant.xlf +295 -0
- package/localization/zh.xlf +295 -0
- package/package.json +194 -86
- package/src/components/geogebra-app.styles.ts +47 -0
- package/{components → src/components}/geogebra-app.ts +237 -332
- package/src/model/geogebra-api.ts +148 -0
- package/src/model/geogebra-options.ts +72 -0
- package/src/model/geogebra-parameters.ts +53 -0
- package/src/model/ggb-file.ts +30 -0
- package/src/types.d.ts +3 -0
- package/{widgets → src/widgets}/webwriter-geogebra-3d.ts +1 -1
- package/{widgets → src/widgets}/webwriter-geogebra.ts +1 -2
- package/tests/conversions.test.ts +80 -0
- package/tests/data-block.test.ts +72 -0
- package/tests/helpers.ts +48 -0
- package/tests/language.test.ts +49 -0
- package/tests/presentation.test.ts +114 -0
- package/tsconfig.json +3 -7
- package/assets/icons/file-earmark-arrow-up.svg +0 -4
- package/components/geogebra-app.styles.ts +0 -10
- package/components/geogebra-options.styles.ts +0 -37
- package/components/geogebra-options.ts +0 -187
- package/custom.d.ts +0 -180
- package/dist/widgets/webwriter-geogebra-3d.css +0 -444
- package/dist/widgets/webwriter-geogebra-classic.css +0 -444
- package/dist/widgets/webwriter-geogebra-geometry.css +0 -444
- package/dist/widgets/webwriter-geogebra-notes.css +0 -444
- package/dist/widgets/webwriter-geogebra-scientific.css +0 -444
- package/dist/widgets/webwriter-geogebra.css +0 -444
- package/localization/generated/locale-codes.js +0 -83
- package/localization/generated/zh-hans.ts +0 -20
- package/localization/generated/zh-hant.ts +0 -20
- package/localization/zh-hans.xlf +0 -30
- package/localization/zh-hant.xlf +0 -30
- package/widgets/webwriter-geogebra-evaluator.ts +0 -15
- /package/.github/workflows/{main.yml → publish.yml} +0 -0
- /package/localization/pkg/{zh-hans.xliff → zh-Hans.xliff} +0 -0
- /package/localization/pkg/{zh-hant.xliff → zh-Hant.xliff} +0 -0
- /package/localization/snippets/{zh-hans.xliff → zh-Hans.xliff} +0 -0
- /package/localization/snippets/{zh-hant.xliff → zh-Hant.xliff} +0 -0
- /package/{utils → src/model}/boolean-attribute-converter.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-classic.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-geometry.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-notes.ts +0 -0
- /package/{widgets → src/widgets}/webwriter-geogebra-scientific.ts +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
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 { SRC_A, dataBlock, 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("keeps the applet mounted when a construction edit is saved", async function () {
|
|
45
|
+
const widget = await mountIn(`<webwriter-geogebra-classic></webwriter-geogebra-classic>`, "webwriter-geogebra-classic");
|
|
46
|
+
const frame = widget.shadowRoot.querySelector("iframe");
|
|
47
|
+
let constructionEdited: (() => void) | undefined;
|
|
48
|
+
const api = Object.assign(fakeApi([]), {
|
|
49
|
+
registerUpdateListener: (callback: () => void) => { constructionEdited = callback; },
|
|
50
|
+
getBase64: () => SRC_A.split(",")[1],
|
|
51
|
+
setBase64: () => assert.fail("the saved construction is already loaded"),
|
|
52
|
+
});
|
|
53
|
+
connect(widget, api);
|
|
54
|
+
|
|
55
|
+
constructionEdited!();
|
|
56
|
+
assert.isTrue(await until(() => JSON.parse(dataBlock(widget)?.textContent ?? "{}").src === SRC_A));
|
|
57
|
+
await widget.updateComplete;
|
|
58
|
+
assert.strictEqual(widget.shadowRoot.querySelector("iframe"), frame);
|
|
59
|
+
assert.isTrue(widget.shadowRoot.querySelector(".applet").hasAttribute("data-ready"));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("updates live options and rebuilds for initialization settings", async function () {
|
|
63
|
+
const widget = await mountIn(`<webwriter-geogebra-classic></webwriter-geogebra-classic>`, "webwriter-geogebra-classic");
|
|
64
|
+
const frame = widget.shadowRoot.querySelector("iframe");
|
|
65
|
+
const toolbarChanges: boolean[] = [];
|
|
66
|
+
connect(widget, Object.assign(fakeApi([]), {
|
|
67
|
+
showToolBar: (visible: boolean) => toolbarChanges.push(visible),
|
|
68
|
+
}));
|
|
69
|
+
widget.showToolBar = false;
|
|
70
|
+
await widget.updateComplete;
|
|
71
|
+
|
|
72
|
+
assert.deepEqual(toolbarChanges, [false]);
|
|
73
|
+
assert.strictEqual(widget.shadowRoot.querySelector("iframe"), frame);
|
|
74
|
+
widget.showMenuBar = true;
|
|
75
|
+
assert.isTrue(await until(() => widget.shadowRoot.querySelector("iframe") !== frame));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("sizes the applet to the container at 300 and 2100 px", async function () {
|
|
79
|
+
this.timeout(15000);
|
|
80
|
+
const widget = await mountIn(`<div style="width: 300px"><webwriter-geogebra-classic></webwriter-geogebra-classic></div>`, "webwriter-geogebra-classic");
|
|
81
|
+
const calls: number[][] = [];
|
|
82
|
+
connect(widget, fakeApi(calls));
|
|
83
|
+
assert.isTrue(await until(() => calls.length > 0, 3000));
|
|
84
|
+
assert.equal(calls.at(-1)![0], 300);
|
|
85
|
+
assert.isAtLeast(calls.at(-1)![1], 288);
|
|
86
|
+
(widget.parentElement as HTMLElement).style.width = "2100px";
|
|
87
|
+
assert.isTrue(await until(() => calls.at(-1)![0] === 2100, 3000));
|
|
88
|
+
assert.isAtLeast(calls.at(-1)![1], 1100);
|
|
89
|
+
const count = calls.length;
|
|
90
|
+
await wait(300);
|
|
91
|
+
assert.equal(calls.length, count, "no further resize without a size change");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("shows the print note only when no applet is loaded, and only on paper", async function () {
|
|
95
|
+
const widget = await mountIn(`<webwriter-geogebra-classic></webwriter-geogebra-classic>`, "webwriter-geogebra-classic");
|
|
96
|
+
const applet = widget.shadowRoot.querySelector(".applet");
|
|
97
|
+
const note = widget.shadowRoot.querySelector(".print-note");
|
|
98
|
+
assert.isFalse(applet.hasAttribute("data-ready"));
|
|
99
|
+
assert.equal(getComputedStyle(note).display, "none");
|
|
100
|
+
const frame = widget.shadowRoot.querySelector("iframe");
|
|
101
|
+
connect(widget, fakeApi([]));
|
|
102
|
+
await widget.updateComplete;
|
|
103
|
+
await wait(200);
|
|
104
|
+
assert.isTrue(applet.hasAttribute("data-ready"), "loading the applet must not trigger a reload");
|
|
105
|
+
assert.strictEqual(widget.shadowRoot.querySelector("iframe"), frame);
|
|
106
|
+
const rules = widget.shadowRoot.adoptedStyleSheets.flatMap((sheet: CSSStyleSheet) => [...sheet.cssRules]).filter((rule: CSSRule) => rule instanceof CSSMediaRule && rule.media.mediaText === "print");
|
|
107
|
+
const text = rules.map((rule: CSSMediaRule) => rule.cssText).join("\n");
|
|
108
|
+
assert.include(text, ".applet:not([data-ready]) .print-note");
|
|
109
|
+
assert.include(text, ".applet:not([data-ready]) iframe");
|
|
110
|
+
assert.include(text, "break-inside: avoid");
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
mocha.run();
|
package/tsconfig.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-arrow-up" viewBox="0 0 16 16">
|
|
2
|
-
<path d="M8.5 11.5a.5.5 0 0 1-1 0V7.707L6.354 8.854a.5.5 0 1 1-.708-.708l2-2a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 7.707z"/>
|
|
3
|
-
<path d="M14 14V4.5L9.5 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2M9.5 3A1.5 1.5 0 0 0 11 4.5h2V14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h5.5z"/>
|
|
4
|
-
</svg>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { css } from "lit";
|
|
2
|
-
|
|
3
|
-
export const geogebraOptionsStyles = css`
|
|
4
|
-
div {
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
gap: 0.5em;
|
|
8
|
-
}
|
|
9
|
-
input {
|
|
10
|
-
display: none;
|
|
11
|
-
}
|
|
12
|
-
sl-button {
|
|
13
|
-
width: 100%;
|
|
14
|
-
}
|
|
15
|
-
sl-button::part(label) {
|
|
16
|
-
text-overflow: ellipsis;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
}
|
|
20
|
-
sl-switch {
|
|
21
|
-
margin-left: 2px;
|
|
22
|
-
}
|
|
23
|
-
.hidden {
|
|
24
|
-
display: none;
|
|
25
|
-
}
|
|
26
|
-
sl-details,
|
|
27
|
-
sl-input::part(form-control-label),
|
|
28
|
-
sl-select::part(form-control-label),
|
|
29
|
-
sl-switch::part(label) {
|
|
30
|
-
font-size: 1rem;
|
|
31
|
-
}
|
|
32
|
-
sl-details::part(content) {
|
|
33
|
-
display: flex;
|
|
34
|
-
flex-direction: column;
|
|
35
|
-
gap: 0.5em;
|
|
36
|
-
}
|
|
37
|
-
`
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { msg } from "@lit/localize";
|
|
2
|
-
import { SlButton, SlChangeEvent, SlDetails, SlIcon, SlInput, SlOption, SlSelect, SlSwitch } from "@shoelace-style/shoelace";
|
|
3
|
-
import { LitElementWw } from "@webwriter/lit";
|
|
4
|
-
import { html } from "lit";
|
|
5
|
-
import FileEarmarkArrowUp from "../assets/icons/file-earmark-arrow-up.svg"
|
|
6
|
-
import { geogebraOptionsStyles } from "./geogebra-options.styles";
|
|
7
|
-
import { property } from "lit/decorators.js";
|
|
8
|
-
|
|
9
|
-
export interface PropertyConfig {
|
|
10
|
-
name: string
|
|
11
|
-
type: "boolean" | "number" | "string" | "select"
|
|
12
|
-
options?: string[]
|
|
13
|
-
value: number | string | boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class GeogebraOptions extends LitElementWw {
|
|
17
|
-
protected static get scopedElements() {
|
|
18
|
-
return {
|
|
19
|
-
"sl-button": SlButton,
|
|
20
|
-
"sl-icon": SlIcon,
|
|
21
|
-
"sl-switch": SlSwitch,
|
|
22
|
-
"sl-details": SlDetails,
|
|
23
|
-
"sl-select": SlSelect,
|
|
24
|
-
"sl-option": SlOption,
|
|
25
|
-
"sl-input": SlInput
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static styles = geogebraOptionsStyles
|
|
30
|
-
|
|
31
|
-
@property({type: Boolean})
|
|
32
|
-
accessor visible: boolean = false
|
|
33
|
-
|
|
34
|
-
@property({type: Array})
|
|
35
|
-
accessor properties: PropertyConfig[] = []
|
|
36
|
-
|
|
37
|
-
private formatLabel(name: string): string {
|
|
38
|
-
const customLabels: Map<string,string> = new Map([
|
|
39
|
-
["enable3d", "Enable 3D"],
|
|
40
|
-
["enableCAS", "Enable CAS"],
|
|
41
|
-
["useBrowserForJs", "Use Browser for JS"],
|
|
42
|
-
["disabledJavaScript", "Disable JavaScript"],
|
|
43
|
-
])
|
|
44
|
-
if(customLabels.has(name)) {
|
|
45
|
-
return customLabels.get(name)!
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return name
|
|
49
|
-
.replace(/([A-Z])/g, ' $1')
|
|
50
|
-
.replace(/^./, str => str.toUpperCase())
|
|
51
|
-
.trim()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private handleFileImport(e: SlChangeEvent) {
|
|
55
|
-
const input = e.target as HTMLInputElement
|
|
56
|
-
const file = input.files?.item(0)
|
|
57
|
-
if(!file) return
|
|
58
|
-
|
|
59
|
-
const reader = new FileReader()
|
|
60
|
-
reader.onload = () => {
|
|
61
|
-
const base64 = (reader.result as string).split(",").at(-1)
|
|
62
|
-
this.dispatchEvent(new CustomEvent("import-file", {
|
|
63
|
-
detail: {base64},
|
|
64
|
-
bubbles: true,
|
|
65
|
-
composed: true
|
|
66
|
-
}))
|
|
67
|
-
}
|
|
68
|
-
reader.readAsDataURL(file)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private handlePropertyChange(name: string, e: Event) {
|
|
72
|
-
const target = e.target as any
|
|
73
|
-
let newValue: string | boolean | number
|
|
74
|
-
|
|
75
|
-
const prop = this.properties.find(p => p.name === name)
|
|
76
|
-
if(!prop) return
|
|
77
|
-
|
|
78
|
-
switch(prop.type) {
|
|
79
|
-
case "boolean":
|
|
80
|
-
newValue = target.checked
|
|
81
|
-
break
|
|
82
|
-
case "number":
|
|
83
|
-
newValue = parseFloat(target.value)
|
|
84
|
-
break
|
|
85
|
-
default:
|
|
86
|
-
newValue = target.value
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.dispatchEvent(new CustomEvent("property-change", {
|
|
90
|
-
detail: {
|
|
91
|
-
name,
|
|
92
|
-
value: newValue
|
|
93
|
-
},
|
|
94
|
-
bubbles: true,
|
|
95
|
-
composed: true
|
|
96
|
-
}))
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private renderPropertyInput(prop) {
|
|
100
|
-
const label = this.formatLabel(prop.name)
|
|
101
|
-
|
|
102
|
-
switch(prop.type) {
|
|
103
|
-
case "boolean":
|
|
104
|
-
return html`
|
|
105
|
-
<sl-switch
|
|
106
|
-
?checked=${prop.value}
|
|
107
|
-
@sl-change=${(e: Event) => {this.handlePropertyChange(prop.name, e)}}
|
|
108
|
-
>
|
|
109
|
-
${label}
|
|
110
|
-
</sl-switch>
|
|
111
|
-
`
|
|
112
|
-
|
|
113
|
-
case "number":
|
|
114
|
-
return html`
|
|
115
|
-
<sl-input
|
|
116
|
-
type="number"
|
|
117
|
-
size="small"
|
|
118
|
-
label=${label}
|
|
119
|
-
value=${prop.value ?? ""}
|
|
120
|
-
@sl-change=${(e: Event) => this.handlePropertyChange(prop.name, e)}
|
|
121
|
-
></sl-input>
|
|
122
|
-
`
|
|
123
|
-
|
|
124
|
-
case "select":
|
|
125
|
-
return html`
|
|
126
|
-
<sl-select
|
|
127
|
-
label=${label}
|
|
128
|
-
size="small"
|
|
129
|
-
value=${prop.value ?? ""}
|
|
130
|
-
@sl-change=${(e: Event) => this.handlePropertyChange(prop.name, e)}
|
|
131
|
-
>
|
|
132
|
-
${prop.options?.map(opt => html`
|
|
133
|
-
<sl-option value=${opt}>${opt}</sl-option>
|
|
134
|
-
`)}
|
|
135
|
-
</sl-select>
|
|
136
|
-
`
|
|
137
|
-
|
|
138
|
-
case "string":
|
|
139
|
-
default:
|
|
140
|
-
return html`
|
|
141
|
-
<sl-input
|
|
142
|
-
type="text"
|
|
143
|
-
size="small"
|
|
144
|
-
label=${label}
|
|
145
|
-
value=${prop.value ?? ""}
|
|
146
|
-
@sl-change=${(e: Event) => this.handlePropertyChange(prop.name, e)}
|
|
147
|
-
></sl-input>
|
|
148
|
-
`
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private renderPropertyInputs() {
|
|
153
|
-
return html`${this.properties.map(prop => this.renderPropertyInput(prop))}`
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
render() {
|
|
157
|
-
return html`
|
|
158
|
-
<div class=${this.visible ? "" : "hidden"}>
|
|
159
|
-
<input type="file" accept=".ggb" id="ggb-upload" name="ggb-upload" @change=${this.handleFileImport}>
|
|
160
|
-
<sl-button @click=${
|
|
161
|
-
() => {
|
|
162
|
-
const input = this.renderRoot.querySelector("#ggb-upload") as HTMLInputElement
|
|
163
|
-
input.value = ""
|
|
164
|
-
input.click()
|
|
165
|
-
}
|
|
166
|
-
}>
|
|
167
|
-
<sl-icon src=${FileEarmarkArrowUp} slot="prefix"></sl-icon>
|
|
168
|
-
${msg("Import GeoGebra File")}
|
|
169
|
-
</sl-button>
|
|
170
|
-
|
|
171
|
-
<sl-details summary=${msg("Advanced Settings")}>
|
|
172
|
-
<p>
|
|
173
|
-
${msg("These settings are not relevant for most users and should not usually be changed. Changing them can completely break your applet.")}
|
|
174
|
-
${msg(html`See the
|
|
175
|
-
<a
|
|
176
|
-
href="https://geogebra.github.io/docs/reference/en/GeoGebra_App_Parameters/"
|
|
177
|
-
target="_blank">
|
|
178
|
-
GeoGebra docs</a>
|
|
179
|
-
for more information.`
|
|
180
|
-
)}
|
|
181
|
-
</p>
|
|
182
|
-
${this.renderPropertyInputs()}
|
|
183
|
-
</sl-details>
|
|
184
|
-
</div>
|
|
185
|
-
`
|
|
186
|
-
}
|
|
187
|
-
}
|
package/custom.d.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
declare module '*.apng' {
|
|
2
|
-
const content: string;
|
|
3
|
-
export default content;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.jpg' {
|
|
6
|
-
const content: string;
|
|
7
|
-
export default content;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.jpeg' {
|
|
10
|
-
const content: string;
|
|
11
|
-
export default content;
|
|
12
|
-
}
|
|
13
|
-
declare module '*.jfif' {
|
|
14
|
-
const content: string;
|
|
15
|
-
export default content;
|
|
16
|
-
}
|
|
17
|
-
declare module '*.pjpeg' {
|
|
18
|
-
const content: string;
|
|
19
|
-
export default content;
|
|
20
|
-
}
|
|
21
|
-
declare module '*.pjp' {
|
|
22
|
-
const content: string;
|
|
23
|
-
export default content;
|
|
24
|
-
}
|
|
25
|
-
declare module '*.png' {
|
|
26
|
-
const content: string;
|
|
27
|
-
export default content;
|
|
28
|
-
}
|
|
29
|
-
declare module '*.svg' {
|
|
30
|
-
const content: string;
|
|
31
|
-
export default content;
|
|
32
|
-
}
|
|
33
|
-
declare module '*.webp' {
|
|
34
|
-
const content: string;
|
|
35
|
-
export default content;
|
|
36
|
-
}
|
|
37
|
-
declare module '*.bmp' {
|
|
38
|
-
const content: string;
|
|
39
|
-
export default content;
|
|
40
|
-
}
|
|
41
|
-
declare module '*.ico' {
|
|
42
|
-
const content: string;
|
|
43
|
-
export default content;
|
|
44
|
-
}
|
|
45
|
-
declare module '*.cur' {
|
|
46
|
-
const content: string;
|
|
47
|
-
export default content;
|
|
48
|
-
}
|
|
49
|
-
declare module '*.tif' {
|
|
50
|
-
const content: string;
|
|
51
|
-
export default content;
|
|
52
|
-
}
|
|
53
|
-
declare module '*.tiff' {
|
|
54
|
-
const content: string;
|
|
55
|
-
export default content;
|
|
56
|
-
}
|
|
57
|
-
declare module '*.wav' {
|
|
58
|
-
const content: string;
|
|
59
|
-
export default content;
|
|
60
|
-
}
|
|
61
|
-
declare module '*.wave' {
|
|
62
|
-
const content: string;
|
|
63
|
-
export default content;
|
|
64
|
-
}
|
|
65
|
-
declare module '*.mp3' {
|
|
66
|
-
const content: string;
|
|
67
|
-
export default content;
|
|
68
|
-
}
|
|
69
|
-
declare module '*.aac' {
|
|
70
|
-
const content: string;
|
|
71
|
-
export default content;
|
|
72
|
-
}
|
|
73
|
-
declare module '*.aacp' {
|
|
74
|
-
const content: string;
|
|
75
|
-
export default content;
|
|
76
|
-
}
|
|
77
|
-
declare module '*.oga' {
|
|
78
|
-
const content: string;
|
|
79
|
-
export default content;
|
|
80
|
-
}
|
|
81
|
-
declare module '*.flac' {
|
|
82
|
-
const content: string;
|
|
83
|
-
export default content;
|
|
84
|
-
}
|
|
85
|
-
declare module '*.weba' {
|
|
86
|
-
const content: string;
|
|
87
|
-
export default content;
|
|
88
|
-
}
|
|
89
|
-
declare module '*.mp4' {
|
|
90
|
-
const content: string;
|
|
91
|
-
export default content;
|
|
92
|
-
}
|
|
93
|
-
declare module '*.webm' {
|
|
94
|
-
const content: string;
|
|
95
|
-
export default content;
|
|
96
|
-
}
|
|
97
|
-
declare module '*.avif' {
|
|
98
|
-
const content: string;
|
|
99
|
-
export default content;
|
|
100
|
-
}
|
|
101
|
-
declare module '*.gif' {
|
|
102
|
-
const content: string;
|
|
103
|
-
export default content;
|
|
104
|
-
}
|
|
105
|
-
declare module '*.mov' {
|
|
106
|
-
const content: string;
|
|
107
|
-
export default content;
|
|
108
|
-
}
|
|
109
|
-
declare module '*.avi' {
|
|
110
|
-
const content: string;
|
|
111
|
-
export default content;
|
|
112
|
-
}
|
|
113
|
-
declare module '*.ogv' {
|
|
114
|
-
const content: string;
|
|
115
|
-
export default content;
|
|
116
|
-
}
|
|
117
|
-
declare module '*.mkv' {
|
|
118
|
-
const content: string;
|
|
119
|
-
export default content;
|
|
120
|
-
}
|
|
121
|
-
declare module '*.opus' {
|
|
122
|
-
const content: string;
|
|
123
|
-
export default content;
|
|
124
|
-
}
|
|
125
|
-
declare module '*.mpeg' {
|
|
126
|
-
const content: string;
|
|
127
|
-
export default content;
|
|
128
|
-
}
|
|
129
|
-
declare module '*.woff' {
|
|
130
|
-
const content: string;
|
|
131
|
-
export default content;
|
|
132
|
-
}
|
|
133
|
-
declare module '*.woff2' {
|
|
134
|
-
const content: string;
|
|
135
|
-
export default content;
|
|
136
|
-
}
|
|
137
|
-
declare module '*.ttf' {
|
|
138
|
-
const content: string;
|
|
139
|
-
export default content;
|
|
140
|
-
}
|
|
141
|
-
declare module '*.otf' {
|
|
142
|
-
const content: string;
|
|
143
|
-
export default content;
|
|
144
|
-
}
|
|
145
|
-
declare module '*.pdf' {
|
|
146
|
-
const content: string;
|
|
147
|
-
export default content;
|
|
148
|
-
}
|
|
149
|
-
declare module '*.json' {
|
|
150
|
-
const content: {[key: string]: any};
|
|
151
|
-
export default content;
|
|
152
|
-
}
|
|
153
|
-
declare module '*.jsonld' {
|
|
154
|
-
const content: {[key: string]: any};
|
|
155
|
-
export default content;
|
|
156
|
-
}
|
|
157
|
-
declare module '*.txt' {
|
|
158
|
-
const content: string;
|
|
159
|
-
export default content;
|
|
160
|
-
}
|
|
161
|
-
declare module '*.csv' {
|
|
162
|
-
const content: string;
|
|
163
|
-
export default content;
|
|
164
|
-
}
|
|
165
|
-
declare module '*.htm' {
|
|
166
|
-
const content: string;
|
|
167
|
-
export default content;
|
|
168
|
-
}
|
|
169
|
-
declare module '*.html' {
|
|
170
|
-
const content: string;
|
|
171
|
-
export default content;
|
|
172
|
-
}
|
|
173
|
-
declare module '*.xml' {
|
|
174
|
-
const content: string;
|
|
175
|
-
export default content;
|
|
176
|
-
}
|
|
177
|
-
declare module 'inline:*' {
|
|
178
|
-
const content: string;
|
|
179
|
-
export default content;
|
|
180
|
-
}
|