@ones-editor/editor 1.1.3-bate.4 → 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");
@@ -34152,6 +34154,11 @@ ${codeText}
34152
34154
  }
34153
34155
  }
34154
34156
  }
34157
+ emitPermissionError() {
34158
+ const err = new Error(PermissionError.msg);
34159
+ err.code = PermissionError.err;
34160
+ this.events.emit("error", err);
34161
+ }
34155
34162
  emitAuthRecover() {
34156
34163
  this.events.emit("authRecover");
34157
34164
  }
@@ -34194,6 +34201,8 @@ ${codeText}
34194
34201
  } finally {
34195
34202
  this.end(false);
34196
34203
  }
34204
+ } else if (err === PermissionError.err) {
34205
+ this.emitPermissionError();
34197
34206
  } else {
34198
34207
  logger$2n.error(`unknown message received: ${JSON.stringify(msg)}`);
34199
34208
  this.emitAuthError();
@@ -34348,9 +34357,6 @@ ${codeText}
34348
34357
  onRequestReloadError(callback) {
34349
34358
  this.connection.onRequestReloadError(callback);
34350
34359
  }
34351
- triggerReAuth() {
34352
- this.connection.reauth();
34353
- }
34354
34360
  async authOnly() {
34355
34361
  await this.connection.auth(this.auth);
34356
34362
  }
@@ -34614,6 +34620,9 @@ ${codeText}
34614
34620
  }
34615
34621
  return ret;
34616
34622
  }
34623
+ reAuth() {
34624
+ this.connection.reAuth();
34625
+ }
34617
34626
  }
34618
34627
  function createEmptyDoc() {
34619
34628
  const id = genId();
@@ -35459,13 +35468,13 @@ ${codeText}
35459
35468
  return (_a = cb.onError) == null ? void 0 : _a.call(cb, err);
35460
35469
  });
35461
35470
  });
35462
- this.client.onWriteConflictError(this.handleWriteConflictError);
35463
35471
  this.client.onAuthRecover(() => {
35464
35472
  this.callbacks.forEach((cb) => {
35465
35473
  var _a;
35466
35474
  return (_a = cb.onAuthRecover) == null ? void 0 : _a.call(cb);
35467
35475
  });
35468
35476
  });
35477
+ this.client.onWriteConflictError(this.handleWriteConflictError);
35469
35478
  }
35470
35479
  clearEvents() {
35471
35480
  this.doc.off("nothing pending", this.handleNothingPending);
@@ -35683,6 +35692,12 @@ ${codeText}
35683
35692
  });
35684
35693
  }
35685
35694
  }
35695
+ onAuthRecover() {
35696
+ this.callbacks.forEach((cb) => {
35697
+ var _a;
35698
+ return (_a = cb.onAuthRecover) == null ? void 0 : _a.call(cb);
35699
+ });
35700
+ }
35686
35701
  async addResources(resourceIds) {
35687
35702
  let hashes = [];
35688
35703
  resourceIds.forEach((res) => {
@@ -35786,7 +35801,7 @@ ${codeText}
35786
35801
  return meta;
35787
35802
  }
35788
35803
  triggerReAuth() {
35789
- this.client.triggerReAuth();
35804
+ this.client.reAuth();
35790
35805
  }
35791
35806
  }
35792
35807
  getLogger("remote-cursor");
@@ -62924,8 +62939,6 @@ ${codeText}
62924
62939
  return (_a = cb.onInsertChildContainer) == null ? void 0 : _a.call(cb, containerId, data, true);
62925
62940
  });
62926
62941
  }
62927
- triggerReAuth() {
62928
- }
62929
62942
  }
62930
62943
  const { t } = i18n$1;
62931
62944
  function getOpDescription(user, type) {
@@ -64816,735 +64829,62 @@ ${codeText}
64816
64829
  document.removeEventListener("touchend", this.handleTouchEnd);
64817
64830
  }
64818
64831
  }
64819
- 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>';
64820
- const logger$e = getLogger("webpage");
64821
- class WebPage {
64822
- constructor(editor, blockData) {
64823
- __publicField(this, "currentSrc", "");
64824
- __publicField(this, "loading", null);
64825
- __publicField(this, "handleMaskMouseMove", (editor, event) => {
64826
- if (window.isDragging) {
64827
- return;
64828
- }
64829
- if (event.target && event.target instanceof Element) {
64830
- const mask = event.target.closest("webpage-mask");
64831
- if (mask) {
64832
- mask.style.display = "none";
64833
- }
64834
- }
64835
- editor.domEvents.addEventListener(document, "mousemove", this.handleDocumentMouseMove);
64836
- });
64837
- __publicField(this, "handleDocumentMouseMove", (editor, event) => {
64838
- if (!event.target || !(event.target instanceof Element)) {
64839
- return;
64840
- }
64841
- const block = this.editor.findBlockById(this.blockData.id);
64842
- if (block) {
64843
- const mask = this.getExistsMask(block);
64844
- if (mask) {
64845
- if (isChildNode(block, event.target)) {
64846
- mask.style.display = "none";
64847
- return;
64848
- }
64849
- mask.style.display = "";
64850
- }
64851
- }
64852
- });
64853
- this.editor = editor;
64854
- this.blockData = blockData;
64855
- }
64856
- create(editor, embedData, parent, block) {
64857
- const src = embedData.src;
64858
- const internalContainer = createElement("div", ["editor-embed"], null);
64859
- const iframe = createElement("iframe", ["editor-preview-iframe"], internalContainer);
64860
- this.loading = this.createLoading(internalContainer);
64861
- const handleIframeLoaded = () => {
64862
- assert(logger$e, this.loading, "not created");
64863
- this.loading.hide();
64864
- this.currentSrc = src;
64865
- };
64866
- editor.domEvents.addEventListener(iframe, "load", handleIframeLoaded);
64867
- const httpReg = /^http:\/\//i;
64868
- iframe.src = src.replace(httpReg, "//");
64869
- this.loading.show();
64870
- parent.append(internalContainer);
64871
- this.createMask(editor, block);
64872
- }
64873
- update(editor, block, embedData) {
64874
- assert(logger$e, this.loading, "not created");
64875
- if (this.currentSrc === embedData.src) {
64876
- return;
64877
- }
64878
- const iframe = block.querySelector(".editor-preview-iframe");
64879
- assert(logger$e, iframe, "no exists iframe");
64880
- this.loading.show();
64881
- iframe.src = embedData.src;
64882
- this.createMask(editor, block);
64883
- }
64884
- createLoading(parent) {
64885
- const loadContainer = createElement("div", ["editor-preview-iframe-loading"], null);
64886
- const iconContainer = createElement("span", [], loadContainer);
64887
- iconContainer.innerHTML = loadingIcon;
64888
- return {
64889
- show() {
64890
- parent.append(loadContainer);
64891
- },
64892
- hide() {
64893
- const loadContainer2 = parent.querySelector(":scope > .editor-preview-iframe-loading");
64894
- if (!loadContainer2)
64895
- return;
64896
- loadContainer2.remove();
64897
- }
64898
- };
64899
- }
64900
- getExistsMask(block) {
64901
- const tools = getBlockTools(block);
64902
- return tools.querySelector(".webpage-mask");
64903
- }
64904
- createMask(editor, block) {
64905
- const tools = getBlockTools(block);
64906
- let mask = this.getExistsMask(block);
64907
- if (mask) {
64908
- mask.style.display = "";
64909
- return;
64910
- }
64911
- mask = createElement("div", ["webpage-mask"], tools);
64912
- editor.domEvents.addEventListener(mask, "mousemove", this.handleMaskMouseMove);
64913
- }
64914
- destroy() {
64915
- const block = this.editor.findBlockById(this.blockData.id);
64916
- if (block) {
64917
- const mask = this.getExistsMask(block);
64918
- if (mask) {
64919
- this.editor.domEvents.removeEventListener(mask, "mousemove", this.handleMaskMouseMove);
64920
- this.editor.domEvents.removeEventListener(document, "mousemove", this.handleDocumentMouseMove);
64921
- }
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;
64922
64838
  }
64923
64839
  }
64840
+ return "";
64924
64841
  }
64925
- function isWebpageBlock(block) {
64926
- return block && isEmbedBlock(block) && getEmbedType(block) === "webpage";
64927
- }
64928
- const MAX_HEIGHT = 1e3;
64929
- const MIN_HEIGHT = 100;
64930
- class WebpageResizer {
64931
- constructor(editor) {
64932
- __publicField(this, "currentBlockElement", null);
64933
- __publicField(this, "resizing", false);
64934
- __publicField(this, "handleHoveringBlockChange", (newBlock, oldBlock) => {
64935
- if (this.resizing) {
64936
- return;
64937
- }
64938
- if (oldBlock && isWebpageBlock(oldBlock)) {
64939
- this.disableBlockResize(oldBlock);
64940
- }
64941
- if (newBlock && isWebpageBlock(newBlock)) {
64942
- this.enableBlockResize(newBlock);
64943
- }
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
64944
64848
  });
64945
- __publicField(this, "handleResizing", (resizer, rect) => {
64946
- this.resizing = true;
64947
- const block = resizer.getBlock();
64948
- if (!block) {
64949
- return;
64950
- }
64951
- const newHeight = Math.max(Math.min(rect.height, MAX_HEIGHT), MIN_HEIGHT);
64952
- block.style.height = `${newHeight}px`;
64953
- addClass(block, "resizing");
64849
+ const reader = new FileReader();
64850
+ const promise = new Promise((resolve, reject) => {
64851
+ reader.onload = resolve;
64852
+ reader.onerror = reject;
64954
64853
  });
64955
- __publicField(this, "handleResized", (resizer) => {
64956
- this.resizing = false;
64957
- const block = resizer.getBlock();
64958
- if (!block) {
64959
- 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];
64960
64863
  }
64961
- removeClass(block, "resizing");
64962
- const oldData = this.editor.getBlockData(block);
64963
- const height = block.getBoundingClientRect().height;
64964
- this.editor.updateBlockData(block, {
64965
- ...oldData,
64966
- height
64967
- });
64968
- });
64969
- this.editor = editor;
64970
- OnesEditorHoveringBlock.get(editor).addListener("change", this.handleHoveringBlockChange);
64971
- }
64972
- destroy() {
64973
- this.currentBlockElement = null;
64974
- OnesEditorHoveringBlock.get(this.editor).removeListener("change", this.handleHoveringBlockChange);
64975
- }
64976
- disableBlockResize(block) {
64977
- const resizer = this.editor.findCustom(`${getBlockId(block)}-resizer`);
64978
- if (resizer) {
64979
- resizer.disableResize();
64980
64864
  }
64981
- }
64982
- enableBlockResize(block) {
64983
- const resizer = this.editor.addCustom(`${getBlockId(block)}-resizer`, () => new BlockResizer(this.editor, {
64984
- resize: ["bottom"]
64985
- }));
64986
- resizer.enableResize(block);
64987
- resizer.removeListener("resizing", this.handleResizing);
64988
- resizer.removeListener("resized", this.handleResized);
64989
- resizer.addListener("resizing", this.handleResizing);
64990
- resizer.addListener("resized", this.handleResized);
64991
- 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;
64992
64871
  }
64993
64872
  }
64994
- const index$3 = "";
64995
- const logger$d = getLogger("editor-dialog");
64996
- function createContainer(content, options) {
64997
- const container = createElement("div", ["editor-dialog-container"], null);
64998
- const header = createElement("div", ["dialog-header"], container);
64999
- createElement("span", ["dialog-header-title"], header, options.title);
65000
- const closeIcon = createElement("span", ["close-icon"], header);
65001
- closeIcon.innerHTML = CloseIcon;
65002
- const contentWrap = createElement("div", ["dialog-content"], container);
65003
- contentWrap.appendChild(content);
65004
- const footer = createElement("div", ["dialog-footer"], container);
65005
- const cancelButton = createButton$1("cancel-button", i18n$1.t("webpage.dialog.cancelText"));
65006
- footer.appendChild(cancelButton);
65007
- const submitButton = createButton$1("submit-button", i18n$1.t("webpage.dialog.okText"), void 0, ["primary"]);
65008
- footer.appendChild(submitButton);
65009
- return container;
64873
+ async function downloadObjectToFile(editor, url) {
64874
+ const file2 = await downloadImageToFile(editor, url);
64875
+ return file2;
65010
64876
  }
65011
- class Dialog extends ManualCloseDialog {
65012
- constructor(content, options) {
65013
- super(createContainer(content, options), options);
65014
- __publicField(this, "_options");
65015
- __publicField(this, "getReferenceClientRect", () => {
65016
- const y = document.documentElement.clientHeight / 2;
65017
- const x = document.documentElement.clientWidth / 2;
65018
- const rootElement = this.getCommandBarRoot();
65019
- assert(logger$d, rootElement, "no command bar root");
65020
- const { width, height } = rootElement.getBoundingClientRect();
65021
- return new DOMRect(Math.max(x - width / 2, 0), Math.max(y - height / 2, 0), 0, 0);
65022
- });
65023
- __publicField(this, "handleOk", async () => {
65024
- var _a, _b;
65025
- try {
65026
- await ((_b = (_a = this._options).onOk) == null ? void 0 : _b.call(_a));
65027
- this.destroy();
65028
- } catch (error2) {
65029
- }
65030
- });
65031
- __publicField(this, "handleClose", () => {
65032
- var _a, _b;
65033
- (_b = (_a = this._options).onClose) == null ? void 0 : _b.call(_a);
65034
- this.destroy();
65035
- });
65036
- const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65037
- const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65038
- const closeIcon = this.content.querySelector(".close-icon");
65039
- submitBtn == null ? void 0 : submitBtn.addEventListener("click", this.handleOk);
65040
- closeIcon == null ? void 0 : closeIcon.addEventListener("click", this.handleClose);
65041
- cancelBtn == null ? void 0 : cancelBtn.addEventListener("click", this.handleClose);
65042
- this._options = options;
65043
- }
65044
- show() {
65045
- super.show(document.documentElement, { getReferenceClientRect: this.getReferenceClientRect });
65046
- setTimeout(() => {
65047
- const mark = document.querySelector(`.editor-disable-scroll[data-scroll-id="${this.id}"]`);
65048
- if (mark) {
65049
- addClass(mark, "editor-disable-scroll-dark");
65050
- }
65051
- });
65052
- }
65053
- destroy() {
65054
- const submitBtn = this.content.querySelector('[data-button-id="submit-button"]');
65055
- const cancelBtn = this.content.querySelector('[data-button-id="cancel-button"]');
65056
- const closeIcon = this.content.querySelector(".close-icon");
65057
- submitBtn == null ? void 0 : submitBtn.removeEventListener("click", this.handleOk);
65058
- cancelBtn == null ? void 0 : cancelBtn.removeEventListener("click", this.handleClose);
65059
- closeIcon == null ? void 0 : closeIcon.removeEventListener("click", this.handleClose);
65060
- super.destroy();
65061
- }
65062
- }
65063
- const getCommandItems = () => [
65064
- {
65065
- name: i18n$1.t("webpage.bilibili"),
65066
- id: "insert-bilibili",
65067
- icon: BilibiliIcon,
65068
- group: "thirdParty",
65069
- subText: getShortcutById("insert-bilibili"),
65070
- value: "bilibili"
65071
- },
65072
- {
65073
- name: i18n$1.t("webpage.youku"),
65074
- id: "insert-youku",
65075
- icon: YoukuIcon,
65076
- group: "thirdParty",
65077
- subText: getShortcutById("insert-youku"),
65078
- value: "youku"
65079
- },
65080
- {
65081
- name: i18n$1.t("webpage.figma"),
65082
- id: "insert-figma",
65083
- icon: FigmaIcon,
65084
- group: "thirdParty",
65085
- subText: getShortcutById("insert-figma"),
65086
- value: "figma"
65087
- },
65088
- {
65089
- name: i18n$1.t("webpage.modao"),
65090
- id: "insert-modao",
65091
- icon: ModaoIcon,
65092
- group: "thirdParty",
65093
- subText: getShortcutById("insert-modao"),
65094
- value: "modao"
65095
- },
65096
- {
65097
- name: i18n$1.t("webpage.tencent"),
65098
- id: "insert-tencent",
65099
- icon: TencentVideoIcon,
65100
- group: "thirdParty",
65101
- subText: getShortcutById("insert-tencent"),
65102
- value: "qqVideo"
65103
- },
65104
- {
65105
- id: "insert-webPage",
65106
- name: i18n$1.t("webpage.title"),
65107
- icon: WebPageIcon,
65108
- group: "common",
65109
- order: 1e3,
65110
- subText: getShortcutById("insert-webPage"),
65111
- value: "url"
65112
- }
65113
- ];
65114
- function getAllowedWebPages(editor) {
65115
- let webpages = getCommandItems();
65116
- const editorOptions = editor.getComponentOptions("webpage");
65117
- if (editorOptions == null ? void 0 : editorOptions.getAllowedWebPages) {
65118
- webpages = editorOptions.getAllowedWebPages(webpages);
65119
- }
65120
- return webpages;
65121
- }
65122
- function isWebPageItem(id) {
65123
- return id === "insert-webPage";
65124
- }
65125
- async function recognizeWebPageLink(editor, url) {
65126
- if (editor.doc.externalDoc.recognizeLink) {
65127
- return editor.doc.externalDoc.recognizeLink(url);
65128
- }
65129
- return null;
65130
- }
65131
- function formatValue(value) {
65132
- if (value && !value.startsWith("http://") && !value.startsWith("https://") && !value.startsWith("//")) {
65133
- return `${window.location.protocol}//${value}`;
65134
- }
65135
- return value;
65136
- }
65137
- async function checkValue(value) {
65138
- if (!value) {
65139
- throw new Error(i18n$1.t("webpage.dialog.errorEnterUrl"));
65140
- }
65141
- const test = value;
65142
- try {
65143
- new URL(test);
65144
- } catch (err) {
65145
- throw new Error(i18n$1.t("webpage.dialog.unsupportedUrl"));
65146
- }
65147
- }
65148
- async function handleInsertEmptyEmbed(editor, options) {
65149
- const itemId = options.item.id;
65150
- const itemOption = getAllowedWebPages(editor).find((item) => item.id === itemId);
65151
- const content = createElement("div", ["webpage-content"], null);
65152
- if (isWebPageItem(itemId)) {
65153
- const helpContainer = createElement("div", ["help-container"], content);
65154
- const helpContent = createElement("div", ["help-content"], helpContainer);
65155
- const span = createElement("span", ["help-icon"], helpContent);
65156
- span.innerHTML = WarningIcon;
65157
- createElement("span", [], helpContent, i18n$1.t("webpage.dialog.helpContent"));
65158
- }
65159
- const { getInputValue, setFieldError, focus, getField } = createInput(content, {
65160
- required: true,
65161
- label: i18n$1.t("webpage.dialog.label"),
65162
- placeholder: i18n$1.t("webpage.dialog.placeholder")
65163
- });
65164
- const webpageOptions = editor.getComponentOptions("webpage");
65165
- if (!isWebPageItem(itemId) && !(webpageOptions == null ? void 0 : webpageOptions.hideHelpLink)) {
65166
- const linkContainer = createElement("div", ["help-link-container"], content);
65167
- const linkContent = createElement("a", ["help-link-content"], linkContainer);
65168
- createElement("span", [], linkContent, i18n$1.t("webpage.dialog.helpLink"));
65169
- const iconSpan = createElement("span", ["help-link-icon"], linkContent);
65170
- iconSpan.innerHTML = LaunchIcon;
65171
- linkContent.href = (webpageOptions == null ? void 0 : webpageOptions.helpLink) || "";
65172
- linkContent.target = "_blank";
65173
- }
65174
- try {
65175
- const result = await new Promise((resolve, reject) => {
65176
- const dialog = new Dialog(content, {
65177
- id: "webpage",
65178
- title: i18n$1.t("webpage.dialog.title", { name: (itemOption == null ? void 0 : itemOption.name) || "" }),
65179
- async onOk() {
65180
- var _a;
65181
- const value = formatValue(getInputValue());
65182
- try {
65183
- await checkValue(value);
65184
- const detail = await recognizeWebPageLink(editor, value);
65185
- resolve((detail == null ? void 0 : detail.url) || "");
65186
- } catch (error2) {
65187
- if (((_a = error2 == null ? void 0 : error2.responseData) == null ? void 0 : _a.statusCode) === 415) {
65188
- if (isWebPageItem(itemId)) {
65189
- resolve(value);
65190
- } else {
65191
- setFieldError(i18n$1.t("webpage.dialog.unsupportedUrl"));
65192
- throw error2;
65193
- }
65194
- } else {
65195
- setFieldError(error2.message || "");
65196
- throw error2;
65197
- }
65198
- }
65199
- },
65200
- onClose() {
65201
- editor.focus();
65202
- reject();
65203
- }
65204
- });
65205
- dialog.addListener("show", focus);
65206
- dialog.show();
65207
- const input2 = getField();
65208
- input2.addEventListener("keydown", async (event) => {
65209
- if (event.isComposing) {
65210
- return;
65211
- }
65212
- if (event.key === "Enter") {
65213
- await dialog.handleOk();
65214
- event.preventDefault();
65215
- return;
65216
- }
65217
- if (event.key === "Escape") {
65218
- dialog.handleClose();
65219
- }
65220
- });
65221
- });
65222
- const blockData = {
65223
- id: genId(),
65224
- type: "embed",
65225
- embedType: "webpage",
65226
- embedData: {
65227
- src: result
65228
- }
65229
- };
65230
- const block = editor.insertBlock(options.containerId, options.blockIndex, blockData);
65231
- editor.focus();
65232
- return block;
65233
- } catch (error2) {
65234
- return null;
65235
- }
65236
- }
65237
- function reloadIframe(block) {
65238
- const iframe = block.querySelector(".editor-preview-iframe");
65239
- const src = iframe.src;
65240
- iframe.src = "about:blank";
65241
- const timer = setTimeout(() => {
65242
- iframe.src = src;
65243
- clearTimeout(timer);
65244
- }, 300);
65245
- return true;
65246
- }
65247
- function openOriginalPage(editor, block) {
65248
- const blockData = editor.getBlockData(block);
65249
- const { embedData } = blockData;
65250
- const src = embedData.src;
65251
- window.open(src, "_blank");
65252
- return true;
65253
- }
65254
- function getBlockProperties$5(editor, block) {
65255
- const properties = getStandardEmbedBlockProperties(editor, block, {
65256
- presetIds: ["add-comment"],
65257
- extCommands: [{
65258
- id: "refresh",
65259
- name: i18n$1.t("webpage.command.refresh"),
65260
- icon: RefreshIcon
65261
- }, {
65262
- id: "open-page",
65263
- name: i18n$1.t("webpage.command.openPage"),
65264
- icon: LaunchIcon
65265
- }],
65266
- handleExecuteCommand: (editor2, block2, item) => {
65267
- switch (item.id) {
65268
- case "refresh":
65269
- return reloadIframe(block2);
65270
- case "open-page":
65271
- return openOriginalPage(editor2, block2);
65272
- }
65273
- return false;
65274
- }
65275
- });
65276
- const abstract = `${i18n$1.t("webpage.abstract")}`;
65277
- return {
65278
- ...properties,
65279
- abstract
65280
- };
65281
- }
65282
- const logger$c = getLogger("webpage-embed");
65283
- function createEmbedContent$5(editor, content, blockData, path, container, block) {
65284
- const { embedData, id } = blockData;
65285
- const { src } = embedData;
65286
- const webpage = editor.addCustom(`webpage-${id}`, () => new WebPage(editor, blockData));
65287
- assert(logger$c, src, "The src from blockData is invalid ");
65288
- webpage.create(editor, embedData, content, block);
65289
- setTimeout(() => {
65290
- if (editor.isBlockWritable(block)) {
65291
- editor.addCustom("webpage-resizer", () => new WebpageResizer(editor));
65292
- }
65293
- });
65294
- if (blockData.height) {
65295
- block.style.height = `${blockData.height}px`;
65296
- }
65297
- }
65298
- function handleUpdateBlock$4(editor, block, blockData) {
65299
- const { embedData, id } = blockData;
65300
- const webpage = editor.getCustom(`webpage-${id}`);
65301
- webpage.update(editor, block, embedData);
65302
- if (blockData.height) {
65303
- block.style.height = `${blockData.height}px`;
65304
- }
65305
- return true;
65306
- }
65307
- function getOptions$2(editor) {
65308
- return {
65309
- name: "WebPage",
65310
- insertEmbedCommandItems: getAllowedWebPages(editor),
65311
- handleInsertEmptyEmbed
65312
- };
65313
- }
65314
- function convertTo$5(editor, blockData, doc2, type) {
65315
- const webpage = blockData.embedData;
65316
- const url = webpage.src;
65317
- if (type === "html") {
65318
- return `<iframe src="${url}" ></iframe>`;
65319
- }
65320
- if (type === "markdown") {
65321
- return `[${url}](${url})`;
65322
- }
65323
- return url;
65324
- }
65325
- const WebPageEmbed = {
65326
- embedType: "webpage",
65327
- createEmbedContent: createEmbedContent$5,
65328
- getBlockProperties: getBlockProperties$5,
65329
- getOptions: getOptions$2,
65330
- handleUpdateBlock: handleUpdateBlock$4,
65331
- convertTo: convertTo$5
65332
- };
65333
- const zhCN$5 = {
65334
- webpage: {
65335
- title: "\u7F51\u9875",
65336
- youku: "\u4F18\u9177\u89C6\u9891",
65337
- modao: "\u58A8\u5200",
65338
- tencent: "\u817E\u8BAF\u89C6\u9891",
65339
- bilibili: "Bilibili",
65340
- figma: "Figma",
65341
- dialog: {
65342
- helpContent: "\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",
65343
- helpLink: "\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",
65344
- label: "\u7F51\u9875\u5730\u5740",
65345
- placeholder: "\u8BF7\u8F93\u5165",
65346
- title: "\u63D2\u5165{name}",
65347
- errorEnterUrl: "\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",
65348
- unsupportedUrl: "\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9",
65349
- okText: "\u786E\u5B9A",
65350
- cancelText: "\u53D6\u6D88"
65351
- },
65352
- abstract: "\u7F51\u9875",
65353
- command: {
65354
- refresh: "\u5237\u65B0\u9875\u9762",
65355
- openPage: "\u6253\u5F00\u539F\u59CB\u9875\u9762"
65356
- }
65357
- }
65358
- };
65359
- const enUS$5 = {
65360
- webpage: {
65361
- title: "Webpage",
65362
- youku: "Youku",
65363
- modao: "Modao",
65364
- tencent: "Tencent Video",
65365
- bilibili: "Bilibili",
65366
- figma: "Figma",
65367
- dialog: {
65368
- helpContent: "Due to landing page limitations, some pages may not be properly displayed during preview.",
65369
- helpLink: "How to get the URL link",
65370
- label: "Website address",
65371
- placeholder: "Please enter",
65372
- title: "Insert {name}",
65373
- errorEnterUrl: "Please enter website address",
65374
- unsupportedUrl: "Unsupported URL",
65375
- okText: "Confirm",
65376
- cancelText: "Cancel"
65377
- },
65378
- abstract: "Webpage",
65379
- command: {
65380
- refresh: "Refresh page",
65381
- openPage: "Open the original page"
65382
- }
65383
- }
65384
- };
65385
- const jaJP$5 = {
65386
- webpage: {
65387
- title: "Web \u30DA\u30FC\u30B8",
65388
- youku: "Youku \u52D5\u753B",
65389
- modao: "Modao",
65390
- tencent: "Tencent \u52D5\u753B",
65391
- bilibili: "Bilibili",
65392
- figma: "Figma",
65393
- dialog: {
65394
- 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",
65395
- helpLink: "URL \u3092\u53D6\u5F97\u3059\u308B\u65B9\u6CD5",
65396
- label: "URL",
65397
- placeholder: "\u5165\u529B",
65398
- title: "{name}\u3092\u633F\u5165",
65399
- errorEnterUrl: "URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
65400
- unsupportedUrl: "\u3053\u306E URL \u306F\u633F\u5165\u3067\u304D\u307E\u305B\u3093",
65401
- okText: "OK",
65402
- cancelText: "\u30AD\u30E3\u30F3\u30BB\u30EB"
65403
- },
65404
- abstract: "Web \u30DA\u30FC\u30B8",
65405
- command: {
65406
- refresh: "\u30DA\u30FC\u30B8\u3092\u518D\u8AAD\u307F\u8FBC\u3080",
65407
- openPage: "URL\u3092\u958B\u304F"
65408
- }
65409
- }
65410
- };
65411
- i18n$1.mergeLang({
65412
- "zh-CN": zhCN$5,
65413
- "en-US": enUS$5,
65414
- "ja-JP": jaJP$5
65415
- });
65416
- const webpageStyle = "";
65417
- class IframeKindEmbedDocCallbacks extends tinyTypedEmitter.TypedEmitter {
65418
- constructor(editor) {
65419
- super();
65420
- __publicField(this, "currentBlock");
65421
- __publicField(this, "currentIframe");
65422
- __publicField(this, "onReAuthErrorWhenIframeEditing");
65423
- __publicField(this, "onIframeExitEdit");
65424
- __publicField(this, "destroy", () => {
65425
- this.editor.doc.unregisterCallback(this);
65426
- });
65427
- __publicField(this, "onError", (error2) => {
65428
- if (error2.code === AuthError.err) {
65429
- if (this.currentIframe) {
65430
- this.onConnectReAuthError();
65431
- }
65432
- }
65433
- });
65434
- __publicField(this, "onAuthRecover", () => {
65435
- if (this.currentBlock) {
65436
- enablePageScroll(this.currentBlock.id);
65437
- }
65438
- });
65439
- __publicField(this, "unregisterCallbacks", () => {
65440
- this.editor.doc.unregisterCallback(this);
65441
- });
65442
- __publicField(this, "register", (block, iframe, options) => {
65443
- this.currentBlock = block;
65444
- this.currentIframe = iframe;
65445
- this.onReAuthErrorWhenIframeEditing = options.onError;
65446
- this.onIframeExitEdit = options.onExit;
65447
- });
65448
- __publicField(this, "unRegister", () => {
65449
- this.currentBlock = void 0;
65450
- this.currentIframe = void 0;
65451
- this.onReAuthErrorWhenIframeEditing = void 0;
65452
- });
65453
- __publicField(this, "onConnectReAuthError", () => {
65454
- var _a;
65455
- if (this.currentBlock && this.currentIframe) {
65456
- (_a = this.onReAuthErrorWhenIframeEditing) == null ? void 0 : _a.call(this, this.currentBlock, this.currentIframe);
65457
- const container = disablePageScroll(this.currentBlock.id);
65458
- const fixedToolbar = createElement("div", ["iframe-embed-auth-error-tips"], container);
65459
- fixedToolbar.innerHTML = i18n$1.t("authError.tips");
65460
- fixedToolbar.addEventListener("click", (event) => {
65461
- const target = event.target;
65462
- if (target instanceof HTMLSpanElement) {
65463
- const id = target.id;
65464
- switch (id) {
65465
- case "retry":
65466
- this.reAuth();
65467
- break;
65468
- case "exit":
65469
- this.exit();
65470
- break;
65471
- }
65472
- }
65473
- });
65474
- }
65475
- });
65476
- this.editor = editor;
65477
- this.editor.doc.registerCallback(this);
65478
- }
65479
- reAuth() {
65480
- var _a, _b;
65481
- (_b = (_a = this.editor.doc).triggerReAuth) == null ? void 0 : _b.call(_a);
65482
- }
65483
- exit() {
65484
- var _a;
65485
- if (this.currentBlock) {
65486
- enablePageScroll(this.currentBlock.id);
65487
- }
65488
- this.unRegister();
65489
- (_a = this.onIframeExitEdit) == null ? void 0 : _a.call(this);
65490
- }
65491
- }
65492
- function getContentTypeFromHeaders(headers) {
65493
- const entries = Object.entries(headers);
65494
- for (let i = 0; i < entries.length; i++) {
65495
- const [key, value] = entries[i];
65496
- if (key.toLocaleLowerCase() === "content-type") {
65497
- return value;
65498
- }
65499
- }
65500
- return "";
65501
- }
65502
- async function downloadImageToFile(editor, src, withCredentials = true) {
65503
- try {
65504
- const res = await editor.doc.request(src, {
65505
- method: "get",
65506
- responseType: "blob",
65507
- withCredentials
65508
- });
65509
- const reader = new FileReader();
65510
- const promise = new Promise((resolve, reject) => {
65511
- reader.onload = resolve;
65512
- reader.onerror = reject;
65513
- });
65514
- reader.readAsArrayBuffer(res.data);
65515
- await promise;
65516
- const buffer = reader.result;
65517
- const contentType = getContentTypeFromHeaders(res.headers).toLocaleLowerCase();
65518
- let ext = "";
65519
- if (contentType) {
65520
- const extensions = mime__default.default[contentType].extensions;
65521
- if (extensions && extensions.length > 0) {
65522
- ext = extensions[0];
65523
- }
65524
- }
65525
- const file2 = new File([buffer], `${Date.now()}.${ext}`, {
65526
- type: contentType
65527
- });
65528
- return file2;
65529
- } catch (err) {
65530
- return null;
65531
- }
65532
- }
65533
- async function downloadObjectToFile(editor, url) {
65534
- const file2 = await downloadImageToFile(editor, url);
65535
- return file2;
65536
- }
65537
- async function downloadSvgToString(editor, url) {
65538
- const file2 = await downloadObjectToFile(editor, url);
65539
- if (!file2)
65540
- return null;
65541
- const text2 = await file2.text();
65542
- return text2;
65543
- }
65544
- const isEmptyImage = (svg) => {
65545
- const rect = svg.getBoundingClientRect();
65546
- if (rect.width <= 1 && rect.height <= 1) {
65547
- 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;
65548
64888
  }
65549
64889
  return false;
65550
64890
  };
@@ -65688,7 +65028,7 @@ ${codeText}
65688
65028
  const SAVE_DELAY_TIME = 30 * 1e3;
65689
65029
  const DRAWIO_EMPTY_CLASS = "editor-empty-drawio";
65690
65030
  const SHOW_FULL_SCREEN_IFRAME = "show-full-screen-iframe";
65691
- const logger$b = getLogger("embed-block-drawio");
65031
+ const logger$e = getLogger("embed-block-drawio");
65692
65032
  function getDrawioOptions(editor) {
65693
65033
  const compOptions = editor.options.componentsOptions;
65694
65034
  return compOptions.drawIO || {};
@@ -65712,7 +65052,7 @@ ${codeText}
65712
65052
  }
65713
65053
  function resizeObserver(el) {
65714
65054
  const resize = () => {
65715
- assert(logger$b, el, "el does not exist");
65055
+ assert(logger$e, el, "el does not exist");
65716
65056
  const width = document.body.clientWidth || document.documentElement.clientWidth;
65717
65057
  const height = document.body.clientHeight || document.documentElement.clientHeight;
65718
65058
  el.setAttribute("width", `${width - 2 * BORDER}`);
@@ -65730,17 +65070,17 @@ ${codeText}
65730
65070
  async function initializeDrawioIframe(editor, block) {
65731
65071
  const options = getDrawioOptions(editor) || {};
65732
65072
  const callbacks = options.callbacks || {};
65733
- const drawioCallbacks = editor.getCustom("drawio-event-callback");
65073
+ const iframeKindEmbedDocCallbacks = editor.getCustom("iframe-embed-reauth-event-callback");
65734
65074
  const { onCreateDrawIoFrame, onCloseDrawIoFrame } = callbacks;
65735
65075
  let drawioIframe = null;
65736
65076
  let exit;
65737
65077
  if (onCreateDrawIoFrame) {
65738
65078
  drawioIframe = await onCreateDrawIoFrame(editor);
65739
- assert(logger$b, drawioIframe, "iframe create failed");
65079
+ assert(logger$e, drawioIframe, "iframe create failed");
65740
65080
  exit = () => {
65741
- assert(logger$b, drawioIframe, "iframe does not exist");
65742
- assert(logger$b, onCloseDrawIoFrame, "missing parameters: onCloseDrawIoFrame");
65743
- drawioCallbacks.unRegister();
65081
+ assert(logger$e, drawioIframe, "iframe does not exist");
65082
+ assert(logger$e, onCloseDrawIoFrame, "missing parameters: onCloseDrawIoFrame");
65083
+ iframeKindEmbedDocCallbacks.unRegister();
65744
65084
  onCloseDrawIoFrame(editor, drawioIframe);
65745
65085
  };
65746
65086
  } else {
@@ -65751,14 +65091,14 @@ ${codeText}
65751
65091
  addClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
65752
65092
  const { disconnect } = resizeObserver(drawioIframe);
65753
65093
  exit = () => {
65754
- assert(logger$b, drawioIframe, "iframe does not exist");
65755
- drawioCallbacks.unRegister();
65094
+ assert(logger$e, drawioIframe, "iframe does not exist");
65095
+ iframeKindEmbedDocCallbacks.unRegister();
65756
65096
  disconnect();
65757
65097
  document.body.removeChild(drawioContainer);
65758
65098
  removeClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
65759
65099
  };
65760
65100
  }
65761
- drawioCallbacks.register(block, drawioIframe, {
65101
+ iframeKindEmbedDocCallbacks.register(block, drawioIframe, {
65762
65102
  onExit: () => exit()
65763
65103
  });
65764
65104
  return {
@@ -65770,7 +65110,7 @@ ${codeText}
65770
65110
  var _a, _b;
65771
65111
  try {
65772
65112
  if (autoSave) {
65773
- logger$b.debug("auto saving drawio data");
65113
+ logger$e.debug("auto saving drawio data");
65774
65114
  }
65775
65115
  const blob = new Blob([svg]);
65776
65116
  const file2 = new File([blob], "drawio.svg", {
@@ -65789,11 +65129,11 @@ ${codeText}
65789
65129
  };
65790
65130
  editor.updateEmbedData(targetBlock, newEmbedData);
65791
65131
  } else {
65792
- logger$b.error("block has been deleted");
65132
+ logger$e.error("block has been deleted");
65793
65133
  }
65794
65134
  } catch (err) {
65795
65135
  const message = `failed to upload drawio data: ${err.message}`;
65796
- logger$b.error(message);
65136
+ logger$e.error(message);
65797
65137
  }
65798
65138
  } catch (err) {
65799
65139
  const message = `failed to save drawio data: ${err.message}`;
@@ -65812,7 +65152,7 @@ ${codeText}
65812
65152
  };
65813
65153
  const receive = async (evt) => {
65814
65154
  var _a, _b;
65815
- assert(logger$b, iframe.contentWindow, "iframe.contentWindow does not exist");
65155
+ assert(logger$e, iframe.contentWindow, "iframe.contentWindow does not exist");
65816
65156
  if (evt.data.length > 0) {
65817
65157
  const msg = JSON.parse(evt.data);
65818
65158
  const xml = drawIoData.xmlSvg || drawIoData.xml;
@@ -65962,7 +65302,7 @@ ${codeText}
65962
65302
  };
65963
65303
  }
65964
65304
  function setGraph(embed, data) {
65965
- assert(logger$b, data, "Required data is missing in setGraph");
65305
+ assert(logger$e, data, "Required data is missing in setGraph");
65966
65306
  if ("src" in data) {
65967
65307
  embed.setAttribute("data-src", data.src);
65968
65308
  return;
@@ -65985,8 +65325,8 @@ ${codeText}
65985
65325
  };
65986
65326
  }
65987
65327
  function updateGraphBySrc(src, embed, editor) {
65988
- assert(logger$b, src, "params error: src");
65989
- assert(logger$b, editor, "params error: editor");
65328
+ assert(logger$e, src, "params error: src");
65329
+ assert(logger$e, editor, "params error: editor");
65990
65330
  const embedEl = embed;
65991
65331
  const url = editor.doc.buildResourceUrl(src);
65992
65332
  const img = document.createElement("img");
@@ -66019,26 +65359,26 @@ ${codeText}
66019
65359
  };
66020
65360
  }
66021
65361
  function updateGraphByXml(mxFile, embed, editor) {
66022
- assert(logger$b, editor, "parameter missing");
65362
+ assert(logger$e, editor, "parameter missing");
66023
65363
  initDrawIo(editor).then(() => {
66024
65364
  const { mxUtils, mxGraph: MxGraph, mxCodec: MxCodec } = window;
66025
- assert(logger$b, mxUtils, "External resource loading exception: mxUtils");
66026
- assert(logger$b, MxGraph, "External resource loading exception: MxGraph");
66027
- 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");
66028
65368
  const file2 = mxUtils.parseXml(mxFile);
66029
65369
  embed.innerHTML = "";
66030
65370
  const node = file2.documentElement;
66031
- assert(logger$b, node, "Resource parsing exception");
66032
- 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");
66033
65373
  const diagrams = node.getElementsByTagName("diagram");
66034
- assert(logger$b, diagrams.length > 0, "Resource parsing exception");
65374
+ assert(logger$e, diagrams.length > 0, "Resource parsing exception");
66035
65375
  let xmlDoc;
66036
65376
  const data = diagrams[0];
66037
65377
  if (data.text || data.textContent) {
66038
65378
  const diagramBase64 = getTextContent(data);
66039
65379
  const raw = atob(diagramBase64);
66040
65380
  const pako = window.pako;
66041
- assert(logger$b, pako, "External resource loading exception: pako");
65381
+ assert(logger$e, pako, "External resource loading exception: pako");
66042
65382
  const encodedXml = pako.inflateRaw(Uint8Array.from(raw, (c) => c.charCodeAt(0)), { to: "string" });
66043
65383
  const xml = decodeURIComponent(encodedXml);
66044
65384
  xmlDoc = mxUtils.parseXml(xml);
@@ -66075,7 +65415,7 @@ ${codeText}
66075
65415
  }
66076
65416
  addDrawioEmptyStatus(embed);
66077
65417
  }
66078
- function getBlockProperties$4(editor, block) {
65418
+ function getBlockProperties$5(editor, block) {
66079
65419
  const properties = getStandardEmbedBlockProperties(editor, block, {
66080
65420
  handleExecuteCommand: (editor2, block2, item) => {
66081
65421
  if (item.id === "edit") {
@@ -66088,7 +65428,7 @@ ${codeText}
66088
65428
  });
66089
65429
  return { ...properties, abstract: i18n$1.t("drawio.abstract") };
66090
65430
  }
66091
- const enUS$4 = {
65431
+ const enUS$5 = {
66092
65432
  drawio: {
66093
65433
  title: "Flowchart/UML",
66094
65434
  empty: "Empty graph",
@@ -66102,7 +65442,7 @@ ${codeText}
66102
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>'
66103
65443
  }
66104
65444
  };
66105
- const zhCN$4 = {
65445
+ const zhCN$5 = {
66106
65446
  drawio: {
66107
65447
  title: "\u6D41\u7A0B\u56FE/UML",
66108
65448
  empty: "\u7A7A\u56FE\u8868",
@@ -66116,7 +65456,7 @@ ${codeText}
66116
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>'
66117
65457
  }
66118
65458
  };
66119
- const jaJP$4 = {
65459
+ const jaJP$5 = {
66120
65460
  drawio: {
66121
65461
  title: "\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",
66122
65462
  empty: "\u30B0\u30E9\u30D5\u30C7\u30FC\u30BF\u306A\u3057",
@@ -66131,16 +65471,16 @@ ${codeText}
66131
65471
  }
66132
65472
  };
66133
65473
  const langs = {
66134
- "en-US": enUS$4,
66135
- "zh-CN": zhCN$4,
66136
- "ja-JP": jaJP$4
65474
+ "en-US": enUS$5,
65475
+ "zh-CN": zhCN$5,
65476
+ "ja-JP": jaJP$5
66137
65477
  };
66138
65478
  i18n$1.mergeLang(langs);
66139
- const logger$a = getLogger("embed-block-drawio");
65479
+ const logger$d = getLogger("embed-block-drawio");
66140
65480
  const isInitializationCompleted = false;
66141
65481
  function editDrawIO(editor, block, embed, data) {
66142
- assert(logger$a, embed, `parameter missing: ${embed}`);
66143
- assert(logger$a, editor, `parameter missing: ${editor}`);
65482
+ assert(logger$d, embed, `parameter missing: ${embed}`);
65483
+ assert(logger$d, editor, `parameter missing: ${editor}`);
66144
65484
  editGraph(editor, block, data, isInitializationCompleted);
66145
65485
  }
66146
65486
  function updateViewLayer(editor, embed, data) {
@@ -66182,23 +65522,20 @@ ${codeText}
66182
65522
  }
66183
65523
  }
66184
65524
  }
66185
- function createEmbedContent$4(editor, content, blockData, path, container, block) {
66186
- editorRunOnce(editor, "drawio-event-callbacks", () => {
66187
- editor.addCustom("drawio-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
66188
- });
65525
+ function createEmbedContent$5(editor, content, blockData, path, container, block) {
66189
65526
  const drawioData = blockData.embedData;
66190
65527
  mount(editor, content, drawioData);
66191
65528
  EmbedBlockResizer.register(editor, block);
66192
65529
  }
66193
- function handleUpdateBlock$3(editor, block, blockData) {
65530
+ function handleUpdateBlock$4(editor, block, blockData) {
66194
65531
  const data = blockData.embedData;
66195
65532
  const content = getBlockContent(block);
66196
65533
  const embed = content.querySelector(":scope > .editor-drawio-content");
66197
- assert(logger$a, embed, "embed should not be null");
65534
+ assert(logger$d, embed, "embed should not be null");
66198
65535
  update$1(editor, embed, data);
66199
65536
  return true;
66200
65537
  }
66201
- function getOptions$1() {
65538
+ function getOptions$2() {
66202
65539
  return {
66203
65540
  name: "UML",
66204
65541
  insertEmbedCommandItems: [{
@@ -66219,7 +65556,7 @@ ${codeText}
66219
65556
  setTimeout(() => {
66220
65557
  const blockContent = getBlockContent(block);
66221
65558
  const embed = blockContent.querySelector(":scope > .editor-drawio-content");
66222
- assert(logger$a, embed, "embed should not be null");
65559
+ assert(logger$d, embed, "embed should not be null");
66223
65560
  const blockData = editor.getBlockData(block);
66224
65561
  editDrawIO(editor, block, embed, blockData.embedData);
66225
65562
  }, 100);
@@ -66227,7 +65564,7 @@ ${codeText}
66227
65564
  }
66228
65565
  };
66229
65566
  }
66230
- function convertTo$4(editor, blockData, doc2, type) {
65567
+ function convertTo$5(editor, blockData, doc2, type) {
66231
65568
  const { embedData } = blockData;
66232
65569
  const data = embedData;
66233
65570
  if (type === "html") {
@@ -66252,13 +65589,683 @@ ${codeText}
66252
65589
  }
66253
65590
  const DrawioEmbed = {
66254
65591
  embedType: "drawio",
66255
- 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",
66256
66179
  createEmbedContent: createEmbedContent$4,
66257
- handleUpdateBlock: handleUpdateBlock$3,
66258
66180
  getBlockProperties: getBlockProperties$4,
66181
+ getOptions: getOptions$1,
66182
+ handleUpdateBlock: handleUpdateBlock$3,
66259
66183
  convertTo: convertTo$4
66260
66184
  };
66261
- 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 = "";
66262
66269
  const index$2 = "";
66263
66270
  const UPDATE_DELAY = 500;
66264
66271
  const DEFAULT_EDIT_CODE_HEIGHT = 300;
@@ -74910,6 +74917,7 @@ ${data.flowchartText}
74910
74917
  editor.addCustom("mention", () => new OnesEditorMention(editor, mentionOptions));
74911
74918
  }
74912
74919
  editor.addCustom("heading-collapse", () => new HeadingBlockCollapseButton(editor));
74920
+ editor.addCustom("iframe-embed-reauth-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
74913
74921
  OnesEditorToolbar.register(editor);
74914
74922
  OnesEditorDropTarget.register(editor);
74915
74923
  OnesEditorTocProvider.register(editor);
@@ -75023,6 +75031,7 @@ ${data.flowchartText}
75023
75031
  }
75024
75032
  }
75025
75033
  });
75034
+ editor.addCustom("iframe-embed-reauth-event-callback", (editor2) => new IframeKindEmbedDocCallbacks(editor2));
75026
75035
  OnesEditorToolbar.register(editor);
75027
75036
  return editor;
75028
75037
  }