@webwriter/geogebra 1.1.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +280 -124
  2. package/custom-elements.json +2255 -1259
  3. package/dist/chunks/af-35CD6HFH.js +12 -0
  4. package/dist/chunks/am-JMDT5LI7.js +12 -0
  5. package/dist/chunks/ar-JL4QKYYL.js +12 -0
  6. package/dist/chunks/az-3SZS6WCY.js +12 -0
  7. package/dist/chunks/be-C4GWVHR2.js +12 -0
  8. package/dist/chunks/bg-6QGE5EQ4.js +12 -0
  9. package/dist/chunks/bn-UM2BV46R.js +12 -0
  10. package/dist/chunks/bs-XE2PWKCS.js +12 -0
  11. package/dist/chunks/ca-ZO2BQKPZ.js +12 -0
  12. package/dist/chunks/ca-balear-GJKWY5R7.js +12 -0
  13. package/dist/chunks/ca-valencia-CNQYSJSJ.js +12 -0
  14. package/dist/chunks/chunk-ACU6XINJ.js +781 -0
  15. package/dist/chunks/chunk-ANJTU3IB.js +203 -0
  16. package/dist/chunks/chunk-BSUFUO7E.js +65 -0
  17. package/dist/chunks/cnr-MCZGASOD.js +12 -0
  18. package/dist/chunks/cs-4Q7FRISG.js +12 -0
  19. package/dist/chunks/cy-7VXG3AYH.js +12 -0
  20. package/dist/chunks/da-VDMHGBXD.js +12 -0
  21. package/dist/chunks/de-AT-YM5GCI75.js +12 -0
  22. package/dist/chunks/de-CH-LQNHTGYT.js +12 -0
  23. package/dist/chunks/de-GJT7RSHT.js +12 -0
  24. package/dist/chunks/el-ZVUVWEQ3.js +12 -0
  25. package/dist/chunks/en-AU-PCIYYC4M.js +12 -0
  26. package/dist/chunks/en-CA-37T7YUIL.js +12 -0
  27. package/dist/chunks/en-GB-ZYCA2CIZ.js +12 -0
  28. package/dist/chunks/en-IN-EPHXLNO6.js +12 -0
  29. package/dist/chunks/en-US-ECSJ5HDL.js +12 -0
  30. package/dist/chunks/es-5VBYK2HE.js +12 -0
  31. package/dist/chunks/et-OFQRRTW6.js +12 -0
  32. package/dist/chunks/eu-7TNOYFB7.js +12 -0
  33. package/dist/chunks/fa-KZU6GKWU.js +12 -0
  34. package/dist/chunks/fi-THJEKJPW.js +12 -0
  35. package/dist/chunks/fr-MUVVTBQZ.js +12 -0
  36. package/dist/chunks/ga-UWUVCWOT.js +12 -0
  37. package/dist/chunks/gl-NHQ52YCN.js +12 -0
  38. package/dist/chunks/gu-HVDD4QHO.js +12 -0
  39. package/dist/chunks/ha-2BPTATOZ.js +12 -0
  40. package/dist/chunks/he-MDESCUHJ.js +12 -0
  41. package/dist/chunks/hi-C6BGPR4Y.js +12 -0
  42. package/dist/chunks/hr-77MP3ELT.js +12 -0
  43. package/dist/chunks/hu-7PRNX6NB.js +12 -0
  44. package/dist/chunks/hy-R3VEL63L.js +12 -0
  45. package/dist/chunks/id-O6B2T3Y2.js +12 -0
  46. package/dist/chunks/is-XLNS5CAZ.js +12 -0
  47. package/dist/chunks/it-NZODUGUP.js +12 -0
  48. package/dist/chunks/ja-FFK5WXSB.js +12 -0
  49. package/dist/chunks/jv-GS3IRAIB.js +12 -0
  50. package/dist/chunks/ka-NWIJAO54.js +12 -0
  51. package/dist/chunks/kk-WQFRFG44.js +12 -0
  52. package/dist/chunks/km-AUKBN3YT.js +12 -0
  53. package/dist/chunks/kn-PKZFPECM.js +12 -0
  54. package/dist/chunks/ko-XNGAWKQ4.js +12 -0
  55. package/dist/chunks/ky-AQTYDJIL.js +12 -0
  56. package/dist/chunks/la-ERS7V4N4.js +12 -0
  57. package/dist/chunks/lb-KU3DVPI4.js +12 -0
  58. package/dist/chunks/locale-codes-TGY5LMYX.js +11 -0
  59. package/dist/chunks/lt-6RI4HSG3.js +12 -0
  60. package/dist/chunks/lv-RGIUQVA7.js +12 -0
  61. package/dist/chunks/mk-JMAYXTCL.js +12 -0
  62. package/dist/chunks/ml-5ZAIPAYV.js +12 -0
  63. package/dist/chunks/mn-N2GZBVDP.js +12 -0
  64. package/dist/chunks/mr-2SRCJIBC.js +12 -0
  65. package/dist/chunks/ms-WHD5PUQM.js +12 -0
  66. package/dist/chunks/mt-EXRK5UO6.js +12 -0
  67. package/dist/chunks/my-D2COGDRI.js +12 -0
  68. package/dist/chunks/nb-3XNBS2DU.js +12 -0
  69. package/dist/chunks/ne-PA4KUBGU.js +12 -0
  70. package/dist/chunks/nl-QMM3PBPM.js +12 -0
  71. package/dist/chunks/nn-CLFEMF2K.js +12 -0
  72. package/dist/chunks/no-CV376NZG.js +12 -0
  73. package/dist/chunks/or-KP7CET7X.js +12 -0
  74. package/dist/chunks/pa-CH5JYVXT.js +12 -0
  75. package/dist/chunks/pl-DDW4HT7M.js +12 -0
  76. package/dist/chunks/pt-BR-CVNA2MRU.js +12 -0
  77. package/dist/chunks/pt-CRTRYTDJ.js +12 -0
  78. package/dist/chunks/pt-PT-IZMPF3BY.js +12 -0
  79. package/dist/chunks/ro-FUOGHWJA.js +12 -0
  80. package/dist/chunks/ru-KAT4X5EC.js +12 -0
  81. package/dist/chunks/si-GDAXEOBK.js +12 -0
  82. package/dist/chunks/sk-CDSK6MY5.js +12 -0
  83. package/dist/chunks/sl-TFJQYNA4.js +12 -0
  84. package/dist/chunks/so-TXI6JJPW.js +12 -0
  85. package/dist/chunks/sq-KMM2QIRU.js +12 -0
  86. package/dist/chunks/sr-OTZNEL5Z.js +12 -0
  87. package/dist/chunks/sv-7CANJ6CF.js +12 -0
  88. package/dist/chunks/sw-5JDMTJ5K.js +12 -0
  89. package/dist/chunks/ta-HT4SO7PD.js +12 -0
  90. package/dist/chunks/te-FECCLHOI.js +12 -0
  91. package/dist/chunks/tg-FJWFJWF2.js +12 -0
  92. package/dist/chunks/th-JEP434LN.js +12 -0
  93. package/dist/chunks/tl-GN35ZR2F.js +12 -0
  94. package/dist/chunks/tr-IPVLQUE4.js +12 -0
  95. package/dist/chunks/uk-LHWPGFRV.js +12 -0
  96. package/dist/chunks/ur-7FU4XRAY.js +12 -0
  97. package/dist/chunks/uz-RO7XCKFE.js +12 -0
  98. package/dist/chunks/vi-5PHPTVV4.js +12 -0
  99. package/dist/chunks/zh-Hans-UM7MUEDB.js +12 -0
  100. package/dist/chunks/zh-Hant-7M2P4G7R.js +12 -0
  101. package/dist/chunks/zh-LHCPWZN2.js +12 -0
  102. package/dist/widgets/webwriter-geogebra-3d.js +19 -25827
  103. package/dist/widgets/webwriter-geogebra-classic.js +18 -25826
  104. package/dist/widgets/webwriter-geogebra-geometry.js +18 -25826
  105. package/dist/widgets/webwriter-geogebra-notes.js +18 -25826
  106. package/dist/widgets/webwriter-geogebra-scientific.js +18 -25826
  107. package/dist/widgets/webwriter-geogebra.js +20 -25830
  108. package/editing-config.json +839 -20
  109. package/lit-localize.json +73 -9
  110. package/localization/af.xlf +290 -0
  111. package/localization/am.xlf +290 -0
  112. package/localization/ar.xlf +271 -6
  113. package/localization/az.xlf +290 -0
  114. package/localization/be.xlf +290 -0
  115. package/localization/bg.xlf +271 -6
  116. package/localization/bn.xlf +290 -0
  117. package/localization/bs.xlf +290 -0
  118. package/localization/ca-balear.xlf +290 -0
  119. package/localization/ca-valencia.xlf +290 -0
  120. package/localization/ca.xlf +290 -0
  121. package/localization/cnr.xlf +290 -0
  122. package/localization/cs.xlf +271 -6
  123. package/localization/cy.xlf +290 -0
  124. package/localization/da.xlf +271 -6
  125. package/localization/de-AT.xlf +294 -0
  126. package/localization/de-CH.xlf +294 -0
  127. package/localization/de.xlf +271 -6
  128. package/localization/el.xlf +271 -6
  129. package/localization/es.xlf +271 -6
  130. package/localization/et.xlf +271 -6
  131. package/localization/eu.xlf +290 -0
  132. package/localization/fa.xlf +290 -0
  133. package/localization/fi.xlf +271 -6
  134. package/localization/fr.xlf +271 -6
  135. package/localization/ga.xlf +290 -0
  136. package/localization/generated/af.ts +16 -0
  137. package/localization/generated/am.ts +16 -0
  138. package/localization/generated/ar.ts +6 -12
  139. package/localization/generated/az.ts +16 -0
  140. package/localization/generated/be.ts +16 -0
  141. package/localization/generated/bg.ts +6 -12
  142. package/localization/generated/bn.ts +16 -0
  143. package/localization/generated/bs.ts +16 -0
  144. package/localization/generated/ca-balear.ts +16 -0
  145. package/localization/generated/ca-valencia.ts +16 -0
  146. package/localization/generated/ca.ts +16 -0
  147. package/localization/generated/cnr.ts +16 -0
  148. package/localization/generated/cs.ts +6 -12
  149. package/localization/generated/cy.ts +16 -0
  150. package/localization/generated/da.ts +6 -12
  151. package/localization/generated/de-AT.ts +16 -0
  152. package/localization/generated/de-CH.ts +16 -0
  153. package/localization/generated/de.ts +6 -11
  154. package/localization/generated/el.ts +6 -12
  155. package/localization/generated/en-AU.ts +16 -0
  156. package/localization/generated/en-CA.ts +16 -0
  157. package/localization/generated/en-GB.ts +16 -0
  158. package/localization/generated/en-IN.ts +16 -0
  159. package/localization/generated/en-US.ts +16 -0
  160. package/localization/generated/es.ts +6 -12
  161. package/localization/generated/et.ts +6 -12
  162. package/localization/generated/eu.ts +16 -0
  163. package/localization/generated/fa.ts +16 -0
  164. package/localization/generated/fi.ts +6 -12
  165. package/localization/generated/fr.ts +6 -12
  166. package/localization/generated/ga.ts +16 -0
  167. package/localization/generated/gl.ts +16 -0
  168. package/localization/generated/gu.ts +16 -0
  169. package/localization/generated/ha.ts +16 -0
  170. package/localization/generated/he.ts +16 -0
  171. package/localization/generated/hi.ts +16 -0
  172. package/localization/generated/hr.ts +16 -0
  173. package/localization/generated/hu.ts +6 -12
  174. package/localization/generated/hy.ts +16 -0
  175. package/localization/generated/id.ts +6 -12
  176. package/localization/generated/is.ts +16 -0
  177. package/localization/generated/it.ts +6 -12
  178. package/localization/generated/ja.ts +6 -12
  179. package/localization/generated/jv.ts +16 -0
  180. package/localization/generated/ka.ts +16 -0
  181. package/localization/generated/kk.ts +16 -0
  182. package/localization/generated/km.ts +16 -0
  183. package/localization/generated/kn.ts +16 -0
  184. package/localization/generated/ko.ts +6 -12
  185. package/localization/generated/ky.ts +16 -0
  186. package/localization/generated/la.ts +16 -0
  187. package/localization/generated/lb.ts +16 -0
  188. package/localization/generated/locale-codes.ts +211 -0
  189. package/localization/generated/lt.ts +6 -12
  190. package/localization/generated/lv.ts +6 -12
  191. package/localization/generated/mk.ts +16 -0
  192. package/localization/generated/ml.ts +16 -0
  193. package/localization/generated/mn.ts +16 -0
  194. package/localization/generated/mr.ts +16 -0
  195. package/localization/generated/ms.ts +16 -0
  196. package/localization/generated/mt.ts +16 -0
  197. package/localization/generated/my.ts +16 -0
  198. package/localization/generated/nb.ts +6 -12
  199. package/localization/generated/ne.ts +16 -0
  200. package/localization/generated/nl.ts +6 -12
  201. package/localization/generated/nn.ts +16 -0
  202. package/localization/generated/no.ts +16 -0
  203. package/localization/generated/or.ts +16 -0
  204. package/localization/generated/pa.ts +16 -0
  205. package/localization/generated/pl.ts +6 -12
  206. package/localization/generated/pt-BR.ts +6 -12
  207. package/localization/generated/pt-PT.ts +6 -12
  208. package/localization/generated/pt.ts +16 -0
  209. package/localization/generated/ro.ts +6 -12
  210. package/localization/generated/ru.ts +6 -12
  211. package/localization/generated/si.ts +16 -0
  212. package/localization/generated/sk.ts +6 -12
  213. package/localization/generated/sl.ts +6 -12
  214. package/localization/generated/so.ts +16 -0
  215. package/localization/generated/sq.ts +16 -0
  216. package/localization/generated/sr.ts +16 -0
  217. package/localization/generated/sv.ts +6 -12
  218. package/localization/generated/sw.ts +16 -0
  219. package/localization/generated/ta.ts +16 -0
  220. package/localization/generated/te.ts +16 -0
  221. package/localization/generated/tg.ts +16 -0
  222. package/localization/generated/th.ts +16 -0
  223. package/localization/generated/tl.ts +16 -0
  224. package/localization/generated/tr.ts +6 -12
  225. package/localization/generated/uk.ts +6 -12
  226. package/localization/generated/ur.ts +16 -0
  227. package/localization/generated/uz.ts +16 -0
  228. package/localization/generated/vi.ts +16 -0
  229. package/localization/generated/zh-Hans.ts +16 -0
  230. package/localization/generated/zh-Hant.ts +16 -0
  231. package/localization/generated/zh.ts +16 -0
  232. package/localization/gl.xlf +290 -0
  233. package/localization/gu.xlf +290 -0
  234. package/localization/ha.xlf +290 -0
  235. package/localization/he.xlf +290 -0
  236. package/localization/hi.xlf +290 -0
  237. package/localization/hr.xlf +290 -0
  238. package/localization/hu.xlf +271 -6
  239. package/localization/hy.xlf +290 -0
  240. package/localization/id.xlf +271 -6
  241. package/localization/is.xlf +290 -0
  242. package/localization/it.xlf +271 -6
  243. package/localization/ja.xlf +271 -6
  244. package/localization/jv.xlf +290 -0
  245. package/localization/ka.xlf +290 -0
  246. package/localization/kk.xlf +290 -0
  247. package/localization/km.xlf +290 -0
  248. package/localization/kn.xlf +290 -0
  249. package/localization/ko.xlf +271 -6
  250. package/localization/ky.xlf +290 -0
  251. package/localization/la.xlf +290 -0
  252. package/localization/lb.xlf +290 -0
  253. package/localization/lt.xlf +271 -6
  254. package/localization/lv.xlf +271 -6
  255. package/localization/mk.xlf +290 -0
  256. package/localization/ml.xlf +290 -0
  257. package/localization/mn.xlf +290 -0
  258. package/localization/mr.xlf +290 -0
  259. package/localization/ms.xlf +290 -0
  260. package/localization/mt.xlf +290 -0
  261. package/localization/my.xlf +290 -0
  262. package/localization/nb.xlf +271 -6
  263. package/localization/ne.xlf +290 -0
  264. package/localization/nl.xlf +271 -6
  265. package/localization/nn.xlf +290 -0
  266. package/localization/no.xlf +295 -0
  267. package/localization/or.xlf +290 -0
  268. package/localization/pa.xlf +290 -0
  269. package/localization/pl.xlf +271 -6
  270. package/localization/pt-BR.xlf +271 -6
  271. package/localization/pt-PT.xlf +271 -6
  272. package/localization/pt.xlf +295 -0
  273. package/localization/ro.xlf +271 -6
  274. package/localization/ru.xlf +271 -6
  275. package/localization/si.xlf +290 -0
  276. package/localization/sk.xlf +271 -6
  277. package/localization/sl.xlf +271 -6
  278. package/localization/so.xlf +290 -0
  279. package/localization/sq.xlf +290 -0
  280. package/localization/sr.xlf +290 -0
  281. package/localization/sv.xlf +271 -6
  282. package/localization/sw.xlf +290 -0
  283. package/localization/ta.xlf +290 -0
  284. package/localization/te.xlf +290 -0
  285. package/localization/tg.xlf +290 -0
  286. package/localization/th.xlf +290 -0
  287. package/localization/tl.xlf +290 -0
  288. package/localization/tr.xlf +271 -6
  289. package/localization/uk.xlf +271 -6
  290. package/localization/ur.xlf +290 -0
  291. package/localization/uz.xlf +290 -0
  292. package/localization/vi.xlf +290 -0
  293. package/localization/zh-Hans.xlf +295 -0
  294. package/localization/zh-Hant.xlf +295 -0
  295. package/localization/zh.xlf +295 -0
  296. package/package.json +194 -86
  297. package/src/components/geogebra-app.styles.ts +47 -0
  298. package/{components → src/components}/geogebra-app.ts +229 -330
  299. package/src/model/geogebra-api.ts +148 -0
  300. package/src/model/geogebra-options.ts +72 -0
  301. package/src/model/geogebra-parameters.ts +53 -0
  302. package/src/model/ggb-file.ts +30 -0
  303. package/src/types.d.ts +3 -0
  304. package/{widgets → src/widgets}/webwriter-geogebra-3d.ts +1 -1
  305. package/{widgets → src/widgets}/webwriter-geogebra.ts +1 -2
  306. package/tests/conversions.test.ts +80 -0
  307. package/tests/data-block.test.ts +72 -0
  308. package/tests/helpers.ts +48 -0
  309. package/tests/language.test.ts +49 -0
  310. package/tests/presentation.test.ts +80 -0
  311. package/tsconfig.json +3 -7
  312. package/assets/icons/file-earmark-arrow-up.svg +0 -4
  313. package/components/geogebra-app.styles.ts +0 -10
  314. package/components/geogebra-options.styles.ts +0 -37
  315. package/components/geogebra-options.ts +0 -187
  316. package/custom.d.ts +0 -180
  317. package/dist/widgets/webwriter-geogebra-3d.css +0 -444
  318. package/dist/widgets/webwriter-geogebra-classic.css +0 -444
  319. package/dist/widgets/webwriter-geogebra-geometry.css +0 -444
  320. package/dist/widgets/webwriter-geogebra-notes.css +0 -444
  321. package/dist/widgets/webwriter-geogebra-scientific.css +0 -444
  322. package/dist/widgets/webwriter-geogebra.css +0 -444
  323. package/localization/generated/locale-codes.js +0 -83
  324. package/localization/generated/zh-hans.ts +0 -20
  325. package/localization/generated/zh-hant.ts +0 -20
  326. package/localization/zh-hans.xlf +0 -30
  327. package/localization/zh-hant.xlf +0 -30
  328. package/widgets/webwriter-geogebra-evaluator.ts +0 -15
  329. /package/.github/workflows/{main.yml → publish.yml} +0 -0
  330. /package/localization/pkg/{zh-hans.xliff → zh-Hans.xliff} +0 -0
  331. /package/localization/pkg/{zh-hant.xliff → zh-Hant.xliff} +0 -0
  332. /package/localization/snippets/{zh-hans.xliff → zh-Hans.xliff} +0 -0
  333. /package/localization/snippets/{zh-hant.xliff → zh-Hant.xliff} +0 -0
  334. /package/{utils → src/model}/boolean-attribute-converter.ts +0 -0
  335. /package/{widgets → src/widgets}/webwriter-geogebra-classic.ts +0 -0
  336. /package/{widgets → src/widgets}/webwriter-geogebra-geometry.ts +0 -0
  337. /package/{widgets → src/widgets}/webwriter-geogebra-notes.ts +0 -0
  338. /package/{widgets → src/widgets}/webwriter-geogebra-scientific.ts +0 -0
@@ -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,8 +1,4 @@
1
1
  {
2
- "compilerOptions": {
3
- "experimentalDecorators": true,
4
- "target": "es2022",
5
- "moduleResolution": "Bundler",
6
- "module": "ES2022"
7
- }
8
- }
2
+ "extends": "@webwriter/build/tsconfig.json",
3
+ "include": ["src", "tests"]
4
+ }
@@ -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,10 +0,0 @@
1
- import { css } from "lit";
2
-
3
- export const geogebraAppStyles = css`
4
- iframe {
5
- display: block;
6
- border: none;
7
- width: 100%;
8
- aspect-ratio: 16/9;
9
- }
10
- `
@@ -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
- }