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

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,6 +34102,7 @@ ${codeText}
34100
34102
  if ("err" in msg || msg.a === "pong") {
34101
34103
  this.handleMessage(msg);
34102
34104
  } else {
34105
+ console.log("connection success");
34103
34106
  if (this.retryCount > 0) {
34104
34107
  logger$2n.info("retrying re-auth success");
34105
34108
  this.emitAuthRecover();
@@ -34125,7 +34128,6 @@ ${codeText}
34125
34128
  Connection.apply(this.connection, [this.ws]);
34126
34129
  }
34127
34130
  async handleAuthError() {
34128
- console.log("handleAuthError");
34129
34131
  if (this.reauthFunc) {
34130
34132
  if (this.retryCount === 5) {
34131
34133
  logger$2n.warn("retry auth times exceed 5, broadcast auth error");
@@ -34355,9 +34357,6 @@ ${codeText}
34355
34357
  onRequestReloadError(callback) {
34356
34358
  this.connection.onRequestReloadError(callback);
34357
34359
  }
34358
- triggerReAuth() {
34359
- this.connection.reauth();
34360
- }
34361
34360
  async authOnly() {
34362
34361
  await this.connection.auth(this.auth);
34363
34362
  }
@@ -34621,6 +34620,9 @@ ${codeText}
34621
34620
  }
34622
34621
  return ret;
34623
34622
  }
34623
+ reAuth() {
34624
+ this.connection.reAuth();
34625
+ }
34624
34626
  }
34625
34627
  function createEmptyDoc() {
34626
34628
  const id = genId();
@@ -35466,13 +35468,13 @@ ${codeText}
35466
35468
  return (_a = cb.onError) == null ? void 0 : _a.call(cb, err);
35467
35469
  });
35468
35470
  });
35469
- this.client.onWriteConflictError(this.handleWriteConflictError);
35470
35471
  this.client.onAuthRecover(() => {
35471
35472
  this.callbacks.forEach((cb) => {
35472
35473
  var _a;
35473
35474
  return (_a = cb.onAuthRecover) == null ? void 0 : _a.call(cb);
35474
35475
  });
35475
35476
  });
35477
+ this.client.onWriteConflictError(this.handleWriteConflictError);
35476
35478
  }
35477
35479
  clearEvents() {
35478
35480
  this.doc.off("nothing pending", this.handleNothingPending);
@@ -35690,6 +35692,12 @@ ${codeText}
35690
35692
  });
35691
35693
  }
35692
35694
  }
35695
+ onAuthRecover() {
35696
+ this.callbacks.forEach((cb) => {
35697
+ var _a;
35698
+ return (_a = cb.onAuthRecover) == null ? void 0 : _a.call(cb);
35699
+ });
35700
+ }
35693
35701
  async addResources(resourceIds) {
35694
35702
  let hashes = [];
35695
35703
  resourceIds.forEach((res) => {
@@ -35793,7 +35801,7 @@ ${codeText}
35793
35801
  return meta;
35794
35802
  }
35795
35803
  triggerReAuth() {
35796
- this.client.triggerReAuth();
35804
+ this.client.reAuth();
35797
35805
  }
35798
35806
  }
35799
35807
  getLogger("remote-cursor");
@@ -62931,8 +62939,6 @@ ${codeText}
62931
62939
  return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, containerId, data, true);
62932
62940
  });
62933
62941
  }
62934
- triggerReAuth() {
62935
- }
62936
62942
  }
62937
62943
  const { t } = i18n$1;
62938
62944
  function getOpDescription(user, type) {
@@ -64823,735 +64829,62 @@ ${codeText}
64823
64829
  document.removeEventListener("touchend", this.handleTouchEnd);
64824
64830
  }
64825
64831
  }
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
- }
64832
+ function getContentTypeFromHeaders(headers) {
64833
+ const entries = Object.entries(headers);
64834
+ for (let i = 0; i < entries.length; i++) {
64835
+ const [key, value] = entries[i];
64836
+ if (key.toLocaleLowerCase() === "content-type") {
64837
+ return value;
64929
64838
  }
64930
64839
  }
64840
+ return "";
64931
64841
  }
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
- }
64842
+ async function downloadImageToFile(editor, src, withCredentials = true) {
64843
+ try {
64844
+ const res = await editor.doc.request(src, {
64845
+ method: "get",
64846
+ responseType: "blob",
64847
+ withCredentials
64951
64848
  });
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");
64849
+ const reader = new FileReader();
64850
+ const promise = new Promise((resolve, reject) => {
64851
+ reader.onload = resolve;
64852
+ reader.onerror = reject;
64961
64853
  });
64962
- __publicField(this, "handleResized", (resizer) => {
64963
- this.resizing = false;
64964
- const block = resizer.getBlock();
64965
- if (!block) {
64966
- return;
64854
+ reader.readAsArrayBuffer(res.data);
64855
+ await promise;
64856
+ const buffer = reader.result;
64857
+ const contentType = getContentTypeFromHeaders(res.headers).toLocaleLowerCase();
64858
+ let ext = "";
64859
+ if (contentType) {
64860
+ const extensions = mime__default.default[contentType].extensions;
64861
+ if (extensions && extensions.length > 0) {
64862
+ ext = extensions[0];
64967
64863
  }
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
64864
  }
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;
64865
+ const file2 = new File([buffer], `${Date.now()}.${ext}`, {
64866
+ type: contentType
64867
+ });
64868
+ return file2;
64869
+ } catch (err) {
64870
+ return null;
64999
64871
  }
65000
64872
  }
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;
64873
+ async function downloadObjectToFile(editor, url) {
64874
+ const file2 = await downloadImageToFile(editor, url);
64875
+ return file2;
65017
64876
  }
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;
64877
+ async function downloadSvgToString(editor, url) {
64878
+ const file2 = await downloadObjectToFile(editor, url);
64879
+ if (!file2)
64880
+ return null;
64881
+ const text2 = await file2.text();
64882
+ return text2;
64883
+ }
64884
+ const isEmptyImage = (svg) => {
64885
+ const rect = svg.getBoundingClientRect();
64886
+ if (rect.width <= 1 && rect.height <= 1) {
64887
+ return true;
65555
64888
  }
65556
64889
  return false;
65557
64890
  };
@@ -65695,7 +65028,7 @@ ${codeText}
65695
65028
  const SAVE_DELAY_TIME = 30 * 1e3;
65696
65029
  const DRAWIO_EMPTY_CLASS = "editor-empty-drawio";
65697
65030
  const SHOW_FULL_SCREEN_IFRAME = "show-full-screen-iframe";
65698
- const logger$b = getLogger("embed-block-drawio");
65031
+ const logger$e = getLogger("embed-block-drawio");
65699
65032
  function getDrawioOptions(editor) {
65700
65033
  const compOptions = editor.options.componentsOptions;
65701
65034
  return compOptions.drawIO || {};
@@ -65719,7 +65052,7 @@ ${codeText}
65719
65052
  }
65720
65053
  function resizeObserver(el) {
65721
65054
  const resize = () => {
65722
- assert(logger$b, el, "el does not exist");
65055
+ assert(logger$e, el, "el does not exist");
65723
65056
  const width = document.body.clientWidth || document.documentElement.clientWidth;
65724
65057
  const height = document.body.clientHeight || document.documentElement.clientHeight;
65725
65058
  el.setAttribute("width", `${width - 2 * BORDER}`);
@@ -65737,17 +65070,17 @@ ${codeText}
65737
65070
  async function initializeDrawioIframe(editor, block) {
65738
65071
  const options = getDrawioOptions(editor) || {};
65739
65072
  const callbacks = options.callbacks || {};
65740
- const drawioCallbacks = editor.getCustom("drawio-event-callback");
65073
+ const iframeKindEmbedDocCallbacks = editor.getCustom("iframe-embed-reauth-event-callback");
65741
65074
  const { onCreateDrawIoFrame, onCloseDrawIoFrame } = callbacks;
65742
65075
  let drawioIframe = null;
65743
65076
  let exit;
65744
65077
  if (onCreateDrawIoFrame) {
65745
65078
  drawioIframe = await onCreateDrawIoFrame(editor);
65746
- assert(logger$b, drawioIframe, "iframe create failed");
65079
+ assert(logger$e, drawioIframe, "iframe create failed");
65747
65080
  exit = () => {
65748
- assert(logger$b, drawioIframe, "iframe does not exist");
65749
- assert(logger$b, onCloseDrawIoFrame, "missing parameters: onCloseDrawIoFrame");
65750
- drawioCallbacks.unRegister();
65081
+ assert(logger$e, drawioIframe, "iframe does not exist");
65082
+ assert(logger$e, onCloseDrawIoFrame, "missing parameters: onCloseDrawIoFrame");
65083
+ iframeKindEmbedDocCallbacks.unRegister();
65751
65084
  onCloseDrawIoFrame(editor, drawioIframe);
65752
65085
  };
65753
65086
  } else {
@@ -65758,14 +65091,14 @@ ${codeText}
65758
65091
  addClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
65759
65092
  const { disconnect } = resizeObserver(drawioIframe);
65760
65093
  exit = () => {
65761
- assert(logger$b, drawioIframe, "iframe does not exist");
65762
- drawioCallbacks.unRegister();
65094
+ assert(logger$e, drawioIframe, "iframe does not exist");
65095
+ iframeKindEmbedDocCallbacks.unRegister();
65763
65096
  disconnect();
65764
65097
  document.body.removeChild(drawioContainer);
65765
65098
  removeClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
65766
65099
  };
65767
65100
  }
65768
- drawioCallbacks.register(block, drawioIframe, {
65101
+ iframeKindEmbedDocCallbacks.register(block, drawioIframe, {
65769
65102
  onExit: () => exit()
65770
65103
  });
65771
65104
  return {
@@ -65777,7 +65110,7 @@ ${codeText}
65777
65110
  var _a, _b;
65778
65111
  try {
65779
65112
  if (autoSave) {
65780
- logger$b.debug("auto saving drawio data");
65113
+ logger$e.debug("auto saving drawio data");
65781
65114
  }
65782
65115
  const blob = new Blob([svg]);
65783
65116
  const file2 = new File([blob], "drawio.svg", {
@@ -65796,11 +65129,11 @@ ${codeText}
65796
65129
  };
65797
65130
  editor.updateEmbedData(targetBlock, newEmbedData);
65798
65131
  } else {
65799
- logger$b.error("block has been deleted");
65132
+ logger$e.error("block has been deleted");
65800
65133
  }
65801
65134
  } catch (err) {
65802
65135
  const message = `failed to upload drawio data: ${err.message}`;
65803
- logger$b.error(message);
65136
+ logger$e.error(message);
65804
65137
  }
65805
65138
  } catch (err) {
65806
65139
  const message = `failed to save drawio data: ${err.message}`;
@@ -65819,7 +65152,7 @@ ${codeText}
65819
65152
  };
65820
65153
  const receive = async (evt) => {
65821
65154
  var _a, _b;
65822
- assert(logger$b, iframe.contentWindow, "iframe.contentWindow does not exist");
65155
+ assert(logger$e, iframe.contentWindow, "iframe.contentWindow does not exist");
65823
65156
  if (evt.data.length > 0) {
65824
65157
  const msg = JSON.parse(evt.data);
65825
65158
  const xml = drawIoData.xmlSvg || drawIoData.xml;
@@ -65969,7 +65302,7 @@ ${codeText}
65969
65302
  };
65970
65303
  }
65971
65304
  function setGraph(embed, data) {
65972
- assert(logger$b, data, "Required data is missing in setGraph");
65305
+ assert(logger$e, data, "Required data is missing in setGraph");
65973
65306
  if ("src" in data) {
65974
65307
  embed.setAttribute("data-src", data.src);
65975
65308
  return;
@@ -65992,8 +65325,8 @@ ${codeText}
65992
65325
  };
65993
65326
  }
65994
65327
  function updateGraphBySrc(src, embed, editor) {
65995
- assert(logger$b, src, "params error: src");
65996
- assert(logger$b, editor, "params error: editor");
65328
+ assert(logger$e, src, "params error: src");
65329
+ assert(logger$e, editor, "params error: editor");
65997
65330
  const embedEl = embed;
65998
65331
  const url = editor.doc.buildResourceUrl(src);
65999
65332
  const img = document.createElement("img");
@@ -66026,26 +65359,26 @@ ${codeText}
66026
65359
  };
66027
65360
  }
66028
65361
  function updateGraphByXml(mxFile, embed, editor) {
66029
- assert(logger$b, editor, "parameter missing");
65362
+ assert(logger$e, editor, "parameter missing");
66030
65363
  initDrawIo(editor).then(() => {
66031
65364
  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");
65365
+ assert(logger$e, mxUtils, "External resource loading exception: mxUtils");
65366
+ assert(logger$e, MxGraph, "External resource loading exception: MxGraph");
65367
+ assert(logger$e, MxCodec, "External resource loading exception: MxCodec");
66035
65368
  const file2 = mxUtils.parseXml(mxFile);
66036
65369
  embed.innerHTML = "";
66037
65370
  const node = file2.documentElement;
66038
- assert(logger$b, node, "Resource parsing exception");
66039
- assert(logger$b, node.nodeName === "mxfile", "Resource parsing exception");
65371
+ assert(logger$e, node, "Resource parsing exception");
65372
+ assert(logger$e, node.nodeName === "mxfile", "Resource parsing exception");
66040
65373
  const diagrams = node.getElementsByTagName("diagram");
66041
- assert(logger$b, diagrams.length > 0, "Resource parsing exception");
65374
+ assert(logger$e, diagrams.length > 0, "Resource parsing exception");
66042
65375
  let xmlDoc;
66043
65376
  const data = diagrams[0];
66044
65377
  if (data.text || data.textContent) {
66045
65378
  const diagramBase64 = getTextContent(data);
66046
65379
  const raw = atob(diagramBase64);
66047
65380
  const pako = window.pako;
66048
- assert(logger$b, pako, "External resource loading exception: pako");
65381
+ assert(logger$e, pako, "External resource loading exception: pako");
66049
65382
  const encodedXml = pako.inflateRaw(Uint8Array.from(raw, (c) => c.charCodeAt(0)), { to: "string" });
66050
65383
  const xml = decodeURIComponent(encodedXml);
66051
65384
  xmlDoc = mxUtils.parseXml(xml);
@@ -66082,7 +65415,7 @@ ${codeText}
66082
65415
  }
66083
65416
  addDrawioEmptyStatus(embed);
66084
65417
  }
66085
- function getBlockProperties$4(editor, block) {
65418
+ function getBlockProperties$5(editor, block) {
66086
65419
  const properties = getStandardEmbedBlockProperties(editor, block, {
66087
65420
  handleExecuteCommand: (editor2, block2, item) => {
66088
65421
  if (item.id === "edit") {
@@ -66095,7 +65428,7 @@ ${codeText}
66095
65428
  });
66096
65429
  return { ...properties, abstract: i18n$1.t("drawio.abstract") };
66097
65430
  }
66098
- const enUS$4 = {
65431
+ const enUS$5 = {
66099
65432
  drawio: {
66100
65433
  title: "Flowchart/UML",
66101
65434
  empty: "Empty graph",
@@ -66109,7 +65442,7 @@ ${codeText}
66109
65442
  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
65443
  }
66111
65444
  };
66112
- const zhCN$4 = {
65445
+ const zhCN$5 = {
66113
65446
  drawio: {
66114
65447
  title: "\u6D41\u7A0B\u56FE/UML",
66115
65448
  empty: "\u7A7A\u56FE\u8868",
@@ -66123,7 +65456,7 @@ ${codeText}
66123
65456
  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
65457
  }
66125
65458
  };
66126
- const jaJP$4 = {
65459
+ const jaJP$5 = {
66127
65460
  drawio: {
66128
65461
  title: "\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",
66129
65462
  empty: "\u30B0\u30E9\u30D5\u30C7\u30FC\u30BF\u306A\u3057",
@@ -66138,16 +65471,16 @@ ${codeText}
66138
65471
  }
66139
65472
  };
66140
65473
  const langs = {
66141
- "en-US": enUS$4,
66142
- "zh-CN": zhCN$4,
66143
- "ja-JP": jaJP$4
65474
+ "en-US": enUS$5,
65475
+ "zh-CN": zhCN$5,
65476
+ "ja-JP": jaJP$5
66144
65477
  };
66145
65478
  i18n$1.mergeLang(langs);
66146
- const logger$a = getLogger("embed-block-drawio");
65479
+ const logger$d = getLogger("embed-block-drawio");
66147
65480
  const isInitializationCompleted = false;
66148
65481
  function editDrawIO(editor, block, embed, data) {
66149
- assert(logger$a, embed, `parameter missing: ${embed}`);
66150
- assert(logger$a, editor, `parameter missing: ${editor}`);
65482
+ assert(logger$d, embed, `parameter missing: ${embed}`);
65483
+ assert(logger$d, editor, `parameter missing: ${editor}`);
66151
65484
  editGraph(editor, block, data, isInitializationCompleted);
66152
65485
  }
66153
65486
  function updateViewLayer(editor, embed, data) {
@@ -66189,23 +65522,20 @@ ${codeText}
66189
65522
  }
66190
65523
  }
66191
65524
  }
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
- });
65525
+ function createEmbedContent$5(editor, content, blockData, path, container, block) {
66196
65526
  const drawioData = blockData.embedData;
66197
65527
  mount(editor, content, drawioData);
66198
65528
  EmbedBlockResizer.register(editor, block);
66199
65529
  }
66200
- function handleUpdateBlock$3(editor, block, blockData) {
65530
+ function handleUpdateBlock$4(editor, block, blockData) {
66201
65531
  const data = blockData.embedData;
66202
65532
  const content = getBlockContent(block);
66203
65533
  const embed = content.querySelector(":scope > .editor-drawio-content");
66204
- assert(logger$a, embed, "embed should not be null");
65534
+ assert(logger$d, embed, "embed should not be null");
66205
65535
  update$1(editor, embed, data);
66206
65536
  return true;
66207
65537
  }
66208
- function getOptions$1() {
65538
+ function getOptions$2() {
66209
65539
  return {
66210
65540
  name: "UML",
66211
65541
  insertEmbedCommandItems: [{
@@ -66226,7 +65556,7 @@ ${codeText}
66226
65556
  setTimeout(() => {
66227
65557
  const blockContent = getBlockContent(block);
66228
65558
  const embed = blockContent.querySelector(":scope > .editor-drawio-content");
66229
- assert(logger$a, embed, "embed should not be null");
65559
+ assert(logger$d, embed, "embed should not be null");
66230
65560
  const blockData = editor.getBlockData(block);
66231
65561
  editDrawIO(editor, block, embed, blockData.embedData);
66232
65562
  }, 100);
@@ -66234,7 +65564,7 @@ ${codeText}
66234
65564
  }
66235
65565
  };
66236
65566
  }
66237
- function convertTo$4(editor, blockData, doc2, type) {
65567
+ function convertTo$5(editor, blockData, doc2, type) {
66238
65568
  const { embedData } = blockData;
66239
65569
  const data = embedData;
66240
65570
  if (type === "html") {
@@ -66259,13 +65589,683 @@ ${codeText}
66259
65589
  }
66260
65590
  const DrawioEmbed = {
66261
65591
  embedType: "drawio",
66262
- getOptions: getOptions$1,
65592
+ getOptions: getOptions$2,
65593
+ createEmbedContent: createEmbedContent$5,
65594
+ handleUpdateBlock: handleUpdateBlock$4,
65595
+ getBlockProperties: getBlockProperties$5,
65596
+ convertTo: convertTo$5
65597
+ };
65598
+ const style = "";
65599
+ class IframeKindEmbedDocCallbacks extends tinyTypedEmitter.TypedEmitter {
65600
+ constructor(editor) {
65601
+ super();
65602
+ __publicField(this, "currentBlock");
65603
+ __publicField(this, "currentIframe");
65604
+ __publicField(this, "onReAuthErrorWhenIframeEditing");
65605
+ __publicField(this, "onIframeExitEdit");
65606
+ __publicField(this, "destroy", () => {
65607
+ this.editor.doc.unregisterCallback(this);
65608
+ });
65609
+ __publicField(this, "onError", (error2) => {
65610
+ if (error2.code === AuthError.err) {
65611
+ if (this.currentIframe) {
65612
+ this.onConnectReAuthError();
65613
+ }
65614
+ }
65615
+ });
65616
+ __publicField(this, "onAuthRecover", () => {
65617
+ if (this.currentBlock) {
65618
+ enablePageScroll(this.currentBlock.id);
65619
+ }
65620
+ });
65621
+ __publicField(this, "unregisterCallbacks", () => {
65622
+ this.editor.doc.unregisterCallback(this);
65623
+ });
65624
+ __publicField(this, "register", (block, iframe, options) => {
65625
+ this.currentBlock = block;
65626
+ this.currentIframe = iframe;
65627
+ this.onReAuthErrorWhenIframeEditing = options.onError;
65628
+ this.onIframeExitEdit = options.onExit;
65629
+ });
65630
+ __publicField(this, "unRegister", () => {
65631
+ this.currentBlock = void 0;
65632
+ this.currentIframe = void 0;
65633
+ this.onReAuthErrorWhenIframeEditing = void 0;
65634
+ });
65635
+ __publicField(this, "onConnectReAuthError", () => {
65636
+ var _a;
65637
+ if (this.currentBlock && this.currentIframe) {
65638
+ (_a = this.onReAuthErrorWhenIframeEditing) == null ? void 0 : _a.call(this, this.currentBlock, this.currentIframe);
65639
+ const container = disablePageScroll(this.currentBlock.id);
65640
+ const fixedToolbar = createElement("div", ["iframe-embed-auth-error-tips"], container);
65641
+ fixedToolbar.innerHTML = i18n$1.t("authError.tips");
65642
+ fixedToolbar.addEventListener("click", (event) => {
65643
+ var _a2, _b;
65644
+ const target = event.target;
65645
+ if (target instanceof HTMLSpanElement) {
65646
+ const id = target.id;
65647
+ switch (id) {
65648
+ case "retry":
65649
+ (_b = (_a2 = this.editor.doc).triggerReAuth) == null ? void 0 : _b.call(_a2);
65650
+ break;
65651
+ case "exit":
65652
+ this.exit();
65653
+ break;
65654
+ }
65655
+ }
65656
+ });
65657
+ }
65658
+ });
65659
+ this.editor = editor;
65660
+ this.editor.doc.registerCallback(this);
65661
+ }
65662
+ exit() {
65663
+ var _a;
65664
+ if (this.currentBlock) {
65665
+ enablePageScroll(this.currentBlock.id);
65666
+ }
65667
+ this.unRegister();
65668
+ (_a = this.onIframeExitEdit) == null ? void 0 : _a.call(this);
65669
+ }
65670
+ }
65671
+ 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>';
65672
+ const logger$c = getLogger("webpage");
65673
+ class WebPage {
65674
+ constructor(editor, blockData) {
65675
+ __publicField(this, "currentSrc", "");
65676
+ __publicField(this, "loading", null);
65677
+ __publicField(this, "handleMaskMouseMove", (editor, event) => {
65678
+ if (window.isDragging) {
65679
+ return;
65680
+ }
65681
+ if (event.target && event.target instanceof Element) {
65682
+ const mask = event.target.closest("webpage-mask");
65683
+ if (mask) {
65684
+ mask.style.display = "none";
65685
+ }
65686
+ }
65687
+ editor.domEvents.addEventListener(document, "mousemove", this.handleDocumentMouseMove);
65688
+ });
65689
+ __publicField(this, "handleDocumentMouseMove", (editor, event) => {
65690
+ if (!event.target || !(event.target instanceof Element)) {
65691
+ return;
65692
+ }
65693
+ const block = this.editor.findBlockById(this.blockData.id);
65694
+ if (block) {
65695
+ const mask = this.getExistsMask(block);
65696
+ if (mask) {
65697
+ if (isChildNode(block, event.target)) {
65698
+ mask.style.display = "none";
65699
+ return;
65700
+ }
65701
+ mask.style.display = "";
65702
+ }
65703
+ }
65704
+ });
65705
+ this.editor = editor;
65706
+ this.blockData = blockData;
65707
+ }
65708
+ create(editor, embedData, parent, block) {
65709
+ const src = embedData.src;
65710
+ const internalContainer = createElement("div", ["editor-embed"], null);
65711
+ const iframe = createElement("iframe", ["editor-preview-iframe"], internalContainer);
65712
+ this.loading = this.createLoading(internalContainer);
65713
+ const handleIframeLoaded = () => {
65714
+ assert(logger$c, this.loading, "not created");
65715
+ this.loading.hide();
65716
+ this.currentSrc = src;
65717
+ };
65718
+ editor.domEvents.addEventListener(iframe, "load", handleIframeLoaded);
65719
+ const httpReg = /^http:\/\//i;
65720
+ iframe.src = src.replace(httpReg, "//");
65721
+ this.loading.show();
65722
+ parent.append(internalContainer);
65723
+ this.createMask(editor, block);
65724
+ }
65725
+ update(editor, block, embedData) {
65726
+ assert(logger$c, this.loading, "not created");
65727
+ if (this.currentSrc === embedData.src) {
65728
+ return;
65729
+ }
65730
+ const iframe = block.querySelector(".editor-preview-iframe");
65731
+ assert(logger$c, iframe, "no exists iframe");
65732
+ this.loading.show();
65733
+ iframe.src = embedData.src;
65734
+ this.createMask(editor, block);
65735
+ }
65736
+ createLoading(parent) {
65737
+ const loadContainer = createElement("div", ["editor-preview-iframe-loading"], null);
65738
+ const iconContainer = createElement("span", [], loadContainer);
65739
+ iconContainer.innerHTML = loadingIcon;
65740
+ return {
65741
+ show() {
65742
+ parent.append(loadContainer);
65743
+ },
65744
+ hide() {
65745
+ const loadContainer2 = parent.querySelector(":scope > .editor-preview-iframe-loading");
65746
+ if (!loadContainer2)
65747
+ return;
65748
+ loadContainer2.remove();
65749
+ }
65750
+ };
65751
+ }
65752
+ getExistsMask(block) {
65753
+ const tools = getBlockTools(block);
65754
+ return tools.querySelector(".webpage-mask");
65755
+ }
65756
+ createMask(editor, block) {
65757
+ const tools = getBlockTools(block);
65758
+ let mask = this.getExistsMask(block);
65759
+ if (mask) {
65760
+ mask.style.display = "";
65761
+ return;
65762
+ }
65763
+ mask = createElement("div", ["webpage-mask"], tools);
65764
+ editor.domEvents.addEventListener(mask, "mousemove", this.handleMaskMouseMove);
65765
+ }
65766
+ destroy() {
65767
+ const block = this.editor.findBlockById(this.blockData.id);
65768
+ if (block) {
65769
+ const mask = this.getExistsMask(block);
65770
+ if (mask) {
65771
+ this.editor.domEvents.removeEventListener(mask, "mousemove", this.handleMaskMouseMove);
65772
+ this.editor.domEvents.removeEventListener(document, "mousemove", this.handleDocumentMouseMove);
65773
+ }
65774
+ }
65775
+ }
65776
+ }
65777
+ function isWebpageBlock(block) {
65778
+ return block && isEmbedBlock(block) && getEmbedType(block) === "webpage";
65779
+ }
65780
+ const MAX_HEIGHT = 1e3;
65781
+ const MIN_HEIGHT = 100;
65782
+ class WebpageResizer {
65783
+ constructor(editor) {
65784
+ __publicField(this, "currentBlockElement", null);
65785
+ __publicField(this, "resizing", false);
65786
+ __publicField(this, "handleHoveringBlockChange", (newBlock, oldBlock) => {
65787
+ if (this.resizing) {
65788
+ return;
65789
+ }
65790
+ if (oldBlock && isWebpageBlock(oldBlock)) {
65791
+ this.disableBlockResize(oldBlock);
65792
+ }
65793
+ if (newBlock && isWebpageBlock(newBlock)) {
65794
+ this.enableBlockResize(newBlock);
65795
+ }
65796
+ });
65797
+ __publicField(this, "handleResizing", (resizer, rect) => {
65798
+ this.resizing = true;
65799
+ const block = resizer.getBlock();
65800
+ if (!block) {
65801
+ return;
65802
+ }
65803
+ const newHeight = Math.max(Math.min(rect.height, MAX_HEIGHT), MIN_HEIGHT);
65804
+ block.style.height = `${newHeight}px`;
65805
+ addClass(block, "resizing");
65806
+ });
65807
+ __publicField(this, "handleResized", (resizer) => {
65808
+ this.resizing = false;
65809
+ const block = resizer.getBlock();
65810
+ if (!block) {
65811
+ return;
65812
+ }
65813
+ removeClass(block, "resizing");
65814
+ const oldData = this.editor.getBlockData(block);
65815
+ const height = block.getBoundingClientRect().height;
65816
+ this.editor.updateBlockData(block, {
65817
+ ...oldData,
65818
+ height
65819
+ });
65820
+ });
65821
+ this.editor = editor;
65822
+ OnesEditorHoveringBlock.get(editor).addListener("change", this.handleHoveringBlockChange);
65823
+ }
65824
+ destroy() {
65825
+ this.currentBlockElement = null;
65826
+ OnesEditorHoveringBlock.get(this.editor).removeListener("change", this.handleHoveringBlockChange);
65827
+ }
65828
+ disableBlockResize(block) {
65829
+ const resizer = this.editor.findCustom(`${getBlockId(block)}-resizer`);
65830
+ if (resizer) {
65831
+ resizer.disableResize();
65832
+ }
65833
+ }
65834
+ enableBlockResize(block) {
65835
+ const resizer = this.editor.addCustom(`${getBlockId(block)}-resizer`, () => new BlockResizer(this.editor, {
65836
+ resize: ["bottom"]
65837
+ }));
65838
+ resizer.enableResize(block);
65839
+ resizer.removeListener("resizing", this.handleResizing);
65840
+ resizer.removeListener("resized", this.handleResized);
65841
+ resizer.addListener("resizing", this.handleResizing);
65842
+ resizer.addListener("resized", this.handleResized);
65843
+ this.currentBlockElement = block;
65844
+ }
65845
+ }
65846
+ const index$3 = "";
65847
+ const logger$b = getLogger("editor-dialog");
65848
+ function createContainer(content, options) {
65849
+ const container = createElement("div", ["editor-dialog-container"], null);
65850
+ const header = createElement("div", ["dialog-header"], container);
65851
+ createElement("span", ["dialog-header-title"], header, options.title);
65852
+ const closeIcon = createElement("span", ["close-icon"], header);
65853
+ closeIcon.innerHTML = CloseIcon;
65854
+ const contentWrap = createElement("div", ["dialog-content"], container);
65855
+ contentWrap.appendChild(content);
65856
+ const footer = createElement("div", ["dialog-footer"], container);
65857
+ const cancelButton = createButton$1("cancel-button", i18n$1.t("webpage.dialog.cancelText"));
65858
+ footer.appendChild(cancelButton);
65859
+ const submitButton = createButton$1("submit-button", i18n$1.t("webpage.dialog.okText"), void 0, ["primary"]);
65860
+ footer.appendChild(submitButton);
65861
+ return container;
65862
+ }
65863
+ class Dialog extends ManualCloseDialog {
65864
+ constructor(content, options) {
65865
+ super(createContainer(content, options), options);
65866
+ __publicField(this, "_options");
65867
+ __publicField(this, "getReferenceClientRect", () => {
65868
+ const y = document.documentElement.clientHeight / 2;
65869
+ const x = document.documentElement.clientWidth / 2;
65870
+ const rootElement = this.getCommandBarRoot();
65871
+ assert(logger$b, rootElement, "no command bar root");
65872
+ const { width, height } = rootElement.getBoundingClientRect();
65873
+ return new DOMRect(Math.max(x - width / 2, 0), Math.max(y - height / 2, 0), 0, 0);
65874
+ });
65875
+ __publicField(this, "handleOk", async () => {
65876
+ var _a, _b;
65877
+ try {
65878
+ await ((_b = (_a = this._options).onOk) == null ? void 0 : _b.call(_a));
65879
+ this.destroy();
65880
+ } catch (error2) {
65881
+ }
65882
+ });
65883
+ __publicField(this, "handleClose", () => {
65884
+ var _a, _b;
65885
+ (_b = (_a = this._options).onClose) == null ? void 0 : _b.call(_a);
65886
+ this.destroy();
65887
+ });
65888
+ const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65889
+ const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65890
+ const closeIcon = this.content.querySelector(".close-icon");
65891
+ submitBtn == null ? void 0 : submitBtn.addEventListener("click", this.handleOk);
65892
+ closeIcon == null ? void 0 : closeIcon.addEventListener("click", this.handleClose);
65893
+ cancelBtn == null ? void 0 : cancelBtn.addEventListener("click", this.handleClose);
65894
+ this._options = options;
65895
+ }
65896
+ show() {
65897
+ super.show(document.documentElement, { getReferenceClientRect: this.getReferenceClientRect });
65898
+ setTimeout(() => {
65899
+ const mark = document.querySelector(`.editor-disable-scroll[data-scroll-id="${this.id}"]`);
65900
+ if (mark) {
65901
+ addClass(mark, "editor-disable-scroll-dark");
65902
+ }
65903
+ });
65904
+ }
65905
+ destroy() {
65906
+ const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65907
+ const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65908
+ const closeIcon = this.content.querySelector(".close-icon");
65909
+ submitBtn == null ? void 0 : submitBtn.removeEventListener("click", this.handleOk);
65910
+ cancelBtn == null ? void 0 : cancelBtn.removeEventListener("click", this.handleClose);
65911
+ closeIcon == null ? void 0 : closeIcon.removeEventListener("click", this.handleClose);
65912
+ super.destroy();
65913
+ }
65914
+ }
65915
+ const getCommandItems = () => [
65916
+ {
65917
+ name: i18n$1.t("webpage.bilibili"),
65918
+ id: "insert-bilibili",
65919
+ icon: BilibiliIcon,
65920
+ group: "thirdParty",
65921
+ subText: getShortcutById("insert-bilibili"),
65922
+ value: "bilibili"
65923
+ },
65924
+ {
65925
+ name: i18n$1.t("webpage.youku"),
65926
+ id: "insert-youku",
65927
+ icon: YoukuIcon,
65928
+ group: "thirdParty",
65929
+ subText: getShortcutById("insert-youku"),
65930
+ value: "youku"
65931
+ },
65932
+ {
65933
+ name: i18n$1.t("webpage.figma"),
65934
+ id: "insert-figma",
65935
+ icon: FigmaIcon,
65936
+ group: "thirdParty",
65937
+ subText: getShortcutById("insert-figma"),
65938
+ value: "figma"
65939
+ },
65940
+ {
65941
+ name: i18n$1.t("webpage.modao"),
65942
+ id: "insert-modao",
65943
+ icon: ModaoIcon,
65944
+ group: "thirdParty",
65945
+ subText: getShortcutById("insert-modao"),
65946
+ value: "modao"
65947
+ },
65948
+ {
65949
+ name: i18n$1.t("webpage.tencent"),
65950
+ id: "insert-tencent",
65951
+ icon: TencentVideoIcon,
65952
+ group: "thirdParty",
65953
+ subText: getShortcutById("insert-tencent"),
65954
+ value: "qqVideo"
65955
+ },
65956
+ {
65957
+ id: "insert-webPage",
65958
+ name: i18n$1.t("webpage.title"),
65959
+ icon: WebPageIcon,
65960
+ group: "common",
65961
+ order: 1e3,
65962
+ subText: getShortcutById("insert-webPage"),
65963
+ value: "url"
65964
+ }
65965
+ ];
65966
+ function getAllowedWebPages(editor) {
65967
+ let webpages = getCommandItems();
65968
+ const editorOptions = editor.getComponentOptions("webpage");
65969
+ if (editorOptions == null ? void 0 : editorOptions.getAllowedWebPages) {
65970
+ webpages = editorOptions.getAllowedWebPages(webpages);
65971
+ }
65972
+ return webpages;
65973
+ }
65974
+ function isWebPageItem(id) {
65975
+ return id === "insert-webPage";
65976
+ }
65977
+ async function recognizeWebPageLink(editor, url) {
65978
+ if (editor.doc.externalDoc.recognizeLink) {
65979
+ return editor.doc.externalDoc.recognizeLink(url);
65980
+ }
65981
+ return null;
65982
+ }
65983
+ function formatValue(value) {
65984
+ if (value && !value.startsWith("http://") && !value.startsWith("https://") && !value.startsWith("//")) {
65985
+ return `${window.location.protocol}//${value}`;
65986
+ }
65987
+ return value;
65988
+ }
65989
+ async function checkValue(value) {
65990
+ if (!value) {
65991
+ throw new Error(i18n$1.t("webpage.dialog.errorEnterUrl"));
65992
+ }
65993
+ const test = value;
65994
+ try {
65995
+ new URL(test);
65996
+ } catch (err) {
65997
+ throw new Error(i18n$1.t("webpage.dialog.unsupportedUrl"));
65998
+ }
65999
+ }
66000
+ async function handleInsertEmptyEmbed(editor, options) {
66001
+ const itemId = options.item.id;
66002
+ const itemOption = getAllowedWebPages(editor).find((item) => item.id === itemId);
66003
+ const content = createElement("div", ["webpage-content"], null);
66004
+ if (isWebPageItem(itemId)) {
66005
+ const helpContainer = createElement("div", ["help-container"], content);
66006
+ const helpContent = createElement("div", ["help-content"], helpContainer);
66007
+ const span = createElement("span", ["help-icon"], helpContent);
66008
+ span.innerHTML = WarningIcon;
66009
+ createElement("span", [], helpContent, i18n$1.t("webpage.dialog.helpContent"));
66010
+ }
66011
+ const { getInputValue, setFieldError, focus, getField } = createInput(content, {
66012
+ required: true,
66013
+ label: i18n$1.t("webpage.dialog.label"),
66014
+ placeholder: i18n$1.t("webpage.dialog.placeholder")
66015
+ });
66016
+ const webpageOptions = editor.getComponentOptions("webpage");
66017
+ if (!isWebPageItem(itemId) && !(webpageOptions == null ? void 0 : webpageOptions.hideHelpLink)) {
66018
+ const linkContainer = createElement("div", ["help-link-container"], content);
66019
+ const linkContent = createElement("a", ["help-link-content"], linkContainer);
66020
+ createElement("span", [], linkContent, i18n$1.t("webpage.dialog.helpLink"));
66021
+ const iconSpan = createElement("span", ["help-link-icon"], linkContent);
66022
+ iconSpan.innerHTML = LaunchIcon;
66023
+ linkContent.href = (webpageOptions == null ? void 0 : webpageOptions.helpLink) || "";
66024
+ linkContent.target = "_blank";
66025
+ }
66026
+ try {
66027
+ const result = await new Promise((resolve, reject) => {
66028
+ const dialog = new Dialog(content, {
66029
+ id: "webpage",
66030
+ title: i18n$1.t("webpage.dialog.title", { name: (itemOption == null ? void 0 : itemOption.name) || "" }),
66031
+ async onOk() {
66032
+ var _a;
66033
+ const value = formatValue(getInputValue());
66034
+ try {
66035
+ await checkValue(value);
66036
+ const detail = await recognizeWebPageLink(editor, value);
66037
+ resolve((detail == null ? void 0 : detail.url) || "");
66038
+ } catch (error2) {
66039
+ if (((_a = error2 == null ? void 0 : error2.responseData) == null ? void 0 : _a.statusCode) === 415) {
66040
+ if (isWebPageItem(itemId)) {
66041
+ resolve(value);
66042
+ } else {
66043
+ setFieldError(i18n$1.t("webpage.dialog.unsupportedUrl"));
66044
+ throw error2;
66045
+ }
66046
+ } else {
66047
+ setFieldError(error2.message || "");
66048
+ throw error2;
66049
+ }
66050
+ }
66051
+ },
66052
+ onClose() {
66053
+ editor.focus();
66054
+ reject();
66055
+ }
66056
+ });
66057
+ dialog.addListener("show", focus);
66058
+ dialog.show();
66059
+ const input2 = getField();
66060
+ input2.addEventListener("keydown", async (event) => {
66061
+ if (event.isComposing) {
66062
+ return;
66063
+ }
66064
+ if (event.key === "Enter") {
66065
+ await dialog.handleOk();
66066
+ event.preventDefault();
66067
+ return;
66068
+ }
66069
+ if (event.key === "Escape") {
66070
+ dialog.handleClose();
66071
+ }
66072
+ });
66073
+ });
66074
+ const blockData = {
66075
+ id: genId(),
66076
+ type: "embed",
66077
+ embedType: "webpage",
66078
+ embedData: {
66079
+ src: result
66080
+ }
66081
+ };
66082
+ const block = editor.insertBlock(options.containerId, options.blockIndex, blockData);
66083
+ editor.focus();
66084
+ return block;
66085
+ } catch (error2) {
66086
+ return null;
66087
+ }
66088
+ }
66089
+ function reloadIframe(block) {
66090
+ const iframe = block.querySelector(".editor-preview-iframe");
66091
+ const src = iframe.src;
66092
+ iframe.src = "about:blank";
66093
+ const timer = setTimeout(() => {
66094
+ iframe.src = src;
66095
+ clearTimeout(timer);
66096
+ }, 300);
66097
+ return true;
66098
+ }
66099
+ function openOriginalPage(editor, block) {
66100
+ const blockData = editor.getBlockData(block);
66101
+ const { embedData } = blockData;
66102
+ const src = embedData.src;
66103
+ window.open(src, "_blank");
66104
+ return true;
66105
+ }
66106
+ function getBlockProperties$4(editor, block) {
66107
+ const properties = getStandardEmbedBlockProperties(editor, block, {
66108
+ presetIds: ["add-comment"],
66109
+ extCommands: [{
66110
+ id: "refresh",
66111
+ name: i18n$1.t("webpage.command.refresh"),
66112
+ icon: RefreshIcon
66113
+ }, {
66114
+ id: "open-page",
66115
+ name: i18n$1.t("webpage.command.openPage"),
66116
+ icon: LaunchIcon
66117
+ }],
66118
+ handleExecuteCommand: (editor2, block2, item) => {
66119
+ switch (item.id) {
66120
+ case "refresh":
66121
+ return reloadIframe(block2);
66122
+ case "open-page":
66123
+ return openOriginalPage(editor2, block2);
66124
+ }
66125
+ return false;
66126
+ }
66127
+ });
66128
+ const abstract = `${i18n$1.t("webpage.abstract")}`;
66129
+ return {
66130
+ ...properties,
66131
+ abstract
66132
+ };
66133
+ }
66134
+ const logger$a = getLogger("webpage-embed");
66135
+ function createEmbedContent$4(editor, content, blockData, path, container, block) {
66136
+ const { embedData, id } = blockData;
66137
+ const { src } = embedData;
66138
+ const webpage = editor.addCustom(`webpage-${id}`, () => new WebPage(editor, blockData));
66139
+ assert(logger$a, src, "The src from blockData is invalid ");
66140
+ webpage.create(editor, embedData, content, block);
66141
+ setTimeout(() => {
66142
+ if (editor.isBlockWritable(block)) {
66143
+ editor.addCustom("webpage-resizer", () => new WebpageResizer(editor));
66144
+ }
66145
+ });
66146
+ if (blockData.height) {
66147
+ block.style.height = `${blockData.height}px`;
66148
+ }
66149
+ }
66150
+ function handleUpdateBlock$3(editor, block, blockData) {
66151
+ const { embedData, id } = blockData;
66152
+ const webpage = editor.getCustom(`webpage-${id}`);
66153
+ webpage.update(editor, block, embedData);
66154
+ if (blockData.height) {
66155
+ block.style.height = `${blockData.height}px`;
66156
+ }
66157
+ return true;
66158
+ }
66159
+ function getOptions$1(editor) {
66160
+ return {
66161
+ name: "WebPage",
66162
+ insertEmbedCommandItems: getAllowedWebPages(editor),
66163
+ handleInsertEmptyEmbed
66164
+ };
66165
+ }
66166
+ function convertTo$4(editor, blockData, doc2, type) {
66167
+ const webpage = blockData.embedData;
66168
+ const url = webpage.src;
66169
+ if (type === "html") {
66170
+ return `<iframe src="${url}" ></iframe>`;
66171
+ }
66172
+ if (type === "markdown") {
66173
+ return `[${url}](${url})`;
66174
+ }
66175
+ return url;
66176
+ }
66177
+ const WebPageEmbed = {
66178
+ embedType: "webpage",
66263
66179
  createEmbedContent: createEmbedContent$4,
66264
- handleUpdateBlock: handleUpdateBlock$3,
66265
66180
  getBlockProperties: getBlockProperties$4,
66181
+ getOptions: getOptions$1,
66182
+ handleUpdateBlock: handleUpdateBlock$3,
66266
66183
  convertTo: convertTo$4
66267
66184
  };
66268
- const style = "";
66185
+ const zhCN$4 = {
66186
+ webpage: {
66187
+ title: "\u7F51\u9875",
66188
+ youku: "\u4F18\u9177\u89C6\u9891",
66189
+ modao: "\u58A8\u5200",
66190
+ tencent: "\u817E\u8BAF\u89C6\u9891",
66191
+ bilibili: "Bilibili",
66192
+ figma: "Figma",
66193
+ dialog: {
66194
+ helpContent: "\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",
66195
+ helpLink: "\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",
66196
+ label: "\u7F51\u9875\u5730\u5740",
66197
+ placeholder: "\u8BF7\u8F93\u5165",
66198
+ title: "\u63D2\u5165{name}",
66199
+ errorEnterUrl: "\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",
66200
+ unsupportedUrl: "\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9",
66201
+ okText: "\u786E\u5B9A",
66202
+ cancelText: "\u53D6\u6D88"
66203
+ },
66204
+ abstract: "\u7F51\u9875",
66205
+ command: {
66206
+ refresh: "\u5237\u65B0\u9875\u9762",
66207
+ openPage: "\u6253\u5F00\u539F\u59CB\u9875\u9762"
66208
+ }
66209
+ }
66210
+ };
66211
+ const enUS$4 = {
66212
+ webpage: {
66213
+ title: "Webpage",
66214
+ youku: "Youku",
66215
+ modao: "Modao",
66216
+ tencent: "Tencent Video",
66217
+ bilibili: "Bilibili",
66218
+ figma: "Figma",
66219
+ dialog: {
66220
+ helpContent: "Due to landing page limitations, some pages may not be properly displayed during preview.",
66221
+ helpLink: "How to get the URL link",
66222
+ label: "Website address",
66223
+ placeholder: "Please enter",
66224
+ title: "Insert {name}",
66225
+ errorEnterUrl: "Please enter website address",
66226
+ unsupportedUrl: "Unsupported URL",
66227
+ okText: "Confirm",
66228
+ cancelText: "Cancel"
66229
+ },
66230
+ abstract: "Webpage",
66231
+ command: {
66232
+ refresh: "Refresh page",
66233
+ openPage: "Open the original page"
66234
+ }
66235
+ }
66236
+ };
66237
+ const jaJP$4 = {
66238
+ webpage: {
66239
+ title: "Web \u30DA\u30FC\u30B8",
66240
+ youku: "Youku \u52D5\u753B",
66241
+ modao: "Modao",
66242
+ tencent: "Tencent \u52D5\u753B",
66243
+ bilibili: "Bilibili",
66244
+ figma: "Figma",
66245
+ dialog: {
66246
+ 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",
66247
+ helpLink: "URL \u3092\u53D6\u5F97\u3059\u308B\u65B9\u6CD5",
66248
+ label: "URL",
66249
+ placeholder: "\u5165\u529B",
66250
+ title: "{name}\u3092\u633F\u5165",
66251
+ errorEnterUrl: "URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
66252
+ unsupportedUrl: "\u3053\u306E URL \u306F\u633F\u5165\u3067\u304D\u307E\u305B\u3093",
66253
+ okText: "OK",
66254
+ cancelText: "\u30AD\u30E3\u30F3\u30BB\u30EB"
66255
+ },
66256
+ abstract: "Web \u30DA\u30FC\u30B8",
66257
+ command: {
66258
+ refresh: "\u30DA\u30FC\u30B8\u3092\u518D\u8AAD\u307F\u8FBC\u3080",
66259
+ openPage: "URL\u3092\u958B\u304F"
66260
+ }
66261
+ }
66262
+ };
66263
+ i18n$1.mergeLang({
66264
+ "zh-CN": zhCN$4,
66265
+ "en-US": enUS$4,
66266
+ "ja-JP": jaJP$4
66267
+ });
66268
+ const webpageStyle = "";
66269
66269
  const index$2 = "";
66270
66270
  const UPDATE_DELAY = 500;
66271
66271
  const DEFAULT_EDIT_CODE_HEIGHT = 300;
@@ -74917,6 +74917,7 @@ ${data.flowchartText}
74917
74917
  editor.addCustom("mention", () => new OnesEditorMention(editor, mentionOptions));
74918
74918
  }
74919
74919
  editor.addCustom("heading-collapse", () => new HeadingBlockCollapseButton(editor));
74920
+ editor.addCustom("iframe-embed-reauth-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
74920
74921
  OnesEditorToolbar.register(editor);
74921
74922
  OnesEditorDropTarget.register(editor);
74922
74923
  OnesEditorTocProvider.register(editor);
@@ -75030,6 +75031,7 @@ ${data.flowchartText}
75030
75031
  }
75031
75032
  }
75032
75033
  });
75034
+ editor.addCustom("iframe-embed-reauth-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
75033
75035
  OnesEditorToolbar.register(editor);
75034
75036
  return editor;
75035
75037
  }