@ones-editor/editor 1.1.3-bate.5 → 1.1.3-bate.7

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/dist/index.js CHANGED
@@ -5172,6 +5172,122 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
5172
5172
  }
5173
5173
  .editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container > img {
5174
5174
  max-width: 100%;
5175
+ }:root {
5176
+ --editor-quoted-color: #7084a4;
5177
+ --editor-drawio-empty-svg: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0zOC43MjAzIDI4LjcwOTdIMjUuOTIzM0MyNS4yMTY1IDI4LjcwOTcgMjQuNjQzNSAyOC4xNDgxIDI0LjY0MzUgMjcuNDU1MlYyNS43MzMzSDIwLjUyODNDMjAuNDk4NiAyNS43Njk2IDIwLjQ2NjkgMjUuODA0MiAyMC40MzMzIDI1LjgzN0wxNS45MTkyIDMwLjI2MjFWMzQuNzU1NkgyNC42NDM1VjMzLjcyNzZDMjQuNjQzNSAzMy4wMzQ4IDI1LjIxNjUgMzIuNDczMiAyNS45MjMzIDMyLjQ3MzJIMzguNzIwM0MzOS40MjcgMzIuNDczMiA0MCAzMy4wMzQ4IDQwIDMzLjcyNzZWMzguNzQ1NUM0MCAzOS40MzgzIDM5LjQyNyA0MCAzOC43MjAzIDQwSDI1LjkyMzNDMjUuMjE2NSA0MCAyNC42NDM1IDM5LjQzODMgMjQuNjQzNSAzOC43NDU1VjM3LjMzMzNIMTQuNjI2M0MxMy45MTIyIDM3LjMzMzMgMTMuMzMzMyAzNi43NTYyIDEzLjMzMzMgMzYuMDQ0NFYzMC42OTQxTDguMzc4NTIgMjUuODM3QzguMTM2MjYgMjUuNjAxNCA4IDI1LjI4MDggOCAyNC45NDYzQzggMjQuNjExOCA4LjEzNjI2IDI0LjI5MTEgOC4zNzg1MiAyNC4wNTU2TDEzLjMzMzMgMTkuMTk4NVYxNS43NzJDMTEuNzc5OCAxNS4yMjI5IDEwLjY2NjcgMTMuNzQxNiAxMC42NjY3IDEyQzEwLjY2NjcgOS43OTA4NSAxMi40NTc1IDggMTQuNjY2NyA4QzE2Ljg3NTggOCAxOC42NjY2IDkuNzkwODUgMTguNjY2NiAxMkMxOC42NjY2IDEzLjcyNjUgMTcuNTU4OCAxNS4yNTgxIDE1LjkxOTEgMTUuNzk4OFYxOS4yODg4QzE1LjkxOTEgMTkuMzkxOCAxNS45MDY4IDE5LjQ5NDMgMTUuODgyMyAxOS41OTQzTDE5LjUxNTEgMjMuMTU1NUgyNC42NDM1VjIyLjQzNzNDMjQuNjQzNSAyMS43NDQ1IDI1LjIxNjUgMjEuMTgyOSAyNS45MjMzIDIxLjE4MjlIMzguNzIwM0MzOS40MjcgMjEuMTgyOSA0MCAyMS43NDQ1IDQwIDIyLjQzNzNWMjcuNDU1MkM0MCAyOC4xNDgxIDM5LjQyNyAyOC43MDk3IDM4LjcyMDMgMjguNzA5N1pNMjcuMjAzIDM3LjQ5MUgzNy40NDA2VjM0Ljk4MjFIMjcuMjAzVjM3LjQ5MVpNMTQuNDA1OSAyOC4xOTU0TDExLjA5MTUgMjQuOTQ2M0wxNC40MDU5IDIxLjY5NzJMMTcuNzIwNCAyNC45NDYzTDE0LjQwNTkgMjguMTk1NFpNMjcuMjAzIDI2LjIwMDhIMzcuNDQwNlYyMy42OTE4SDI3LjIwM1YyNi4yMDA4WiIgZmlsbD0iIzA3MTQyQSIvPgo8L3N2Zz4K");
5178
+ }
5179
+ .flex-center, .editor-drawio-iframe-container.loading:before {
5180
+ display: flex;
5181
+ align-items: center;
5182
+ justify-content: center;
5183
+ }
5184
+ .full-screen, .editor-drawio-iframe-container.loading:before, .drawio-iframe-element, .editor-drawio-iframe-container {
5185
+ width: 100%;
5186
+ height: 100%;
5187
+ }
5188
+ .editor-drawio-iframe-container {
5189
+ position: fixed;
5190
+ top: 0;
5191
+ left: 0;
5192
+ z-index: 1000;
5193
+ }
5194
+ div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] {
5195
+ outline: 1px solid #dedede;
5196
+ }
5197
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio].drawio-load-error > div[data-type=block-content] {
5198
+ padding: 0;
5199
+ min-height: 200px;
5200
+ }
5201
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio].drawio-load-error > div[data-type=block-content] .editor-drawio-content {
5202
+ width: 100%;
5203
+ height: 100%;
5204
+ }
5205
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] {
5206
+ justify-content: center;
5207
+ border-radius: 3px;
5208
+ padding: 10px;
5209
+ }
5210
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content {
5211
+ display: flex;
5212
+ flex-direction: column;
5213
+ align-items: center;
5214
+ justify-content: center;
5215
+ }
5216
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content {
5217
+ width: 100%;
5218
+ height: 100%;
5219
+ background-color: #f8f8f8;
5220
+ display: flex;
5221
+ flex-direction: column;
5222
+ justify-content: center;
5223
+ text-align: center;
5224
+ }
5225
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-brand-icon > svg {
5226
+ width: 48px;
5227
+ height: 48px;
5228
+ }
5229
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-title {
5230
+ font-weight: 500;
5231
+ font-size: 18px;
5232
+ line-height: 26px;
5233
+ text-align: center;
5234
+ color: #303030;
5235
+ margin: 23px 0 5px;
5236
+ }
5237
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-sub-title {
5238
+ font-size: 14px;
5239
+ line-height: 22px;
5240
+ text-align: center;
5241
+ color: #606060;
5242
+ }
5243
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-sub-title > span.drawio-error-retry-button {
5244
+ cursor: pointer;
5245
+ margin-left: 4px;
5246
+ color: #0064ff;
5247
+ }
5248
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .drawio-empty-content {
5249
+ display: flex;
5250
+ flex-direction: column;
5251
+ align-items: center;
5252
+ }
5253
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .drawio-empty-content > span {
5254
+ font-size: 14px;
5255
+ line-height: 22px;
5256
+ text-align: center;
5257
+ color: #606060;
5258
+ margin-top: 23px;
5259
+ }
5260
+ .embed-block .editor-empty-drawio.editor-drawio-content.editor-embed {
5261
+ width: 240px;
5262
+ height: 400px;
5263
+ display: inline-block;
5264
+ text-align: center;
5265
+ }
5266
+ div.editor-root div.editor-content div[data-type=editor-container] div[data-embed-type=drawio].embed-block > div[data-type=block-content] img {
5267
+ max-width: 100%;
5268
+ max-height: 100%;
5269
+ }
5270
+ .editor-drawio-iframe-container.loading:before {
5271
+ content: attr(data-placeholder);
5272
+ position: absolute;
5273
+ top: 0;
5274
+ left: 0;
5275
+ background-color: #f7f6f3;
5276
+ z-index: 2;
5277
+ }
5278
+ :root .iframe-embed-auth-error-tips {
5279
+ width: 100%;
5280
+ height: 34px;
5281
+ line-height: 34px;
5282
+ background-color: #f7f8fa;
5283
+ text-align: center;
5284
+ color: #bebfc2;
5285
+ box-shadow: 0px 2px 4px 0px rgba(45, 45, 46, 0.15), 0px 0px 1px 0px rgba(45, 45, 46, 0.1);
5286
+ }
5287
+ :root .iframe-embed-auth-error-tips span {
5288
+ cursor: pointer;
5289
+ color: #0064ff;
5290
+ user-select: none;
5175
5291
  }:root div[data-command-bar-id=webpage] > div.tippy-box {
5176
5292
  max-width: 500px;
5177
5293
  }
@@ -5306,122 +5422,6 @@ div.editor-root div.editor-content div[data-type=editor-container] div[data-type
5306
5422
  }
5307
5423
  div.editor-root div.editor-content div[data-type=editor-container].root.select-all > .container-blocks > div[data-type=editor-block][data-embed-type=webpage] > div[data-type=block-content]::before {
5308
5424
  display: block;
5309
- }:root {
5310
- --editor-quoted-color: #7084a4;
5311
- --editor-drawio-empty-svg: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0zOC43MjAzIDI4LjcwOTdIMjUuOTIzM0MyNS4yMTY1IDI4LjcwOTcgMjQuNjQzNSAyOC4xNDgxIDI0LjY0MzUgMjcuNDU1MlYyNS43MzMzSDIwLjUyODNDMjAuNDk4NiAyNS43Njk2IDIwLjQ2NjkgMjUuODA0MiAyMC40MzMzIDI1LjgzN0wxNS45MTkyIDMwLjI2MjFWMzQuNzU1NkgyNC42NDM1VjMzLjcyNzZDMjQuNjQzNSAzMy4wMzQ4IDI1LjIxNjUgMzIuNDczMiAyNS45MjMzIDMyLjQ3MzJIMzguNzIwM0MzOS40MjcgMzIuNDczMiA0MCAzMy4wMzQ4IDQwIDMzLjcyNzZWMzguNzQ1NUM0MCAzOS40MzgzIDM5LjQyNyA0MCAzOC43MjAzIDQwSDI1LjkyMzNDMjUuMjE2NSA0MCAyNC42NDM1IDM5LjQzODMgMjQuNjQzNSAzOC43NDU1VjM3LjMzMzNIMTQuNjI2M0MxMy45MTIyIDM3LjMzMzMgMTMuMzMzMyAzNi43NTYyIDEzLjMzMzMgMzYuMDQ0NFYzMC42OTQxTDguMzc4NTIgMjUuODM3QzguMTM2MjYgMjUuNjAxNCA4IDI1LjI4MDggOCAyNC45NDYzQzggMjQuNjExOCA4LjEzNjI2IDI0LjI5MTEgOC4zNzg1MiAyNC4wNTU2TDEzLjMzMzMgMTkuMTk4NVYxNS43NzJDMTEuNzc5OCAxNS4yMjI5IDEwLjY2NjcgMTMuNzQxNiAxMC42NjY3IDEyQzEwLjY2NjcgOS43OTA4NSAxMi40NTc1IDggMTQuNjY2NyA4QzE2Ljg3NTggOCAxOC42NjY2IDkuNzkwODUgMTguNjY2NiAxMkMxOC42NjY2IDEzLjcyNjUgMTcuNTU4OCAxNS4yNTgxIDE1LjkxOTEgMTUuNzk4OFYxOS4yODg4QzE1LjkxOTEgMTkuMzkxOCAxNS45MDY4IDE5LjQ5NDMgMTUuODgyMyAxOS41OTQzTDE5LjUxNTEgMjMuMTU1NUgyNC42NDM1VjIyLjQzNzNDMjQuNjQzNSAyMS43NDQ1IDI1LjIxNjUgMjEuMTgyOSAyNS45MjMzIDIxLjE4MjlIMzguNzIwM0MzOS40MjcgMjEuMTgyOSA0MCAyMS43NDQ1IDQwIDIyLjQzNzNWMjcuNDU1MkM0MCAyOC4xNDgxIDM5LjQyNyAyOC43MDk3IDM4LjcyMDMgMjguNzA5N1pNMjcuMjAzIDM3LjQ5MUgzNy40NDA2VjM0Ljk4MjFIMjcuMjAzVjM3LjQ5MVpNMTQuNDA1OSAyOC4xOTU0TDExLjA5MTUgMjQuOTQ2M0wxNC40MDU5IDIxLjY5NzJMMTcuNzIwNCAyNC45NDYzTDE0LjQwNTkgMjguMTk1NFpNMjcuMjAzIDI2LjIwMDhIMzcuNDQwNlYyMy42OTE4SDI3LjIwM1YyNi4yMDA4WiIgZmlsbD0iIzA3MTQyQSIvPgo8L3N2Zz4K");
5312
- }
5313
- .flex-center, .editor-drawio-iframe-container.loading:before {
5314
- display: flex;
5315
- align-items: center;
5316
- justify-content: center;
5317
- }
5318
- .full-screen, .editor-drawio-iframe-container.loading:before, .drawio-iframe-element, .editor-drawio-iframe-container {
5319
- width: 100%;
5320
- height: 100%;
5321
- }
5322
- .editor-drawio-iframe-container {
5323
- position: fixed;
5324
- top: 0;
5325
- left: 0;
5326
- z-index: 1000;
5327
- }
5328
- div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] {
5329
- outline: 1px solid #dedede;
5330
- }
5331
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio].drawio-load-error > div[data-type=block-content] {
5332
- padding: 0;
5333
- min-height: 200px;
5334
- }
5335
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio].drawio-load-error > div[data-type=block-content] .editor-drawio-content {
5336
- width: 100%;
5337
- height: 100%;
5338
- }
5339
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] {
5340
- justify-content: center;
5341
- border-radius: 3px;
5342
- padding: 10px;
5343
- }
5344
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content {
5345
- display: flex;
5346
- flex-direction: column;
5347
- align-items: center;
5348
- justify-content: center;
5349
- }
5350
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content {
5351
- width: 100%;
5352
- height: 100%;
5353
- background-color: #f8f8f8;
5354
- display: flex;
5355
- flex-direction: column;
5356
- justify-content: center;
5357
- text-align: center;
5358
- }
5359
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-brand-icon > svg {
5360
- width: 48px;
5361
- height: 48px;
5362
- }
5363
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-title {
5364
- font-weight: 500;
5365
- font-size: 18px;
5366
- line-height: 26px;
5367
- text-align: center;
5368
- color: #303030;
5369
- margin: 23px 0 5px;
5370
- }
5371
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-sub-title {
5372
- font-size: 14px;
5373
- line-height: 22px;
5374
- text-align: center;
5375
- color: #606060;
5376
- }
5377
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .editor-drawio-content > div.drawio-error-content > div.drawio-error-sub-title > span.drawio-error-retry-button {
5378
- cursor: pointer;
5379
- margin-left: 4px;
5380
- color: #0064ff;
5381
- }
5382
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .drawio-empty-content {
5383
- display: flex;
5384
- flex-direction: column;
5385
- align-items: center;
5386
- }
5387
- div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio] > div[data-type=block-content] .drawio-empty-content > span {
5388
- font-size: 14px;
5389
- line-height: 22px;
5390
- text-align: center;
5391
- color: #606060;
5392
- margin-top: 23px;
5393
- }
5394
- .embed-block .editor-empty-drawio.editor-drawio-content.editor-embed {
5395
- width: 240px;
5396
- height: 400px;
5397
- display: inline-block;
5398
- text-align: center;
5399
- }
5400
- div.editor-root div.editor-content div[data-type=editor-container] div[data-embed-type=drawio].embed-block > div[data-type=block-content] img {
5401
- max-width: 100%;
5402
- max-height: 100%;
5403
- }
5404
- .editor-drawio-iframe-container.loading:before {
5405
- content: attr(data-placeholder);
5406
- position: absolute;
5407
- top: 0;
5408
- left: 0;
5409
- background-color: #f7f6f3;
5410
- z-index: 2;
5411
- }
5412
- :root .iframe-embed-auth-error-tips {
5413
- width: 100%;
5414
- height: 34px;
5415
- line-height: 34px;
5416
- background-color: #f7f8fa;
5417
- text-align: center;
5418
- color: #bebfc2;
5419
- box-shadow: 0px 2px 4px 0px rgba(45, 45, 46, 0.15), 0px 0px 1px 0px rgba(45, 45, 46, 0.1);
5420
- }
5421
- :root .iframe-embed-auth-error-tips span {
5422
- cursor: pointer;
5423
- color: #0064ff;
5424
- user-select: none;
5425
5425
  }.editor-content .editing {
5426
5426
  background-color: rgba(205, 205, 205, 0.2509803922);
5427
5427
  }
@@ -26919,6 +26919,10 @@ ${codeText}
26919
26919
  getRemoteUsers() {
26920
26920
  return this.externalDoc.getRemoteUsers();
26921
26921
  }
26922
+ triggerReAuth() {
26923
+ var _a, _b;
26924
+ return (_b = (_a = this.externalDoc).triggerReAuth) == null ? void 0 : _b.call(_a);
26925
+ }
26922
26926
  destroy() {
26923
26927
  this.externalDoc.destroy();
26924
26928
  this.clearCallbacks();
@@ -28667,8 +28671,6 @@ ${codeText}
28667
28671
  destroy() {
28668
28672
  this.clearCallbacks();
28669
28673
  }
28670
- triggerReAuth() {
28671
- }
28672
28674
  }
28673
28675
  class OnesEditorRunOnceCustom {
28674
28676
  constructor(cleanup) {
@@ -34014,7 +34016,7 @@ ${codeText}
34014
34016
  __publicField(this, "events", new events.EventEmitter());
34015
34017
  __publicField(this, "token", null);
34016
34018
  __publicField(this, "resourceToken", null);
34017
- __publicField(this, "reauth", async () => {
34019
+ __publicField(this, "reAuth", async () => {
34018
34020
  if (this.connection && this.reauthFunc) {
34019
34021
  const newAuth = await this.reauthFunc();
34020
34022
  await this.auth(newAuth);
@@ -34100,11 +34102,11 @@ ${codeText}
34100
34102
  if ("err" in msg || msg.a === "pong") {
34101
34103
  this.handleMessage(msg);
34102
34104
  } else {
34103
- if (this.retryCount > 0) {
34104
- logger$2n.info("retrying re-auth success");
34105
- this.emitAuthRecover();
34106
- }
34107
34105
  if (Object.prototype.hasOwnProperty.call(msg, "a") && msg.a !== "init" && msg.a !== "hs") {
34106
+ if (this.retryCount > 0) {
34107
+ logger$2n.info("retrying re-auth success");
34108
+ this.emitAuthRecover();
34109
+ }
34108
34110
  this.retryCount = 0;
34109
34111
  }
34110
34112
  try {
@@ -34125,7 +34127,6 @@ ${codeText}
34125
34127
  Connection.apply(this.connection, [this.ws]);
34126
34128
  }
34127
34129
  async handleAuthError() {
34128
- console.log("handleAuthError");
34129
34130
  if (this.reauthFunc) {
34130
34131
  if (this.retryCount === 5) {
34131
34132
  logger$2n.warn("retry auth times exceed 5, broadcast auth error");
@@ -34355,9 +34356,6 @@ ${codeText}
34355
34356
  onRequestReloadError(callback) {
34356
34357
  this.connection.onRequestReloadError(callback);
34357
34358
  }
34358
- triggerReAuth() {
34359
- this.connection.reauth();
34360
- }
34361
34359
  async authOnly() {
34362
34360
  await this.connection.auth(this.auth);
34363
34361
  }
@@ -34621,6 +34619,9 @@ ${codeText}
34621
34619
  }
34622
34620
  return ret;
34623
34621
  }
34622
+ reAuth() {
34623
+ this.connection.reAuth();
34624
+ }
34624
34625
  }
34625
34626
  function createEmptyDoc() {
34626
34627
  const id = genId();
@@ -35466,13 +35467,13 @@ ${codeText}
35466
35467
  return (_a = cb.onError) == null ? void 0 : _a.call(cb, err);
35467
35468
  });
35468
35469
  });
35469
- this.client.onWriteConflictError(this.handleWriteConflictError);
35470
35470
  this.client.onAuthRecover(() => {
35471
35471
  this.callbacks.forEach((cb) => {
35472
35472
  var _a;
35473
35473
  return (_a = cb.onAuthRecover) == null ? void 0 : _a.call(cb);
35474
35474
  });
35475
35475
  });
35476
+ this.client.onWriteConflictError(this.handleWriteConflictError);
35476
35477
  }
35477
35478
  clearEvents() {
35478
35479
  this.doc.off("nothing pending", this.handleNothingPending);
@@ -35690,6 +35691,12 @@ ${codeText}
35690
35691
  });
35691
35692
  }
35692
35693
  }
35694
+ onAuthRecover() {
35695
+ this.callbacks.forEach((cb) => {
35696
+ var _a;
35697
+ return (_a = cb.onAuthRecover) == null ? void 0 : _a.call(cb);
35698
+ });
35699
+ }
35693
35700
  async addResources(resourceIds) {
35694
35701
  let hashes = [];
35695
35702
  resourceIds.forEach((res) => {
@@ -35793,7 +35800,7 @@ ${codeText}
35793
35800
  return meta;
35794
35801
  }
35795
35802
  triggerReAuth() {
35796
- this.client.triggerReAuth();
35803
+ this.client.reAuth();
35797
35804
  }
35798
35805
  }
35799
35806
  getLogger("remote-cursor");
@@ -62931,8 +62938,6 @@ ${codeText}
62931
62938
  return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, containerId, data, true);
62932
62939
  });
62933
62940
  }
62934
- triggerReAuth() {
62935
- }
62936
62941
  }
62937
62942
  const { t } = i18n$1;
62938
62943
  function getOpDescription(user, type) {
@@ -64823,735 +64828,62 @@ ${codeText}
64823
64828
  document.removeEventListener("touchend", this.handleTouchEnd);
64824
64829
  }
64825
64830
  }
64826
- const loadingIcon = '<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M12 7.61719C11.4477 7.61719 11 7.16947 11 6.61719V3.61719C11 3.0649 11.4477 2.61719 12 2.61719C12.5523 2.61719 13 3.0649 13 3.61719V6.61719C13 7.16947 12.5523 7.61719 12 7.61719ZM4.92893 5.54612C5.31946 5.15559 5.95262 5.1556 6.34315 5.54612L8.46447 7.66744C8.85499 8.05796 8.85499 8.69113 8.46447 9.08165C8.07394 9.47218 7.44078 9.47218 7.05025 9.08165L4.92893 6.96033C4.53841 6.56981 4.53841 5.93664 4.92893 5.54612ZM15.5355 9.08165C15.145 8.69113 15.145 8.05796 15.5355 7.66744L17.6569 5.54612C18.0474 5.1556 18.6805 5.1556 19.0711 5.54612C19.4616 5.93664 19.4616 6.56981 19.0711 6.96033L16.9497 9.08165C16.5592 9.47218 15.9261 9.47218 15.5355 9.08165ZM2 12.6172C2 12.0649 2.44772 11.6172 3 11.6172L6 11.6172C6.55229 11.6172 7 12.0649 7 12.6172C7 13.1695 6.55228 13.6172 6 13.6172L3 13.6172C2.44772 13.6172 2 13.1695 2 12.6172ZM17 12.6172C17 12.0649 17.4477 11.6172 18 11.6172L21 11.6172C21.5523 11.6172 22 12.0649 22 12.6172C22 13.1695 21.5523 13.6172 21 13.6172L18 13.6172C17.4477 13.6172 17 13.1695 17 12.6172ZM15.5355 16.1527C15.9261 15.7622 16.5592 15.7622 16.9497 16.1527L19.0711 18.274C19.4616 18.6646 19.4616 19.2977 19.0711 19.6883C18.6805 20.0788 18.0474 20.0788 17.6569 19.6883L15.5355 17.5669C15.145 17.1764 15.145 16.5432 15.5355 16.1527ZM4.92893 19.6883C4.53841 19.2977 4.53841 18.6646 4.92893 18.274L7.05025 16.1527C7.44078 15.7622 8.07394 15.7622 8.46447 16.1527C8.85499 16.5432 8.85499 17.1764 8.46447 17.5669L6.34315 19.6883C5.95262 20.0788 5.31946 20.0788 4.92893 19.6883ZM12 22.6172C11.4477 22.6172 11 22.1695 11 21.6172V18.6172C11 18.0649 11.4477 17.6172 12 17.6172C12.5523 17.6172 13 18.0649 13 18.6172V21.6172C13 22.1695 12.5523 22.6172 12 22.6172Z" fill="#5587F0"/>\n<animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />\n</g>\n</svg>';
64827
- const logger$e = getLogger("webpage");
64828
- class WebPage {
64829
- constructor(editor, blockData) {
64830
- __publicField(this, "currentSrc", "");
64831
- __publicField(this, "loading", null);
64832
- __publicField(this, "handleMaskMouseMove", (editor, event) => {
64833
- if (window.isDragging) {
64834
- return;
64835
- }
64836
- if (event.target && event.target instanceof Element) {
64837
- const mask = event.target.closest("webpage-mask");
64838
- if (mask) {
64839
- mask.style.display = "none";
64840
- }
64841
- }
64842
- editor.domEvents.addEventListener(document, "mousemove", this.handleDocumentMouseMove);
64843
- });
64844
- __publicField(this, "handleDocumentMouseMove", (editor, event) => {
64845
- if (!event.target || !(event.target instanceof Element)) {
64846
- return;
64847
- }
64848
- const block = this.editor.findBlockById(this.blockData.id);
64849
- if (block) {
64850
- const mask = this.getExistsMask(block);
64851
- if (mask) {
64852
- if (isChildNode(block, event.target)) {
64853
- mask.style.display = "none";
64854
- return;
64855
- }
64856
- mask.style.display = "";
64857
- }
64858
- }
64859
- });
64860
- this.editor = editor;
64861
- this.blockData = blockData;
64862
- }
64863
- create(editor, embedData, parent, block) {
64864
- const src = embedData.src;
64865
- const internalContainer = createElement("div", ["editor-embed"], null);
64866
- const iframe = createElement("iframe", ["editor-preview-iframe"], internalContainer);
64867
- this.loading = this.createLoading(internalContainer);
64868
- const handleIframeLoaded = () => {
64869
- assert(logger$e, this.loading, "not created");
64870
- this.loading.hide();
64871
- this.currentSrc = src;
64872
- };
64873
- editor.domEvents.addEventListener(iframe, "load", handleIframeLoaded);
64874
- const httpReg = /^http:\/\//i;
64875
- iframe.src = src.replace(httpReg, "//");
64876
- this.loading.show();
64877
- parent.append(internalContainer);
64878
- this.createMask(editor, block);
64879
- }
64880
- update(editor, block, embedData) {
64881
- assert(logger$e, this.loading, "not created");
64882
- if (this.currentSrc === embedData.src) {
64883
- return;
64884
- }
64885
- const iframe = block.querySelector(".editor-preview-iframe");
64886
- assert(logger$e, iframe, "no exists iframe");
64887
- this.loading.show();
64888
- iframe.src = embedData.src;
64889
- this.createMask(editor, block);
64890
- }
64891
- createLoading(parent) {
64892
- const loadContainer = createElement("div", ["editor-preview-iframe-loading"], null);
64893
- const iconContainer = createElement("span", [], loadContainer);
64894
- iconContainer.innerHTML = loadingIcon;
64895
- return {
64896
- show() {
64897
- parent.append(loadContainer);
64898
- },
64899
- hide() {
64900
- const loadContainer2 = parent.querySelector(":scope > .editor-preview-iframe-loading");
64901
- if (!loadContainer2)
64902
- return;
64903
- loadContainer2.remove();
64904
- }
64905
- };
64906
- }
64907
- getExistsMask(block) {
64908
- const tools = getBlockTools(block);
64909
- return tools.querySelector(".webpage-mask");
64910
- }
64911
- createMask(editor, block) {
64912
- const tools = getBlockTools(block);
64913
- let mask = this.getExistsMask(block);
64914
- if (mask) {
64915
- mask.style.display = "";
64916
- return;
64917
- }
64918
- mask = createElement("div", ["webpage-mask"], tools);
64919
- editor.domEvents.addEventListener(mask, "mousemove", this.handleMaskMouseMove);
64920
- }
64921
- destroy() {
64922
- const block = this.editor.findBlockById(this.blockData.id);
64923
- if (block) {
64924
- const mask = this.getExistsMask(block);
64925
- if (mask) {
64926
- this.editor.domEvents.removeEventListener(mask, "mousemove", this.handleMaskMouseMove);
64927
- this.editor.domEvents.removeEventListener(document, "mousemove", this.handleDocumentMouseMove);
64928
- }
64831
+ function getContentTypeFromHeaders(headers) {
64832
+ const entries = Object.entries(headers);
64833
+ for (let i = 0; i < entries.length; i++) {
64834
+ const [key, value] = entries[i];
64835
+ if (key.toLocaleLowerCase() === "content-type") {
64836
+ return value;
64929
64837
  }
64930
64838
  }
64839
+ return "";
64931
64840
  }
64932
- function isWebpageBlock(block) {
64933
- return block && isEmbedBlock(block) && getEmbedType(block) === "webpage";
64934
- }
64935
- const MAX_HEIGHT = 1e3;
64936
- const MIN_HEIGHT = 100;
64937
- class WebpageResizer {
64938
- constructor(editor) {
64939
- __publicField(this, "currentBlockElement", null);
64940
- __publicField(this, "resizing", false);
64941
- __publicField(this, "handleHoveringBlockChange", (newBlock, oldBlock) => {
64942
- if (this.resizing) {
64943
- return;
64944
- }
64945
- if (oldBlock && isWebpageBlock(oldBlock)) {
64946
- this.disableBlockResize(oldBlock);
64947
- }
64948
- if (newBlock && isWebpageBlock(newBlock)) {
64949
- this.enableBlockResize(newBlock);
64950
- }
64841
+ async function downloadImageToFile(editor, src, withCredentials = true) {
64842
+ try {
64843
+ const res = await editor.doc.request(src, {
64844
+ method: "get",
64845
+ responseType: "blob",
64846
+ withCredentials
64951
64847
  });
64952
- __publicField(this, "handleResizing", (resizer, rect) => {
64953
- this.resizing = true;
64954
- const block = resizer.getBlock();
64955
- if (!block) {
64956
- return;
64957
- }
64958
- const newHeight = Math.max(Math.min(rect.height, MAX_HEIGHT), MIN_HEIGHT);
64959
- block.style.height = `${newHeight}px`;
64960
- addClass(block, "resizing");
64848
+ const reader = new FileReader();
64849
+ const promise = new Promise((resolve, reject) => {
64850
+ reader.onload = resolve;
64851
+ reader.onerror = reject;
64961
64852
  });
64962
- __publicField(this, "handleResized", (resizer) => {
64963
- this.resizing = false;
64964
- const block = resizer.getBlock();
64965
- if (!block) {
64966
- return;
64853
+ reader.readAsArrayBuffer(res.data);
64854
+ await promise;
64855
+ const buffer = reader.result;
64856
+ const contentType = getContentTypeFromHeaders(res.headers).toLocaleLowerCase();
64857
+ let ext = "";
64858
+ if (contentType) {
64859
+ const extensions = mime__default.default[contentType].extensions;
64860
+ if (extensions && extensions.length > 0) {
64861
+ ext = extensions[0];
64967
64862
  }
64968
- removeClass(block, "resizing");
64969
- const oldData = this.editor.getBlockData(block);
64970
- const height = block.getBoundingClientRect().height;
64971
- this.editor.updateBlockData(block, {
64972
- ...oldData,
64973
- height
64974
- });
64975
- });
64976
- this.editor = editor;
64977
- OnesEditorHoveringBlock.get(editor).addListener("change", this.handleHoveringBlockChange);
64978
- }
64979
- destroy() {
64980
- this.currentBlockElement = null;
64981
- OnesEditorHoveringBlock.get(this.editor).removeListener("change", this.handleHoveringBlockChange);
64982
- }
64983
- disableBlockResize(block) {
64984
- const resizer = this.editor.findCustom(`${getBlockId(block)}-resizer`);
64985
- if (resizer) {
64986
- resizer.disableResize();
64987
64863
  }
64988
- }
64989
- enableBlockResize(block) {
64990
- const resizer = this.editor.addCustom(`${getBlockId(block)}-resizer`, () => new BlockResizer(this.editor, {
64991
- resize: ["bottom"]
64992
- }));
64993
- resizer.enableResize(block);
64994
- resizer.removeListener("resizing", this.handleResizing);
64995
- resizer.removeListener("resized", this.handleResized);
64996
- resizer.addListener("resizing", this.handleResizing);
64997
- resizer.addListener("resized", this.handleResized);
64998
- this.currentBlockElement = block;
64864
+ const file2 = new File([buffer], `${Date.now()}.${ext}`, {
64865
+ type: contentType
64866
+ });
64867
+ return file2;
64868
+ } catch (err) {
64869
+ return null;
64999
64870
  }
65000
64871
  }
65001
- const index$3 = "";
65002
- const logger$d = getLogger("editor-dialog");
65003
- function createContainer(content, options) {
65004
- const container = createElement("div", ["editor-dialog-container"], null);
65005
- const header = createElement("div", ["dialog-header"], container);
65006
- createElement("span", ["dialog-header-title"], header, options.title);
65007
- const closeIcon = createElement("span", ["close-icon"], header);
65008
- closeIcon.innerHTML = CloseIcon;
65009
- const contentWrap = createElement("div", ["dialog-content"], container);
65010
- contentWrap.appendChild(content);
65011
- const footer = createElement("div", ["dialog-footer"], container);
65012
- const cancelButton = createButton$1("cancel-button", i18n$1.t("webpage.dialog.cancelText"));
65013
- footer.appendChild(cancelButton);
65014
- const submitButton = createButton$1("submit-button", i18n$1.t("webpage.dialog.okText"), void 0, ["primary"]);
65015
- footer.appendChild(submitButton);
65016
- return container;
64872
+ async function downloadObjectToFile(editor, url) {
64873
+ const file2 = await downloadImageToFile(editor, url);
64874
+ return file2;
65017
64875
  }
65018
- class Dialog extends ManualCloseDialog {
65019
- constructor(content, options) {
65020
- super(createContainer(content, options), options);
65021
- __publicField(this, "_options");
65022
- __publicField(this, "getReferenceClientRect", () => {
65023
- const y = document.documentElement.clientHeight / 2;
65024
- const x = document.documentElement.clientWidth / 2;
65025
- const rootElement = this.getCommandBarRoot();
65026
- assert(logger$d, rootElement, "no command bar root");
65027
- const { width, height } = rootElement.getBoundingClientRect();
65028
- return new DOMRect(Math.max(x - width / 2, 0), Math.max(y - height / 2, 0), 0, 0);
65029
- });
65030
- __publicField(this, "handleOk", async () => {
65031
- var _a, _b;
65032
- try {
65033
- await ((_b = (_a = this._options).onOk) == null ? void 0 : _b.call(_a));
65034
- this.destroy();
65035
- } catch (error2) {
65036
- }
65037
- });
65038
- __publicField(this, "handleClose", () => {
65039
- var _a, _b;
65040
- (_b = (_a = this._options).onClose) == null ? void 0 : _b.call(_a);
65041
- this.destroy();
65042
- });
65043
- const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65044
- const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65045
- const closeIcon = this.content.querySelector(".close-icon");
65046
- submitBtn == null ? void 0 : submitBtn.addEventListener("click", this.handleOk);
65047
- closeIcon == null ? void 0 : closeIcon.addEventListener("click", this.handleClose);
65048
- cancelBtn == null ? void 0 : cancelBtn.addEventListener("click", this.handleClose);
65049
- this._options = options;
65050
- }
65051
- show() {
65052
- super.show(document.documentElement, { getReferenceClientRect: this.getReferenceClientRect });
65053
- setTimeout(() => {
65054
- const mark = document.querySelector(`.editor-disable-scroll[data-scroll-id="${this.id}"]`);
65055
- if (mark) {
65056
- addClass(mark, "editor-disable-scroll-dark");
65057
- }
65058
- });
65059
- }
65060
- destroy() {
65061
- const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65062
- const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65063
- const closeIcon = this.content.querySelector(".close-icon");
65064
- submitBtn == null ? void 0 : submitBtn.removeEventListener("click", this.handleOk);
65065
- cancelBtn == null ? void 0 : cancelBtn.removeEventListener("click", this.handleClose);
65066
- closeIcon == null ? void 0 : closeIcon.removeEventListener("click", this.handleClose);
65067
- super.destroy();
65068
- }
65069
- }
65070
- const getCommandItems = () => [
65071
- {
65072
- name: i18n$1.t("webpage.bilibili"),
65073
- id: "insert-bilibili",
65074
- icon: BilibiliIcon,
65075
- group: "thirdParty",
65076
- subText: getShortcutById("insert-bilibili"),
65077
- value: "bilibili"
65078
- },
65079
- {
65080
- name: i18n$1.t("webpage.youku"),
65081
- id: "insert-youku",
65082
- icon: YoukuIcon,
65083
- group: "thirdParty",
65084
- subText: getShortcutById("insert-youku"),
65085
- value: "youku"
65086
- },
65087
- {
65088
- name: i18n$1.t("webpage.figma"),
65089
- id: "insert-figma",
65090
- icon: FigmaIcon,
65091
- group: "thirdParty",
65092
- subText: getShortcutById("insert-figma"),
65093
- value: "figma"
65094
- },
65095
- {
65096
- name: i18n$1.t("webpage.modao"),
65097
- id: "insert-modao",
65098
- icon: ModaoIcon,
65099
- group: "thirdParty",
65100
- subText: getShortcutById("insert-modao"),
65101
- value: "modao"
65102
- },
65103
- {
65104
- name: i18n$1.t("webpage.tencent"),
65105
- id: "insert-tencent",
65106
- icon: TencentVideoIcon,
65107
- group: "thirdParty",
65108
- subText: getShortcutById("insert-tencent"),
65109
- value: "qqVideo"
65110
- },
65111
- {
65112
- id: "insert-webPage",
65113
- name: i18n$1.t("webpage.title"),
65114
- icon: WebPageIcon,
65115
- group: "common",
65116
- order: 1e3,
65117
- subText: getShortcutById("insert-webPage"),
65118
- value: "url"
65119
- }
65120
- ];
65121
- function getAllowedWebPages(editor) {
65122
- let webpages = getCommandItems();
65123
- const editorOptions = editor.getComponentOptions("webpage");
65124
- if (editorOptions == null ? void 0 : editorOptions.getAllowedWebPages) {
65125
- webpages = editorOptions.getAllowedWebPages(webpages);
65126
- }
65127
- return webpages;
65128
- }
65129
- function isWebPageItem(id) {
65130
- return id === "insert-webPage";
65131
- }
65132
- async function recognizeWebPageLink(editor, url) {
65133
- if (editor.doc.externalDoc.recognizeLink) {
65134
- return editor.doc.externalDoc.recognizeLink(url);
65135
- }
65136
- return null;
65137
- }
65138
- function formatValue(value) {
65139
- if (value && !value.startsWith("http://") && !value.startsWith("https://") && !value.startsWith("//")) {
65140
- return `${window.location.protocol}//${value}`;
65141
- }
65142
- return value;
65143
- }
65144
- async function checkValue(value) {
65145
- if (!value) {
65146
- throw new Error(i18n$1.t("webpage.dialog.errorEnterUrl"));
65147
- }
65148
- const test = value;
65149
- try {
65150
- new URL(test);
65151
- } catch (err) {
65152
- throw new Error(i18n$1.t("webpage.dialog.unsupportedUrl"));
65153
- }
65154
- }
65155
- async function handleInsertEmptyEmbed(editor, options) {
65156
- const itemId = options.item.id;
65157
- const itemOption = getAllowedWebPages(editor).find((item) => item.id === itemId);
65158
- const content = createElement("div", ["webpage-content"], null);
65159
- if (isWebPageItem(itemId)) {
65160
- const helpContainer = createElement("div", ["help-container"], content);
65161
- const helpContent = createElement("div", ["help-content"], helpContainer);
65162
- const span = createElement("span", ["help-icon"], helpContent);
65163
- span.innerHTML = WarningIcon;
65164
- createElement("span", [], helpContent, i18n$1.t("webpage.dialog.helpContent"));
65165
- }
65166
- const { getInputValue, setFieldError, focus, getField } = createInput(content, {
65167
- required: true,
65168
- label: i18n$1.t("webpage.dialog.label"),
65169
- placeholder: i18n$1.t("webpage.dialog.placeholder")
65170
- });
65171
- const webpageOptions = editor.getComponentOptions("webpage");
65172
- if (!isWebPageItem(itemId) && !(webpageOptions == null ? void 0 : webpageOptions.hideHelpLink)) {
65173
- const linkContainer = createElement("div", ["help-link-container"], content);
65174
- const linkContent = createElement("a", ["help-link-content"], linkContainer);
65175
- createElement("span", [], linkContent, i18n$1.t("webpage.dialog.helpLink"));
65176
- const iconSpan = createElement("span", ["help-link-icon"], linkContent);
65177
- iconSpan.innerHTML = LaunchIcon;
65178
- linkContent.href = (webpageOptions == null ? void 0 : webpageOptions.helpLink) || "";
65179
- linkContent.target = "_blank";
65180
- }
65181
- try {
65182
- const result = await new Promise((resolve, reject) => {
65183
- const dialog = new Dialog(content, {
65184
- id: "webpage",
65185
- title: i18n$1.t("webpage.dialog.title", { name: (itemOption == null ? void 0 : itemOption.name) || "" }),
65186
- async onOk() {
65187
- var _a;
65188
- const value = formatValue(getInputValue());
65189
- try {
65190
- await checkValue(value);
65191
- const detail = await recognizeWebPageLink(editor, value);
65192
- resolve((detail == null ? void 0 : detail.url) || "");
65193
- } catch (error2) {
65194
- if (((_a = error2 == null ? void 0 : error2.responseData) == null ? void 0 : _a.statusCode) === 415) {
65195
- if (isWebPageItem(itemId)) {
65196
- resolve(value);
65197
- } else {
65198
- setFieldError(i18n$1.t("webpage.dialog.unsupportedUrl"));
65199
- throw error2;
65200
- }
65201
- } else {
65202
- setFieldError(error2.message || "");
65203
- throw error2;
65204
- }
65205
- }
65206
- },
65207
- onClose() {
65208
- editor.focus();
65209
- reject();
65210
- }
65211
- });
65212
- dialog.addListener("show", focus);
65213
- dialog.show();
65214
- const input2 = getField();
65215
- input2.addEventListener("keydown", async (event) => {
65216
- if (event.isComposing) {
65217
- return;
65218
- }
65219
- if (event.key === "Enter") {
65220
- await dialog.handleOk();
65221
- event.preventDefault();
65222
- return;
65223
- }
65224
- if (event.key === "Escape") {
65225
- dialog.handleClose();
65226
- }
65227
- });
65228
- });
65229
- const blockData = {
65230
- id: genId(),
65231
- type: "embed",
65232
- embedType: "webpage",
65233
- embedData: {
65234
- src: result
65235
- }
65236
- };
65237
- const block = editor.insertBlock(options.containerId, options.blockIndex, blockData);
65238
- editor.focus();
65239
- return block;
65240
- } catch (error2) {
65241
- return null;
65242
- }
65243
- }
65244
- function reloadIframe(block) {
65245
- const iframe = block.querySelector(".editor-preview-iframe");
65246
- const src = iframe.src;
65247
- iframe.src = "about:blank";
65248
- const timer = setTimeout(() => {
65249
- iframe.src = src;
65250
- clearTimeout(timer);
65251
- }, 300);
65252
- return true;
65253
- }
65254
- function openOriginalPage(editor, block) {
65255
- const blockData = editor.getBlockData(block);
65256
- const { embedData } = blockData;
65257
- const src = embedData.src;
65258
- window.open(src, "_blank");
65259
- return true;
65260
- }
65261
- function getBlockProperties$5(editor, block) {
65262
- const properties = getStandardEmbedBlockProperties(editor, block, {
65263
- presetIds: ["add-comment"],
65264
- extCommands: [{
65265
- id: "refresh",
65266
- name: i18n$1.t("webpage.command.refresh"),
65267
- icon: RefreshIcon
65268
- }, {
65269
- id: "open-page",
65270
- name: i18n$1.t("webpage.command.openPage"),
65271
- icon: LaunchIcon
65272
- }],
65273
- handleExecuteCommand: (editor2, block2, item) => {
65274
- switch (item.id) {
65275
- case "refresh":
65276
- return reloadIframe(block2);
65277
- case "open-page":
65278
- return openOriginalPage(editor2, block2);
65279
- }
65280
- return false;
65281
- }
65282
- });
65283
- const abstract = `${i18n$1.t("webpage.abstract")}`;
65284
- return {
65285
- ...properties,
65286
- abstract
65287
- };
65288
- }
65289
- const logger$c = getLogger("webpage-embed");
65290
- function createEmbedContent$5(editor, content, blockData, path, container, block) {
65291
- const { embedData, id } = blockData;
65292
- const { src } = embedData;
65293
- const webpage = editor.addCustom(`webpage-${id}`, () => new WebPage(editor, blockData));
65294
- assert(logger$c, src, "The src from blockData is invalid ");
65295
- webpage.create(editor, embedData, content, block);
65296
- setTimeout(() => {
65297
- if (editor.isBlockWritable(block)) {
65298
- editor.addCustom("webpage-resizer", () => new WebpageResizer(editor));
65299
- }
65300
- });
65301
- if (blockData.height) {
65302
- block.style.height = `${blockData.height}px`;
65303
- }
65304
- }
65305
- function handleUpdateBlock$4(editor, block, blockData) {
65306
- const { embedData, id } = blockData;
65307
- const webpage = editor.getCustom(`webpage-${id}`);
65308
- webpage.update(editor, block, embedData);
65309
- if (blockData.height) {
65310
- block.style.height = `${blockData.height}px`;
65311
- }
65312
- return true;
65313
- }
65314
- function getOptions$2(editor) {
65315
- return {
65316
- name: "WebPage",
65317
- insertEmbedCommandItems: getAllowedWebPages(editor),
65318
- handleInsertEmptyEmbed
65319
- };
65320
- }
65321
- function convertTo$5(editor, blockData, doc2, type) {
65322
- const webpage = blockData.embedData;
65323
- const url = webpage.src;
65324
- if (type === "html") {
65325
- return `<iframe src="${url}" ></iframe>`;
65326
- }
65327
- if (type === "markdown") {
65328
- return `[${url}](${url})`;
65329
- }
65330
- return url;
65331
- }
65332
- const WebPageEmbed = {
65333
- embedType: "webpage",
65334
- createEmbedContent: createEmbedContent$5,
65335
- getBlockProperties: getBlockProperties$5,
65336
- getOptions: getOptions$2,
65337
- handleUpdateBlock: handleUpdateBlock$4,
65338
- convertTo: convertTo$5
65339
- };
65340
- const zhCN$5 = {
65341
- webpage: {
65342
- title: "\u7F51\u9875",
65343
- youku: "\u4F18\u9177\u89C6\u9891",
65344
- modao: "\u58A8\u5200",
65345
- tencent: "\u817E\u8BAF\u89C6\u9891",
65346
- bilibili: "Bilibili",
65347
- figma: "Figma",
65348
- dialog: {
65349
- helpContent: "\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",
65350
- helpLink: "\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",
65351
- label: "\u7F51\u9875\u5730\u5740",
65352
- placeholder: "\u8BF7\u8F93\u5165",
65353
- title: "\u63D2\u5165{name}",
65354
- errorEnterUrl: "\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",
65355
- unsupportedUrl: "\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9",
65356
- okText: "\u786E\u5B9A",
65357
- cancelText: "\u53D6\u6D88"
65358
- },
65359
- abstract: "\u7F51\u9875",
65360
- command: {
65361
- refresh: "\u5237\u65B0\u9875\u9762",
65362
- openPage: "\u6253\u5F00\u539F\u59CB\u9875\u9762"
65363
- }
65364
- }
65365
- };
65366
- const enUS$5 = {
65367
- webpage: {
65368
- title: "Webpage",
65369
- youku: "Youku",
65370
- modao: "Modao",
65371
- tencent: "Tencent Video",
65372
- bilibili: "Bilibili",
65373
- figma: "Figma",
65374
- dialog: {
65375
- helpContent: "Due to landing page limitations, some pages may not be properly displayed during preview.",
65376
- helpLink: "How to get the URL link",
65377
- label: "Website address",
65378
- placeholder: "Please enter",
65379
- title: "Insert {name}",
65380
- errorEnterUrl: "Please enter website address",
65381
- unsupportedUrl: "Unsupported URL",
65382
- okText: "Confirm",
65383
- cancelText: "Cancel"
65384
- },
65385
- abstract: "Webpage",
65386
- command: {
65387
- refresh: "Refresh page",
65388
- openPage: "Open the original page"
65389
- }
65390
- }
65391
- };
65392
- const jaJP$5 = {
65393
- webpage: {
65394
- title: "Web \u30DA\u30FC\u30B8",
65395
- youku: "Youku \u52D5\u753B",
65396
- modao: "Modao",
65397
- tencent: "Tencent \u52D5\u753B",
65398
- bilibili: "Bilibili",
65399
- figma: "Figma",
65400
- dialog: {
65401
- helpContent: "\u30A2\u30AF\u30BB\u30B9\u5148\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u4E00\u90E8\u306E\u30DA\u30FC\u30B8\u304C\u8868\u793A\u3067\u304D\u306A\u3044\u5834\u5408\u304C\u3042\u308A\u307E\u3059\u3002",
65402
- helpLink: "URL \u3092\u53D6\u5F97\u3059\u308B\u65B9\u6CD5",
65403
- label: "URL",
65404
- placeholder: "\u5165\u529B",
65405
- title: "{name}\u3092\u633F\u5165",
65406
- errorEnterUrl: "URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
65407
- unsupportedUrl: "\u3053\u306E URL \u306F\u633F\u5165\u3067\u304D\u307E\u305B\u3093",
65408
- okText: "OK",
65409
- cancelText: "\u30AD\u30E3\u30F3\u30BB\u30EB"
65410
- },
65411
- abstract: "Web \u30DA\u30FC\u30B8",
65412
- command: {
65413
- refresh: "\u30DA\u30FC\u30B8\u3092\u518D\u8AAD\u307F\u8FBC\u3080",
65414
- openPage: "URL\u3092\u958B\u304F"
65415
- }
65416
- }
65417
- };
65418
- i18n$1.mergeLang({
65419
- "zh-CN": zhCN$5,
65420
- "en-US": enUS$5,
65421
- "ja-JP": jaJP$5
65422
- });
65423
- const webpageStyle = "";
65424
- class IframeKindEmbedDocCallbacks extends tinyTypedEmitter.TypedEmitter {
65425
- constructor(editor) {
65426
- super();
65427
- __publicField(this, "currentBlock");
65428
- __publicField(this, "currentIframe");
65429
- __publicField(this, "onReAuthErrorWhenIframeEditing");
65430
- __publicField(this, "onIframeExitEdit");
65431
- __publicField(this, "destroy", () => {
65432
- this.editor.doc.unregisterCallback(this);
65433
- });
65434
- __publicField(this, "onError", (error2) => {
65435
- if (error2.code === AuthError.err) {
65436
- if (this.currentIframe) {
65437
- this.onConnectReAuthError();
65438
- }
65439
- }
65440
- });
65441
- __publicField(this, "onAuthRecover", () => {
65442
- if (this.currentBlock) {
65443
- enablePageScroll(this.currentBlock.id);
65444
- }
65445
- });
65446
- __publicField(this, "unregisterCallbacks", () => {
65447
- this.editor.doc.unregisterCallback(this);
65448
- });
65449
- __publicField(this, "register", (block, iframe, options) => {
65450
- this.currentBlock = block;
65451
- this.currentIframe = iframe;
65452
- this.onReAuthErrorWhenIframeEditing = options.onError;
65453
- this.onIframeExitEdit = options.onExit;
65454
- });
65455
- __publicField(this, "unRegister", () => {
65456
- this.currentBlock = void 0;
65457
- this.currentIframe = void 0;
65458
- this.onReAuthErrorWhenIframeEditing = void 0;
65459
- });
65460
- __publicField(this, "onConnectReAuthError", () => {
65461
- var _a;
65462
- if (this.currentBlock && this.currentIframe) {
65463
- (_a = this.onReAuthErrorWhenIframeEditing) == null ? void 0 : _a.call(this, this.currentBlock, this.currentIframe);
65464
- const container = disablePageScroll(this.currentBlock.id);
65465
- const fixedToolbar = createElement("div", ["iframe-embed-auth-error-tips"], container);
65466
- fixedToolbar.innerHTML = i18n$1.t("authError.tips");
65467
- fixedToolbar.addEventListener("click", (event) => {
65468
- const target = event.target;
65469
- if (target instanceof HTMLSpanElement) {
65470
- const id = target.id;
65471
- switch (id) {
65472
- case "retry":
65473
- this.reAuth();
65474
- break;
65475
- case "exit":
65476
- this.exit();
65477
- break;
65478
- }
65479
- }
65480
- });
65481
- }
65482
- });
65483
- this.editor = editor;
65484
- this.editor.doc.registerCallback(this);
65485
- }
65486
- reAuth() {
65487
- var _a, _b;
65488
- (_b = (_a = this.editor.doc).triggerReAuth) == null ? void 0 : _b.call(_a);
65489
- }
65490
- exit() {
65491
- var _a;
65492
- if (this.currentBlock) {
65493
- enablePageScroll(this.currentBlock.id);
65494
- }
65495
- this.unRegister();
65496
- (_a = this.onIframeExitEdit) == null ? void 0 : _a.call(this);
65497
- }
65498
- }
65499
- function getContentTypeFromHeaders(headers) {
65500
- const entries = Object.entries(headers);
65501
- for (let i = 0; i < entries.length; i++) {
65502
- const [key, value] = entries[i];
65503
- if (key.toLocaleLowerCase() === "content-type") {
65504
- return value;
65505
- }
65506
- }
65507
- return "";
65508
- }
65509
- async function downloadImageToFile(editor, src, withCredentials = true) {
65510
- try {
65511
- const res = await editor.doc.request(src, {
65512
- method: "get",
65513
- responseType: "blob",
65514
- withCredentials
65515
- });
65516
- const reader = new FileReader();
65517
- const promise = new Promise((resolve, reject) => {
65518
- reader.onload = resolve;
65519
- reader.onerror = reject;
65520
- });
65521
- reader.readAsArrayBuffer(res.data);
65522
- await promise;
65523
- const buffer = reader.result;
65524
- const contentType = getContentTypeFromHeaders(res.headers).toLocaleLowerCase();
65525
- let ext = "";
65526
- if (contentType) {
65527
- const extensions = mime__default.default[contentType].extensions;
65528
- if (extensions && extensions.length > 0) {
65529
- ext = extensions[0];
65530
- }
65531
- }
65532
- const file2 = new File([buffer], `${Date.now()}.${ext}`, {
65533
- type: contentType
65534
- });
65535
- return file2;
65536
- } catch (err) {
65537
- return null;
65538
- }
65539
- }
65540
- async function downloadObjectToFile(editor, url) {
65541
- const file2 = await downloadImageToFile(editor, url);
65542
- return file2;
65543
- }
65544
- async function downloadSvgToString(editor, url) {
65545
- const file2 = await downloadObjectToFile(editor, url);
65546
- if (!file2)
65547
- return null;
65548
- const text2 = await file2.text();
65549
- return text2;
65550
- }
65551
- const isEmptyImage = (svg) => {
65552
- const rect = svg.getBoundingClientRect();
65553
- if (rect.width <= 1 && rect.height <= 1) {
65554
- return true;
64876
+ async function downloadSvgToString(editor, url) {
64877
+ const file2 = await downloadObjectToFile(editor, url);
64878
+ if (!file2)
64879
+ return null;
64880
+ const text2 = await file2.text();
64881
+ return text2;
64882
+ }
64883
+ const isEmptyImage = (svg) => {
64884
+ const rect = svg.getBoundingClientRect();
64885
+ if (rect.width <= 1 && rect.height <= 1) {
64886
+ return true;
65555
64887
  }
65556
64888
  return false;
65557
64889
  };
@@ -65695,7 +65027,7 @@ ${codeText}
65695
65027
  const SAVE_DELAY_TIME = 30 * 1e3;
65696
65028
  const DRAWIO_EMPTY_CLASS = "editor-empty-drawio";
65697
65029
  const SHOW_FULL_SCREEN_IFRAME = "show-full-screen-iframe";
65698
- const logger$b = getLogger("embed-block-drawio");
65030
+ const logger$e = getLogger("embed-block-drawio");
65699
65031
  function getDrawioOptions(editor) {
65700
65032
  const compOptions = editor.options.componentsOptions;
65701
65033
  return compOptions.drawIO || {};
@@ -65719,7 +65051,7 @@ ${codeText}
65719
65051
  }
65720
65052
  function resizeObserver(el) {
65721
65053
  const resize = () => {
65722
- assert(logger$b, el, "el does not exist");
65054
+ assert(logger$e, el, "el does not exist");
65723
65055
  const width = document.body.clientWidth || document.documentElement.clientWidth;
65724
65056
  const height = document.body.clientHeight || document.documentElement.clientHeight;
65725
65057
  el.setAttribute("width", `${width - 2 * BORDER}`);
@@ -65737,17 +65069,17 @@ ${codeText}
65737
65069
  async function initializeDrawioIframe(editor, block) {
65738
65070
  const options = getDrawioOptions(editor) || {};
65739
65071
  const callbacks = options.callbacks || {};
65740
- const drawioCallbacks = editor.getCustom("drawio-event-callback");
65072
+ const iframeKindEmbedDocCallbacks = editor.getCustom("iframe-embed-reauth-event-callback");
65741
65073
  const { onCreateDrawIoFrame, onCloseDrawIoFrame } = callbacks;
65742
65074
  let drawioIframe = null;
65743
65075
  let exit;
65744
65076
  if (onCreateDrawIoFrame) {
65745
65077
  drawioIframe = await onCreateDrawIoFrame(editor);
65746
- assert(logger$b, drawioIframe, "iframe create failed");
65078
+ assert(logger$e, drawioIframe, "iframe create failed");
65747
65079
  exit = () => {
65748
- assert(logger$b, drawioIframe, "iframe does not exist");
65749
- assert(logger$b, onCloseDrawIoFrame, "missing parameters: onCloseDrawIoFrame");
65750
- drawioCallbacks.unRegister();
65080
+ assert(logger$e, drawioIframe, "iframe does not exist");
65081
+ assert(logger$e, onCloseDrawIoFrame, "missing parameters: onCloseDrawIoFrame");
65082
+ iframeKindEmbedDocCallbacks.unRegister();
65751
65083
  onCloseDrawIoFrame(editor, drawioIframe);
65752
65084
  };
65753
65085
  } else {
@@ -65758,14 +65090,14 @@ ${codeText}
65758
65090
  addClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
65759
65091
  const { disconnect } = resizeObserver(drawioIframe);
65760
65092
  exit = () => {
65761
- assert(logger$b, drawioIframe, "iframe does not exist");
65762
- drawioCallbacks.unRegister();
65093
+ assert(logger$e, drawioIframe, "iframe does not exist");
65094
+ iframeKindEmbedDocCallbacks.unRegister();
65763
65095
  disconnect();
65764
65096
  document.body.removeChild(drawioContainer);
65765
65097
  removeClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
65766
65098
  };
65767
65099
  }
65768
- drawioCallbacks.register(block, drawioIframe, {
65100
+ iframeKindEmbedDocCallbacks.register(block, drawioIframe, {
65769
65101
  onExit: () => exit()
65770
65102
  });
65771
65103
  return {
@@ -65777,7 +65109,7 @@ ${codeText}
65777
65109
  var _a, _b;
65778
65110
  try {
65779
65111
  if (autoSave) {
65780
- logger$b.debug("auto saving drawio data");
65112
+ logger$e.debug("auto saving drawio data");
65781
65113
  }
65782
65114
  const blob = new Blob([svg]);
65783
65115
  const file2 = new File([blob], "drawio.svg", {
@@ -65796,11 +65128,11 @@ ${codeText}
65796
65128
  };
65797
65129
  editor.updateEmbedData(targetBlock, newEmbedData);
65798
65130
  } else {
65799
- logger$b.error("block has been deleted");
65131
+ logger$e.error("block has been deleted");
65800
65132
  }
65801
65133
  } catch (err) {
65802
65134
  const message = `failed to upload drawio data: ${err.message}`;
65803
- logger$b.error(message);
65135
+ logger$e.error(message);
65804
65136
  }
65805
65137
  } catch (err) {
65806
65138
  const message = `failed to save drawio data: ${err.message}`;
@@ -65819,7 +65151,7 @@ ${codeText}
65819
65151
  };
65820
65152
  const receive = async (evt) => {
65821
65153
  var _a, _b;
65822
- assert(logger$b, iframe.contentWindow, "iframe.contentWindow does not exist");
65154
+ assert(logger$e, iframe.contentWindow, "iframe.contentWindow does not exist");
65823
65155
  if (evt.data.length > 0) {
65824
65156
  const msg = JSON.parse(evt.data);
65825
65157
  const xml = drawIoData.xmlSvg || drawIoData.xml;
@@ -65969,7 +65301,7 @@ ${codeText}
65969
65301
  };
65970
65302
  }
65971
65303
  function setGraph(embed, data) {
65972
- assert(logger$b, data, "Required data is missing in setGraph");
65304
+ assert(logger$e, data, "Required data is missing in setGraph");
65973
65305
  if ("src" in data) {
65974
65306
  embed.setAttribute("data-src", data.src);
65975
65307
  return;
@@ -65992,8 +65324,8 @@ ${codeText}
65992
65324
  };
65993
65325
  }
65994
65326
  function updateGraphBySrc(src, embed, editor) {
65995
- assert(logger$b, src, "params error: src");
65996
- assert(logger$b, editor, "params error: editor");
65327
+ assert(logger$e, src, "params error: src");
65328
+ assert(logger$e, editor, "params error: editor");
65997
65329
  const embedEl = embed;
65998
65330
  const url = editor.doc.buildResourceUrl(src);
65999
65331
  const img = document.createElement("img");
@@ -66026,26 +65358,26 @@ ${codeText}
66026
65358
  };
66027
65359
  }
66028
65360
  function updateGraphByXml(mxFile, embed, editor) {
66029
- assert(logger$b, editor, "parameter missing");
65361
+ assert(logger$e, editor, "parameter missing");
66030
65362
  initDrawIo(editor).then(() => {
66031
65363
  const { mxUtils, mxGraph: MxGraph, mxCodec: MxCodec } = window;
66032
- assert(logger$b, mxUtils, "External resource loading exception: mxUtils");
66033
- assert(logger$b, MxGraph, "External resource loading exception: MxGraph");
66034
- assert(logger$b, MxCodec, "External resource loading exception: MxCodec");
65364
+ assert(logger$e, mxUtils, "External resource loading exception: mxUtils");
65365
+ assert(logger$e, MxGraph, "External resource loading exception: MxGraph");
65366
+ assert(logger$e, MxCodec, "External resource loading exception: MxCodec");
66035
65367
  const file2 = mxUtils.parseXml(mxFile);
66036
65368
  embed.innerHTML = "";
66037
65369
  const node = file2.documentElement;
66038
- assert(logger$b, node, "Resource parsing exception");
66039
- assert(logger$b, node.nodeName === "mxfile", "Resource parsing exception");
65370
+ assert(logger$e, node, "Resource parsing exception");
65371
+ assert(logger$e, node.nodeName === "mxfile", "Resource parsing exception");
66040
65372
  const diagrams = node.getElementsByTagName("diagram");
66041
- assert(logger$b, diagrams.length > 0, "Resource parsing exception");
65373
+ assert(logger$e, diagrams.length > 0, "Resource parsing exception");
66042
65374
  let xmlDoc;
66043
65375
  const data = diagrams[0];
66044
65376
  if (data.text || data.textContent) {
66045
65377
  const diagramBase64 = getTextContent(data);
66046
65378
  const raw = atob(diagramBase64);
66047
65379
  const pako = window.pako;
66048
- assert(logger$b, pako, "External resource loading exception: pako");
65380
+ assert(logger$e, pako, "External resource loading exception: pako");
66049
65381
  const encodedXml = pako.inflateRaw(Uint8Array.from(raw, (c) => c.charCodeAt(0)), { to: "string" });
66050
65382
  const xml = decodeURIComponent(encodedXml);
66051
65383
  xmlDoc = mxUtils.parseXml(xml);
@@ -66082,7 +65414,7 @@ ${codeText}
66082
65414
  }
66083
65415
  addDrawioEmptyStatus(embed);
66084
65416
  }
66085
- function getBlockProperties$4(editor, block) {
65417
+ function getBlockProperties$5(editor, block) {
66086
65418
  const properties = getStandardEmbedBlockProperties(editor, block, {
66087
65419
  handleExecuteCommand: (editor2, block2, item) => {
66088
65420
  if (item.id === "edit") {
@@ -66095,7 +65427,7 @@ ${codeText}
66095
65427
  });
66096
65428
  return { ...properties, abstract: i18n$1.t("drawio.abstract") };
66097
65429
  }
66098
- const enUS$4 = {
65430
+ const enUS$5 = {
66099
65431
  drawio: {
66100
65432
  title: "Flowchart/UML",
66101
65433
  empty: "Empty graph",
@@ -66109,7 +65441,7 @@ ${codeText}
66109
65441
  tips: '<div>\u670D\u52A1\u5DF2\u65AD\u5F00\uFF0C\u4E3A\u4E86\u907F\u514D\u5185\u5BB9\u4E22\u5931\uFF0C\u6211\u4EEC\u6682\u65F6\u7981\u7528\u7F16\u8F91\u529F\u80FD\uFF0C\u4F60\u53EF\u4EE5 <span id="retry">\u91CD\u8FDE\u670D\u52A1</span> \u6216 <span id="exit">\u9000\u51FA\u7F16\u8F91</span></div>'
66110
65442
  }
66111
65443
  };
66112
- const zhCN$4 = {
65444
+ const zhCN$5 = {
66113
65445
  drawio: {
66114
65446
  title: "\u6D41\u7A0B\u56FE/UML",
66115
65447
  empty: "\u7A7A\u56FE\u8868",
@@ -66123,7 +65455,7 @@ ${codeText}
66123
65455
  tips: '<div>\u670D\u52A1\u5DF2\u65AD\u5F00\uFF0C\u4E3A\u4E86\u907F\u514D\u5185\u5BB9\u4E22\u5931\uFF0C\u6211\u4EEC\u6682\u65F6\u7981\u7528\u7F16\u8F91\u529F\u80FD\uFF0C\u4F60\u53EF\u4EE5 <span id="retry">\u91CD\u8FDE\u670D\u52A1</span> \u6216 <span id="exit">\u9000\u51FA\u7F16\u8F91</span></div>'
66124
65456
  }
66125
65457
  };
66126
- const jaJP$4 = {
65458
+ const jaJP$5 = {
66127
65459
  drawio: {
66128
65460
  title: "\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",
66129
65461
  empty: "\u30B0\u30E9\u30D5\u30C7\u30FC\u30BF\u306A\u3057",
@@ -66138,16 +65470,16 @@ ${codeText}
66138
65470
  }
66139
65471
  };
66140
65472
  const langs = {
66141
- "en-US": enUS$4,
66142
- "zh-CN": zhCN$4,
66143
- "ja-JP": jaJP$4
65473
+ "en-US": enUS$5,
65474
+ "zh-CN": zhCN$5,
65475
+ "ja-JP": jaJP$5
66144
65476
  };
66145
65477
  i18n$1.mergeLang(langs);
66146
- const logger$a = getLogger("embed-block-drawio");
65478
+ const logger$d = getLogger("embed-block-drawio");
66147
65479
  const isInitializationCompleted = false;
66148
65480
  function editDrawIO(editor, block, embed, data) {
66149
- assert(logger$a, embed, `parameter missing: ${embed}`);
66150
- assert(logger$a, editor, `parameter missing: ${editor}`);
65481
+ assert(logger$d, embed, `parameter missing: ${embed}`);
65482
+ assert(logger$d, editor, `parameter missing: ${editor}`);
66151
65483
  editGraph(editor, block, data, isInitializationCompleted);
66152
65484
  }
66153
65485
  function updateViewLayer(editor, embed, data) {
@@ -66189,23 +65521,20 @@ ${codeText}
66189
65521
  }
66190
65522
  }
66191
65523
  }
66192
- function createEmbedContent$4(editor, content, blockData, path, container, block) {
66193
- editorRunOnce(editor, "drawio-event-callbacks", () => {
66194
- editor.addCustom("drawio-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
66195
- });
65524
+ function createEmbedContent$5(editor, content, blockData, path, container, block) {
66196
65525
  const drawioData = blockData.embedData;
66197
65526
  mount(editor, content, drawioData);
66198
65527
  EmbedBlockResizer.register(editor, block);
66199
65528
  }
66200
- function handleUpdateBlock$3(editor, block, blockData) {
65529
+ function handleUpdateBlock$4(editor, block, blockData) {
66201
65530
  const data = blockData.embedData;
66202
65531
  const content = getBlockContent(block);
66203
65532
  const embed = content.querySelector(":scope > .editor-drawio-content");
66204
- assert(logger$a, embed, "embed should not be null");
65533
+ assert(logger$d, embed, "embed should not be null");
66205
65534
  update$1(editor, embed, data);
66206
65535
  return true;
66207
65536
  }
66208
- function getOptions$1() {
65537
+ function getOptions$2() {
66209
65538
  return {
66210
65539
  name: "UML",
66211
65540
  insertEmbedCommandItems: [{
@@ -66226,7 +65555,7 @@ ${codeText}
66226
65555
  setTimeout(() => {
66227
65556
  const blockContent = getBlockContent(block);
66228
65557
  const embed = blockContent.querySelector(":scope > .editor-drawio-content");
66229
- assert(logger$a, embed, "embed should not be null");
65558
+ assert(logger$d, embed, "embed should not be null");
66230
65559
  const blockData = editor.getBlockData(block);
66231
65560
  editDrawIO(editor, block, embed, blockData.embedData);
66232
65561
  }, 100);
@@ -66234,7 +65563,7 @@ ${codeText}
66234
65563
  }
66235
65564
  };
66236
65565
  }
66237
- function convertTo$4(editor, blockData, doc2, type) {
65566
+ function convertTo$5(editor, blockData, doc2, type) {
66238
65567
  const { embedData } = blockData;
66239
65568
  const data = embedData;
66240
65569
  if (type === "html") {
@@ -66259,13 +65588,683 @@ ${codeText}
66259
65588
  }
66260
65589
  const DrawioEmbed = {
66261
65590
  embedType: "drawio",
66262
- getOptions: getOptions$1,
65591
+ getOptions: getOptions$2,
65592
+ createEmbedContent: createEmbedContent$5,
65593
+ handleUpdateBlock: handleUpdateBlock$4,
65594
+ getBlockProperties: getBlockProperties$5,
65595
+ convertTo: convertTo$5
65596
+ };
65597
+ const style = "";
65598
+ class IframeKindEmbedDocCallbacks extends tinyTypedEmitter.TypedEmitter {
65599
+ constructor(editor) {
65600
+ super();
65601
+ __publicField(this, "currentBlock");
65602
+ __publicField(this, "currentIframe");
65603
+ __publicField(this, "onReAuthErrorWhenIframeEditing");
65604
+ __publicField(this, "onIframeExitEdit");
65605
+ __publicField(this, "destroy", () => {
65606
+ this.editor.doc.externalDoc.unregisterCallback(this);
65607
+ });
65608
+ __publicField(this, "onError", (error2) => {
65609
+ if (error2.code === AuthError.err) {
65610
+ if (this.currentIframe) {
65611
+ this.onConnectReAuthError();
65612
+ }
65613
+ }
65614
+ });
65615
+ __publicField(this, "onAuthRecover", () => {
65616
+ if (this.currentBlock) {
65617
+ enablePageScroll(this.currentBlock.id);
65618
+ }
65619
+ });
65620
+ __publicField(this, "unregisterCallbacks", () => {
65621
+ this.editor.doc.unregisterCallback(this);
65622
+ });
65623
+ __publicField(this, "register", (block, iframe, options) => {
65624
+ this.currentBlock = block;
65625
+ this.currentIframe = iframe;
65626
+ this.onReAuthErrorWhenIframeEditing = options.onError;
65627
+ this.onIframeExitEdit = options.onExit;
65628
+ });
65629
+ __publicField(this, "unRegister", () => {
65630
+ this.currentBlock = void 0;
65631
+ this.currentIframe = void 0;
65632
+ this.onReAuthErrorWhenIframeEditing = void 0;
65633
+ });
65634
+ __publicField(this, "onConnectReAuthError", () => {
65635
+ var _a;
65636
+ if (this.currentBlock && this.currentIframe) {
65637
+ (_a = this.onReAuthErrorWhenIframeEditing) == null ? void 0 : _a.call(this, this.currentBlock, this.currentIframe);
65638
+ const container = disablePageScroll(this.currentBlock.id);
65639
+ const fixedToolbar = createElement("div", ["iframe-embed-auth-error-tips"], container);
65640
+ fixedToolbar.innerHTML = i18n$1.t("authError.tips");
65641
+ fixedToolbar.addEventListener("click", (event) => {
65642
+ var _a2, _b;
65643
+ const target = event.target;
65644
+ if (target instanceof HTMLSpanElement) {
65645
+ const id = target.id;
65646
+ switch (id) {
65647
+ case "retry":
65648
+ (_b = (_a2 = this.editor.doc).triggerReAuth) == null ? void 0 : _b.call(_a2);
65649
+ break;
65650
+ case "exit":
65651
+ this.exit();
65652
+ break;
65653
+ }
65654
+ }
65655
+ });
65656
+ }
65657
+ });
65658
+ this.editor = editor;
65659
+ this.editor.doc.externalDoc.registerCallback(this);
65660
+ }
65661
+ exit() {
65662
+ var _a;
65663
+ if (this.currentBlock) {
65664
+ enablePageScroll(this.currentBlock.id);
65665
+ }
65666
+ this.unRegister();
65667
+ (_a = this.onIframeExitEdit) == null ? void 0 : _a.call(this);
65668
+ }
65669
+ }
65670
+ const loadingIcon = '<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M12 7.61719C11.4477 7.61719 11 7.16947 11 6.61719V3.61719C11 3.0649 11.4477 2.61719 12 2.61719C12.5523 2.61719 13 3.0649 13 3.61719V6.61719C13 7.16947 12.5523 7.61719 12 7.61719ZM4.92893 5.54612C5.31946 5.15559 5.95262 5.1556 6.34315 5.54612L8.46447 7.66744C8.85499 8.05796 8.85499 8.69113 8.46447 9.08165C8.07394 9.47218 7.44078 9.47218 7.05025 9.08165L4.92893 6.96033C4.53841 6.56981 4.53841 5.93664 4.92893 5.54612ZM15.5355 9.08165C15.145 8.69113 15.145 8.05796 15.5355 7.66744L17.6569 5.54612C18.0474 5.1556 18.6805 5.1556 19.0711 5.54612C19.4616 5.93664 19.4616 6.56981 19.0711 6.96033L16.9497 9.08165C16.5592 9.47218 15.9261 9.47218 15.5355 9.08165ZM2 12.6172C2 12.0649 2.44772 11.6172 3 11.6172L6 11.6172C6.55229 11.6172 7 12.0649 7 12.6172C7 13.1695 6.55228 13.6172 6 13.6172L3 13.6172C2.44772 13.6172 2 13.1695 2 12.6172ZM17 12.6172C17 12.0649 17.4477 11.6172 18 11.6172L21 11.6172C21.5523 11.6172 22 12.0649 22 12.6172C22 13.1695 21.5523 13.6172 21 13.6172L18 13.6172C17.4477 13.6172 17 13.1695 17 12.6172ZM15.5355 16.1527C15.9261 15.7622 16.5592 15.7622 16.9497 16.1527L19.0711 18.274C19.4616 18.6646 19.4616 19.2977 19.0711 19.6883C18.6805 20.0788 18.0474 20.0788 17.6569 19.6883L15.5355 17.5669C15.145 17.1764 15.145 16.5432 15.5355 16.1527ZM4.92893 19.6883C4.53841 19.2977 4.53841 18.6646 4.92893 18.274L7.05025 16.1527C7.44078 15.7622 8.07394 15.7622 8.46447 16.1527C8.85499 16.5432 8.85499 17.1764 8.46447 17.5669L6.34315 19.6883C5.95262 20.0788 5.31946 20.0788 4.92893 19.6883ZM12 22.6172C11.4477 22.6172 11 22.1695 11 21.6172V18.6172C11 18.0649 11.4477 17.6172 12 17.6172C12.5523 17.6172 13 18.0649 13 18.6172V21.6172C13 22.1695 12.5523 22.6172 12 22.6172Z" fill="#5587F0"/>\n<animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />\n</g>\n</svg>';
65671
+ const logger$c = getLogger("webpage");
65672
+ class WebPage {
65673
+ constructor(editor, blockData) {
65674
+ __publicField(this, "currentSrc", "");
65675
+ __publicField(this, "loading", null);
65676
+ __publicField(this, "handleMaskMouseMove", (editor, event) => {
65677
+ if (window.isDragging) {
65678
+ return;
65679
+ }
65680
+ if (event.target && event.target instanceof Element) {
65681
+ const mask = event.target.closest("webpage-mask");
65682
+ if (mask) {
65683
+ mask.style.display = "none";
65684
+ }
65685
+ }
65686
+ editor.domEvents.addEventListener(document, "mousemove", this.handleDocumentMouseMove);
65687
+ });
65688
+ __publicField(this, "handleDocumentMouseMove", (editor, event) => {
65689
+ if (!event.target || !(event.target instanceof Element)) {
65690
+ return;
65691
+ }
65692
+ const block = this.editor.findBlockById(this.blockData.id);
65693
+ if (block) {
65694
+ const mask = this.getExistsMask(block);
65695
+ if (mask) {
65696
+ if (isChildNode(block, event.target)) {
65697
+ mask.style.display = "none";
65698
+ return;
65699
+ }
65700
+ mask.style.display = "";
65701
+ }
65702
+ }
65703
+ });
65704
+ this.editor = editor;
65705
+ this.blockData = blockData;
65706
+ }
65707
+ create(editor, embedData, parent, block) {
65708
+ const src = embedData.src;
65709
+ const internalContainer = createElement("div", ["editor-embed"], null);
65710
+ const iframe = createElement("iframe", ["editor-preview-iframe"], internalContainer);
65711
+ this.loading = this.createLoading(internalContainer);
65712
+ const handleIframeLoaded = () => {
65713
+ assert(logger$c, this.loading, "not created");
65714
+ this.loading.hide();
65715
+ this.currentSrc = src;
65716
+ };
65717
+ editor.domEvents.addEventListener(iframe, "load", handleIframeLoaded);
65718
+ const httpReg = /^http:\/\//i;
65719
+ iframe.src = src.replace(httpReg, "//");
65720
+ this.loading.show();
65721
+ parent.append(internalContainer);
65722
+ this.createMask(editor, block);
65723
+ }
65724
+ update(editor, block, embedData) {
65725
+ assert(logger$c, this.loading, "not created");
65726
+ if (this.currentSrc === embedData.src) {
65727
+ return;
65728
+ }
65729
+ const iframe = block.querySelector(".editor-preview-iframe");
65730
+ assert(logger$c, iframe, "no exists iframe");
65731
+ this.loading.show();
65732
+ iframe.src = embedData.src;
65733
+ this.createMask(editor, block);
65734
+ }
65735
+ createLoading(parent) {
65736
+ const loadContainer = createElement("div", ["editor-preview-iframe-loading"], null);
65737
+ const iconContainer = createElement("span", [], loadContainer);
65738
+ iconContainer.innerHTML = loadingIcon;
65739
+ return {
65740
+ show() {
65741
+ parent.append(loadContainer);
65742
+ },
65743
+ hide() {
65744
+ const loadContainer2 = parent.querySelector(":scope > .editor-preview-iframe-loading");
65745
+ if (!loadContainer2)
65746
+ return;
65747
+ loadContainer2.remove();
65748
+ }
65749
+ };
65750
+ }
65751
+ getExistsMask(block) {
65752
+ const tools = getBlockTools(block);
65753
+ return tools.querySelector(".webpage-mask");
65754
+ }
65755
+ createMask(editor, block) {
65756
+ const tools = getBlockTools(block);
65757
+ let mask = this.getExistsMask(block);
65758
+ if (mask) {
65759
+ mask.style.display = "";
65760
+ return;
65761
+ }
65762
+ mask = createElement("div", ["webpage-mask"], tools);
65763
+ editor.domEvents.addEventListener(mask, "mousemove", this.handleMaskMouseMove);
65764
+ }
65765
+ destroy() {
65766
+ const block = this.editor.findBlockById(this.blockData.id);
65767
+ if (block) {
65768
+ const mask = this.getExistsMask(block);
65769
+ if (mask) {
65770
+ this.editor.domEvents.removeEventListener(mask, "mousemove", this.handleMaskMouseMove);
65771
+ this.editor.domEvents.removeEventListener(document, "mousemove", this.handleDocumentMouseMove);
65772
+ }
65773
+ }
65774
+ }
65775
+ }
65776
+ function isWebpageBlock(block) {
65777
+ return block && isEmbedBlock(block) && getEmbedType(block) === "webpage";
65778
+ }
65779
+ const MAX_HEIGHT = 1e3;
65780
+ const MIN_HEIGHT = 100;
65781
+ class WebpageResizer {
65782
+ constructor(editor) {
65783
+ __publicField(this, "currentBlockElement", null);
65784
+ __publicField(this, "resizing", false);
65785
+ __publicField(this, "handleHoveringBlockChange", (newBlock, oldBlock) => {
65786
+ if (this.resizing) {
65787
+ return;
65788
+ }
65789
+ if (oldBlock && isWebpageBlock(oldBlock)) {
65790
+ this.disableBlockResize(oldBlock);
65791
+ }
65792
+ if (newBlock && isWebpageBlock(newBlock)) {
65793
+ this.enableBlockResize(newBlock);
65794
+ }
65795
+ });
65796
+ __publicField(this, "handleResizing", (resizer, rect) => {
65797
+ this.resizing = true;
65798
+ const block = resizer.getBlock();
65799
+ if (!block) {
65800
+ return;
65801
+ }
65802
+ const newHeight = Math.max(Math.min(rect.height, MAX_HEIGHT), MIN_HEIGHT);
65803
+ block.style.height = `${newHeight}px`;
65804
+ addClass(block, "resizing");
65805
+ });
65806
+ __publicField(this, "handleResized", (resizer) => {
65807
+ this.resizing = false;
65808
+ const block = resizer.getBlock();
65809
+ if (!block) {
65810
+ return;
65811
+ }
65812
+ removeClass(block, "resizing");
65813
+ const oldData = this.editor.getBlockData(block);
65814
+ const height = block.getBoundingClientRect().height;
65815
+ this.editor.updateBlockData(block, {
65816
+ ...oldData,
65817
+ height
65818
+ });
65819
+ });
65820
+ this.editor = editor;
65821
+ OnesEditorHoveringBlock.get(editor).addListener("change", this.handleHoveringBlockChange);
65822
+ }
65823
+ destroy() {
65824
+ this.currentBlockElement = null;
65825
+ OnesEditorHoveringBlock.get(this.editor).removeListener("change", this.handleHoveringBlockChange);
65826
+ }
65827
+ disableBlockResize(block) {
65828
+ const resizer = this.editor.findCustom(`${getBlockId(block)}-resizer`);
65829
+ if (resizer) {
65830
+ resizer.disableResize();
65831
+ }
65832
+ }
65833
+ enableBlockResize(block) {
65834
+ const resizer = this.editor.addCustom(`${getBlockId(block)}-resizer`, () => new BlockResizer(this.editor, {
65835
+ resize: ["bottom"]
65836
+ }));
65837
+ resizer.enableResize(block);
65838
+ resizer.removeListener("resizing", this.handleResizing);
65839
+ resizer.removeListener("resized", this.handleResized);
65840
+ resizer.addListener("resizing", this.handleResizing);
65841
+ resizer.addListener("resized", this.handleResized);
65842
+ this.currentBlockElement = block;
65843
+ }
65844
+ }
65845
+ const index$3 = "";
65846
+ const logger$b = getLogger("editor-dialog");
65847
+ function createContainer(content, options) {
65848
+ const container = createElement("div", ["editor-dialog-container"], null);
65849
+ const header = createElement("div", ["dialog-header"], container);
65850
+ createElement("span", ["dialog-header-title"], header, options.title);
65851
+ const closeIcon = createElement("span", ["close-icon"], header);
65852
+ closeIcon.innerHTML = CloseIcon;
65853
+ const contentWrap = createElement("div", ["dialog-content"], container);
65854
+ contentWrap.appendChild(content);
65855
+ const footer = createElement("div", ["dialog-footer"], container);
65856
+ const cancelButton = createButton$1("cancel-button", i18n$1.t("webpage.dialog.cancelText"));
65857
+ footer.appendChild(cancelButton);
65858
+ const submitButton = createButton$1("submit-button", i18n$1.t("webpage.dialog.okText"), void 0, ["primary"]);
65859
+ footer.appendChild(submitButton);
65860
+ return container;
65861
+ }
65862
+ class Dialog extends ManualCloseDialog {
65863
+ constructor(content, options) {
65864
+ super(createContainer(content, options), options);
65865
+ __publicField(this, "_options");
65866
+ __publicField(this, "getReferenceClientRect", () => {
65867
+ const y = document.documentElement.clientHeight / 2;
65868
+ const x = document.documentElement.clientWidth / 2;
65869
+ const rootElement = this.getCommandBarRoot();
65870
+ assert(logger$b, rootElement, "no command bar root");
65871
+ const { width, height } = rootElement.getBoundingClientRect();
65872
+ return new DOMRect(Math.max(x - width / 2, 0), Math.max(y - height / 2, 0), 0, 0);
65873
+ });
65874
+ __publicField(this, "handleOk", async () => {
65875
+ var _a, _b;
65876
+ try {
65877
+ await ((_b = (_a = this._options).onOk) == null ? void 0 : _b.call(_a));
65878
+ this.destroy();
65879
+ } catch (error2) {
65880
+ }
65881
+ });
65882
+ __publicField(this, "handleClose", () => {
65883
+ var _a, _b;
65884
+ (_b = (_a = this._options).onClose) == null ? void 0 : _b.call(_a);
65885
+ this.destroy();
65886
+ });
65887
+ const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65888
+ const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65889
+ const closeIcon = this.content.querySelector(".close-icon");
65890
+ submitBtn == null ? void 0 : submitBtn.addEventListener("click", this.handleOk);
65891
+ closeIcon == null ? void 0 : closeIcon.addEventListener("click", this.handleClose);
65892
+ cancelBtn == null ? void 0 : cancelBtn.addEventListener("click", this.handleClose);
65893
+ this._options = options;
65894
+ }
65895
+ show() {
65896
+ super.show(document.documentElement, { getReferenceClientRect: this.getReferenceClientRect });
65897
+ setTimeout(() => {
65898
+ const mark = document.querySelector(`.editor-disable-scroll[data-scroll-id="${this.id}"]`);
65899
+ if (mark) {
65900
+ addClass(mark, "editor-disable-scroll-dark");
65901
+ }
65902
+ });
65903
+ }
65904
+ destroy() {
65905
+ const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65906
+ const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65907
+ const closeIcon = this.content.querySelector(".close-icon");
65908
+ submitBtn == null ? void 0 : submitBtn.removeEventListener("click", this.handleOk);
65909
+ cancelBtn == null ? void 0 : cancelBtn.removeEventListener("click", this.handleClose);
65910
+ closeIcon == null ? void 0 : closeIcon.removeEventListener("click", this.handleClose);
65911
+ super.destroy();
65912
+ }
65913
+ }
65914
+ const getCommandItems = () => [
65915
+ {
65916
+ name: i18n$1.t("webpage.bilibili"),
65917
+ id: "insert-bilibili",
65918
+ icon: BilibiliIcon,
65919
+ group: "thirdParty",
65920
+ subText: getShortcutById("insert-bilibili"),
65921
+ value: "bilibili"
65922
+ },
65923
+ {
65924
+ name: i18n$1.t("webpage.youku"),
65925
+ id: "insert-youku",
65926
+ icon: YoukuIcon,
65927
+ group: "thirdParty",
65928
+ subText: getShortcutById("insert-youku"),
65929
+ value: "youku"
65930
+ },
65931
+ {
65932
+ name: i18n$1.t("webpage.figma"),
65933
+ id: "insert-figma",
65934
+ icon: FigmaIcon,
65935
+ group: "thirdParty",
65936
+ subText: getShortcutById("insert-figma"),
65937
+ value: "figma"
65938
+ },
65939
+ {
65940
+ name: i18n$1.t("webpage.modao"),
65941
+ id: "insert-modao",
65942
+ icon: ModaoIcon,
65943
+ group: "thirdParty",
65944
+ subText: getShortcutById("insert-modao"),
65945
+ value: "modao"
65946
+ },
65947
+ {
65948
+ name: i18n$1.t("webpage.tencent"),
65949
+ id: "insert-tencent",
65950
+ icon: TencentVideoIcon,
65951
+ group: "thirdParty",
65952
+ subText: getShortcutById("insert-tencent"),
65953
+ value: "qqVideo"
65954
+ },
65955
+ {
65956
+ id: "insert-webPage",
65957
+ name: i18n$1.t("webpage.title"),
65958
+ icon: WebPageIcon,
65959
+ group: "common",
65960
+ order: 1e3,
65961
+ subText: getShortcutById("insert-webPage"),
65962
+ value: "url"
65963
+ }
65964
+ ];
65965
+ function getAllowedWebPages(editor) {
65966
+ let webpages = getCommandItems();
65967
+ const editorOptions = editor.getComponentOptions("webpage");
65968
+ if (editorOptions == null ? void 0 : editorOptions.getAllowedWebPages) {
65969
+ webpages = editorOptions.getAllowedWebPages(webpages);
65970
+ }
65971
+ return webpages;
65972
+ }
65973
+ function isWebPageItem(id) {
65974
+ return id === "insert-webPage";
65975
+ }
65976
+ async function recognizeWebPageLink(editor, url) {
65977
+ if (editor.doc.externalDoc.recognizeLink) {
65978
+ return editor.doc.externalDoc.recognizeLink(url);
65979
+ }
65980
+ return null;
65981
+ }
65982
+ function formatValue(value) {
65983
+ if (value && !value.startsWith("http://") && !value.startsWith("https://") && !value.startsWith("//")) {
65984
+ return `${window.location.protocol}//${value}`;
65985
+ }
65986
+ return value;
65987
+ }
65988
+ async function checkValue(value) {
65989
+ if (!value) {
65990
+ throw new Error(i18n$1.t("webpage.dialog.errorEnterUrl"));
65991
+ }
65992
+ const test = value;
65993
+ try {
65994
+ new URL(test);
65995
+ } catch (err) {
65996
+ throw new Error(i18n$1.t("webpage.dialog.unsupportedUrl"));
65997
+ }
65998
+ }
65999
+ async function handleInsertEmptyEmbed(editor, options) {
66000
+ const itemId = options.item.id;
66001
+ const itemOption = getAllowedWebPages(editor).find((item) => item.id === itemId);
66002
+ const content = createElement("div", ["webpage-content"], null);
66003
+ if (isWebPageItem(itemId)) {
66004
+ const helpContainer = createElement("div", ["help-container"], content);
66005
+ const helpContent = createElement("div", ["help-content"], helpContainer);
66006
+ const span = createElement("span", ["help-icon"], helpContent);
66007
+ span.innerHTML = WarningIcon;
66008
+ createElement("span", [], helpContent, i18n$1.t("webpage.dialog.helpContent"));
66009
+ }
66010
+ const { getInputValue, setFieldError, focus, getField } = createInput(content, {
66011
+ required: true,
66012
+ label: i18n$1.t("webpage.dialog.label"),
66013
+ placeholder: i18n$1.t("webpage.dialog.placeholder")
66014
+ });
66015
+ const webpageOptions = editor.getComponentOptions("webpage");
66016
+ if (!isWebPageItem(itemId) && !(webpageOptions == null ? void 0 : webpageOptions.hideHelpLink)) {
66017
+ const linkContainer = createElement("div", ["help-link-container"], content);
66018
+ const linkContent = createElement("a", ["help-link-content"], linkContainer);
66019
+ createElement("span", [], linkContent, i18n$1.t("webpage.dialog.helpLink"));
66020
+ const iconSpan = createElement("span", ["help-link-icon"], linkContent);
66021
+ iconSpan.innerHTML = LaunchIcon;
66022
+ linkContent.href = (webpageOptions == null ? void 0 : webpageOptions.helpLink) || "";
66023
+ linkContent.target = "_blank";
66024
+ }
66025
+ try {
66026
+ const result = await new Promise((resolve, reject) => {
66027
+ const dialog = new Dialog(content, {
66028
+ id: "webpage",
66029
+ title: i18n$1.t("webpage.dialog.title", { name: (itemOption == null ? void 0 : itemOption.name) || "" }),
66030
+ async onOk() {
66031
+ var _a;
66032
+ const value = formatValue(getInputValue());
66033
+ try {
66034
+ await checkValue(value);
66035
+ const detail = await recognizeWebPageLink(editor, value);
66036
+ resolve((detail == null ? void 0 : detail.url) || "");
66037
+ } catch (error2) {
66038
+ if (((_a = error2 == null ? void 0 : error2.responseData) == null ? void 0 : _a.statusCode) === 415) {
66039
+ if (isWebPageItem(itemId)) {
66040
+ resolve(value);
66041
+ } else {
66042
+ setFieldError(i18n$1.t("webpage.dialog.unsupportedUrl"));
66043
+ throw error2;
66044
+ }
66045
+ } else {
66046
+ setFieldError(error2.message || "");
66047
+ throw error2;
66048
+ }
66049
+ }
66050
+ },
66051
+ onClose() {
66052
+ editor.focus();
66053
+ reject();
66054
+ }
66055
+ });
66056
+ dialog.addListener("show", focus);
66057
+ dialog.show();
66058
+ const input2 = getField();
66059
+ input2.addEventListener("keydown", async (event) => {
66060
+ if (event.isComposing) {
66061
+ return;
66062
+ }
66063
+ if (event.key === "Enter") {
66064
+ await dialog.handleOk();
66065
+ event.preventDefault();
66066
+ return;
66067
+ }
66068
+ if (event.key === "Escape") {
66069
+ dialog.handleClose();
66070
+ }
66071
+ });
66072
+ });
66073
+ const blockData = {
66074
+ id: genId(),
66075
+ type: "embed",
66076
+ embedType: "webpage",
66077
+ embedData: {
66078
+ src: result
66079
+ }
66080
+ };
66081
+ const block = editor.insertBlock(options.containerId, options.blockIndex, blockData);
66082
+ editor.focus();
66083
+ return block;
66084
+ } catch (error2) {
66085
+ return null;
66086
+ }
66087
+ }
66088
+ function reloadIframe(block) {
66089
+ const iframe = block.querySelector(".editor-preview-iframe");
66090
+ const src = iframe.src;
66091
+ iframe.src = "about:blank";
66092
+ const timer = setTimeout(() => {
66093
+ iframe.src = src;
66094
+ clearTimeout(timer);
66095
+ }, 300);
66096
+ return true;
66097
+ }
66098
+ function openOriginalPage(editor, block) {
66099
+ const blockData = editor.getBlockData(block);
66100
+ const { embedData } = blockData;
66101
+ const src = embedData.src;
66102
+ window.open(src, "_blank");
66103
+ return true;
66104
+ }
66105
+ function getBlockProperties$4(editor, block) {
66106
+ const properties = getStandardEmbedBlockProperties(editor, block, {
66107
+ presetIds: ["add-comment"],
66108
+ extCommands: [{
66109
+ id: "refresh",
66110
+ name: i18n$1.t("webpage.command.refresh"),
66111
+ icon: RefreshIcon
66112
+ }, {
66113
+ id: "open-page",
66114
+ name: i18n$1.t("webpage.command.openPage"),
66115
+ icon: LaunchIcon
66116
+ }],
66117
+ handleExecuteCommand: (editor2, block2, item) => {
66118
+ switch (item.id) {
66119
+ case "refresh":
66120
+ return reloadIframe(block2);
66121
+ case "open-page":
66122
+ return openOriginalPage(editor2, block2);
66123
+ }
66124
+ return false;
66125
+ }
66126
+ });
66127
+ const abstract = `${i18n$1.t("webpage.abstract")}`;
66128
+ return {
66129
+ ...properties,
66130
+ abstract
66131
+ };
66132
+ }
66133
+ const logger$a = getLogger("webpage-embed");
66134
+ function createEmbedContent$4(editor, content, blockData, path, container, block) {
66135
+ const { embedData, id } = blockData;
66136
+ const { src } = embedData;
66137
+ const webpage = editor.addCustom(`webpage-${id}`, () => new WebPage(editor, blockData));
66138
+ assert(logger$a, src, "The src from blockData is invalid ");
66139
+ webpage.create(editor, embedData, content, block);
66140
+ setTimeout(() => {
66141
+ if (editor.isBlockWritable(block)) {
66142
+ editor.addCustom("webpage-resizer", () => new WebpageResizer(editor));
66143
+ }
66144
+ });
66145
+ if (blockData.height) {
66146
+ block.style.height = `${blockData.height}px`;
66147
+ }
66148
+ }
66149
+ function handleUpdateBlock$3(editor, block, blockData) {
66150
+ const { embedData, id } = blockData;
66151
+ const webpage = editor.getCustom(`webpage-${id}`);
66152
+ webpage.update(editor, block, embedData);
66153
+ if (blockData.height) {
66154
+ block.style.height = `${blockData.height}px`;
66155
+ }
66156
+ return true;
66157
+ }
66158
+ function getOptions$1(editor) {
66159
+ return {
66160
+ name: "WebPage",
66161
+ insertEmbedCommandItems: getAllowedWebPages(editor),
66162
+ handleInsertEmptyEmbed
66163
+ };
66164
+ }
66165
+ function convertTo$4(editor, blockData, doc2, type) {
66166
+ const webpage = blockData.embedData;
66167
+ const url = webpage.src;
66168
+ if (type === "html") {
66169
+ return `<iframe src="${url}" ></iframe>`;
66170
+ }
66171
+ if (type === "markdown") {
66172
+ return `[${url}](${url})`;
66173
+ }
66174
+ return url;
66175
+ }
66176
+ const WebPageEmbed = {
66177
+ embedType: "webpage",
66263
66178
  createEmbedContent: createEmbedContent$4,
66264
- handleUpdateBlock: handleUpdateBlock$3,
66265
66179
  getBlockProperties: getBlockProperties$4,
66180
+ getOptions: getOptions$1,
66181
+ handleUpdateBlock: handleUpdateBlock$3,
66266
66182
  convertTo: convertTo$4
66267
66183
  };
66268
- const style = "";
66184
+ const zhCN$4 = {
66185
+ webpage: {
66186
+ title: "\u7F51\u9875",
66187
+ youku: "\u4F18\u9177\u89C6\u9891",
66188
+ modao: "\u58A8\u5200",
66189
+ tencent: "\u817E\u8BAF\u89C6\u9891",
66190
+ bilibili: "Bilibili",
66191
+ figma: "Figma",
66192
+ dialog: {
66193
+ helpContent: "\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",
66194
+ helpLink: "\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",
66195
+ label: "\u7F51\u9875\u5730\u5740",
66196
+ placeholder: "\u8BF7\u8F93\u5165",
66197
+ title: "\u63D2\u5165{name}",
66198
+ errorEnterUrl: "\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",
66199
+ unsupportedUrl: "\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9",
66200
+ okText: "\u786E\u5B9A",
66201
+ cancelText: "\u53D6\u6D88"
66202
+ },
66203
+ abstract: "\u7F51\u9875",
66204
+ command: {
66205
+ refresh: "\u5237\u65B0\u9875\u9762",
66206
+ openPage: "\u6253\u5F00\u539F\u59CB\u9875\u9762"
66207
+ }
66208
+ }
66209
+ };
66210
+ const enUS$4 = {
66211
+ webpage: {
66212
+ title: "Webpage",
66213
+ youku: "Youku",
66214
+ modao: "Modao",
66215
+ tencent: "Tencent Video",
66216
+ bilibili: "Bilibili",
66217
+ figma: "Figma",
66218
+ dialog: {
66219
+ helpContent: "Due to landing page limitations, some pages may not be properly displayed during preview.",
66220
+ helpLink: "How to get the URL link",
66221
+ label: "Website address",
66222
+ placeholder: "Please enter",
66223
+ title: "Insert {name}",
66224
+ errorEnterUrl: "Please enter website address",
66225
+ unsupportedUrl: "Unsupported URL",
66226
+ okText: "Confirm",
66227
+ cancelText: "Cancel"
66228
+ },
66229
+ abstract: "Webpage",
66230
+ command: {
66231
+ refresh: "Refresh page",
66232
+ openPage: "Open the original page"
66233
+ }
66234
+ }
66235
+ };
66236
+ const jaJP$4 = {
66237
+ webpage: {
66238
+ title: "Web \u30DA\u30FC\u30B8",
66239
+ youku: "Youku \u52D5\u753B",
66240
+ modao: "Modao",
66241
+ tencent: "Tencent \u52D5\u753B",
66242
+ bilibili: "Bilibili",
66243
+ figma: "Figma",
66244
+ dialog: {
66245
+ helpContent: "\u30A2\u30AF\u30BB\u30B9\u5148\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u4E00\u90E8\u306E\u30DA\u30FC\u30B8\u304C\u8868\u793A\u3067\u304D\u306A\u3044\u5834\u5408\u304C\u3042\u308A\u307E\u3059\u3002",
66246
+ helpLink: "URL \u3092\u53D6\u5F97\u3059\u308B\u65B9\u6CD5",
66247
+ label: "URL",
66248
+ placeholder: "\u5165\u529B",
66249
+ title: "{name}\u3092\u633F\u5165",
66250
+ errorEnterUrl: "URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
66251
+ unsupportedUrl: "\u3053\u306E URL \u306F\u633F\u5165\u3067\u304D\u307E\u305B\u3093",
66252
+ okText: "OK",
66253
+ cancelText: "\u30AD\u30E3\u30F3\u30BB\u30EB"
66254
+ },
66255
+ abstract: "Web \u30DA\u30FC\u30B8",
66256
+ command: {
66257
+ refresh: "\u30DA\u30FC\u30B8\u3092\u518D\u8AAD\u307F\u8FBC\u3080",
66258
+ openPage: "URL\u3092\u958B\u304F"
66259
+ }
66260
+ }
66261
+ };
66262
+ i18n$1.mergeLang({
66263
+ "zh-CN": zhCN$4,
66264
+ "en-US": enUS$4,
66265
+ "ja-JP": jaJP$4
66266
+ });
66267
+ const webpageStyle = "";
66269
66268
  const index$2 = "";
66270
66269
  const UPDATE_DELAY = 500;
66271
66270
  const DEFAULT_EDIT_CODE_HEIGHT = 300;
@@ -74917,6 +74916,7 @@ ${data.flowchartText}
74917
74916
  editor.addCustom("mention", () => new OnesEditorMention(editor, mentionOptions));
74918
74917
  }
74919
74918
  editor.addCustom("heading-collapse", () => new HeadingBlockCollapseButton(editor));
74919
+ editor.addCustom("iframe-embed-reauth-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
74920
74920
  OnesEditorToolbar.register(editor);
74921
74921
  OnesEditorDropTarget.register(editor);
74922
74922
  OnesEditorTocProvider.register(editor);
@@ -75030,6 +75030,7 @@ ${data.flowchartText}
75030
75030
  }
75031
75031
  }
75032
75032
  });
75033
+ editor.addCustom("iframe-embed-reauth-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
75033
75034
  OnesEditorToolbar.register(editor);
75034
75035
  return editor;
75035
75036
  }