Skip to content

Commit c2e61bf

Browse files
Merge pull request #4574 from serlo/webcomponent-add-new-field
chore(editor-web-component): use new editor version, add new field, bump version
2 parents 5b7fff3 + e503cf2 commit c2e61bf

10 files changed

+76
-88
lines changed
-1.04 MB
Binary file not shown.
1.04 MB
Binary file not shown.
-57.1 KB
Binary file not shown.
Binary file not shown.
-639 KB
Binary file not shown.
-22.4 KB
Binary file not shown.
-32.4 KB
Binary file not shown.

packages/editor-web-component/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serlo/editor-web-component",
3-
"version": "0.16.0",
3+
"version": "0.17.0",
44
"homepage": "https://de.serlo.org/editor",
55
"bugs": {
66
"url": "https://github.com/serlo/frontend/issues"
@@ -40,13 +40,13 @@
4040
"yalc:publish": "yarn build && yalc publish --push --sig"
4141
},
4242
"resolutions": {
43-
"@serlo/editor": "0.21.2"
43+
"@serlo/editor": "0.26.0"
4444
},
4545
"devDependencies": {
4646
"@eslint/eslintrc": "^3.3.1",
4747
"@eslint/js": "^9.23.0",
4848
"@rollup/plugin-replace": "^6.0.1",
49-
"@serlo/editor": "0.24.0",
49+
"@serlo/editor": "0.26.0",
5050
"@serlo/typescript-config": "workspace:*",
5151
"@types/react": "^18.0.25",
5252
"@types/react-dom": "^18.3.1",

packages/editor-web-component/src/editor-web-component.tsx

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ export class EditorWebComponent extends HTMLElement {
3636
private _initialState: InitialState = exampleInitialState
3737
private _currentState: unknown
3838

39+
// Deprecated and ignored
40+
private _testingSecret: string | null = null
41+
3942
private _editorVariant: EditorVariant = 'unknown'
4043

4144
private _plugins = defaultPlugins
4245

4346
private _isProductionEnvironment: boolean = false
4447

48+
private _disableMediaUpload: boolean | null = null
49+
4550
private _language: SupportedLanguage = 'de' as const
4651

4752
constructor() {
@@ -58,33 +63,64 @@ export class EditorWebComponent extends HTMLElement {
5863
'editor-variant',
5964
'plugins',
6065
'is-production-environment',
66+
'disable-media-upload',
6167
'language',
6268
]
6369
}
6470

65-
attributeChangedCallback(name: string, oldValue: string, newValue: string) {
66-
if (name === 'initial-state' && oldValue !== newValue) {
67-
this.initialState = JSON.parse(newValue) as InitialState
71+
attributeChangedCallback(
72+
name: string,
73+
oldValue: string | null,
74+
newValue: string | null
75+
) {
76+
if (oldValue === newValue) return
77+
78+
if (name === 'initial-state') {
79+
this.initialState =
80+
newValue === null ? null : (JSON.parse(newValue) as InitialState)
6881
} else if (
6982
name === 'mode' &&
70-
oldValue !== newValue &&
7183
(newValue === 'read' || newValue === 'write')
7284
) {
7385
this.mode = newValue
74-
} else if (name === 'editor-variant' && oldValue !== newValue) {
75-
this.editorVariant = newValue as EditorVariant
76-
} else if (name === 'plugins' && oldValue !== newValue) {
77-
this.plugins = JSON.parse(newValue) as EditorPluginType[]
86+
} else if (name === 'editor-variant') {
87+
this.editorVariant =
88+
newValue === null ? 'unknown' : (newValue as EditorVariant)
89+
} else if (name === 'plugins') {
90+
this.plugins =
91+
newValue === null
92+
? defaultPlugins
93+
: (JSON.parse(newValue) as EditorPluginType[])
7894
} else if (name === 'is-production-environment') {
7995
this.isProductionEnvironment = newValue === 'true'
80-
} else if (name === 'language' && oldValue !== newValue) {
96+
} else if (name === 'disable-media-upload') {
97+
this.disableMediaUpload =
98+
newValue === 'true' ? true : newValue === 'false' ? false : null
99+
} else if (name === 'testing-secret') {
100+
this.testingSecret = newValue
101+
} else if (name === 'language') {
81102
// Validates the language attribute. Will need to keep this in sync with
82103
// the SupportedLanguage type, if we add more language support!
83104
const validatedLanguage = newValue === 'en' ? 'en' : 'de'
84105
this.language = validatedLanguage
85106
}
86107
}
87108

109+
get testingSecret(): string | null {
110+
return this._testingSecret
111+
}
112+
113+
// Deprecated and ignored
114+
set testingSecret(value) {
115+
this._testingSecret = value
116+
if (value === null) {
117+
this.removeAttribute('testing-secret')
118+
} else {
119+
this.setAttribute('testing-secret', String(value))
120+
}
121+
this.mountReactComponent()
122+
}
123+
88124
get initialState() {
89125
return this._initialState
90126
}
@@ -159,6 +195,20 @@ export class EditorWebComponent extends HTMLElement {
159195
this.mountReactComponent()
160196
}
161197

198+
get disableMediaUpload(): boolean | null {
199+
return this._disableMediaUpload
200+
}
201+
202+
set disableMediaUpload(value: boolean | null) {
203+
this._disableMediaUpload = value
204+
if (value === null) {
205+
this.removeAttribute('disable-media-upload')
206+
} else {
207+
this.setAttribute('disable-media-upload', String(value))
208+
}
209+
this.mountReactComponent()
210+
}
211+
162212
get language(): SupportedLanguage {
163213
return this._language
164214
}
@@ -228,6 +278,11 @@ export class EditorWebComponent extends HTMLElement {
228278
initialState={this.initialState}
229279
plugins={this.plugins}
230280
isProductionEnvironment={this.isProductionEnvironment}
281+
disableMediaUpload={
282+
this._disableMediaUpload === null
283+
? undefined
284+
: this._disableMediaUpload
285+
}
231286
onChange={(newState) => {
232287
this._currentState = newState
233288
this.broadcastNewState(newState)

yarn.lock

Lines changed: 9 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -5488,7 +5488,7 @@ __metadata:
54885488
"@eslint/eslintrc": ^3.3.1
54895489
"@eslint/js": ^9.23.0
54905490
"@rollup/plugin-replace": ^6.0.1
5491-
"@serlo/editor": 0.24.0
5491+
"@serlo/editor": 0.26.0
54925492
"@serlo/typescript-config": "workspace:*"
54935493
"@types/react": ^18.0.25
54945494
"@types/react-dom": ^18.3.1
@@ -5512,21 +5512,21 @@ __metadata:
55125512
languageName: unknown
55135513
linkType: soft
55145514

5515-
"@serlo/editor@npm:0.24.0":
5516-
version: 0.24.0
5517-
resolution: "@serlo/editor@npm:0.24.0"
5515+
"@serlo/editor@npm:0.26.0":
5516+
version: 0.26.0
5517+
resolution: "@serlo/editor@npm:0.26.0"
55185518
dependencies:
55195519
"@open-iframe-resizer/react": 1.2.1
55205520
"@serlo/katex-styles": 1.0.1
55215521
"@vidstack/react": next
5522-
isomorphic-dompurify: ^2.19.0
5522+
isomorphic-dompurify: ^2.22.0
55235523
lit: ^3.2.1
55245524
motion: ^11.11.17
55255525
react: ^18.2.0
55265526
react-dom: ^18.3.1
55275527
react-hot-toast: ^2.4.1
55285528
react-resizable: ^3.0.5
5529-
checksum: dc071e92e96bc22691a5138eb9e7365a1270bf1c054d668857786f6f9918191cefa181e5141540b2014ca2a982becf1619ee7efbc521520a53f4ea9d6b45cc0f
5529+
checksum: fc0337e89dd0b447274ce9b0b395516fd77b5a1203820e8ed299eb9e439b881fd428c11ac1a4bcd136245b4204f1dc22c7e81e0a3a47a2e8d9843f2fc1e04a29
55305530
languageName: node
55315531
linkType: hard
55325532

@@ -8750,15 +8750,6 @@ __metadata:
87508750
languageName: node
87518751
linkType: hard
87528752

8753-
"cssstyle@npm:^4.1.0":
8754-
version: 4.1.0
8755-
resolution: "cssstyle@npm:4.1.0"
8756-
dependencies:
8757-
rrweb-cssom: ^0.7.1
8758-
checksum: a8f5746430c42347e76dc830548f3a296882e42a90af188ae44e4c1a4131aec246b0b6c8562e3e6e4fa0ff14aeee5cd14a0e2fe5a7105dcf39f98eb70d16b634
8759-
languageName: node
8760-
linkType: hard
8761-
87628753
"cssstyle@npm:^4.2.1":
87638754
version: 4.3.0
87648755
resolution: "cssstyle@npm:4.3.0"
@@ -9205,7 +9196,7 @@ __metadata:
92059196
languageName: node
92069197
linkType: hard
92079198

9208-
"dompurify@npm:^3.2.3, dompurify@npm:^3.2.4":
9199+
"dompurify@npm:^3.2.4":
92099200
version: 3.2.4
92109201
resolution: "dompurify@npm:3.2.4"
92119202
dependencies:
@@ -11467,7 +11458,7 @@ __metadata:
1146711458
languageName: node
1146811459
linkType: hard
1146911460

11470-
"https-proxy-agent@npm:^7.0.5, https-proxy-agent@npm:^7.0.6":
11461+
"https-proxy-agent@npm:^7.0.6":
1147111462
version: 7.0.6
1147211463
resolution: "https-proxy-agent@npm:7.0.6"
1147311464
dependencies:
@@ -12342,16 +12333,6 @@ __metadata:
1234212333
languageName: node
1234312334
linkType: hard
1234412335

12345-
"isomorphic-dompurify@npm:^2.19.0":
12346-
version: 2.19.0
12347-
resolution: "isomorphic-dompurify@npm:2.19.0"
12348-
dependencies:
12349-
dompurify: ^3.2.3
12350-
jsdom: ^25.0.1
12351-
checksum: 42fb8a4d5e88b51f0081993733d2babb9bf8793ef7ec0b1baf387fbaeab58f3b3f749d084222f13ed72018d6dbf4ffacc2e8335e63aaa204a01d4dd02ef59222
12352-
languageName: node
12353-
linkType: hard
12354-
1235512336
"isomorphic-dompurify@npm:^2.22.0":
1235612337
version: 2.22.0
1235712338
resolution: "isomorphic-dompurify@npm:2.22.0"
@@ -12515,40 +12496,6 @@ __metadata:
1251512496
languageName: node
1251612497
linkType: hard
1251712498

12518-
"jsdom@npm:^25.0.1":
12519-
version: 25.0.1
12520-
resolution: "jsdom@npm:25.0.1"
12521-
dependencies:
12522-
cssstyle: ^4.1.0
12523-
data-urls: ^5.0.0
12524-
decimal.js: ^10.4.3
12525-
form-data: ^4.0.0
12526-
html-encoding-sniffer: ^4.0.0
12527-
http-proxy-agent: ^7.0.2
12528-
https-proxy-agent: ^7.0.5
12529-
is-potential-custom-element-name: ^1.0.1
12530-
nwsapi: ^2.2.12
12531-
parse5: ^7.1.2
12532-
rrweb-cssom: ^0.7.1
12533-
saxes: ^6.0.0
12534-
symbol-tree: ^3.2.4
12535-
tough-cookie: ^5.0.0
12536-
w3c-xmlserializer: ^5.0.0
12537-
webidl-conversions: ^7.0.0
12538-
whatwg-encoding: ^3.1.1
12539-
whatwg-mimetype: ^4.0.0
12540-
whatwg-url: ^14.0.0
12541-
ws: ^8.18.0
12542-
xml-name-validator: ^5.0.0
12543-
peerDependencies:
12544-
canvas: ^2.11.2
12545-
peerDependenciesMeta:
12546-
canvas:
12547-
optional: true
12548-
checksum: b637d28445d570014195b3c77d06e54ef69d1f807eaf61388cb470e4d9227244e7fe2e0c32b6df03ac4fe35f746d7c721672d9136ecebb49d2e61a04ab9628e0
12549-
languageName: node
12550-
linkType: hard
12551-
1255212499
"jsdom@npm:^26.0.0":
1255312500
version: 26.0.0
1255412501
resolution: "jsdom@npm:26.0.0"
@@ -14522,13 +14469,6 @@ __metadata:
1452214469
languageName: node
1452314470
linkType: hard
1452414471

14525-
"nwsapi@npm:^2.2.12":
14526-
version: 2.2.16
14527-
resolution: "nwsapi@npm:2.2.16"
14528-
checksum: 467b36a74b7b8647d53fd61d05ca7d6c73a4a5d1b94ea84f770c03150b00ef46d38076cf8e708936246ae450c42a1f21e28e153023719784dc4d1a19b1737d47
14529-
languageName: node
14530-
linkType: hard
14531-
1453214472
"nwsapi@npm:^2.2.16":
1453314473
version: 2.2.19
1453414474
resolution: "nwsapi@npm:2.2.19"
@@ -14952,7 +14892,7 @@ __metadata:
1495214892
languageName: node
1495314893
linkType: hard
1495414894

14955-
"parse5@npm:^7.1.2, parse5@npm:^7.2.1":
14895+
"parse5@npm:^7.2.1":
1495614896
version: 7.2.1
1495714897
resolution: "parse5@npm:7.2.1"
1495814898
dependencies:
@@ -16475,13 +16415,6 @@ react-mathquill@Entkenntnis/tmp-react-mathquill:
1647516415
languageName: node
1647616416
linkType: hard
1647716417

16478-
"rrweb-cssom@npm:^0.7.1":
16479-
version: 0.7.1
16480-
resolution: "rrweb-cssom@npm:0.7.1"
16481-
checksum: 62e410ddbaaba6abc196c3bbfa8de4952e0a134d9f2b454ee293039bf9931322d806e14d52ed122a5c2bd332a868b9da2e99358fb6232c33758b5ede86d992c8
16482-
languageName: node
16483-
linkType: hard
16484-
1648516418
"rrweb-cssom@npm:^0.8.0":
1648616419
version: 0.8.0
1648716420
resolution: "rrweb-cssom@npm:0.8.0"

0 commit comments

Comments
 (0)