@ni/ok-components 1.9.6 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-components-bundle.js +1851 -1525
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +5087 -5046
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/fv/chip-selector/index.js +0 -4
- package/dist/esm/fv/chip-selector/index.js.map +1 -1
- package/dist/esm/fv/chip-selector/template.js +3 -1
- package/dist/esm/fv/chip-selector/template.js.map +1 -1
- package/package.json +5 -5
|
@@ -18971,7 +18971,7 @@ Defines an interaction area clip-path that leaves out the severity text so it is
|
|
|
18971
18971
|
};
|
|
18972
18972
|
const electronicChipZoomed16X16 = {
|
|
18973
18973
|
name: 'electronic_chip_zoomed_16_x_16',
|
|
18974
|
-
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="
|
|
18974
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M8 7h6v7H7V8c0-.55.45-1 1-1m4-6v3h-2V1H8v3C5.79 4 4 5.79 4 8H1v2h3v2H1v2h5V8c0-1.1.9-2 2-2h6V1z" class="cls-1"/></svg>`,
|
|
18975
18975
|
};
|
|
18976
18976
|
const exclamationMark16X16 = {
|
|
18977
18977
|
name: 'exclamation_mark_16_x_16',
|
|
@@ -18997,14 +18997,26 @@ Defines an interaction area clip-path that leaves out the severity text so it is
|
|
|
18997
18997
|
name: 'file_arrow_curved_right_16_x_16',
|
|
18998
18998
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="m7 2 3 3H7zM6 6V2H2v12h4.282l.03-.187A4.51 4.51 0 0 1 10 10.065V6zm8 5.5L11 9v2c-1.817-.091-3.412 1.137-3.701 2.97.576-.672 2.077-2.065 3.701-1.82V14z" class="cls-1"/></svg>`,
|
|
18999
18999
|
};
|
|
19000
|
+
const fileClock16X16 = {
|
|
19001
|
+
name: 'file_clock_16_x_16',
|
|
19002
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M12 6H9V3zm-.01 2.19H12V7H8V3H4v10h4.41c-.1-.34-.17-.69-.17-1.06 0-2.07 1.68-3.75 3.75-3.75m3 3.75c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3 3 1.34 3 3m-1 2c.04-.26-.23-.54-.23-.54l-1.19-1.19q.06-.12.06-.27c0-.15-.02-.19-.06-.27.11-.11.73-.73.79-.81.06-.09.11-.32.11-.4-.11 0-.35.06-.42.13-.06.06-.68.69-.78.78a.644.644 0 0 0-.92.58c0 .35.28.64.64.64.1 0 .19-.02.28-.06.13.14.88.89 1.1 1.12.25.26.43.31.61.31Z" class="cls-1"/></svg>`,
|
|
19003
|
+
};
|
|
19000
19004
|
const fileDrawer16X16 = {
|
|
19001
19005
|
name: 'file_drawer_16_x_16',
|
|
19002
19006
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M2 4v10h12V4Zm8 4H6V6h4Zm4-5H2V2h12Z" class="cls-1"/></svg>`,
|
|
19003
19007
|
};
|
|
19008
|
+
const filePlus16X16 = {
|
|
19009
|
+
name: 'file_plus_16_x_16',
|
|
19010
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M12 6H9V3zm-1 3h1V7H8V3H4v10h5v-2h2zm2 3v-2h-1v2h-2v1h2v2h1v-2h2v-1z" class="cls-1"/></svg>`,
|
|
19011
|
+
};
|
|
19004
19012
|
const fileSearch16X16 = {
|
|
19005
19013
|
name: 'file_search_16_x_16',
|
|
19006
19014
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M14 6v6h-3.333a3.7 3.7 0 0 0 .249-1.302A3.7 3.7 0 0 0 7.22 7 3.7 3.7 0 0 0 6 7.223V2h4v4Zm-3-4v3h3Zm-1.126 8.698a2.697 2.697 0 0 1-4.73 1.772L2.521 14l-.48-.823 2.613-1.523a2.698 2.698 0 1 1 5.22-.956m-.952 0a1.745 1.745 0 1 0-1.745 1.745 1.747 1.747 0 0 0 1.745-1.745" class="cls-1"/></svg>`,
|
|
19007
19015
|
};
|
|
19016
|
+
const fileStar16X16 = {
|
|
19017
|
+
name: 'file_star_16_x_16',
|
|
19018
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M12 6H9V3zm-2.06 5.35-1.4-2.71 2.69 1.41.77-2.94V7H8V3H4v10h4.81l-2.62-.68 3.74-.97Zm5.23.97-1.82-.48.74-1.43-1.42.74-.48-1.83-.48 1.83-1.42-.75.74 1.43-1.86.48 1.86.49-.74 1.43 1.42-.74.48 1.83.48-1.83 1.42.75-.74-1.43 1.82-.48Z" class="cls-1"/></svg>`,
|
|
19019
|
+
};
|
|
19008
19020
|
const filter16X16 = {
|
|
19009
19021
|
name: 'filter_16_x_16',
|
|
19010
19022
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M2 3.045v1.29h.787a2.069 2.069 0 1 0 2.907 2.903l1.32 2.173v4.522l1.973-1.846V9.411l3.878-5.076h1.134v-1.29Zm2.033 4.059a1.154 1.154 0 0 1 0-2.308c.023 0 .045.006.068.007l1.002 1.575a1.15 1.15 0 0 1-1.07.726" class="cls-1"/></svg>`,
|
|
@@ -19033,10 +19045,22 @@ Defines an interaction area clip-path that leaves out the severity text so it is
|
|
|
19033
19045
|
name: 'folder_16_x_16',
|
|
19034
19046
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M7 4V3H2v10h12V4Zm6 2H3V5h10Z" class="cls-1"/></svg>`,
|
|
19035
19047
|
};
|
|
19048
|
+
const folderClock16X16 = {
|
|
19049
|
+
name: 'folder_clock_16_x_16',
|
|
19050
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M8.24 11.94c0-2.07 1.68-3.75 3.75-3.75.74 0 1.43.22 2.01.6V4.01H7v-1H2v10h6.41c-.1-.34-.17-.69-.17-1.06ZM3 5h10v1H3zm8.99 3.94c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3m.29 2.43.78-.78c.07-.07.31-.13.42-.13 0 .08-.05.31-.11.4-.06.08-.68.7-.79.81q.06.12.06.27c0 .15-.02.19-.06.27l1.19 1.19s.27.28.23.54c-.18 0-.36-.05-.61-.31-.23-.23-.97-.98-1.1-1.12a.644.644 0 0 1-.92-.58c0-.35.28-.64.64-.64.1 0 .2.02.28.06" class="cls-1"/></svg>`,
|
|
19051
|
+
};
|
|
19036
19052
|
const folderOpen16X16 = {
|
|
19037
19053
|
name: 'folder_open_16_x_16',
|
|
19038
19054
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M7 3v1.002h6V6h-1V5H3v1H2V3ZM2 13h11l1-6H2Z" class="cls-1"/></svg>`,
|
|
19039
19055
|
};
|
|
19056
|
+
const folderPlus16X16 = {
|
|
19057
|
+
name: 'folder_plus_16_x_16',
|
|
19058
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M9 11h2V9h3V4H7V3H2v10h7zM3 5h10v1H3zm12 8h-2v2h-1v-2h-2v-1h2v-2h1v2h2z" class="cls-1"/></svg>`,
|
|
19059
|
+
};
|
|
19060
|
+
const folderStar16X16 = {
|
|
19061
|
+
name: 'folder_star_16_x_16',
|
|
19062
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="m6.19 12.32 3.74-.97-1.4-2.71 2.69 1.41.54-2.05h.86l.54 2.05.84-.44V4H7V3H2v10h6.81zM3 5h10v1H3zm10.35 6.84 1.82.48-1.82.48.74 1.43-1.42-.75-.48 1.83-.48-1.83-1.42.74.74-1.43-1.86-.49 1.86-.48-.74-1.43 1.42.75.48-1.83.48 1.83 1.42-.74-.74 1.43Z" class="cls-1"/></svg>`,
|
|
19063
|
+
};
|
|
19040
19064
|
const forklift16X16 = {
|
|
19041
19065
|
name: 'forklift_16_x_16',
|
|
19042
19066
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M13 11V4c0-.55-.45-1-1-1h-1v4.24l-1.53-3.3C9.24 3.37 8.69 3 8.08 3H4.01l1 1v3h-2v2.19c-.31.35-.5.81-.5 1.31 0 1.1.9 2 2 2 .5 0 .96-.19 1.31-.5h3.04c.39.32.88.52 1.42.52s1.04-.2 1.42-.52H15zm-8.5.25c-.41 0-.75-.34-.75-.75s.34-.75.75-.75.75.34.75.75-.34.75-.75.75m4.18-2.57L7 7H6V4h2.07c.21 0 .39.12.47.34l1.71 3.68c-.62 0-1.18.25-1.58.66Zm1.59 2.59c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1" class="cls-1"/></svg>`,
|
|
@@ -19281,6 +19305,10 @@ Defines an interaction area clip-path that leaves out the severity text so it is
|
|
|
19281
19305
|
name: 'scanner_gun_16_x_16',
|
|
19282
19306
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M11.48 4.99 12 3H6c-1.66-.02-2.97 1.24-2.99 2.89 0 .55.41 1.09.97 1.1H4v1l-.53 2.65c-.2.98.38 1.89 1.25 2.21a.85.85 0 0 1-.2.45c-.12.12-.28.18-.5.18h-2v.5h2c.36 0 .65-.11.86-.33s.29-.49.33-.69c.06 0 .12.02.19.02.93 0 .74-.66.92-1.58L8 7.98v-1h2.98l.25-1h-.5l.25-1h.5Zm-1.6.5h-2.9s0-.5.5-.5h2.5zm3.86-.76h-.93c-.14 0-.25-.11-.25-.25s.11-.25.25-.25h.93c.14 0 .25.11.25.25s-.11.25-.25.25m.02-2.15-.68.68c-.1.1-.26.1-.35 0-.1-.1-.1-.26 0-.35l.68-.68c.1-.1.26-.1.35 0 .1.1.1.26 0 .35m-1.14 4.38-.59-.59c-.1-.1-.1-.26 0-.35.1-.1.26-.1.35 0l.59.59c.1.1.1.26 0 .35-.1.1-.26.1-.35 0"/></svg>`,
|
|
19283
19307
|
};
|
|
19308
|
+
const scissors16X16 = {
|
|
19309
|
+
name: 'scissors_16_x_16',
|
|
19310
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M10.35 8.62 15 12c-.54.54-1.17.7-1.89.42-.67-.25-2.95-1.36-4.84-2.29zM15 4l-9.25 6.73c.62.85.55 2.04-.21 2.8-.42.42-.98.63-1.53.63s-1.11-.21-1.53-.63-.63-.97-.63-1.53c0-1.35.99-2.07 2.14-2.24.75-.11 1.47-.33 1.82-.93a1.79 1.79 0 0 0 0-1.68c-.34-.6-1.07-.82-1.82-.93-1.15-.16-2.14-.88-2.14-2.24 0-.55.21-1.1.63-1.53.42-.42.98-.63 1.53-.63s1.11.21 1.53.63c.76.76.83 1.95.21 2.8l1.51 1.1c1.98-.98 5.05-2.49 5.85-2.79.72-.27 1.35-.12 1.89.42zM4.92 4c0-.24-.1-.48-.27-.65a.915.915 0 0 0-1.3 0 .915.915 0 0 0 0 1.3.915.915 0 0 0 1.3 0c.17-.17.27-.4.27-.65m0 8c0-.24-.1-.48-.27-.65a.915.915 0 0 0-1.3 0 .915.915 0 0 0 0 1.3.915.915 0 0 0 1.3 0c.17-.17.27-.4.27-.65M8 8c0-.28-.22-.5-.5-.5S7 7.72 7 8s.22.5.5.5.5-.22.5-.5" class="st0"/></svg>`,
|
|
19311
|
+
};
|
|
19284
19312
|
const screenCheckLines16X16 = {
|
|
19285
19313
|
name: 'screen_check_lines_16_x_16',
|
|
19286
19314
|
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M3 3H2v8h5v1H5v1h6v-1H9v-1h5V3zm10 7H3V4h10z" class="cls-1"/><path d="M5.743 9 4 7.242l.766-.742.97 1.007L8.273 5 9 5.758zM10 6h2v1h-2zM8 8h4v1H8z" class="cls-1"/></svg>`,
|
|
@@ -19359,7 +19387,7 @@ Defines an interaction area clip-path that leaves out the severity text so it is
|
|
|
19359
19387
|
};
|
|
19360
19388
|
const systemlink16X16 = {
|
|
19361
19389
|
name: 'systemlink_16_x_16',
|
|
19362
|
-
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="
|
|
19390
|
+
data: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="m5.24 6.29-1.07-.35c.16-.23.34-.44.54-.65.55-.55 1.23-.95 1.96-1.17v1.13c-.44.18-.85.44-1.21.79-.08.08-.15.16-.22.24Zm5.51 0 1.07-.35c-.16-.23-.34-.45-.54-.65-.55-.55-1.23-.95-1.96-1.17v1.13c.44.18.85.44 1.21.79.08.08.15.16.22.24ZM8 12.16c-.3 0-.6-.04-.88-.11l-.66.91a4.7 4.7 0 0 0 3.08 0l-.66-.91c-.29.07-.58.11-.88.11m-3.03-1.67a3.5 3.5 0 0 1-.54-1.68l-1.07-.35c-.03 1.03.29 2.07.95 2.93l.66-.91Zm6.6-1.68c-.04.6-.23 1.18-.54 1.68l.66.91c.62-.81.96-1.79.96-2.82v-.11l-1.07.35Zm2.76-3.2c-.61-.31-1.35-.07-1.66.54-.07.13-.1.26-.12.4l-2.06.67c-.13-.23-.29-.45-.48-.64-.42-.42-.93-.68-1.47-.78V3.63c.42-.2.71-.62.71-1.11a1.23 1.23 0 1 0-2.46 0c0 .49.29.91.71 1.11 0 0-.01 0 0 0V5.8c-.54.1-1.05.36-1.47.78-.19.19-.35.41-.48.64l-2.06-.67a1.4 1.4 0 0 0-.12-.4c-.31-.61-1.05-.85-1.66-.54s-.85 1.05-.54 1.66a1.23 1.23 0 0 0 1.99.29l2.06.67c-.1.81.15 1.66.74 2.29l-1.28 1.75c-.13-.02-.28-.03-.42 0-.67.11-1.13.74-1.03 1.41.11.67.74 1.13 1.41 1.03.67-.11 1.13-.74 1.03-1.41-.02-.14-.07-.28-.14-.4l1.27-1.75c.76.36 1.65.36 2.41 0l1.27 1.75a1.226 1.226 0 0 0 .89 1.81c.67.11 1.31-.35 1.41-1.03.11-.67-.35-1.31-1.03-1.41q-.21-.03-.42 0l-1.28-1.75c.6-.64.85-1.48.74-2.29l2.06-.67c.1.1.21.19.33.25.61.31 1.35.07 1.66-.54s.07-1.35-.54-1.66Z" class="cls-1"/></svg>`,
|
|
19363
19391
|
};
|
|
19364
19392
|
const t16X16 = {
|
|
19365
19393
|
name: 't_16_x_16',
|
|
@@ -25220,6 +25248,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25220
25248
|
}
|
|
25221
25249
|
registerIconSvg('icon-file-arrow-curved-right', IconFileArrowCurvedRight);
|
|
25222
25250
|
|
|
25251
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25252
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25253
|
+
/**
|
|
25254
|
+
* The icon component for the 'fileClock' icon
|
|
25255
|
+
*/
|
|
25256
|
+
class IconFileClock extends IconSvg {
|
|
25257
|
+
constructor() {
|
|
25258
|
+
super(fileClock16X16);
|
|
25259
|
+
}
|
|
25260
|
+
}
|
|
25261
|
+
registerIconSvg('icon-file-clock', IconFileClock);
|
|
25262
|
+
|
|
25223
25263
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25224
25264
|
// See generation source in nimble-components/build/generate-icons
|
|
25225
25265
|
/**
|
|
@@ -25232,6 +25272,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25232
25272
|
}
|
|
25233
25273
|
registerIconSvg('icon-file-drawer', IconFileDrawer);
|
|
25234
25274
|
|
|
25275
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25276
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25277
|
+
/**
|
|
25278
|
+
* The icon component for the 'filePlus' icon
|
|
25279
|
+
*/
|
|
25280
|
+
class IconFilePlus extends IconSvg {
|
|
25281
|
+
constructor() {
|
|
25282
|
+
super(filePlus16X16);
|
|
25283
|
+
}
|
|
25284
|
+
}
|
|
25285
|
+
registerIconSvg('icon-file-plus', IconFilePlus);
|
|
25286
|
+
|
|
25235
25287
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25236
25288
|
// See generation source in nimble-components/build/generate-icons
|
|
25237
25289
|
/**
|
|
@@ -25244,6 +25296,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25244
25296
|
}
|
|
25245
25297
|
registerIconSvg('icon-file-search', IconFileSearch);
|
|
25246
25298
|
|
|
25299
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25300
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25301
|
+
/**
|
|
25302
|
+
* The icon component for the 'fileStar' icon
|
|
25303
|
+
*/
|
|
25304
|
+
class IconFileStar extends IconSvg {
|
|
25305
|
+
constructor() {
|
|
25306
|
+
super(fileStar16X16);
|
|
25307
|
+
}
|
|
25308
|
+
}
|
|
25309
|
+
registerIconSvg('icon-file-star', IconFileStar);
|
|
25310
|
+
|
|
25247
25311
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25248
25312
|
// See generation source in nimble-components/build/generate-icons
|
|
25249
25313
|
/**
|
|
@@ -25328,6 +25392,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25328
25392
|
}
|
|
25329
25393
|
registerIconSvg('icon-folder', IconFolder);
|
|
25330
25394
|
|
|
25395
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25396
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25397
|
+
/**
|
|
25398
|
+
* The icon component for the 'folderClock' icon
|
|
25399
|
+
*/
|
|
25400
|
+
class IconFolderClock extends IconSvg {
|
|
25401
|
+
constructor() {
|
|
25402
|
+
super(folderClock16X16);
|
|
25403
|
+
}
|
|
25404
|
+
}
|
|
25405
|
+
registerIconSvg('icon-folder-clock', IconFolderClock);
|
|
25406
|
+
|
|
25331
25407
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25332
25408
|
// See generation source in nimble-components/build/generate-icons
|
|
25333
25409
|
/**
|
|
@@ -25340,6 +25416,30 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25340
25416
|
}
|
|
25341
25417
|
registerIconSvg('icon-folder-open', IconFolderOpen);
|
|
25342
25418
|
|
|
25419
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25420
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25421
|
+
/**
|
|
25422
|
+
* The icon component for the 'folderPlus' icon
|
|
25423
|
+
*/
|
|
25424
|
+
class IconFolderPlus extends IconSvg {
|
|
25425
|
+
constructor() {
|
|
25426
|
+
super(folderPlus16X16);
|
|
25427
|
+
}
|
|
25428
|
+
}
|
|
25429
|
+
registerIconSvg('icon-folder-plus', IconFolderPlus);
|
|
25430
|
+
|
|
25431
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25432
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25433
|
+
/**
|
|
25434
|
+
* The icon component for the 'folderStar' icon
|
|
25435
|
+
*/
|
|
25436
|
+
class IconFolderStar extends IconSvg {
|
|
25437
|
+
constructor() {
|
|
25438
|
+
super(folderStar16X16);
|
|
25439
|
+
}
|
|
25440
|
+
}
|
|
25441
|
+
registerIconSvg('icon-folder-star', IconFolderStar);
|
|
25442
|
+
|
|
25343
25443
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25344
25444
|
// See generation source in nimble-components/build/generate-icons
|
|
25345
25445
|
/**
|
|
@@ -26067,6 +26167,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
26067
26167
|
}
|
|
26068
26168
|
registerIconSvg('icon-scanner-gun', IconScannerGun);
|
|
26069
26169
|
|
|
26170
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
26171
|
+
// See generation source in nimble-components/build/generate-icons
|
|
26172
|
+
/**
|
|
26173
|
+
* The icon component for the 'scissors' icon
|
|
26174
|
+
*/
|
|
26175
|
+
class IconScissors extends IconSvg {
|
|
26176
|
+
constructor() {
|
|
26177
|
+
super(scissors16X16);
|
|
26178
|
+
}
|
|
26179
|
+
}
|
|
26180
|
+
registerIconSvg('icon-scissors', IconScissors);
|
|
26181
|
+
|
|
26070
26182
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
26071
26183
|
// See generation source in nimble-components/build/generate-icons
|
|
26072
26184
|
/**
|
|
@@ -29693,7 +29805,6 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
29693
29805
|
if (!type)
|
|
29694
29806
|
throw new RangeError(`There is no mark type ${json.type} in this schema`);
|
|
29695
29807
|
let mark = type.create(json.attrs);
|
|
29696
|
-
type.checkAttrs(mark.attrs);
|
|
29697
29808
|
return mark;
|
|
29698
29809
|
}
|
|
29699
29810
|
/**
|
|
@@ -30673,11 +30784,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
30673
30784
|
*/
|
|
30674
30785
|
check() {
|
|
30675
30786
|
this.type.checkContent(this.content);
|
|
30676
|
-
this.type.
|
|
30787
|
+
checkAttrs(this.type.attrs, this.attrs, "node", this.type.name);
|
|
30677
30788
|
let copy = Mark$1.none;
|
|
30678
30789
|
for (let i = 0; i < this.marks.length; i++) {
|
|
30679
30790
|
let mark = this.marks[i];
|
|
30680
|
-
mark.type.
|
|
30791
|
+
checkAttrs(mark.type.attrs, mark.attrs, "mark", mark.type.name);
|
|
30681
30792
|
copy = mark.addToSet(copy);
|
|
30682
30793
|
}
|
|
30683
30794
|
if (!Mark$1.sameSet(copy, this.marks))
|
|
@@ -30718,7 +30829,6 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
30718
30829
|
}
|
|
30719
30830
|
let content = Fragment.fromJSON(schema, json.content);
|
|
30720
30831
|
let node = schema.nodeType(json.type).create(json.attrs, content, marks);
|
|
30721
|
-
node.type.checkAttrs(node.attrs);
|
|
30722
30832
|
return node;
|
|
30723
30833
|
}
|
|
30724
30834
|
};
|
|
@@ -30768,6 +30878,15 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
30768
30878
|
str = marks[i].type.name + "(" + str + ")";
|
|
30769
30879
|
return str;
|
|
30770
30880
|
}
|
|
30881
|
+
function checkAttrs(attrs, values, type, name) {
|
|
30882
|
+
for (let attr in values)
|
|
30883
|
+
if (!(attr in attrs))
|
|
30884
|
+
throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
30885
|
+
for (let attr in attrs) {
|
|
30886
|
+
if (attrs[attr].validate)
|
|
30887
|
+
attrs[attr].validate(values[attr]);
|
|
30888
|
+
}
|
|
30889
|
+
}
|
|
30771
30890
|
|
|
30772
30891
|
/**
|
|
30773
30892
|
Instances of this class represent a match state of a node type's
|
|
@@ -31222,27 +31341,21 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
31222
31341
|
function computeAttrs(attrs, value) {
|
|
31223
31342
|
let built = Object.create(null);
|
|
31224
31343
|
for (let name in attrs) {
|
|
31344
|
+
let attr = attrs[name];
|
|
31225
31345
|
let given = value && value[name];
|
|
31226
31346
|
if (given === undefined) {
|
|
31227
|
-
let attr = attrs[name];
|
|
31228
31347
|
if (attr.hasDefault)
|
|
31229
31348
|
given = attr.default;
|
|
31230
31349
|
else
|
|
31231
31350
|
throw new RangeError("No value supplied for attribute " + name);
|
|
31232
31351
|
}
|
|
31352
|
+
else if (attr.validate) {
|
|
31353
|
+
attr.validate(given);
|
|
31354
|
+
}
|
|
31233
31355
|
built[name] = given;
|
|
31234
31356
|
}
|
|
31235
31357
|
return built;
|
|
31236
31358
|
}
|
|
31237
|
-
function checkAttrs(attrs, values, type, name) {
|
|
31238
|
-
for (let attr in values)
|
|
31239
|
-
if (!(attr in attrs))
|
|
31240
|
-
throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
31241
|
-
for (let attr in attrs) {
|
|
31242
|
-
if (attrs[attr].validate)
|
|
31243
|
-
attrs[attr].validate(values[attr]);
|
|
31244
|
-
}
|
|
31245
|
-
}
|
|
31246
31359
|
function initAttrs(typeName, attrs) {
|
|
31247
31360
|
let result = Object.create(null);
|
|
31248
31361
|
if (attrs)
|
|
@@ -31414,11 +31527,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
31414
31527
|
throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
|
|
31415
31528
|
}
|
|
31416
31529
|
/**
|
|
31417
|
-
@internal
|
|
31530
|
+
@internal no longer useful, but called by old prosemirror-view versions
|
|
31418
31531
|
*/
|
|
31419
|
-
checkAttrs(attrs) {
|
|
31420
|
-
checkAttrs(this.attrs, attrs, "node", this.name);
|
|
31421
|
-
}
|
|
31532
|
+
checkAttrs(attrs) { }
|
|
31422
31533
|
/**
|
|
31423
31534
|
Check whether the given mark type is allowed in this node.
|
|
31424
31535
|
*/
|
|
@@ -31565,12 +31676,6 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
31565
31676
|
return set[i];
|
|
31566
31677
|
}
|
|
31567
31678
|
/**
|
|
31568
|
-
@internal
|
|
31569
|
-
*/
|
|
31570
|
-
checkAttrs(attrs) {
|
|
31571
|
-
checkAttrs(this.attrs, attrs, "mark", this.name);
|
|
31572
|
-
}
|
|
31573
|
-
/**
|
|
31574
31679
|
Queries whether a given mark type is
|
|
31575
31680
|
[excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
|
|
31576
31681
|
*/
|
|
@@ -32761,9 +32866,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
32761
32866
|
if (simple)
|
|
32762
32867
|
return result;
|
|
32763
32868
|
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
32764
|
-
let del =
|
|
32765
|
-
if (
|
|
32766
|
-
del |=
|
|
32869
|
+
let del = 0;
|
|
32870
|
+
if (oldSize) {
|
|
32871
|
+
del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
32872
|
+
if (assoc < 0 ? pos != start : pos != end)
|
|
32873
|
+
del |= DEL_SIDE;
|
|
32874
|
+
}
|
|
32767
32875
|
return new MapResult(result, del, recover);
|
|
32768
32876
|
}
|
|
32769
32877
|
diff += newSize - oldSize;
|
|
@@ -36701,15 +36809,15 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36701
36809
|
return true;
|
|
36702
36810
|
if (off == (dir < 0 ? 0 : nodeSize(node))) {
|
|
36703
36811
|
let parent = node.parentNode;
|
|
36704
|
-
if (!parent || parent
|
|
36812
|
+
if (!parent || !isElt(parent) || hasBlockDesc(node) || atomElements.test(node.nodeName) ||
|
|
36705
36813
|
node.contentEditable == "false")
|
|
36706
36814
|
return false;
|
|
36707
36815
|
off = domIndex(node) + (dir < 0 ? 0 : 1);
|
|
36708
36816
|
node = parent;
|
|
36709
36817
|
}
|
|
36710
|
-
else if (node
|
|
36818
|
+
else if (isElt(node)) {
|
|
36711
36819
|
let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
|
|
36712
|
-
if (child
|
|
36820
|
+
if (isElt(child) && child.contentEditable == "false") {
|
|
36713
36821
|
if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection)
|
|
36714
36822
|
off += dir;
|
|
36715
36823
|
else
|
|
@@ -36728,11 +36836,16 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36728
36836
|
function nodeSize(node) {
|
|
36729
36837
|
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
36730
36838
|
}
|
|
36839
|
+
function isElt(node) { return node.nodeType == 1; }
|
|
36840
|
+
function isText(node) { return node.nodeType == 3; }
|
|
36841
|
+
function contains(parent, child) {
|
|
36842
|
+
return child ? parent.contains(isElt(child) ? child : child.parentNode) : false;
|
|
36843
|
+
}
|
|
36731
36844
|
function textNodeBefore$1(node, offset) {
|
|
36732
36845
|
for (;;) {
|
|
36733
|
-
if (node
|
|
36846
|
+
if (isText(node) && offset)
|
|
36734
36847
|
return node;
|
|
36735
|
-
if (node
|
|
36848
|
+
if (isElt(node) && offset > 0) {
|
|
36736
36849
|
if (node.contentEditable == "false")
|
|
36737
36850
|
return null;
|
|
36738
36851
|
node = node.childNodes[offset - 1];
|
|
@@ -36749,9 +36862,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36749
36862
|
}
|
|
36750
36863
|
function textNodeAfter$1(node, offset) {
|
|
36751
36864
|
for (;;) {
|
|
36752
|
-
if (node
|
|
36865
|
+
if (isText(node) && offset < node.nodeValue.length)
|
|
36753
36866
|
return node;
|
|
36754
|
-
if (node
|
|
36867
|
+
if (isElt(node) && offset < node.childNodes.length) {
|
|
36755
36868
|
if (node.contentEditable == "false")
|
|
36756
36869
|
return null;
|
|
36757
36870
|
node = node.childNodes[offset];
|
|
@@ -36875,13 +36988,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36875
36988
|
for (let parent = startDOM || view.dom;;) {
|
|
36876
36989
|
if (!parent)
|
|
36877
36990
|
break;
|
|
36878
|
-
if (parent
|
|
36991
|
+
if (!isElt(parent)) {
|
|
36879
36992
|
parent = parentNode(parent);
|
|
36880
36993
|
continue;
|
|
36881
36994
|
}
|
|
36882
|
-
let
|
|
36883
|
-
let
|
|
36884
|
-
let bounding = atTop ? windowRect(doc) : clientRect(elt);
|
|
36995
|
+
let atTop = parent == doc.body;
|
|
36996
|
+
let bounding = atTop ? windowRect(doc) : clientRect(parent);
|
|
36885
36997
|
let moveX = 0, moveY = 0;
|
|
36886
36998
|
if (rect.top < bounding.top + getSide$1(scrollThreshold, "top"))
|
|
36887
36999
|
moveY = -(bounding.top - rect.top + getSide$1(scrollMargin, "top"));
|
|
@@ -36898,12 +37010,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36898
37010
|
doc.defaultView.scrollBy(moveX, moveY);
|
|
36899
37011
|
}
|
|
36900
37012
|
else {
|
|
36901
|
-
let startX =
|
|
37013
|
+
let startX = parent.scrollLeft, startY = parent.scrollTop;
|
|
36902
37014
|
if (moveY)
|
|
36903
|
-
|
|
37015
|
+
parent.scrollTop += moveY;
|
|
36904
37016
|
if (moveX)
|
|
36905
|
-
|
|
36906
|
-
let dX =
|
|
37017
|
+
parent.scrollLeft += moveX;
|
|
37018
|
+
let dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
|
|
36907
37019
|
rect = { left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY };
|
|
36908
37020
|
}
|
|
36909
37021
|
}
|
|
@@ -36978,14 +37090,15 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36978
37090
|
}
|
|
36979
37091
|
}
|
|
36980
37092
|
function findOffsetInNode(node, coords) {
|
|
36981
|
-
let closest
|
|
37093
|
+
let closest;
|
|
37094
|
+
let dxClosest = 2e8, coordsClosest, offset = 0;
|
|
36982
37095
|
let rowBot = coords.top, rowTop = coords.top;
|
|
36983
37096
|
let firstBelow, coordsBelow;
|
|
36984
37097
|
for (let child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {
|
|
36985
37098
|
let rects;
|
|
36986
|
-
if (child
|
|
37099
|
+
if (isElt(child))
|
|
36987
37100
|
rects = child.getClientRects();
|
|
36988
|
-
else if (child
|
|
37101
|
+
else if (isText(child))
|
|
36989
37102
|
rects = textRange(child).getClientRects();
|
|
36990
37103
|
else
|
|
36991
37104
|
continue;
|
|
@@ -36999,11 +37112,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36999
37112
|
if (dx < dxClosest) {
|
|
37000
37113
|
closest = child;
|
|
37001
37114
|
dxClosest = dx;
|
|
37002
|
-
coordsClosest = dx && closest
|
|
37115
|
+
coordsClosest = dx && isText(closest) ? {
|
|
37003
37116
|
left: rect.right < coords.left ? rect.right : rect.left,
|
|
37004
37117
|
top: coords.top
|
|
37005
37118
|
} : coords;
|
|
37006
|
-
if (child
|
|
37119
|
+
if (isElt(child) && dx)
|
|
37007
37120
|
offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
|
|
37008
37121
|
continue;
|
|
37009
37122
|
}
|
|
@@ -37022,9 +37135,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37022
37135
|
coordsClosest = coordsBelow;
|
|
37023
37136
|
dxClosest = 0;
|
|
37024
37137
|
}
|
|
37025
|
-
if (closest && closest
|
|
37138
|
+
if (closest && isText(closest))
|
|
37026
37139
|
return findOffsetInText(closest, coordsClosest);
|
|
37027
|
-
if (!closest ||
|
|
37140
|
+
if (!closest || dxClosest)
|
|
37028
37141
|
return { node, offset };
|
|
37029
37142
|
return findOffsetInNode(closest, coordsClosest);
|
|
37030
37143
|
}
|
|
@@ -37057,7 +37170,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37057
37170
|
}
|
|
37058
37171
|
function posFromElement(view, elt, coords) {
|
|
37059
37172
|
let { node, offset } = findOffsetInNode(elt, coords), bias = -1;
|
|
37060
|
-
if (node
|
|
37173
|
+
if (isElt(node) && !node.firstChild) {
|
|
37061
37174
|
let rect = node.getBoundingClientRect();
|
|
37062
37175
|
bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
|
|
37063
37176
|
}
|
|
@@ -37077,7 +37190,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37077
37190
|
let desc = view.docView.nearestDesc(cur, true), rect;
|
|
37078
37191
|
if (!desc)
|
|
37079
37192
|
return null;
|
|
37080
|
-
if (desc.dom
|
|
37193
|
+
if (isElt(desc.dom) && (desc.node.isBlock && desc.parent || !desc.contentDOM) &&
|
|
37081
37194
|
// Ignore elements with zero-size bounding rectangles
|
|
37082
37195
|
((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
|
|
37083
37196
|
if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {
|
|
@@ -37104,7 +37217,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37104
37217
|
if (len && box.top < box.bottom) {
|
|
37105
37218
|
for (let startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {
|
|
37106
37219
|
let child = element.childNodes[i];
|
|
37107
|
-
if (child
|
|
37220
|
+
if (isElt(child)) {
|
|
37108
37221
|
let rects = child.getClientRects();
|
|
37109
37222
|
for (let j = 0; j < rects.length; j++) {
|
|
37110
37223
|
let rect = rects[j];
|
|
@@ -37127,7 +37240,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37127
37240
|
let elt = (view.root.elementFromPoint ? view.root : doc)
|
|
37128
37241
|
.elementFromPoint(coords.left, coords.top);
|
|
37129
37242
|
let pos;
|
|
37130
|
-
if (!elt || !view.dom.contains(elt
|
|
37243
|
+
if (!elt || !view.dom.contains(elt)) {
|
|
37131
37244
|
let box = view.dom.getBoundingClientRect();
|
|
37132
37245
|
if (!inRect(coords, box))
|
|
37133
37246
|
return null;
|
|
@@ -37143,7 +37256,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37143
37256
|
}
|
|
37144
37257
|
elt = targetKludge(elt, coords);
|
|
37145
37258
|
if (node) {
|
|
37146
|
-
if (gecko && node
|
|
37259
|
+
if (gecko && isElt(node)) {
|
|
37147
37260
|
// Firefox will sometimes return offsets into <input> nodes, which
|
|
37148
37261
|
// have no actual children, from caretPositionFromPoint (#953)
|
|
37149
37262
|
offset = Math.min(offset, node.childNodes.length);
|
|
@@ -37158,18 +37271,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37158
37271
|
}
|
|
37159
37272
|
let prev;
|
|
37160
37273
|
// When clicking above the right side of an uneditable node, Chrome will report a cursor position after that node.
|
|
37161
|
-
if (webkit && offset && node
|
|
37274
|
+
if (webkit && offset && isElt(node) && isElt(prev = node.childNodes[offset - 1]) &&
|
|
37162
37275
|
prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top)
|
|
37163
37276
|
offset--;
|
|
37164
37277
|
// Suspiciously specific kludge to work around caret*FromPoint
|
|
37165
37278
|
// never returning a position at the end of the document
|
|
37166
|
-
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild
|
|
37279
|
+
if (node == view.dom && offset == node.childNodes.length - 1 && isElt(node.lastChild) &&
|
|
37167
37280
|
coords.top > node.lastChild.getBoundingClientRect().bottom)
|
|
37168
37281
|
pos = view.state.doc.content.size;
|
|
37169
37282
|
// Ignore positions directly after a BR, since caret*FromPoint
|
|
37170
37283
|
// 'round up' positions that would be more accurately placed
|
|
37171
37284
|
// before the BR node.
|
|
37172
|
-
else if (offset == 0 || node
|
|
37285
|
+
else if (offset == 0 || !isElt(node) || node.childNodes[offset - 1].nodeName != "BR")
|
|
37173
37286
|
pos = posFromCaret(view, node, offset, coords);
|
|
37174
37287
|
}
|
|
37175
37288
|
if (pos == null)
|
|
@@ -37195,7 +37308,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37195
37308
|
function coordsAtPos(view, pos, side) {
|
|
37196
37309
|
let { node, offset, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
|
|
37197
37310
|
let supportEmptyRange = webkit || gecko;
|
|
37198
|
-
if (node
|
|
37311
|
+
if (isText(node)) {
|
|
37199
37312
|
// These browsers support querying empty text ranges. Prefer that in
|
|
37200
37313
|
// bidi context or when at the end of a node.
|
|
37201
37314
|
if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
|
|
@@ -37237,12 +37350,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37237
37350
|
if (!$dom.parent.inlineContent) {
|
|
37238
37351
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
37239
37352
|
let before = node.childNodes[offset - 1];
|
|
37240
|
-
if (before
|
|
37353
|
+
if (isElt(before))
|
|
37241
37354
|
return flattenH(before.getBoundingClientRect(), false);
|
|
37242
37355
|
}
|
|
37243
37356
|
if (atom == null && offset < nodeSize(node)) {
|
|
37244
37357
|
let after = node.childNodes[offset];
|
|
37245
|
-
if (after
|
|
37358
|
+
if (isElt(after))
|
|
37246
37359
|
return flattenH(after.getBoundingClientRect(), true);
|
|
37247
37360
|
}
|
|
37248
37361
|
return flattenH(node.getBoundingClientRect(), side >= 0);
|
|
@@ -37250,10 +37363,10 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37250
37363
|
// Inline, not in text node (this is not Bidi-safe)
|
|
37251
37364
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
37252
37365
|
let before = node.childNodes[offset - 1];
|
|
37253
|
-
let target = before
|
|
37366
|
+
let target = isText(before) ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1))
|
|
37254
37367
|
// BR nodes tend to only return the rectangle before them.
|
|
37255
37368
|
// Only use them if they are the last element in their parent
|
|
37256
|
-
: before
|
|
37369
|
+
: isElt(before) && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
|
|
37257
37370
|
if (target)
|
|
37258
37371
|
return flattenV(singleRect(target, 1), false);
|
|
37259
37372
|
}
|
|
@@ -37261,13 +37374,13 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37261
37374
|
let after = node.childNodes[offset];
|
|
37262
37375
|
while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords)
|
|
37263
37376
|
after = after.nextSibling;
|
|
37264
|
-
let target = !after ? null : after
|
|
37265
|
-
: after
|
|
37377
|
+
let target = !after ? null : isText(after) ? textRange(after, 0, (supportEmptyRange ? 0 : 1))
|
|
37378
|
+
: isElt(after) ? after : null;
|
|
37266
37379
|
if (target)
|
|
37267
37380
|
return flattenV(singleRect(target, -1), true);
|
|
37268
37381
|
}
|
|
37269
37382
|
// All else failed, just try to get a rectangle for the target node
|
|
37270
|
-
return flattenV(singleRect(node
|
|
37383
|
+
return flattenV(singleRect(isText(node) ? textRange(node) : node, -side), side >= 0);
|
|
37271
37384
|
}
|
|
37272
37385
|
function flattenV(rect, left) {
|
|
37273
37386
|
if (rect.width == 0)
|
|
@@ -37317,9 +37430,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37317
37430
|
let coords = coordsAtPos(view, $pos.pos, 1);
|
|
37318
37431
|
for (let child = dom.firstChild; child; child = child.nextSibling) {
|
|
37319
37432
|
let boxes;
|
|
37320
|
-
if (child
|
|
37433
|
+
if (isElt(child))
|
|
37321
37434
|
boxes = child.getClientRects();
|
|
37322
|
-
else if (child
|
|
37435
|
+
else if (isText(child))
|
|
37323
37436
|
boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
|
|
37324
37437
|
else
|
|
37325
37438
|
continue;
|
|
@@ -37359,8 +37472,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37359
37472
|
sel.modify("move", dir, "character");
|
|
37360
37473
|
let parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;
|
|
37361
37474
|
let { focusNode: newNode, focusOffset: newOff } = view.domSelectionRange();
|
|
37362
|
-
let result = newNode && !
|
|
37363
|
-
(oldNode == newNode && oldOff == newOff);
|
|
37475
|
+
let result = newNode && !contains(parentDOM, newNode) || (oldNode == newNode && oldOff == newOff);
|
|
37364
37476
|
// Restore the previous selection
|
|
37365
37477
|
try {
|
|
37366
37478
|
sel.collapse(anchorNode, anchorOffset);
|
|
@@ -37468,7 +37580,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37468
37580
|
localPosFromDOM(dom, offset, bias) {
|
|
37469
37581
|
// If the DOM position is in the content, use the child desc after
|
|
37470
37582
|
// it to figure out a position.
|
|
37471
|
-
if (this.contentDOM && this.contentDOM
|
|
37583
|
+
if (this.contentDOM && contains(this.contentDOM, dom)) {
|
|
37472
37584
|
if (bias < 0) {
|
|
37473
37585
|
let domBefore, desc;
|
|
37474
37586
|
if (dom == this.contentDOM) {
|
|
@@ -37506,7 +37618,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37506
37618
|
atEnd = offset > domIndex(this.contentDOM);
|
|
37507
37619
|
}
|
|
37508
37620
|
else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {
|
|
37509
|
-
atEnd = dom.compareDocumentPosition(this.contentDOM) &
|
|
37621
|
+
atEnd = !!(dom.compareDocumentPosition(this.contentDOM) & 4);
|
|
37510
37622
|
}
|
|
37511
37623
|
else if (this.dom.firstChild) {
|
|
37512
37624
|
if (offset == 0)
|
|
@@ -37536,7 +37648,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37536
37648
|
if (desc && (!onlyNodes || desc.node)) {
|
|
37537
37649
|
// If dom is outside of this desc's nodeDOM, don't count it.
|
|
37538
37650
|
if (first && (nodeDOM = desc.nodeDOM) &&
|
|
37539
|
-
!(nodeDOM
|
|
37651
|
+
!(isElt(nodeDOM) ? contains(nodeDOM, dom) : nodeDOM == dom))
|
|
37540
37652
|
first = false;
|
|
37541
37653
|
else
|
|
37542
37654
|
return desc;
|
|
@@ -37586,7 +37698,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37586
37698
|
let i = 0, offset = 0;
|
|
37587
37699
|
for (let curPos = 0; i < this.children.length; i++) {
|
|
37588
37700
|
let child = this.children[i], end = curPos + child.size;
|
|
37589
|
-
if (end > pos
|
|
37701
|
+
if (end > pos) {
|
|
37590
37702
|
offset = pos - curPos;
|
|
37591
37703
|
break;
|
|
37592
37704
|
}
|
|
@@ -37596,7 +37708,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37596
37708
|
if (offset)
|
|
37597
37709
|
return this.children[i].domFromPos(offset - this.children[i].border, side);
|
|
37598
37710
|
// Go back if there were any zero-length widgets with side >= 0 before this point
|
|
37599
|
-
for (
|
|
37711
|
+
for (; i > 0; i--) {
|
|
37712
|
+
let prev = this.children[i - 1];
|
|
37713
|
+
if (prev.size || !(prev instanceof BufferHackViewDesc || prev instanceof WidgetViewDesc && prev.side >= 0))
|
|
37714
|
+
break;
|
|
37715
|
+
}
|
|
37600
37716
|
// Scan towards the first useable node
|
|
37601
37717
|
if (side <= 0) {
|
|
37602
37718
|
let prev, enter = true;
|
|
@@ -37673,7 +37789,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37673
37789
|
}
|
|
37674
37790
|
domAfterPos(pos) {
|
|
37675
37791
|
let { node, offset } = this.domFromPos(pos, 0);
|
|
37676
|
-
if (node
|
|
37792
|
+
if (!isElt(node) || offset == node.childNodes.length)
|
|
37677
37793
|
throw new RangeError("No node after pos " + pos);
|
|
37678
37794
|
return node.childNodes[offset];
|
|
37679
37795
|
}
|
|
@@ -37702,7 +37818,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37702
37818
|
// reported position in such situations (#1092).
|
|
37703
37819
|
if ((gecko || safari) && anchor == head) {
|
|
37704
37820
|
let { node, offset } = anchorDOM;
|
|
37705
|
-
if (node
|
|
37821
|
+
if (isText(node)) {
|
|
37706
37822
|
brKludge = !!(offset && node.nodeValue[offset - 1] == "\n");
|
|
37707
37823
|
// Issue #1128
|
|
37708
37824
|
if (brKludge && offset == node.nodeValue.length) {
|
|
@@ -37725,7 +37841,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37725
37841
|
}
|
|
37726
37842
|
// Firefox can act strangely when the selection is in front of an
|
|
37727
37843
|
// uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536
|
|
37728
|
-
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode
|
|
37844
|
+
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && isElt(selRange.focusNode)) {
|
|
37729
37845
|
let after = selRange.focusNode.childNodes[selRange.focusOffset];
|
|
37730
37846
|
if (after && after.contentEditable == "false")
|
|
37731
37847
|
force = true;
|
|
@@ -37824,14 +37940,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37824
37940
|
return self.parent.posBeforeChild(self);
|
|
37825
37941
|
});
|
|
37826
37942
|
if (!widget.type.spec.raw) {
|
|
37827
|
-
|
|
37828
|
-
|
|
37829
|
-
|
|
37830
|
-
|
|
37831
|
-
|
|
37832
|
-
|
|
37833
|
-
dom.contentEditable = "false";
|
|
37834
|
-
dom.classList.add("ProseMirror-widget");
|
|
37943
|
+
let elt = isElt(dom) ? dom : document.createElement("span");
|
|
37944
|
+
if (elt != dom)
|
|
37945
|
+
elt.appendChild(dom);
|
|
37946
|
+
if (!elt.hasAttribute("contenteditable"))
|
|
37947
|
+
elt.contentEditable = "false";
|
|
37948
|
+
elt.classList.add("ProseMirror-widget");
|
|
37835
37949
|
}
|
|
37836
37950
|
super(parent, [], dom, null);
|
|
37837
37951
|
this.widget = widget;
|
|
@@ -37967,7 +38081,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37967
38081
|
if (node.isText) {
|
|
37968
38082
|
if (!dom)
|
|
37969
38083
|
dom = document.createTextNode(node.text);
|
|
37970
|
-
else if (dom
|
|
38084
|
+
else if (!isText(dom))
|
|
37971
38085
|
throw new RangeError("Text must be rendered as a DOM text node");
|
|
37972
38086
|
}
|
|
37973
38087
|
else if (!dom) {
|
|
@@ -38019,7 +38133,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38019
38133
|
}
|
|
38020
38134
|
if (!rule.contentElement) {
|
|
38021
38135
|
let found = addedNodes &&
|
|
38022
|
-
addedNodes.find(n => n
|
|
38136
|
+
addedNodes.find(n => isElt(n) && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
|
|
38023
38137
|
if (found)
|
|
38024
38138
|
rule.contentElement = found;
|
|
38025
38139
|
else
|
|
@@ -38044,6 +38158,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38044
38158
|
let localComposition = composition && composition.pos > -1 ? composition : null;
|
|
38045
38159
|
let compositionInChild = composition && composition.pos < 0;
|
|
38046
38160
|
let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
|
|
38161
|
+
let addBuffers = this.node.inlineContent, atBufferPos = addBuffers && this.node.isBlock;
|
|
38047
38162
|
iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
|
|
38048
38163
|
if (widget.spec.marks)
|
|
38049
38164
|
updater.syncToMarks(widget.spec.marks, inline, view, i);
|
|
@@ -38055,6 +38170,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38055
38170
|
}, (child, outerDeco, innerDeco, i) => {
|
|
38056
38171
|
// Make sure the wrapping mark descs match the node's marks.
|
|
38057
38172
|
updater.syncToMarks(child.marks, inline, view, i);
|
|
38173
|
+
if (atBufferPos && child.isAtom && !child.isText)
|
|
38174
|
+
updater.addHackNode("IMG", updater.top);
|
|
38058
38175
|
// Try several strategies for drawing this node
|
|
38059
38176
|
let compIndex;
|
|
38060
38177
|
if (updater.findNodeMatch(child, outerDeco, innerDeco, i)) ;
|
|
@@ -38068,6 +38185,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38068
38185
|
updater.addNode(child, outerDeco, innerDeco, view, off);
|
|
38069
38186
|
}
|
|
38070
38187
|
off += child.nodeSize;
|
|
38188
|
+
if (addBuffers)
|
|
38189
|
+
atBufferPos = child.isAtom && !child.isText;
|
|
38071
38190
|
});
|
|
38072
38191
|
// Drop all remaining descs after the current position.
|
|
38073
38192
|
updater.syncToMarks([], inline, view, 0);
|
|
@@ -38146,7 +38265,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38146
38265
|
updateOuterDeco(outerDeco) {
|
|
38147
38266
|
if (sameOuterDeco(outerDeco, this.outerDeco))
|
|
38148
38267
|
return;
|
|
38149
|
-
let needsWrap = this.nodeDOM
|
|
38268
|
+
let needsWrap = !isElt(this.nodeDOM);
|
|
38150
38269
|
let oldDOM = this.dom;
|
|
38151
38270
|
this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
|
|
38152
38271
|
if (this.dom != oldDOM) {
|
|
@@ -38157,7 +38276,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38157
38276
|
}
|
|
38158
38277
|
// Mark this node as being the selected node.
|
|
38159
38278
|
selectNode() {
|
|
38160
|
-
if (this.nodeDOM
|
|
38279
|
+
if (isElt(this.nodeDOM)) {
|
|
38161
38280
|
this.nodeDOM.classList.add("ProseMirror-selectednode");
|
|
38162
38281
|
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
38163
38282
|
this.nodeDOM.draggable = true;
|
|
@@ -38165,7 +38284,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38165
38284
|
}
|
|
38166
38285
|
// Remove selected node marking from this node.
|
|
38167
38286
|
deselectNode() {
|
|
38168
|
-
if (this.nodeDOM
|
|
38287
|
+
if (isElt(this.nodeDOM)) {
|
|
38169
38288
|
this.nodeDOM.classList.remove("ProseMirror-selectednode");
|
|
38170
38289
|
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
38171
38290
|
this.nodeDOM.removeAttribute("draggable");
|
|
@@ -38236,9 +38355,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38236
38355
|
get domAtom() { return false; }
|
|
38237
38356
|
isText(text) { return this.node.text == text; }
|
|
38238
38357
|
}
|
|
38239
|
-
// A dummy desc used to tag
|
|
38358
|
+
// A dummy desc used to tag extra BR or IMG nodes created to work
|
|
38240
38359
|
// around contentEditable terribleness.
|
|
38241
|
-
class
|
|
38360
|
+
class BufferHackViewDesc extends ViewDesc {
|
|
38242
38361
|
parseRule() { return { ignore: true }; }
|
|
38243
38362
|
matchesHack(nodeName) { return this.dirty == NOT_DIRTY && this.dom.nodeName == nodeName; }
|
|
38244
38363
|
get domAtom() { return true; }
|
|
@@ -38411,7 +38530,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38411
38530
|
}
|
|
38412
38531
|
}
|
|
38413
38532
|
function applyOuterDeco(dom, deco, node) {
|
|
38414
|
-
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom
|
|
38533
|
+
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, !isElt(dom)));
|
|
38415
38534
|
}
|
|
38416
38535
|
function sameOuterDeco(a, b) {
|
|
38417
38536
|
if (a.length != b.length)
|
|
@@ -38674,7 +38793,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38674
38793
|
}
|
|
38675
38794
|
if (nodeName == "BR")
|
|
38676
38795
|
dom.className = "ProseMirror-trailingBreak";
|
|
38677
|
-
let hack = new
|
|
38796
|
+
let hack = new BufferHackViewDesc(this.top, [], dom, null);
|
|
38678
38797
|
if (parent != this.top)
|
|
38679
38798
|
parent.children.push(hack);
|
|
38680
38799
|
else
|
|
@@ -38683,7 +38802,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38683
38802
|
}
|
|
38684
38803
|
}
|
|
38685
38804
|
isLocked(node) {
|
|
38686
|
-
return this.lock && (node == this.lock || node
|
|
38805
|
+
return this.lock && (node == this.lock || isElt(node) && node.contains(this.lock.parentNode));
|
|
38687
38806
|
}
|
|
38688
38807
|
}
|
|
38689
38808
|
// Iterate from the end of the fragment and array of descs to find
|
|
@@ -38885,12 +39004,27 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38885
39004
|
anchor = head;
|
|
38886
39005
|
while (nearestDesc && !nearestDesc.node)
|
|
38887
39006
|
nearestDesc = nearestDesc.parent;
|
|
38888
|
-
|
|
38889
|
-
|
|
38890
|
-
|
|
39007
|
+
if (nearestDesc && nearestDesc.node.isAtom && NodeSelection.isSelectable(nearestDesc.node) &&
|
|
39008
|
+
nearestDesc.parent &&
|
|
39009
|
+
!(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
|
|
38891
39010
|
let pos = nearestDesc.posBefore;
|
|
38892
39011
|
selection = new NodeSelection(head == pos ? $head : doc.resolve(pos));
|
|
38893
39012
|
}
|
|
39013
|
+
else if (gecko && origin == "key" && head > view.state.selection.to &&
|
|
39014
|
+
isElt(domSel.focusNode) && domSel.focusOffset == domSel.focusNode.childNodes.length &&
|
|
39015
|
+
nearestDesc && nearestDesc.posAtStart > view.state.selection.to) {
|
|
39016
|
+
// Firefox will jump across scrollable wrapper nodes on keyboard
|
|
39017
|
+
// cursor motion (#1594). This tries to detect this situation
|
|
39018
|
+
// and work around it.
|
|
39019
|
+
for (let scan = domSel.focusNode;; scan = scan.parentNode) {
|
|
39020
|
+
if (getComputedStyle(scan).overflow != "visible") {
|
|
39021
|
+
selection = Selection$2.findFrom(doc.resolve(nearestDesc.posAtStart), 1);
|
|
39022
|
+
break;
|
|
39023
|
+
}
|
|
39024
|
+
if (scan == nearestDesc.dom || scan.nextSibling || !scan.parentNode || !isElt(scan.parentNode))
|
|
39025
|
+
break;
|
|
39026
|
+
}
|
|
39027
|
+
}
|
|
38894
39028
|
}
|
|
38895
39029
|
else {
|
|
38896
39030
|
if (domSel instanceof view.dom.ownerDocument.defaultView.Selection && domSel.rangeCount > 1) {
|
|
@@ -39076,8 +39210,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39076
39210
|
// Firefox will raise 'permission denied' errors when accessing
|
|
39077
39211
|
// properties of `sel.anchorNode` when it's in a generated CSS
|
|
39078
39212
|
// element.
|
|
39079
|
-
return view.dom
|
|
39080
|
-
(view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode));
|
|
39213
|
+
return contains(view.dom, sel.anchorNode) && (view.editable || contains(view.dom, sel.focusNode));
|
|
39081
39214
|
}
|
|
39082
39215
|
catch (_) {
|
|
39083
39216
|
return false;
|
|
@@ -39128,15 +39261,14 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39128
39261
|
if (NodeSelection.isSelectable(node)) {
|
|
39129
39262
|
return apply(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head));
|
|
39130
39263
|
}
|
|
39131
|
-
else
|
|
39264
|
+
else {
|
|
39132
39265
|
// Chrome and Safari will introduce extra pointless cursor
|
|
39133
|
-
// positions around inline uneditable nodes,
|
|
39134
|
-
//
|
|
39266
|
+
// positions around inline uneditable nodes (#937), and
|
|
39267
|
+
// Firefox will sometimes just plain refuse to move across
|
|
39268
|
+
// them (#1592), so in this situation we move the cursor
|
|
39269
|
+
// ourselves.
|
|
39135
39270
|
return apply(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
|
|
39136
39271
|
}
|
|
39137
|
-
else {
|
|
39138
|
-
return false;
|
|
39139
|
-
}
|
|
39140
39272
|
}
|
|
39141
39273
|
}
|
|
39142
39274
|
else if (sel instanceof NodeSelection && sel.node.isInline) {
|
|
@@ -39149,12 +39281,10 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39149
39281
|
return false;
|
|
39150
39282
|
}
|
|
39151
39283
|
}
|
|
39152
|
-
function nodeLen(node) {
|
|
39153
|
-
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
39154
|
-
}
|
|
39155
39284
|
function isIgnorable(dom, dir) {
|
|
39156
39285
|
let desc = dom.pmViewDesc;
|
|
39157
|
-
return desc
|
|
39286
|
+
return desc ? desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR")
|
|
39287
|
+
: isElt(dom) && dom.contentEditable == "false";
|
|
39158
39288
|
}
|
|
39159
39289
|
function skipIgnoredNodes(view, dir) {
|
|
39160
39290
|
return dir < 0 ? skipIgnoredNodesBefore(view) : skipIgnoredNodesAfter(view);
|
|
@@ -39170,25 +39300,23 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39170
39300
|
// Gecko will do odd things when the selection is directly in front
|
|
39171
39301
|
// of a non-editable node, so in that case, move it into the next
|
|
39172
39302
|
// node if possible. Issue prosemirror/prosemirror#832.
|
|
39173
|
-
if (gecko && node
|
|
39303
|
+
if (gecko && isElt(node) && offset < nodeSize(node) && isIgnorable(node.childNodes[offset], -1))
|
|
39174
39304
|
force = true;
|
|
39175
39305
|
for (;;) {
|
|
39176
39306
|
if (offset > 0) {
|
|
39177
|
-
if (node
|
|
39307
|
+
if (!isElt(node))
|
|
39178
39308
|
break;
|
|
39309
|
+
let before = node.childNodes[offset - 1];
|
|
39310
|
+
if (isIgnorable(before, -1)) {
|
|
39311
|
+
moveNode = node;
|
|
39312
|
+
moveOffset = --offset;
|
|
39313
|
+
}
|
|
39314
|
+
else if (isText(before)) {
|
|
39315
|
+
node = before;
|
|
39316
|
+
offset = node.nodeValue.length;
|
|
39179
39317
|
}
|
|
39180
39318
|
else {
|
|
39181
|
-
|
|
39182
|
-
if (isIgnorable(before, -1)) {
|
|
39183
|
-
moveNode = node;
|
|
39184
|
-
moveOffset = --offset;
|
|
39185
|
-
}
|
|
39186
|
-
else if (before.nodeType == 3) {
|
|
39187
|
-
node = before;
|
|
39188
|
-
offset = node.nodeValue.length;
|
|
39189
|
-
}
|
|
39190
|
-
else
|
|
39191
|
-
break;
|
|
39319
|
+
break;
|
|
39192
39320
|
}
|
|
39193
39321
|
}
|
|
39194
39322
|
else if (isBlockNode(node)) {
|
|
@@ -39209,7 +39337,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39209
39337
|
}
|
|
39210
39338
|
else {
|
|
39211
39339
|
node = prev;
|
|
39212
|
-
offset =
|
|
39340
|
+
offset = nodeSize(node);
|
|
39213
39341
|
}
|
|
39214
39342
|
}
|
|
39215
39343
|
}
|
|
@@ -39225,19 +39353,20 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39225
39353
|
let node = sel.focusNode, offset = sel.focusOffset;
|
|
39226
39354
|
if (!node)
|
|
39227
39355
|
return;
|
|
39228
|
-
let len =
|
|
39356
|
+
let len = nodeSize(node);
|
|
39229
39357
|
let moveNode, moveOffset;
|
|
39230
39358
|
for (;;) {
|
|
39231
39359
|
if (offset < len) {
|
|
39232
|
-
if (node
|
|
39360
|
+
if (!isElt(node))
|
|
39233
39361
|
break;
|
|
39234
39362
|
let after = node.childNodes[offset];
|
|
39235
39363
|
if (isIgnorable(after, 1)) {
|
|
39236
39364
|
moveNode = node;
|
|
39237
39365
|
moveOffset = ++offset;
|
|
39238
39366
|
}
|
|
39239
|
-
else
|
|
39367
|
+
else {
|
|
39240
39368
|
break;
|
|
39369
|
+
}
|
|
39241
39370
|
}
|
|
39242
39371
|
else if (isBlockNode(node)) {
|
|
39243
39372
|
break;
|
|
@@ -39258,7 +39387,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39258
39387
|
else {
|
|
39259
39388
|
node = next;
|
|
39260
39389
|
offset = 0;
|
|
39261
|
-
len =
|
|
39390
|
+
len = nodeSize(node);
|
|
39262
39391
|
}
|
|
39263
39392
|
}
|
|
39264
39393
|
}
|
|
@@ -39276,9 +39405,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39276
39405
|
}
|
|
39277
39406
|
while (node && offset < node.childNodes.length) {
|
|
39278
39407
|
let next = node.childNodes[offset];
|
|
39279
|
-
if (next
|
|
39408
|
+
if (isText(next))
|
|
39280
39409
|
return next;
|
|
39281
|
-
if (next
|
|
39410
|
+
if (isElt(next) && next.contentEditable == "false")
|
|
39282
39411
|
break;
|
|
39283
39412
|
node = next;
|
|
39284
39413
|
offset = 0;
|
|
@@ -39291,16 +39420,16 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39291
39420
|
}
|
|
39292
39421
|
while (node && offset) {
|
|
39293
39422
|
let next = node.childNodes[offset - 1];
|
|
39294
|
-
if (next
|
|
39423
|
+
if (isText(next))
|
|
39295
39424
|
return next;
|
|
39296
|
-
if (next
|
|
39425
|
+
if (isElt(next) && next.contentEditable == "false")
|
|
39297
39426
|
break;
|
|
39298
39427
|
node = next;
|
|
39299
39428
|
offset = node.childNodes.length;
|
|
39300
39429
|
}
|
|
39301
39430
|
}
|
|
39302
39431
|
function setSelFocus(view, node, offset) {
|
|
39303
|
-
if (node
|
|
39432
|
+
if (!isText(node)) {
|
|
39304
39433
|
let before, after;
|
|
39305
39434
|
if (after = textNodeAfter(node, offset)) {
|
|
39306
39435
|
node = after;
|
|
@@ -39410,8 +39539,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39410
39539
|
if (!safari || view.state.selection.$head.parentOffset > 0)
|
|
39411
39540
|
return false;
|
|
39412
39541
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
39413
|
-
if (focusNode && focusNode
|
|
39414
|
-
focusNode.firstChild && focusNode.firstChild.contentEditable == "false") {
|
|
39542
|
+
if (focusNode && isElt(focusNode) && focusOffset == 0 &&
|
|
39543
|
+
focusNode.firstChild && isElt(focusNode.firstChild) && focusNode.firstChild.contentEditable == "false") {
|
|
39415
39544
|
let child = focusNode.firstChild;
|
|
39416
39545
|
switchEditable(view, child, "true");
|
|
39417
39546
|
setTimeout(() => switchEditable(view, child, "false"), 20);
|
|
@@ -39482,7 +39611,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39482
39611
|
let doc = detachedDoc(), wrap = doc.createElement("div");
|
|
39483
39612
|
wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
|
|
39484
39613
|
let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
|
|
39485
|
-
while (firstChild && firstChild
|
|
39614
|
+
while (firstChild && isElt(firstChild) && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
|
|
39486
39615
|
for (let i = needsWrap.length - 1; i >= 0; i--) {
|
|
39487
39616
|
let wrapper = doc.createElement(needsWrap[i]);
|
|
39488
39617
|
while (wrap.firstChild)
|
|
@@ -39492,7 +39621,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39492
39621
|
}
|
|
39493
39622
|
firstChild = wrap.firstChild;
|
|
39494
39623
|
}
|
|
39495
|
-
if (firstChild && firstChild
|
|
39624
|
+
if (firstChild && isElt(firstChild))
|
|
39496
39625
|
firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
|
|
39497
39626
|
let text = view.someProp("clipboardTextSerializer", f => f(slice, view)) ||
|
|
39498
39627
|
slice.content.textBetween(0, slice.content.size, "\n\n");
|
|
@@ -39538,7 +39667,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39538
39667
|
if (sliceData && sliceData[3])
|
|
39539
39668
|
for (let i = +sliceData[3]; i > 0; i--) {
|
|
39540
39669
|
let child = dom.firstChild;
|
|
39541
|
-
while (child && child
|
|
39670
|
+
while (child && !isElt(child))
|
|
39542
39671
|
child = child.nextSibling;
|
|
39543
39672
|
if (!child)
|
|
39544
39673
|
break;
|
|
@@ -39743,12 +39872,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39743
39872
|
if (!type || type.hasRequiredAttrs())
|
|
39744
39873
|
break;
|
|
39745
39874
|
try {
|
|
39746
|
-
type.
|
|
39875
|
+
content = Fragment.from(type.create(array[i + 1], content));
|
|
39747
39876
|
}
|
|
39748
39877
|
catch (e) {
|
|
39749
39878
|
break;
|
|
39750
39879
|
}
|
|
39751
|
-
content = Fragment.from(type.create(array[i + 1], content));
|
|
39752
39880
|
openStart++;
|
|
39753
39881
|
openEnd++;
|
|
39754
39882
|
}
|
|
@@ -40080,7 +40208,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40080
40208
|
}
|
|
40081
40209
|
const target = flushed ? null : event.target;
|
|
40082
40210
|
const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
40083
|
-
this.target = targetDesc && targetDesc.nodeDOM
|
|
40211
|
+
this.target = targetDesc && isElt(targetDesc.nodeDOM) ? targetDesc.nodeDOM : null;
|
|
40084
40212
|
let { selection } = view.state;
|
|
40085
40213
|
if (event.button == 0 &&
|
|
40086
40214
|
(targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
@@ -40228,7 +40356,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40228
40356
|
if (!view.composing) {
|
|
40229
40357
|
view.domObserver.flush();
|
|
40230
40358
|
let { state } = view, $pos = state.selection.$to;
|
|
40231
|
-
if (state.selection instanceof TextSelection &&
|
|
40359
|
+
if (state.selection instanceof TextSelection && state.selection.empty &&
|
|
40232
40360
|
(state.storedMarks ||
|
|
40233
40361
|
(!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(m => m.type.spec.inclusive === false)) ||
|
|
40234
40362
|
chrome && windows$1 && selectionBeforeUneditable(view))) { // Issue #1500
|
|
@@ -40244,11 +40372,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40244
40372
|
// inside if necessary.
|
|
40245
40373
|
if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
|
|
40246
40374
|
let sel = view.domSelectionRange();
|
|
40247
|
-
for (let node = sel.focusNode, offset = sel.focusOffset; node && node
|
|
40375
|
+
for (let node = sel.focusNode, offset = sel.focusOffset; node && isElt(node) && offset != 0;) {
|
|
40248
40376
|
let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
|
|
40249
40377
|
if (!before)
|
|
40250
40378
|
break;
|
|
40251
|
-
if (before
|
|
40379
|
+
if (isText(before)) {
|
|
40252
40380
|
let sel = view.domSelection();
|
|
40253
40381
|
if (sel)
|
|
40254
40382
|
sel.collapse(before, before.nodeValue.length);
|
|
@@ -40267,10 +40395,10 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40267
40395
|
};
|
|
40268
40396
|
function selectionBeforeUneditable(view) {
|
|
40269
40397
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
40270
|
-
if (!focusNode || focusNode
|
|
40398
|
+
if (!focusNode || !isElt(focusNode) || focusOffset >= focusNode.childNodes.length)
|
|
40271
40399
|
return false;
|
|
40272
40400
|
let next = focusNode.childNodes[focusOffset];
|
|
40273
|
-
return next
|
|
40401
|
+
return isElt(next) && next.contentEditable == "false";
|
|
40274
40402
|
}
|
|
40275
40403
|
editHandlers.compositionend = (view, event) => {
|
|
40276
40404
|
if (view.composing) {
|
|
@@ -40472,7 +40600,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40472
40600
|
else if (mouseDown && mouseDown.mightDrag) {
|
|
40473
40601
|
node = NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);
|
|
40474
40602
|
}
|
|
40475
|
-
else if (event.target && event.target
|
|
40603
|
+
else if (event.target && isElt(event.target)) {
|
|
40476
40604
|
let desc = view.docView.nearestDesc(event.target, true);
|
|
40477
40605
|
if (desc && desc.node.type.spec.draggable && desc != view.docView)
|
|
40478
40606
|
node = NodeSelection.create(view.state.doc, desc.posBefore);
|
|
@@ -41443,7 +41571,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41443
41571
|
let desc = container && this.view.docView.nearestDesc(container);
|
|
41444
41572
|
if (desc && desc.ignoreMutation({
|
|
41445
41573
|
type: "selection",
|
|
41446
|
-
target: container
|
|
41574
|
+
target: isText(container) ? container.parentNode : container
|
|
41447
41575
|
})) {
|
|
41448
41576
|
this.setCurSelection();
|
|
41449
41577
|
return true;
|
|
@@ -41485,7 +41613,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41485
41613
|
for (let node of added)
|
|
41486
41614
|
if (node.nodeName == "BR" && node.parentNode) {
|
|
41487
41615
|
let after = node.nextSibling;
|
|
41488
|
-
while (after && after
|
|
41616
|
+
while (after && isElt(after)) {
|
|
41489
41617
|
if (after.contentEditable == "false") {
|
|
41490
41618
|
node.parentNode.removeChild(node);
|
|
41491
41619
|
break;
|
|
@@ -41558,7 +41686,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41558
41686
|
for (let i = 0; i < mut.addedNodes.length; i++) {
|
|
41559
41687
|
let node = mut.addedNodes[i];
|
|
41560
41688
|
added.push(node);
|
|
41561
|
-
if (node
|
|
41689
|
+
if (isText(node))
|
|
41562
41690
|
this.lastChangedTextNode = node;
|
|
41563
41691
|
}
|
|
41564
41692
|
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
|
|
@@ -41673,8 +41801,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41673
41801
|
let parent = nextCell;
|
|
41674
41802
|
for (;;) {
|
|
41675
41803
|
let first = parent.firstChild;
|
|
41676
|
-
if (!first || first
|
|
41677
|
-
/^(BR|IMG)$/.test(first.nodeName))
|
|
41804
|
+
if (!first || !isElt(first) || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName))
|
|
41678
41805
|
break;
|
|
41679
41806
|
parent = first;
|
|
41680
41807
|
}
|
|
@@ -41699,7 +41826,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41699
41826
|
let domSel = view.domSelectionRange();
|
|
41700
41827
|
let find;
|
|
41701
41828
|
let anchor = domSel.anchorNode;
|
|
41702
|
-
if (anchor && view.dom
|
|
41829
|
+
if (anchor && contains(view.dom, anchor)) {
|
|
41703
41830
|
find = [{ node: anchor, offset: domSel.anchorOffset }];
|
|
41704
41831
|
if (!selectionCollapsed(domSel))
|
|
41705
41832
|
find.push({ node: domSel.focusNode, offset: domSel.focusOffset });
|
|
@@ -41807,7 +41934,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41807
41934
|
if (change)
|
|
41808
41935
|
view.input.domChangeCount++;
|
|
41809
41936
|
if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) &&
|
|
41810
|
-
addedNodes.some(n => n
|
|
41937
|
+
addedNodes.some(n => isElt(n) && !isInline.test(n.nodeName)) &&
|
|
41811
41938
|
(!change || change.endA >= change.endB) &&
|
|
41812
41939
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
41813
41940
|
view.input.lastIOSEnter = 0;
|
|
@@ -41865,9 +41992,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41865
41992
|
// as being an iOS enter press), just dispatch an Enter key instead.
|
|
41866
41993
|
if (((ios && view.input.lastIOSEnter > Date.now() - 225 &&
|
|
41867
41994
|
(!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
|
|
41868
|
-
(!inlineChange && $from.pos
|
|
41869
|
-
(!$from.sameParent($to) || !$from.parent.inlineContent) &&
|
|
41870
|
-
$from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")))) &&
|
|
41995
|
+
(!inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos))) &&
|
|
41871
41996
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
41872
41997
|
view.input.lastIOSEnter = 0;
|
|
41873
41998
|
return;
|
|
@@ -42018,6 +42143,16 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42018
42143
|
// The fragments after the join point must match
|
|
42019
42144
|
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
|
|
42020
42145
|
}
|
|
42146
|
+
function looksLikeEnter(content, from, to) {
|
|
42147
|
+
let newTextlines = 0, newLeaves = 0;
|
|
42148
|
+
content.nodesBetween(from, to, (node, pos) => {
|
|
42149
|
+
if (node.isTextblock && pos >= from && pos < to)
|
|
42150
|
+
newTextlines++;
|
|
42151
|
+
else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf)
|
|
42152
|
+
newLeaves++;
|
|
42153
|
+
});
|
|
42154
|
+
return newLeaves == 0 && newTextlines == 1;
|
|
42155
|
+
}
|
|
42021
42156
|
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
42022
42157
|
let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;
|
|
42023
42158
|
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
|
|
@@ -42278,11 +42413,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42278
42413
|
*/
|
|
42279
42414
|
scrollToSelection() {
|
|
42280
42415
|
let startDOM = this.domSelectionRange().focusNode;
|
|
42281
|
-
if (!startDOM || !this.dom
|
|
42416
|
+
if (!startDOM || !contains(this.dom, startDOM)) ;
|
|
42282
42417
|
else if (this.someProp("handleScrollToSelection", f => f(this))) ;
|
|
42283
42418
|
else if (this.state.selection instanceof NodeSelection) {
|
|
42284
42419
|
let target = this.docView.domAfterPos(this.state.selection.from);
|
|
42285
|
-
if (target
|
|
42420
|
+
if (isElt(target))
|
|
42286
42421
|
scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
|
|
42287
42422
|
}
|
|
42288
42423
|
else {
|
|
@@ -42547,7 +42682,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42547
42682
|
@internal
|
|
42548
42683
|
*/
|
|
42549
42684
|
domSelectionRange() {
|
|
42550
|
-
let sel = this.domSelection();
|
|
42685
|
+
let sel = this.dom.isConnected !== false && this.domSelection();
|
|
42551
42686
|
if (!sel)
|
|
42552
42687
|
return { focusNode: null, focusOffset: 0, anchorNode: null, anchorOffset: 0 };
|
|
42553
42688
|
return safari && this.root.nodeType === 11 &&
|
|
@@ -42878,336 +43013,967 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42878
43013
|
};
|
|
42879
43014
|
}
|
|
42880
43015
|
|
|
42881
|
-
|
|
42882
|
-
|
|
42883
|
-
|
|
42884
|
-
|
|
42885
|
-
|
|
42886
|
-
|
|
42887
|
-
|
|
42888
|
-
|
|
42889
|
-
|
|
42890
|
-
|
|
42891
|
-
|
|
42892
|
-
|
|
42893
|
-
|
|
42894
|
-
|
|
42895
|
-
|
|
42896
|
-
plugins: state.plugins,
|
|
42897
|
-
schema: state.schema,
|
|
42898
|
-
reconfigure: state.reconfigure.bind(state),
|
|
42899
|
-
toJSON: state.toJSON.bind(state),
|
|
42900
|
-
get storedMarks() {
|
|
42901
|
-
return storedMarks;
|
|
42902
|
-
},
|
|
42903
|
-
get selection() {
|
|
42904
|
-
return selection;
|
|
42905
|
-
},
|
|
42906
|
-
get doc() {
|
|
42907
|
-
return doc;
|
|
42908
|
-
},
|
|
42909
|
-
get tr() {
|
|
42910
|
-
selection = transaction.selection;
|
|
42911
|
-
doc = transaction.doc;
|
|
42912
|
-
storedMarks = transaction.storedMarks;
|
|
42913
|
-
return transaction;
|
|
42914
|
-
}
|
|
42915
|
-
};
|
|
42916
|
-
}
|
|
42917
|
-
//#endregion
|
|
42918
|
-
//#region src/CommandManager.ts
|
|
42919
|
-
var CommandManager = class CommandManager {
|
|
42920
|
-
constructor(props) {
|
|
42921
|
-
this.editor = props.editor;
|
|
42922
|
-
this.rawCommands = this.editor.extensionManager.commands;
|
|
42923
|
-
this.customState = props.state;
|
|
42924
|
-
}
|
|
42925
|
-
get hasCustomState() {
|
|
42926
|
-
return !!this.customState;
|
|
42927
|
-
}
|
|
42928
|
-
get state() {
|
|
42929
|
-
return this.customState || this.editor.state;
|
|
42930
|
-
}
|
|
42931
|
-
get commands() {
|
|
42932
|
-
const { rawCommands, editor, state } = this;
|
|
42933
|
-
const { view } = editor;
|
|
42934
|
-
const { tr } = state;
|
|
42935
|
-
const props = this.buildProps(tr);
|
|
42936
|
-
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
42937
|
-
const method = (...args) => {
|
|
42938
|
-
const callback = command(...args)(props);
|
|
42939
|
-
if (!tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
42940
|
-
return callback;
|
|
42941
|
-
};
|
|
42942
|
-
return [name, method];
|
|
42943
|
-
}));
|
|
42944
|
-
}
|
|
42945
|
-
get chain() {
|
|
42946
|
-
return () => this.createChain();
|
|
42947
|
-
}
|
|
42948
|
-
get can() {
|
|
42949
|
-
return () => this.createCan();
|
|
42950
|
-
}
|
|
42951
|
-
createChain(startTr, shouldDispatch = true) {
|
|
42952
|
-
const { rawCommands, editor, state } = this;
|
|
42953
|
-
const { view } = editor;
|
|
42954
|
-
const callbacks = [];
|
|
42955
|
-
const hasStartTransaction = !!startTr;
|
|
42956
|
-
const tr = startTr || state.tr;
|
|
42957
|
-
const run = () => {
|
|
42958
|
-
if (!hasStartTransaction && shouldDispatch && !tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
42959
|
-
return callbacks.every((callback) => callback === true);
|
|
42960
|
-
};
|
|
42961
|
-
const chain = {
|
|
42962
|
-
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
42963
|
-
const chainedCommand = (...args) => {
|
|
42964
|
-
const props = this.buildProps(tr, shouldDispatch);
|
|
42965
|
-
const callback = command(...args)(props);
|
|
42966
|
-
callbacks.push(callback);
|
|
42967
|
-
return chain;
|
|
42968
|
-
};
|
|
42969
|
-
return [name, chainedCommand];
|
|
42970
|
-
})),
|
|
42971
|
-
run
|
|
42972
|
-
};
|
|
42973
|
-
return chain;
|
|
42974
|
-
}
|
|
42975
|
-
/**
|
|
42976
|
-
* Creates a chain that safely returns `false` when run.
|
|
42977
|
-
* @returns A non-dispatching command chain.
|
|
42978
|
-
* @example
|
|
42979
|
-
* const chain = CommandManager.createFakeChain()
|
|
42980
|
-
* chain.focus().run() // false
|
|
42981
|
-
*/
|
|
42982
|
-
static createFakeChain() {
|
|
42983
|
-
const chain = new Proxy({}, { get: (_target, property) => {
|
|
42984
|
-
if (property === "then") return;
|
|
42985
|
-
if (property === "run") return () => false;
|
|
42986
|
-
return () => chain;
|
|
42987
|
-
} });
|
|
42988
|
-
return chain;
|
|
42989
|
-
}
|
|
42990
|
-
createCan(startTr) {
|
|
42991
|
-
const { rawCommands, state } = this;
|
|
42992
|
-
const dispatch = false;
|
|
42993
|
-
const tr = startTr || state.tr;
|
|
42994
|
-
const props = this.buildProps(tr, dispatch);
|
|
42995
|
-
return {
|
|
42996
|
-
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
42997
|
-
return [name, (...args) => command(...args)({
|
|
42998
|
-
...props,
|
|
42999
|
-
dispatch: void 0
|
|
43000
|
-
})];
|
|
43001
|
-
})),
|
|
43002
|
-
chain: () => this.createChain(tr, dispatch)
|
|
43003
|
-
};
|
|
43004
|
-
}
|
|
43005
|
-
/**
|
|
43006
|
-
* Creates capability checks that safely return `false`.
|
|
43007
|
-
* @returns A non-dispatching capability checker.
|
|
43008
|
-
* @example
|
|
43009
|
-
* const can = CommandManager.createFallbackCan()
|
|
43010
|
-
* can.focus() // false
|
|
43011
|
-
*/
|
|
43012
|
-
static createFallbackCan() {
|
|
43013
|
-
const chain = CommandManager.createFakeChain();
|
|
43014
|
-
return new Proxy({ chain: () => chain }, { get: (target, property) => {
|
|
43015
|
-
if (property === "then") return;
|
|
43016
|
-
if (property === "chain") return target.chain;
|
|
43017
|
-
return () => false;
|
|
43018
|
-
} });
|
|
43019
|
-
}
|
|
43020
|
-
buildProps(tr, shouldDispatch = true) {
|
|
43021
|
-
const { rawCommands, editor, state } = this;
|
|
43022
|
-
const { view } = editor;
|
|
43023
|
-
const props = {
|
|
43024
|
-
tr,
|
|
43025
|
-
editor,
|
|
43026
|
-
view,
|
|
43027
|
-
state: createChainableState({
|
|
43028
|
-
state,
|
|
43029
|
-
transaction: tr
|
|
43030
|
-
}),
|
|
43031
|
-
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
43032
|
-
chain: () => this.createChain(tr, shouldDispatch),
|
|
43033
|
-
can: () => this.createCan(tr),
|
|
43034
|
-
get commands() {
|
|
43035
|
-
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43036
|
-
return [name, (...args) => command(...args)(props)];
|
|
43037
|
-
}));
|
|
43038
|
-
}
|
|
43039
|
-
};
|
|
43040
|
-
return props;
|
|
43041
|
-
}
|
|
43042
|
-
};
|
|
43043
|
-
//#endregion
|
|
43044
|
-
//#region src/commands/blur.ts
|
|
43045
|
-
const blur = () => ({ editor, view }) => {
|
|
43046
|
-
requestAnimationFrame(() => {
|
|
43047
|
-
if (!editor.isDestroyed) {
|
|
43048
|
-
var _window;
|
|
43049
|
-
view.dom.blur();
|
|
43050
|
-
(_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 || _window.removeAllRanges();
|
|
43051
|
-
}
|
|
43052
|
-
});
|
|
43053
|
-
return true;
|
|
43054
|
-
};
|
|
43055
|
-
//#endregion
|
|
43056
|
-
//#region src/commands/clearContent.ts
|
|
43057
|
-
const clearContent = (emitUpdate = true) => ({ commands }) => {
|
|
43058
|
-
return commands.setContent("", { emitUpdate });
|
|
43059
|
-
};
|
|
43060
|
-
//#endregion
|
|
43061
|
-
//#region src/commands/clearNodes.ts
|
|
43062
|
-
const clearNodes = () => ({ state, tr, dispatch }) => {
|
|
43063
|
-
const { selection } = tr;
|
|
43064
|
-
const { ranges } = selection;
|
|
43065
|
-
if (!dispatch) return true;
|
|
43066
|
-
ranges.forEach(({ $from, $to }) => {
|
|
43067
|
-
state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
43068
|
-
if (node.type.isText) return;
|
|
43069
|
-
const { doc, mapping } = tr;
|
|
43070
|
-
const $mappedFrom = doc.resolve(mapping.map(pos));
|
|
43071
|
-
const $mappedTo = doc.resolve(mapping.map(pos + node.nodeSize));
|
|
43072
|
-
const nodeRange = $mappedFrom.blockRange($mappedTo);
|
|
43073
|
-
if (!nodeRange) return;
|
|
43074
|
-
const targetLiftDepth = liftTarget(nodeRange);
|
|
43075
|
-
if (node.type.isTextblock) {
|
|
43076
|
-
const { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index());
|
|
43077
|
-
tr.setNodeMarkup(nodeRange.start, defaultType);
|
|
43078
|
-
}
|
|
43079
|
-
if (targetLiftDepth || targetLiftDepth === 0) tr.lift(nodeRange, targetLiftDepth);
|
|
43080
|
-
});
|
|
43081
|
-
});
|
|
43082
|
-
return true;
|
|
43083
|
-
};
|
|
43084
|
-
//#endregion
|
|
43085
|
-
//#region src/commands/command.ts
|
|
43086
|
-
const command = (fn) => (props) => {
|
|
43087
|
-
return fn(props);
|
|
43088
|
-
};
|
|
43089
|
-
//#endregion
|
|
43090
|
-
//#region src/commands/createParagraphNear.ts
|
|
43091
|
-
const createParagraphNear$1 = () => ({ state, dispatch }) => {
|
|
43092
|
-
return createParagraphNear(state, dispatch);
|
|
43093
|
-
};
|
|
43094
|
-
//#endregion
|
|
43095
|
-
//#region src/commands/cut.ts
|
|
43096
|
-
const cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
43097
|
-
const { state } = editor;
|
|
43098
|
-
const contentSlice = state.doc.slice(originRange.from, originRange.to);
|
|
43099
|
-
tr.deleteRange(originRange.from, originRange.to);
|
|
43100
|
-
const newPos = tr.mapping.map(targetPos);
|
|
43101
|
-
tr.insert(newPos, contentSlice.content);
|
|
43102
|
-
tr.setSelection(new TextSelection(tr.doc.resolve(Math.max(newPos - 1, 0))));
|
|
43103
|
-
return true;
|
|
43016
|
+
var GOOD_LEAF_SIZE = 200;
|
|
43017
|
+
|
|
43018
|
+
// :: class<T> A rope sequence is a persistent sequence data structure
|
|
43019
|
+
// that supports appending, prepending, and slicing without doing a
|
|
43020
|
+
// full copy. It is represented as a mostly-balanced tree.
|
|
43021
|
+
var RopeSequence = function RopeSequence () {};
|
|
43022
|
+
|
|
43023
|
+
RopeSequence.prototype.append = function append (other) {
|
|
43024
|
+
if (!other.length) { return this }
|
|
43025
|
+
other = RopeSequence.from(other);
|
|
43026
|
+
|
|
43027
|
+
return (!this.length && other) ||
|
|
43028
|
+
(other.length < GOOD_LEAF_SIZE && this.leafAppend(other)) ||
|
|
43029
|
+
(this.length < GOOD_LEAF_SIZE && other.leafPrepend(this)) ||
|
|
43030
|
+
this.appendInner(other)
|
|
43104
43031
|
};
|
|
43105
|
-
|
|
43106
|
-
|
|
43107
|
-
|
|
43108
|
-
|
|
43109
|
-
|
|
43110
|
-
|
|
43111
|
-
const $pos = tr.selection.$anchor;
|
|
43112
|
-
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === currentNode.type) {
|
|
43113
|
-
if (dispatch) {
|
|
43114
|
-
const from = $pos.before(depth);
|
|
43115
|
-
const to = $pos.after(depth);
|
|
43116
|
-
tr.delete(from, to).scrollIntoView();
|
|
43117
|
-
}
|
|
43118
|
-
return true;
|
|
43119
|
-
}
|
|
43120
|
-
return false;
|
|
43032
|
+
|
|
43033
|
+
// :: (union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
43034
|
+
// Prepend an array or other rope to this one, returning a new rope.
|
|
43035
|
+
RopeSequence.prototype.prepend = function prepend (other) {
|
|
43036
|
+
if (!other.length) { return this }
|
|
43037
|
+
return RopeSequence.from(other).append(this)
|
|
43121
43038
|
};
|
|
43122
|
-
|
|
43123
|
-
|
|
43124
|
-
|
|
43125
|
-
if (typeof nameOrType === "string") {
|
|
43126
|
-
if (!schema.nodes[nameOrType]) throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`);
|
|
43127
|
-
return schema.nodes[nameOrType];
|
|
43128
|
-
}
|
|
43129
|
-
return nameOrType;
|
|
43130
|
-
}
|
|
43131
|
-
//#endregion
|
|
43132
|
-
//#region src/commands/deleteNode.ts
|
|
43133
|
-
const deleteNode = (typeOrName) => ({ tr, state, dispatch }) => {
|
|
43134
|
-
const type = getNodeType(typeOrName, state.schema);
|
|
43135
|
-
const $pos = tr.selection.$anchor;
|
|
43136
|
-
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === type) {
|
|
43137
|
-
if (dispatch) {
|
|
43138
|
-
const from = $pos.before(depth);
|
|
43139
|
-
const to = $pos.after(depth);
|
|
43140
|
-
tr.delete(from, to).scrollIntoView();
|
|
43141
|
-
}
|
|
43142
|
-
return true;
|
|
43143
|
-
}
|
|
43144
|
-
return false;
|
|
43039
|
+
|
|
43040
|
+
RopeSequence.prototype.appendInner = function appendInner (other) {
|
|
43041
|
+
return new Append(this, other)
|
|
43145
43042
|
};
|
|
43146
|
-
|
|
43147
|
-
|
|
43148
|
-
|
|
43149
|
-
|
|
43150
|
-
|
|
43151
|
-
|
|
43043
|
+
|
|
43044
|
+
// :: (?number, ?number) → RopeSequence<T>
|
|
43045
|
+
// Create a rope repesenting a sub-sequence of this rope.
|
|
43046
|
+
RopeSequence.prototype.slice = function slice (from, to) {
|
|
43047
|
+
if ( from === void 0 ) from = 0;
|
|
43048
|
+
if ( to === void 0 ) to = this.length;
|
|
43049
|
+
|
|
43050
|
+
if (from >= to) { return RopeSequence.empty }
|
|
43051
|
+
return this.sliceInner(Math.max(0, from), Math.min(this.length, to))
|
|
43152
43052
|
};
|
|
43153
|
-
|
|
43154
|
-
|
|
43155
|
-
|
|
43156
|
-
|
|
43157
|
-
|
|
43158
|
-
|
|
43159
|
-
const hasTextContent = (nodeSpec) => {
|
|
43160
|
-
if (!nodeSpec.content) return false;
|
|
43161
|
-
return /^text(\*|\+)/.test(nodeSpec.content);
|
|
43053
|
+
|
|
43054
|
+
// :: (number) → T
|
|
43055
|
+
// Retrieve the element at the given position from this rope.
|
|
43056
|
+
RopeSequence.prototype.get = function get (i) {
|
|
43057
|
+
if (i < 0 || i >= this.length) { return undefined }
|
|
43058
|
+
return this.getInner(i)
|
|
43162
43059
|
};
|
|
43163
|
-
|
|
43164
|
-
|
|
43165
|
-
|
|
43166
|
-
|
|
43167
|
-
|
|
43168
|
-
|
|
43169
|
-
|
|
43170
|
-
|
|
43171
|
-
|
|
43172
|
-
|
|
43173
|
-
|
|
43174
|
-
|
|
43175
|
-
|
|
43176
|
-
|
|
43177
|
-
return side === "left" ? $pos.start() - 1 : $pos.end() + 1;
|
|
43060
|
+
|
|
43061
|
+
// :: ((element: T, index: number) → ?bool, ?number, ?number)
|
|
43062
|
+
// Call the given function for each element between the given
|
|
43063
|
+
// indices. This tends to be more efficient than looping over the
|
|
43064
|
+
// indices and calling `get`, because it doesn't have to descend the
|
|
43065
|
+
// tree for every element.
|
|
43066
|
+
RopeSequence.prototype.forEach = function forEach (f, from, to) {
|
|
43067
|
+
if ( from === void 0 ) from = 0;
|
|
43068
|
+
if ( to === void 0 ) to = this.length;
|
|
43069
|
+
|
|
43070
|
+
if (from <= to)
|
|
43071
|
+
{ this.forEachInner(f, from, to, 0); }
|
|
43072
|
+
else
|
|
43073
|
+
{ this.forEachInvertedInner(f, from, to, 0); }
|
|
43178
43074
|
};
|
|
43179
|
-
|
|
43180
|
-
|
|
43181
|
-
|
|
43182
|
-
|
|
43183
|
-
|
|
43184
|
-
|
|
43185
|
-
|
|
43186
|
-
|
|
43187
|
-
|
|
43188
|
-
|
|
43189
|
-
|
|
43075
|
+
|
|
43076
|
+
// :: ((element: T, index: number) → U, ?number, ?number) → [U]
|
|
43077
|
+
// Map the given functions over the elements of the rope, producing
|
|
43078
|
+
// a flat array.
|
|
43079
|
+
RopeSequence.prototype.map = function map (f, from, to) {
|
|
43080
|
+
if ( from === void 0 ) from = 0;
|
|
43081
|
+
if ( to === void 0 ) to = this.length;
|
|
43082
|
+
|
|
43083
|
+
var result = [];
|
|
43084
|
+
this.forEach(function (elt, i) { return result.push(f(elt, i)); }, from, to);
|
|
43085
|
+
return result
|
|
43190
43086
|
};
|
|
43191
|
-
|
|
43192
|
-
|
|
43193
|
-
|
|
43194
|
-
|
|
43195
|
-
|
|
43196
|
-
|
|
43197
|
-
|
|
43198
|
-
const mapping = tr.mapping.slice(mapFrom);
|
|
43199
|
-
const $from = tr.doc.resolve(mapping.map(range.$from.pos));
|
|
43200
|
-
const $to = tr.doc.resolve(mapping.map(range.$to.pos));
|
|
43201
|
-
const { from, to } = expandSelectionForInlineText($from, $to, state.schema);
|
|
43202
|
-
tr.deleteRange(from, to);
|
|
43203
|
-
});
|
|
43204
|
-
if (!tr.selection.empty) tr.setSelection(TextSelection.near(tr.doc.resolve(tr.selection.from)));
|
|
43205
|
-
tr.scrollIntoView();
|
|
43206
|
-
dispatch(tr);
|
|
43207
|
-
}
|
|
43208
|
-
return true;
|
|
43087
|
+
|
|
43088
|
+
// :: (?union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
43089
|
+
// Create a rope representing the given array, or return the rope
|
|
43090
|
+
// itself if a rope was given.
|
|
43091
|
+
RopeSequence.from = function from (values) {
|
|
43092
|
+
if (values instanceof RopeSequence) { return values }
|
|
43093
|
+
return values && values.length ? new Leaf(values) : RopeSequence.empty
|
|
43209
43094
|
};
|
|
43210
|
-
|
|
43095
|
+
|
|
43096
|
+
var Leaf = /*@__PURE__*/(function (RopeSequence) {
|
|
43097
|
+
function Leaf(values) {
|
|
43098
|
+
RopeSequence.call(this);
|
|
43099
|
+
this.values = values;
|
|
43100
|
+
}
|
|
43101
|
+
|
|
43102
|
+
if ( RopeSequence ) Leaf.__proto__ = RopeSequence;
|
|
43103
|
+
Leaf.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
43104
|
+
Leaf.prototype.constructor = Leaf;
|
|
43105
|
+
|
|
43106
|
+
var prototypeAccessors = { length: { configurable: true },depth: { configurable: true } };
|
|
43107
|
+
|
|
43108
|
+
Leaf.prototype.flatten = function flatten () {
|
|
43109
|
+
return this.values
|
|
43110
|
+
};
|
|
43111
|
+
|
|
43112
|
+
Leaf.prototype.sliceInner = function sliceInner (from, to) {
|
|
43113
|
+
if (from == 0 && to == this.length) { return this }
|
|
43114
|
+
return new Leaf(this.values.slice(from, to))
|
|
43115
|
+
};
|
|
43116
|
+
|
|
43117
|
+
Leaf.prototype.getInner = function getInner (i) {
|
|
43118
|
+
return this.values[i]
|
|
43119
|
+
};
|
|
43120
|
+
|
|
43121
|
+
Leaf.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
43122
|
+
for (var i = from; i < to; i++)
|
|
43123
|
+
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
43124
|
+
};
|
|
43125
|
+
|
|
43126
|
+
Leaf.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
43127
|
+
for (var i = from - 1; i >= to; i--)
|
|
43128
|
+
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
43129
|
+
};
|
|
43130
|
+
|
|
43131
|
+
Leaf.prototype.leafAppend = function leafAppend (other) {
|
|
43132
|
+
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
43133
|
+
{ return new Leaf(this.values.concat(other.flatten())) }
|
|
43134
|
+
};
|
|
43135
|
+
|
|
43136
|
+
Leaf.prototype.leafPrepend = function leafPrepend (other) {
|
|
43137
|
+
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
43138
|
+
{ return new Leaf(other.flatten().concat(this.values)) }
|
|
43139
|
+
};
|
|
43140
|
+
|
|
43141
|
+
prototypeAccessors.length.get = function () { return this.values.length };
|
|
43142
|
+
|
|
43143
|
+
prototypeAccessors.depth.get = function () { return 0 };
|
|
43144
|
+
|
|
43145
|
+
Object.defineProperties( Leaf.prototype, prototypeAccessors );
|
|
43146
|
+
|
|
43147
|
+
return Leaf;
|
|
43148
|
+
}(RopeSequence));
|
|
43149
|
+
|
|
43150
|
+
// :: RopeSequence
|
|
43151
|
+
// The empty rope sequence.
|
|
43152
|
+
RopeSequence.empty = new Leaf([]);
|
|
43153
|
+
|
|
43154
|
+
var Append = /*@__PURE__*/(function (RopeSequence) {
|
|
43155
|
+
function Append(left, right) {
|
|
43156
|
+
RopeSequence.call(this);
|
|
43157
|
+
this.left = left;
|
|
43158
|
+
this.right = right;
|
|
43159
|
+
this.length = left.length + right.length;
|
|
43160
|
+
this.depth = Math.max(left.depth, right.depth) + 1;
|
|
43161
|
+
}
|
|
43162
|
+
|
|
43163
|
+
if ( RopeSequence ) Append.__proto__ = RopeSequence;
|
|
43164
|
+
Append.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
43165
|
+
Append.prototype.constructor = Append;
|
|
43166
|
+
|
|
43167
|
+
Append.prototype.flatten = function flatten () {
|
|
43168
|
+
return this.left.flatten().concat(this.right.flatten())
|
|
43169
|
+
};
|
|
43170
|
+
|
|
43171
|
+
Append.prototype.getInner = function getInner (i) {
|
|
43172
|
+
return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length)
|
|
43173
|
+
};
|
|
43174
|
+
|
|
43175
|
+
Append.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
43176
|
+
var leftLen = this.left.length;
|
|
43177
|
+
if (from < leftLen &&
|
|
43178
|
+
this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false)
|
|
43179
|
+
{ return false }
|
|
43180
|
+
if (to > leftLen &&
|
|
43181
|
+
this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false)
|
|
43182
|
+
{ return false }
|
|
43183
|
+
};
|
|
43184
|
+
|
|
43185
|
+
Append.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
43186
|
+
var leftLen = this.left.length;
|
|
43187
|
+
if (from > leftLen &&
|
|
43188
|
+
this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false)
|
|
43189
|
+
{ return false }
|
|
43190
|
+
if (to < leftLen &&
|
|
43191
|
+
this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false)
|
|
43192
|
+
{ return false }
|
|
43193
|
+
};
|
|
43194
|
+
|
|
43195
|
+
Append.prototype.sliceInner = function sliceInner (from, to) {
|
|
43196
|
+
if (from == 0 && to == this.length) { return this }
|
|
43197
|
+
var leftLen = this.left.length;
|
|
43198
|
+
if (to <= leftLen) { return this.left.slice(from, to) }
|
|
43199
|
+
if (from >= leftLen) { return this.right.slice(from - leftLen, to - leftLen) }
|
|
43200
|
+
return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen))
|
|
43201
|
+
};
|
|
43202
|
+
|
|
43203
|
+
Append.prototype.leafAppend = function leafAppend (other) {
|
|
43204
|
+
var inner = this.right.leafAppend(other);
|
|
43205
|
+
if (inner) { return new Append(this.left, inner) }
|
|
43206
|
+
};
|
|
43207
|
+
|
|
43208
|
+
Append.prototype.leafPrepend = function leafPrepend (other) {
|
|
43209
|
+
var inner = this.left.leafPrepend(other);
|
|
43210
|
+
if (inner) { return new Append(inner, this.right) }
|
|
43211
|
+
};
|
|
43212
|
+
|
|
43213
|
+
Append.prototype.appendInner = function appendInner (other) {
|
|
43214
|
+
if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1)
|
|
43215
|
+
{ return new Append(this.left, new Append(this.right, other)) }
|
|
43216
|
+
return new Append(this, other)
|
|
43217
|
+
};
|
|
43218
|
+
|
|
43219
|
+
return Append;
|
|
43220
|
+
}(RopeSequence));
|
|
43221
|
+
|
|
43222
|
+
// ProseMirror's history isn't simply a way to roll back to a previous
|
|
43223
|
+
// state, because ProseMirror supports applying changes without adding
|
|
43224
|
+
// them to the history (for example during collaboration).
|
|
43225
|
+
//
|
|
43226
|
+
// To this end, each 'Branch' (one for the undo history and one for
|
|
43227
|
+
// the redo history) keeps an array of 'Items', which can optionally
|
|
43228
|
+
// hold a step (an actual undoable change), and always hold a position
|
|
43229
|
+
// map (which is needed to move changes below them to apply to the
|
|
43230
|
+
// current document).
|
|
43231
|
+
//
|
|
43232
|
+
// An item that has both a step and a selection bookmark is the start
|
|
43233
|
+
// of an 'event' — a group of changes that will be undone or redone at
|
|
43234
|
+
// once. (It stores only the bookmark, since that way we don't have to
|
|
43235
|
+
// provide a document until the selection is actually applied, which
|
|
43236
|
+
// is useful when compressing.)
|
|
43237
|
+
// Used to schedule history compression
|
|
43238
|
+
const max_empty_items = 500;
|
|
43239
|
+
class Branch {
|
|
43240
|
+
constructor(items, eventCount) {
|
|
43241
|
+
this.items = items;
|
|
43242
|
+
this.eventCount = eventCount;
|
|
43243
|
+
}
|
|
43244
|
+
// Pop the latest event off the branch's history and apply it
|
|
43245
|
+
// to a document transform.
|
|
43246
|
+
popEvent(state, preserveItems) {
|
|
43247
|
+
if (this.eventCount == 0)
|
|
43248
|
+
return null;
|
|
43249
|
+
let end = this.items.length;
|
|
43250
|
+
for (;; end--) {
|
|
43251
|
+
let next = this.items.get(end - 1);
|
|
43252
|
+
if (next.selection) {
|
|
43253
|
+
--end;
|
|
43254
|
+
break;
|
|
43255
|
+
}
|
|
43256
|
+
}
|
|
43257
|
+
let remap, mapFrom;
|
|
43258
|
+
if (preserveItems) {
|
|
43259
|
+
remap = this.remapping(end, this.items.length);
|
|
43260
|
+
mapFrom = remap.maps.length;
|
|
43261
|
+
}
|
|
43262
|
+
let transform = state.tr;
|
|
43263
|
+
let selection, remaining;
|
|
43264
|
+
let addAfter = [], addBefore = [];
|
|
43265
|
+
this.items.forEach((item, i) => {
|
|
43266
|
+
if (!item.step) {
|
|
43267
|
+
if (!remap) {
|
|
43268
|
+
remap = this.remapping(end, i + 1);
|
|
43269
|
+
mapFrom = remap.maps.length;
|
|
43270
|
+
}
|
|
43271
|
+
mapFrom--;
|
|
43272
|
+
addBefore.push(item);
|
|
43273
|
+
return;
|
|
43274
|
+
}
|
|
43275
|
+
if (remap) {
|
|
43276
|
+
addBefore.push(new Item(item.map));
|
|
43277
|
+
let step = item.step.map(remap.slice(mapFrom)), map;
|
|
43278
|
+
if (step && transform.maybeStep(step).doc) {
|
|
43279
|
+
map = transform.mapping.maps[transform.mapping.maps.length - 1];
|
|
43280
|
+
addAfter.push(new Item(map, undefined, undefined, addAfter.length + addBefore.length));
|
|
43281
|
+
}
|
|
43282
|
+
mapFrom--;
|
|
43283
|
+
if (map)
|
|
43284
|
+
remap.appendMap(map, mapFrom);
|
|
43285
|
+
}
|
|
43286
|
+
else {
|
|
43287
|
+
transform.maybeStep(item.step);
|
|
43288
|
+
}
|
|
43289
|
+
if (item.selection) {
|
|
43290
|
+
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
|
|
43291
|
+
remaining = new Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
|
|
43292
|
+
return false;
|
|
43293
|
+
}
|
|
43294
|
+
}, this.items.length, 0);
|
|
43295
|
+
return { remaining: remaining, transform, selection: selection };
|
|
43296
|
+
}
|
|
43297
|
+
// Create a new branch with the given transform added.
|
|
43298
|
+
addTransform(transform, selection, histOptions, preserveItems) {
|
|
43299
|
+
let newItems = [], eventCount = this.eventCount;
|
|
43300
|
+
let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
|
|
43301
|
+
for (let i = 0; i < transform.steps.length; i++) {
|
|
43302
|
+
let step = transform.steps[i].invert(transform.docs[i]);
|
|
43303
|
+
let item = new Item(transform.mapping.maps[i], step, selection), merged;
|
|
43304
|
+
if (merged = lastItem && lastItem.merge(item)) {
|
|
43305
|
+
item = merged;
|
|
43306
|
+
if (i)
|
|
43307
|
+
newItems.pop();
|
|
43308
|
+
else
|
|
43309
|
+
oldItems = oldItems.slice(0, oldItems.length - 1);
|
|
43310
|
+
}
|
|
43311
|
+
newItems.push(item);
|
|
43312
|
+
if (selection) {
|
|
43313
|
+
eventCount++;
|
|
43314
|
+
selection = undefined;
|
|
43315
|
+
}
|
|
43316
|
+
if (!preserveItems)
|
|
43317
|
+
lastItem = item;
|
|
43318
|
+
}
|
|
43319
|
+
let overflow = eventCount - histOptions.depth;
|
|
43320
|
+
if (overflow > DEPTH_OVERFLOW) {
|
|
43321
|
+
oldItems = cutOffEvents(oldItems, overflow);
|
|
43322
|
+
eventCount -= overflow;
|
|
43323
|
+
}
|
|
43324
|
+
return new Branch(oldItems.append(newItems), eventCount);
|
|
43325
|
+
}
|
|
43326
|
+
remapping(from, to) {
|
|
43327
|
+
let maps = new Mapping;
|
|
43328
|
+
this.items.forEach((item, i) => {
|
|
43329
|
+
let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from
|
|
43330
|
+
? maps.maps.length - item.mirrorOffset : undefined;
|
|
43331
|
+
maps.appendMap(item.map, mirrorPos);
|
|
43332
|
+
}, from, to);
|
|
43333
|
+
return maps;
|
|
43334
|
+
}
|
|
43335
|
+
addMaps(array) {
|
|
43336
|
+
if (this.eventCount == 0)
|
|
43337
|
+
return this;
|
|
43338
|
+
return new Branch(this.items.append(array.map(map => new Item(map))), this.eventCount);
|
|
43339
|
+
}
|
|
43340
|
+
// When the collab module receives remote changes, the history has
|
|
43341
|
+
// to know about those, so that it can adjust the steps that were
|
|
43342
|
+
// rebased on top of the remote changes, and include the position
|
|
43343
|
+
// maps for the remote changes in its array of items.
|
|
43344
|
+
rebased(rebasedTransform, rebasedCount) {
|
|
43345
|
+
if (!this.eventCount)
|
|
43346
|
+
return this;
|
|
43347
|
+
rebasedCount = Math.min(this.items.length, rebasedCount);
|
|
43348
|
+
let rebasedItems = [], start = this.items.length - rebasedCount;
|
|
43349
|
+
let mapping = rebasedTransform.mapping;
|
|
43350
|
+
let newUntil = rebasedTransform.steps.length;
|
|
43351
|
+
let eventCount = this.eventCount;
|
|
43352
|
+
this.items.forEach(item => { if (item.selection)
|
|
43353
|
+
eventCount--; }, start);
|
|
43354
|
+
let iRebased = rebasedCount;
|
|
43355
|
+
this.items.forEach(item => {
|
|
43356
|
+
let pos = mapping.getMirror(--iRebased);
|
|
43357
|
+
if (pos == null)
|
|
43358
|
+
return;
|
|
43359
|
+
newUntil = Math.min(newUntil, pos);
|
|
43360
|
+
let map = mapping.maps[pos];
|
|
43361
|
+
if (item.step) {
|
|
43362
|
+
let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
|
|
43363
|
+
let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
|
|
43364
|
+
if (selection)
|
|
43365
|
+
eventCount++;
|
|
43366
|
+
rebasedItems.push(new Item(map, step, selection));
|
|
43367
|
+
}
|
|
43368
|
+
else {
|
|
43369
|
+
rebasedItems.push(new Item(map));
|
|
43370
|
+
}
|
|
43371
|
+
}, start);
|
|
43372
|
+
let newMaps = [];
|
|
43373
|
+
for (let i = rebasedCount; i < newUntil; i++)
|
|
43374
|
+
newMaps.push(new Item(mapping.maps[i]));
|
|
43375
|
+
let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
|
|
43376
|
+
let branch = new Branch(items, eventCount);
|
|
43377
|
+
if (branch.emptyItemCount() > max_empty_items)
|
|
43378
|
+
branch = branch.compress(this.items.length - rebasedItems.length);
|
|
43379
|
+
return branch;
|
|
43380
|
+
}
|
|
43381
|
+
emptyItemCount() {
|
|
43382
|
+
let count = 0;
|
|
43383
|
+
this.items.forEach(item => { if (!item.step)
|
|
43384
|
+
count++; });
|
|
43385
|
+
return count;
|
|
43386
|
+
}
|
|
43387
|
+
// Compressing a branch means rewriting it to push the air (map-only
|
|
43388
|
+
// items) out. During collaboration, these naturally accumulate
|
|
43389
|
+
// because each remote change adds one. The `upto` argument is used
|
|
43390
|
+
// to ensure that only the items below a given level are compressed,
|
|
43391
|
+
// because `rebased` relies on a clean, untouched set of items in
|
|
43392
|
+
// order to associate old items with rebased steps.
|
|
43393
|
+
compress(upto = this.items.length) {
|
|
43394
|
+
let remap = this.remapping(0, upto), mapFrom = remap.maps.length;
|
|
43395
|
+
let items = [], events = 0;
|
|
43396
|
+
this.items.forEach((item, i) => {
|
|
43397
|
+
if (i >= upto) {
|
|
43398
|
+
items.push(item);
|
|
43399
|
+
if (item.selection)
|
|
43400
|
+
events++;
|
|
43401
|
+
}
|
|
43402
|
+
else if (item.step) {
|
|
43403
|
+
let step = item.step.map(remap.slice(mapFrom)), map = step && step.getMap();
|
|
43404
|
+
mapFrom--;
|
|
43405
|
+
if (map)
|
|
43406
|
+
remap.appendMap(map, mapFrom);
|
|
43407
|
+
if (step) {
|
|
43408
|
+
let selection = item.selection && item.selection.map(remap.slice(mapFrom));
|
|
43409
|
+
if (selection)
|
|
43410
|
+
events++;
|
|
43411
|
+
let newItem = new Item(map.invert(), step, selection), merged, last = items.length - 1;
|
|
43412
|
+
if (merged = items.length && items[last].merge(newItem))
|
|
43413
|
+
items[last] = merged;
|
|
43414
|
+
else
|
|
43415
|
+
items.push(newItem);
|
|
43416
|
+
}
|
|
43417
|
+
}
|
|
43418
|
+
else if (item.map) {
|
|
43419
|
+
mapFrom--;
|
|
43420
|
+
}
|
|
43421
|
+
}, this.items.length, 0);
|
|
43422
|
+
return new Branch(RopeSequence.from(items.reverse()), events);
|
|
43423
|
+
}
|
|
43424
|
+
}
|
|
43425
|
+
Branch.empty = new Branch(RopeSequence.empty, 0);
|
|
43426
|
+
function cutOffEvents(items, n) {
|
|
43427
|
+
let cutPoint;
|
|
43428
|
+
items.forEach((item, i) => {
|
|
43429
|
+
if (item.selection && (n-- == 0)) {
|
|
43430
|
+
cutPoint = i;
|
|
43431
|
+
return false;
|
|
43432
|
+
}
|
|
43433
|
+
});
|
|
43434
|
+
return items.slice(cutPoint);
|
|
43435
|
+
}
|
|
43436
|
+
class Item {
|
|
43437
|
+
constructor(
|
|
43438
|
+
// The (forward) step map for this item.
|
|
43439
|
+
map,
|
|
43440
|
+
// The inverted step
|
|
43441
|
+
step,
|
|
43442
|
+
// If this is non-null, this item is the start of a group, and
|
|
43443
|
+
// this selection is the starting selection for the group (the one
|
|
43444
|
+
// that was active before the first step was applied)
|
|
43445
|
+
selection,
|
|
43446
|
+
// If this item is the inverse of a previous mapping on the stack,
|
|
43447
|
+
// this points at the inverse's offset
|
|
43448
|
+
mirrorOffset) {
|
|
43449
|
+
this.map = map;
|
|
43450
|
+
this.step = step;
|
|
43451
|
+
this.selection = selection;
|
|
43452
|
+
this.mirrorOffset = mirrorOffset;
|
|
43453
|
+
}
|
|
43454
|
+
merge(other) {
|
|
43455
|
+
if (this.step && other.step && !other.selection) {
|
|
43456
|
+
let step = other.step.merge(this.step);
|
|
43457
|
+
if (step)
|
|
43458
|
+
return new Item(step.getMap().invert(), step, this.selection);
|
|
43459
|
+
}
|
|
43460
|
+
}
|
|
43461
|
+
}
|
|
43462
|
+
// The value of the state field that tracks undo/redo history for that
|
|
43463
|
+
// state. Will be stored in the plugin state when the history plugin
|
|
43464
|
+
// is active.
|
|
43465
|
+
class HistoryState {
|
|
43466
|
+
constructor(done, undone, prevRanges, prevTime, prevComposition) {
|
|
43467
|
+
this.done = done;
|
|
43468
|
+
this.undone = undone;
|
|
43469
|
+
this.prevRanges = prevRanges;
|
|
43470
|
+
this.prevTime = prevTime;
|
|
43471
|
+
this.prevComposition = prevComposition;
|
|
43472
|
+
}
|
|
43473
|
+
}
|
|
43474
|
+
const DEPTH_OVERFLOW = 20;
|
|
43475
|
+
// Record a transformation in undo history.
|
|
43476
|
+
function applyTransaction(history, state, tr, options) {
|
|
43477
|
+
let historyTr = tr.getMeta(historyKey), rebased;
|
|
43478
|
+
if (historyTr)
|
|
43479
|
+
return historyTr.historyState;
|
|
43480
|
+
if (tr.getMeta(closeHistoryKey))
|
|
43481
|
+
history = new HistoryState(history.done, history.undone, null, 0, -1);
|
|
43482
|
+
let appended = tr.getMeta("appendedTransaction");
|
|
43483
|
+
if (tr.steps.length == 0) {
|
|
43484
|
+
return history;
|
|
43485
|
+
}
|
|
43486
|
+
else if (appended && appended.getMeta(historyKey)) {
|
|
43487
|
+
if (appended.getMeta(historyKey).redo)
|
|
43488
|
+
return new HistoryState(history.done.addTransform(tr, undefined, options, mustPreserveItems(state)), history.undone, rangesFor(tr.mapping.maps), history.prevTime, history.prevComposition);
|
|
43489
|
+
else
|
|
43490
|
+
return new HistoryState(history.done, history.undone.addTransform(tr, undefined, options, mustPreserveItems(state)), null, history.prevTime, history.prevComposition);
|
|
43491
|
+
}
|
|
43492
|
+
else if (tr.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
|
|
43493
|
+
// Group transforms that occur in quick succession into one event.
|
|
43494
|
+
let composition = tr.getMeta("composition");
|
|
43495
|
+
let newGroup = history.prevTime == 0 ||
|
|
43496
|
+
(!appended && history.prevComposition != composition &&
|
|
43497
|
+
(history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history.prevRanges)));
|
|
43498
|
+
let prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps);
|
|
43499
|
+
return new HistoryState(history.done.addTransform(tr, newGroup ? state.selection.getBookmark() : undefined, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time, composition == null ? history.prevComposition : composition);
|
|
43500
|
+
}
|
|
43501
|
+
else if (rebased = tr.getMeta("rebased")) {
|
|
43502
|
+
// Used by the collab module to tell the history that some of its
|
|
43503
|
+
// content has been rebased.
|
|
43504
|
+
return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);
|
|
43505
|
+
}
|
|
43506
|
+
else {
|
|
43507
|
+
return new HistoryState(history.done.addMaps(tr.mapping.maps), history.undone.addMaps(tr.mapping.maps), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);
|
|
43508
|
+
}
|
|
43509
|
+
}
|
|
43510
|
+
function isAdjacentTo(transform, prevRanges) {
|
|
43511
|
+
if (!prevRanges)
|
|
43512
|
+
return false;
|
|
43513
|
+
if (!transform.docChanged)
|
|
43514
|
+
return true;
|
|
43515
|
+
let adjacent = false;
|
|
43516
|
+
transform.mapping.maps[0].forEach((start, end) => {
|
|
43517
|
+
for (let i = 0; i < prevRanges.length; i += 2)
|
|
43518
|
+
if (start <= prevRanges[i + 1] && end >= prevRanges[i])
|
|
43519
|
+
adjacent = true;
|
|
43520
|
+
});
|
|
43521
|
+
return adjacent;
|
|
43522
|
+
}
|
|
43523
|
+
function rangesFor(maps) {
|
|
43524
|
+
let result = [];
|
|
43525
|
+
for (let i = maps.length - 1; i >= 0 && result.length == 0; i--)
|
|
43526
|
+
maps[i].forEach((_from, _to, from, to) => result.push(from, to));
|
|
43527
|
+
return result;
|
|
43528
|
+
}
|
|
43529
|
+
function mapRanges(ranges, mapping) {
|
|
43530
|
+
if (!ranges)
|
|
43531
|
+
return null;
|
|
43532
|
+
let result = [];
|
|
43533
|
+
for (let i = 0; i < ranges.length; i += 2) {
|
|
43534
|
+
let from = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1);
|
|
43535
|
+
if (from <= to)
|
|
43536
|
+
result.push(from, to);
|
|
43537
|
+
}
|
|
43538
|
+
return result;
|
|
43539
|
+
}
|
|
43540
|
+
// Apply the latest event from one branch to the document and shift the event
|
|
43541
|
+
// onto the other branch.
|
|
43542
|
+
function histTransaction(history, state, redo) {
|
|
43543
|
+
let preserveItems = mustPreserveItems(state);
|
|
43544
|
+
let histOptions = historyKey.get(state).spec.config;
|
|
43545
|
+
let pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);
|
|
43546
|
+
if (!pop)
|
|
43547
|
+
return null;
|
|
43548
|
+
let selection = pop.selection.resolve(pop.transform.doc);
|
|
43549
|
+
let added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
|
|
43550
|
+
let newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0, -1);
|
|
43551
|
+
return pop.transform.setSelection(selection).setMeta(historyKey, { redo, historyState: newHist });
|
|
43552
|
+
}
|
|
43553
|
+
let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
|
|
43554
|
+
// Check whether any plugin in the given state has a
|
|
43555
|
+
// `historyPreserveItems` property in its spec, in which case we must
|
|
43556
|
+
// preserve steps exactly as they came in, so that they can be
|
|
43557
|
+
// rebased.
|
|
43558
|
+
function mustPreserveItems(state) {
|
|
43559
|
+
let plugins = state.plugins;
|
|
43560
|
+
if (cachedPreserveItemsPlugins != plugins) {
|
|
43561
|
+
cachedPreserveItems = false;
|
|
43562
|
+
cachedPreserveItemsPlugins = plugins;
|
|
43563
|
+
for (let i = 0; i < plugins.length; i++)
|
|
43564
|
+
if (plugins[i].spec.historyPreserveItems) {
|
|
43565
|
+
cachedPreserveItems = true;
|
|
43566
|
+
break;
|
|
43567
|
+
}
|
|
43568
|
+
}
|
|
43569
|
+
return cachedPreserveItems;
|
|
43570
|
+
}
|
|
43571
|
+
/**
|
|
43572
|
+
Set a flag on the given transaction that will prevent further steps
|
|
43573
|
+
from being appended to an existing history event (so that they
|
|
43574
|
+
require a separate undo command to undo).
|
|
43575
|
+
*/
|
|
43576
|
+
function closeHistory(tr) {
|
|
43577
|
+
return tr.setMeta(closeHistoryKey, true);
|
|
43578
|
+
}
|
|
43579
|
+
const historyKey = new PluginKey("history");
|
|
43580
|
+
const closeHistoryKey = new PluginKey("closeHistory");
|
|
43581
|
+
/**
|
|
43582
|
+
Returns a plugin that enables the undo history for an editor. The
|
|
43583
|
+
plugin will track undo and redo stacks, which can be used with the
|
|
43584
|
+
[`undo`](https://prosemirror.net/docs/ref/#history.undo) and [`redo`](https://prosemirror.net/docs/ref/#history.redo) commands.
|
|
43585
|
+
|
|
43586
|
+
You can set an `"addToHistory"` [metadata
|
|
43587
|
+
property](https://prosemirror.net/docs/ref/#state.Transaction.setMeta) of `false` on a transaction
|
|
43588
|
+
to prevent it from being rolled back by undo.
|
|
43589
|
+
*/
|
|
43590
|
+
function history(config = {}) {
|
|
43591
|
+
config = { depth: config.depth || 100,
|
|
43592
|
+
newGroupDelay: config.newGroupDelay || 500 };
|
|
43593
|
+
return new Plugin({
|
|
43594
|
+
key: historyKey,
|
|
43595
|
+
state: {
|
|
43596
|
+
init() {
|
|
43597
|
+
return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
|
|
43598
|
+
},
|
|
43599
|
+
apply(tr, hist, state) {
|
|
43600
|
+
return applyTransaction(hist, state, tr, config);
|
|
43601
|
+
}
|
|
43602
|
+
},
|
|
43603
|
+
config,
|
|
43604
|
+
props: {
|
|
43605
|
+
handleDOMEvents: {
|
|
43606
|
+
beforeinput(view, e) {
|
|
43607
|
+
let inputType = e.inputType;
|
|
43608
|
+
let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
|
|
43609
|
+
if (!command || !view.editable)
|
|
43610
|
+
return false;
|
|
43611
|
+
e.preventDefault();
|
|
43612
|
+
return command(view.state, view.dispatch);
|
|
43613
|
+
}
|
|
43614
|
+
}
|
|
43615
|
+
}
|
|
43616
|
+
});
|
|
43617
|
+
}
|
|
43618
|
+
function buildCommand(redo, scroll) {
|
|
43619
|
+
return (state, dispatch) => {
|
|
43620
|
+
let hist = historyKey.getState(state);
|
|
43621
|
+
if (!hist || (redo ? hist.undone : hist.done).eventCount == 0)
|
|
43622
|
+
return false;
|
|
43623
|
+
if (dispatch) {
|
|
43624
|
+
let tr = histTransaction(hist, state, redo);
|
|
43625
|
+
if (tr)
|
|
43626
|
+
dispatch(scroll ? tr.scrollIntoView() : tr);
|
|
43627
|
+
}
|
|
43628
|
+
return true;
|
|
43629
|
+
};
|
|
43630
|
+
}
|
|
43631
|
+
/**
|
|
43632
|
+
A command function that undoes the last change, if any.
|
|
43633
|
+
*/
|
|
43634
|
+
const undo = buildCommand(false, true);
|
|
43635
|
+
/**
|
|
43636
|
+
A command function that redoes the last undone change, if any.
|
|
43637
|
+
*/
|
|
43638
|
+
const redo = buildCommand(true, true);
|
|
43639
|
+
/**
|
|
43640
|
+
Returns true if the given transaction was generated by the history
|
|
43641
|
+
plugin.
|
|
43642
|
+
*/
|
|
43643
|
+
function isHistoryTransaction(tr) {
|
|
43644
|
+
return tr.getMeta(historyKey) != null;
|
|
43645
|
+
}
|
|
43646
|
+
|
|
43647
|
+
//#region src/helpers/createChainableState.ts
|
|
43648
|
+
/**
|
|
43649
|
+
* Takes a Transaction & Editor State and turns it into a chainable state object
|
|
43650
|
+
* @param config The transaction and state to create the chainable state from
|
|
43651
|
+
* @returns A chainable Editor state object
|
|
43652
|
+
*/
|
|
43653
|
+
function createChainableState(config) {
|
|
43654
|
+
const { state, transaction } = config;
|
|
43655
|
+
let { selection } = transaction;
|
|
43656
|
+
let { doc } = transaction;
|
|
43657
|
+
let { storedMarks } = transaction;
|
|
43658
|
+
return {
|
|
43659
|
+
...state,
|
|
43660
|
+
apply: state.apply.bind(state),
|
|
43661
|
+
applyTransaction: state.applyTransaction.bind(state),
|
|
43662
|
+
plugins: state.plugins,
|
|
43663
|
+
schema: state.schema,
|
|
43664
|
+
reconfigure: state.reconfigure.bind(state),
|
|
43665
|
+
toJSON: state.toJSON.bind(state),
|
|
43666
|
+
get storedMarks() {
|
|
43667
|
+
return storedMarks;
|
|
43668
|
+
},
|
|
43669
|
+
get selection() {
|
|
43670
|
+
return selection;
|
|
43671
|
+
},
|
|
43672
|
+
get doc() {
|
|
43673
|
+
return doc;
|
|
43674
|
+
},
|
|
43675
|
+
get tr() {
|
|
43676
|
+
selection = transaction.selection;
|
|
43677
|
+
doc = transaction.doc;
|
|
43678
|
+
storedMarks = transaction.storedMarks;
|
|
43679
|
+
return transaction;
|
|
43680
|
+
}
|
|
43681
|
+
};
|
|
43682
|
+
}
|
|
43683
|
+
//#endregion
|
|
43684
|
+
//#region src/CommandManager.ts
|
|
43685
|
+
var CommandManager = class CommandManager {
|
|
43686
|
+
constructor(props) {
|
|
43687
|
+
this.editor = props.editor;
|
|
43688
|
+
this.rawCommands = this.editor.extensionManager.commands;
|
|
43689
|
+
this.customState = props.state;
|
|
43690
|
+
}
|
|
43691
|
+
get hasCustomState() {
|
|
43692
|
+
return !!this.customState;
|
|
43693
|
+
}
|
|
43694
|
+
get state() {
|
|
43695
|
+
return this.customState || this.editor.state;
|
|
43696
|
+
}
|
|
43697
|
+
get commands() {
|
|
43698
|
+
const { rawCommands, editor, state } = this;
|
|
43699
|
+
const { view } = editor;
|
|
43700
|
+
const { tr } = state;
|
|
43701
|
+
const props = this.buildProps(tr);
|
|
43702
|
+
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43703
|
+
const method = (...args) => {
|
|
43704
|
+
const callback = command(...args)(props);
|
|
43705
|
+
if (!tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
43706
|
+
return callback;
|
|
43707
|
+
};
|
|
43708
|
+
return [name, method];
|
|
43709
|
+
}));
|
|
43710
|
+
}
|
|
43711
|
+
get chain() {
|
|
43712
|
+
return () => this.createChain();
|
|
43713
|
+
}
|
|
43714
|
+
get can() {
|
|
43715
|
+
return () => this.createCan();
|
|
43716
|
+
}
|
|
43717
|
+
createChain(startTr, shouldDispatch = true) {
|
|
43718
|
+
const { rawCommands, editor, state } = this;
|
|
43719
|
+
const { view } = editor;
|
|
43720
|
+
const callbacks = [];
|
|
43721
|
+
const hasStartTransaction = !!startTr;
|
|
43722
|
+
const tr = startTr || state.tr;
|
|
43723
|
+
const run = () => {
|
|
43724
|
+
if (!hasStartTransaction && shouldDispatch && !tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
43725
|
+
return callbacks.every((callback) => callback === true);
|
|
43726
|
+
};
|
|
43727
|
+
const chain = {
|
|
43728
|
+
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43729
|
+
const chainedCommand = (...args) => {
|
|
43730
|
+
const props = this.buildProps(tr, shouldDispatch);
|
|
43731
|
+
const callback = command(...args)(props);
|
|
43732
|
+
callbacks.push(callback);
|
|
43733
|
+
return chain;
|
|
43734
|
+
};
|
|
43735
|
+
return [name, chainedCommand];
|
|
43736
|
+
})),
|
|
43737
|
+
run
|
|
43738
|
+
};
|
|
43739
|
+
return chain;
|
|
43740
|
+
}
|
|
43741
|
+
/**
|
|
43742
|
+
* Creates a chain that safely returns `false` when run.
|
|
43743
|
+
* @returns A non-dispatching command chain.
|
|
43744
|
+
* @example
|
|
43745
|
+
* const chain = CommandManager.createFakeChain()
|
|
43746
|
+
* chain.focus().run() // false
|
|
43747
|
+
*/
|
|
43748
|
+
static createFakeChain() {
|
|
43749
|
+
const chain = new Proxy({}, { get: (_target, property) => {
|
|
43750
|
+
if (property === "then") return;
|
|
43751
|
+
if (property === "run") return () => false;
|
|
43752
|
+
return () => chain;
|
|
43753
|
+
} });
|
|
43754
|
+
return chain;
|
|
43755
|
+
}
|
|
43756
|
+
createCan(startTr) {
|
|
43757
|
+
const { rawCommands, state } = this;
|
|
43758
|
+
const dispatch = false;
|
|
43759
|
+
const tr = startTr || state.tr;
|
|
43760
|
+
const props = this.buildProps(tr, dispatch);
|
|
43761
|
+
return {
|
|
43762
|
+
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43763
|
+
return [name, (...args) => command(...args)({
|
|
43764
|
+
...props,
|
|
43765
|
+
dispatch: void 0
|
|
43766
|
+
})];
|
|
43767
|
+
})),
|
|
43768
|
+
chain: () => this.createChain(tr, dispatch)
|
|
43769
|
+
};
|
|
43770
|
+
}
|
|
43771
|
+
/**
|
|
43772
|
+
* Creates capability checks that safely return `false`.
|
|
43773
|
+
* @returns A non-dispatching capability checker.
|
|
43774
|
+
* @example
|
|
43775
|
+
* const can = CommandManager.createFallbackCan()
|
|
43776
|
+
* can.focus() // false
|
|
43777
|
+
*/
|
|
43778
|
+
static createFallbackCan() {
|
|
43779
|
+
const chain = CommandManager.createFakeChain();
|
|
43780
|
+
return new Proxy({ chain: () => chain }, { get: (target, property) => {
|
|
43781
|
+
if (property === "then") return;
|
|
43782
|
+
if (property === "chain") return target.chain;
|
|
43783
|
+
return () => false;
|
|
43784
|
+
} });
|
|
43785
|
+
}
|
|
43786
|
+
buildProps(tr, shouldDispatch = true) {
|
|
43787
|
+
const { rawCommands, editor, state } = this;
|
|
43788
|
+
const { view } = editor;
|
|
43789
|
+
const props = {
|
|
43790
|
+
tr,
|
|
43791
|
+
editor,
|
|
43792
|
+
view,
|
|
43793
|
+
state: createChainableState({
|
|
43794
|
+
state,
|
|
43795
|
+
transaction: tr
|
|
43796
|
+
}),
|
|
43797
|
+
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
43798
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
43799
|
+
can: () => this.createCan(tr),
|
|
43800
|
+
get commands() {
|
|
43801
|
+
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43802
|
+
return [name, (...args) => command(...args)(props)];
|
|
43803
|
+
}));
|
|
43804
|
+
}
|
|
43805
|
+
};
|
|
43806
|
+
return props;
|
|
43807
|
+
}
|
|
43808
|
+
};
|
|
43809
|
+
//#endregion
|
|
43810
|
+
//#region src/commands/blur.ts
|
|
43811
|
+
const blur = () => ({ editor, view }) => {
|
|
43812
|
+
requestAnimationFrame(() => {
|
|
43813
|
+
if (!editor.isDestroyed) {
|
|
43814
|
+
var _window;
|
|
43815
|
+
view.dom.blur();
|
|
43816
|
+
(_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 || _window.removeAllRanges();
|
|
43817
|
+
}
|
|
43818
|
+
});
|
|
43819
|
+
return true;
|
|
43820
|
+
};
|
|
43821
|
+
//#endregion
|
|
43822
|
+
//#region src/commands/clearContent.ts
|
|
43823
|
+
const clearContent = (emitUpdate = true) => ({ commands }) => {
|
|
43824
|
+
return commands.setContent("", { emitUpdate });
|
|
43825
|
+
};
|
|
43826
|
+
//#endregion
|
|
43827
|
+
//#region src/commands/clearNodes.ts
|
|
43828
|
+
const clearNodes = () => ({ state, tr, dispatch }) => {
|
|
43829
|
+
const { selection } = tr;
|
|
43830
|
+
const { ranges } = selection;
|
|
43831
|
+
if (!dispatch) return true;
|
|
43832
|
+
ranges.forEach(({ $from, $to }) => {
|
|
43833
|
+
state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
43834
|
+
if (node.type.isText) return;
|
|
43835
|
+
const { doc, mapping } = tr;
|
|
43836
|
+
const $mappedFrom = doc.resolve(mapping.map(pos));
|
|
43837
|
+
const $mappedTo = doc.resolve(mapping.map(pos + node.nodeSize));
|
|
43838
|
+
const nodeRange = $mappedFrom.blockRange($mappedTo);
|
|
43839
|
+
if (!nodeRange) return;
|
|
43840
|
+
const targetLiftDepth = liftTarget(nodeRange);
|
|
43841
|
+
if (node.type.isTextblock) {
|
|
43842
|
+
const { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index());
|
|
43843
|
+
tr.setNodeMarkup(nodeRange.start, defaultType);
|
|
43844
|
+
}
|
|
43845
|
+
if (targetLiftDepth || targetLiftDepth === 0) tr.lift(nodeRange, targetLiftDepth);
|
|
43846
|
+
});
|
|
43847
|
+
});
|
|
43848
|
+
return true;
|
|
43849
|
+
};
|
|
43850
|
+
//#endregion
|
|
43851
|
+
//#region src/commands/command.ts
|
|
43852
|
+
const command = (fn) => (props) => {
|
|
43853
|
+
return fn(props);
|
|
43854
|
+
};
|
|
43855
|
+
//#endregion
|
|
43856
|
+
//#region src/commands/createParagraphNear.ts
|
|
43857
|
+
const createParagraphNear$1 = () => ({ state, dispatch }) => {
|
|
43858
|
+
return createParagraphNear(state, dispatch);
|
|
43859
|
+
};
|
|
43860
|
+
//#endregion
|
|
43861
|
+
//#region src/commands/cut.ts
|
|
43862
|
+
const cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
43863
|
+
const { state } = editor;
|
|
43864
|
+
const contentSlice = state.doc.slice(originRange.from, originRange.to);
|
|
43865
|
+
tr.deleteRange(originRange.from, originRange.to);
|
|
43866
|
+
const newPos = tr.mapping.map(targetPos);
|
|
43867
|
+
tr.insert(newPos, contentSlice.content);
|
|
43868
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(Math.max(newPos - 1, 0))));
|
|
43869
|
+
return true;
|
|
43870
|
+
};
|
|
43871
|
+
//#endregion
|
|
43872
|
+
//#region src/commands/deleteCurrentNode.ts
|
|
43873
|
+
const deleteCurrentNode = () => ({ tr, dispatch }) => {
|
|
43874
|
+
const { selection } = tr;
|
|
43875
|
+
const currentNode = selection.$anchor.node();
|
|
43876
|
+
if (currentNode.content.size > 0) return false;
|
|
43877
|
+
const $pos = tr.selection.$anchor;
|
|
43878
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === currentNode.type) {
|
|
43879
|
+
if (dispatch) {
|
|
43880
|
+
const from = $pos.before(depth);
|
|
43881
|
+
const to = $pos.after(depth);
|
|
43882
|
+
tr.delete(from, to).scrollIntoView();
|
|
43883
|
+
}
|
|
43884
|
+
return true;
|
|
43885
|
+
}
|
|
43886
|
+
return false;
|
|
43887
|
+
};
|
|
43888
|
+
//#endregion
|
|
43889
|
+
//#region src/helpers/getNodeType.ts
|
|
43890
|
+
function getNodeType(nameOrType, schema) {
|
|
43891
|
+
if (typeof nameOrType === "string") {
|
|
43892
|
+
if (!schema.nodes[nameOrType]) throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`);
|
|
43893
|
+
return schema.nodes[nameOrType];
|
|
43894
|
+
}
|
|
43895
|
+
return nameOrType;
|
|
43896
|
+
}
|
|
43897
|
+
//#endregion
|
|
43898
|
+
//#region src/commands/deleteNode.ts
|
|
43899
|
+
const deleteNode = (typeOrName) => ({ tr, state, dispatch }) => {
|
|
43900
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
43901
|
+
const $pos = tr.selection.$anchor;
|
|
43902
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === type) {
|
|
43903
|
+
if (dispatch) {
|
|
43904
|
+
const from = $pos.before(depth);
|
|
43905
|
+
const to = $pos.after(depth);
|
|
43906
|
+
tr.delete(from, to).scrollIntoView();
|
|
43907
|
+
}
|
|
43908
|
+
return true;
|
|
43909
|
+
}
|
|
43910
|
+
return false;
|
|
43911
|
+
};
|
|
43912
|
+
//#endregion
|
|
43913
|
+
//#region src/commands/deleteRange.ts
|
|
43914
|
+
const deleteRange = (range) => ({ tr, dispatch }) => {
|
|
43915
|
+
const { from, to } = range;
|
|
43916
|
+
if (dispatch) tr.delete(from, to);
|
|
43917
|
+
return true;
|
|
43918
|
+
};
|
|
43919
|
+
//#endregion
|
|
43920
|
+
//#region src/commands/deleteSelection.ts
|
|
43921
|
+
/**
|
|
43922
|
+
* Check if a node has text content based on its content specification.
|
|
43923
|
+
* Returns true if the node's content spec matches text* or text+ patterns.
|
|
43924
|
+
*/
|
|
43925
|
+
const hasTextContent = (nodeSpec) => {
|
|
43926
|
+
if (!nodeSpec.content) return false;
|
|
43927
|
+
return /^text(\*|\+)/.test(nodeSpec.content);
|
|
43928
|
+
};
|
|
43929
|
+
/**
|
|
43930
|
+
* Expand selection position for a specific side (left or right) to handle inline text nodes.
|
|
43931
|
+
* This function checks if the position is within an inline node with text content and
|
|
43932
|
+
* expands it to include the entire node boundaries for proper deletion.
|
|
43933
|
+
* @param $pos - The resolved position to expand
|
|
43934
|
+
* @param schema - The ProseMirror schema
|
|
43935
|
+
* @param side - Which side to expand ('left' or 'right')
|
|
43936
|
+
* @returns The expanded position for deletion
|
|
43937
|
+
*/
|
|
43938
|
+
const expandSelectionForSide = ($pos, schema, side) => {
|
|
43939
|
+
if (!$pos.parent.isInline) return $pos.pos;
|
|
43940
|
+
if (side === "left" && $pos.pos > $pos.start() || side === "right" && $pos.pos < $pos.end()) return $pos.pos;
|
|
43941
|
+
const parentContent = schema.nodes[$pos.parent.type.name].spec;
|
|
43942
|
+
if (!hasTextContent(parentContent)) return $pos.pos;
|
|
43943
|
+
return side === "left" ? $pos.start() - 1 : $pos.end() + 1;
|
|
43944
|
+
};
|
|
43945
|
+
/**
|
|
43946
|
+
* Expand selection range to properly handle deletion of inline text nodes.
|
|
43947
|
+
* Inline text nodes don't collapse correctly when text inside is deleted,
|
|
43948
|
+
* so we need to expand the selection to include the entire node.
|
|
43949
|
+
* See: https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1365
|
|
43950
|
+
*/
|
|
43951
|
+
const expandSelectionForInlineText = ($from, $to, schema) => {
|
|
43952
|
+
return {
|
|
43953
|
+
from: expandSelectionForSide($from, schema, "left"),
|
|
43954
|
+
to: expandSelectionForSide($to, schema, "right")
|
|
43955
|
+
};
|
|
43956
|
+
};
|
|
43957
|
+
const deleteSelection = () => ({ state, dispatch }) => {
|
|
43958
|
+
if (state.selection.empty) return false;
|
|
43959
|
+
if (dispatch) {
|
|
43960
|
+
const tr = state.tr;
|
|
43961
|
+
const { ranges } = state.selection;
|
|
43962
|
+
const mapFrom = tr.steps.length;
|
|
43963
|
+
ranges.forEach((range) => {
|
|
43964
|
+
const mapping = tr.mapping.slice(mapFrom);
|
|
43965
|
+
const $from = tr.doc.resolve(mapping.map(range.$from.pos));
|
|
43966
|
+
const $to = tr.doc.resolve(mapping.map(range.$to.pos));
|
|
43967
|
+
const { from, to } = expandSelectionForInlineText($from, $to, state.schema);
|
|
43968
|
+
tr.deleteRange(from, to);
|
|
43969
|
+
});
|
|
43970
|
+
if (!tr.selection.empty) tr.setSelection(TextSelection.near(tr.doc.resolve(tr.selection.from)));
|
|
43971
|
+
tr.scrollIntoView();
|
|
43972
|
+
dispatch(tr);
|
|
43973
|
+
}
|
|
43974
|
+
return true;
|
|
43975
|
+
};
|
|
43976
|
+
//#endregion
|
|
43211
43977
|
//#region src/commands/enter.ts
|
|
43212
43978
|
const enter = () => ({ commands }) => {
|
|
43213
43979
|
return commands.keyboardShortcut("Enter");
|
|
@@ -43680,11 +44446,21 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
43680
44446
|
return joinForward(state, dispatch);
|
|
43681
44447
|
};
|
|
43682
44448
|
//#endregion
|
|
44449
|
+
//#region src/commands/canJoinItemsAt.ts
|
|
44450
|
+
const canJoinItemsAt = (doc, pos) => {
|
|
44451
|
+
const $pos = doc.resolve(pos);
|
|
44452
|
+
const before = $pos.nodeBefore;
|
|
44453
|
+
const after = $pos.nodeAfter;
|
|
44454
|
+
if (!before || !after) return false;
|
|
44455
|
+
return !before.type.spec.isolating && !after.type.spec.isolating;
|
|
44456
|
+
};
|
|
44457
|
+
//#endregion
|
|
43683
44458
|
//#region src/commands/joinItemBackward.ts
|
|
43684
44459
|
const joinItemBackward = () => ({ state, dispatch, tr }) => {
|
|
43685
44460
|
try {
|
|
43686
44461
|
const point = joinPoint(state.doc, state.selection.$from.pos, -1);
|
|
43687
44462
|
if (point === null || point === void 0) return false;
|
|
44463
|
+
if (!canJoinItemsAt(state.doc, point)) return false;
|
|
43688
44464
|
tr.join(point, 2);
|
|
43689
44465
|
if (dispatch) dispatch(tr);
|
|
43690
44466
|
return true;
|
|
@@ -43698,6 +44474,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
43698
44474
|
try {
|
|
43699
44475
|
const point = joinPoint(state.doc, state.selection.$from.pos, 1);
|
|
43700
44476
|
if (point === null || point === void 0) return false;
|
|
44477
|
+
if (!canJoinItemsAt(state.doc, point)) return false;
|
|
43701
44478
|
tr.join(point, 2);
|
|
43702
44479
|
if (dispatch) dispatch(tr);
|
|
43703
44480
|
return true;
|
|
@@ -45104,8 +45881,14 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45104
45881
|
type: deflt,
|
|
45105
45882
|
attrs: newAttributes
|
|
45106
45883
|
}] : void 0;
|
|
45107
|
-
|
|
45108
|
-
|
|
45884
|
+
const deletedTr = selection instanceof TextSelection && !selection.empty ? EditorState.create({
|
|
45885
|
+
doc: tr.doc,
|
|
45886
|
+
selection
|
|
45887
|
+
}).tr.deleteSelection() : null;
|
|
45888
|
+
const splitDoc = deletedTr ? deletedTr.doc : tr.doc;
|
|
45889
|
+
const splitPos = deletedTr ? deletedTr.mapping.map($from.pos) : $from.pos;
|
|
45890
|
+
let can = canSplit(splitDoc, splitPos, 1, types);
|
|
45891
|
+
if (!types && !can && canSplit(splitDoc, splitPos, 1, deflt ? [{ type: deflt }] : void 0)) {
|
|
45109
45892
|
can = true;
|
|
45110
45893
|
types = deflt ? [{
|
|
45111
45894
|
type: deflt,
|
|
@@ -45114,12 +45897,13 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45114
45897
|
}
|
|
45115
45898
|
if (dispatch) {
|
|
45116
45899
|
if (can) {
|
|
45900
|
+
const mapFrom = tr.steps.length;
|
|
45117
45901
|
if (selection instanceof TextSelection) tr.deleteSelection();
|
|
45118
|
-
tr.split(tr.mapping.map($from.pos), 1, types);
|
|
45902
|
+
tr.split(tr.mapping.slice(mapFrom).map($from.pos), 1, types);
|
|
45119
45903
|
if (deflt && !atEnd && !$from.parentOffset && $from.parent.type !== deflt) {
|
|
45120
|
-
const first = tr.mapping.map($from.before());
|
|
45904
|
+
const first = tr.mapping.slice(mapFrom).map($from.before());
|
|
45121
45905
|
const $first = tr.doc.resolve(first);
|
|
45122
|
-
if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(tr.mapping.map($from.before()), deflt);
|
|
45906
|
+
if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(tr.mapping.slice(mapFrom).map($from.before()), deflt);
|
|
45123
45907
|
}
|
|
45124
45908
|
}
|
|
45125
45909
|
if (keepMarks) ensureMarks(state, editor.extensionManager.splittableMarks);
|
|
@@ -45172,16 +45956,19 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45172
45956
|
...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
|
|
45173
45957
|
...overrideAttrs
|
|
45174
45958
|
};
|
|
45959
|
+
const splitsAtStartOfItem = $from.parentOffset === 0 && $from.index(-1) === 0;
|
|
45960
|
+
const itemStart = $from.before(-1);
|
|
45175
45961
|
tr.delete($from.pos, $to.pos);
|
|
45962
|
+
const trailingTypeAttributes = splitsAtStartOfItem ? grandParent.attrs : newTypeAttributes;
|
|
45176
45963
|
const types = nextType ? [{
|
|
45177
45964
|
type,
|
|
45178
|
-
attrs:
|
|
45965
|
+
attrs: trailingTypeAttributes
|
|
45179
45966
|
}, {
|
|
45180
45967
|
type: nextType,
|
|
45181
45968
|
attrs: newNextTypeAttributes
|
|
45182
45969
|
}] : [{
|
|
45183
45970
|
type,
|
|
45184
|
-
attrs:
|
|
45971
|
+
attrs: trailingTypeAttributes
|
|
45185
45972
|
}];
|
|
45186
45973
|
if (!canSplit(tr.doc, $from.pos, 2)) return false;
|
|
45187
45974
|
if (dispatch) {
|
|
@@ -45189,6 +45976,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45189
45976
|
const { splittableMarks } = editor.extensionManager;
|
|
45190
45977
|
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
|
|
45191
45978
|
tr.split($from.pos, 2, types).scrollIntoView();
|
|
45979
|
+
if (splitsAtStartOfItem) tr.setNodeMarkup(itemStart, void 0, newTypeAttributes);
|
|
45192
45980
|
if (!marks || !dispatch) return true;
|
|
45193
45981
|
const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
|
|
45194
45982
|
tr.ensureMarks(filteredMarks);
|
|
@@ -46721,55 +47509,106 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
46721
47509
|
}
|
|
46722
47510
|
return result;
|
|
46723
47511
|
};
|
|
47512
|
+
/**
|
|
47513
|
+
* Prepares the typed text so the rule handler can inspect the resulting document.
|
|
47514
|
+
*/
|
|
47515
|
+
function createRuleTransaction(config) {
|
|
47516
|
+
const { editor, from, to, text, insertText } = config;
|
|
47517
|
+
if (!insertText) return {
|
|
47518
|
+
inputTransaction: null,
|
|
47519
|
+
tr: editor.view.state.tr
|
|
47520
|
+
};
|
|
47521
|
+
const inputTransaction = editor.view.state.tr.insertText(text, from, to);
|
|
47522
|
+
return {
|
|
47523
|
+
inputTransaction,
|
|
47524
|
+
tr: EditorState.create({
|
|
47525
|
+
doc: inputTransaction.doc,
|
|
47526
|
+
selection: inputTransaction.selection,
|
|
47527
|
+
storedMarks: inputTransaction.storedMarks
|
|
47528
|
+
}).tr
|
|
47529
|
+
};
|
|
47530
|
+
}
|
|
47531
|
+
/**
|
|
47532
|
+
* Runs a matching rule and dispatches the typed text before its conversion.
|
|
47533
|
+
*/
|
|
47534
|
+
function applyRule(config) {
|
|
47535
|
+
const { editor, from, to, text, rule, match, plugin, insertText } = config;
|
|
47536
|
+
const { view } = editor;
|
|
47537
|
+
const { inputTransaction, tr } = createRuleTransaction({
|
|
47538
|
+
editor,
|
|
47539
|
+
from,
|
|
47540
|
+
to,
|
|
47541
|
+
text,
|
|
47542
|
+
insertText
|
|
47543
|
+
});
|
|
47544
|
+
const inputEnd = inputTransaction ? from + text.length : to;
|
|
47545
|
+
const state = createChainableState({
|
|
47546
|
+
state: view.state,
|
|
47547
|
+
transaction: tr
|
|
47548
|
+
});
|
|
47549
|
+
const range = {
|
|
47550
|
+
from: from - (match[0].length - text.length),
|
|
47551
|
+
to: inputEnd
|
|
47552
|
+
};
|
|
47553
|
+
const { commands, chain, can } = new CommandManager({
|
|
47554
|
+
editor,
|
|
47555
|
+
state
|
|
47556
|
+
});
|
|
47557
|
+
if (rule.handler({
|
|
47558
|
+
state,
|
|
47559
|
+
range,
|
|
47560
|
+
match,
|
|
47561
|
+
commands,
|
|
47562
|
+
chain,
|
|
47563
|
+
can
|
|
47564
|
+
}) === null || !tr.steps.length) return false;
|
|
47565
|
+
if (inputTransaction) {
|
|
47566
|
+
view.dispatch(inputTransaction);
|
|
47567
|
+
if (!view.state.doc.eq(inputTransaction.doc)) return true;
|
|
47568
|
+
}
|
|
47569
|
+
closeHistory(tr);
|
|
47570
|
+
tr.setMeta("inputRule", true);
|
|
47571
|
+
if (rule.undoable) tr.setMeta(plugin, {
|
|
47572
|
+
transform: tr,
|
|
47573
|
+
from,
|
|
47574
|
+
to: inputEnd,
|
|
47575
|
+
text
|
|
47576
|
+
});
|
|
47577
|
+
view.dispatch(tr);
|
|
47578
|
+
return true;
|
|
47579
|
+
}
|
|
47580
|
+
/**
|
|
47581
|
+
* Checks that the part of a match already in the document has matching positions.
|
|
47582
|
+
*/
|
|
47583
|
+
function matchesDocument($from, match, text) {
|
|
47584
|
+
const matchedDocLength = match[0].length - text.length;
|
|
47585
|
+
if (matchedDocLength <= 0) return true;
|
|
47586
|
+
const matchStartOffset = $from.parentOffset - matchedDocLength;
|
|
47587
|
+
return matchStartOffset >= 0 && $from.parent.textBetween(matchStartOffset, $from.parentOffset) === match[0].slice(0, matchedDocLength);
|
|
47588
|
+
}
|
|
46724
47589
|
function run$1$1(config) {
|
|
46725
47590
|
var _ref;
|
|
46726
|
-
const { editor, from, to, text, rules, plugin } = config;
|
|
47591
|
+
const { editor, from, to, text, rules, plugin, insertText } = config;
|
|
46727
47592
|
const { view } = editor;
|
|
46728
47593
|
if (view.composing) return false;
|
|
46729
47594
|
const $from = view.state.doc.resolve(from);
|
|
46730
47595
|
if ($from.parent.type.spec.code || !!((_ref = $from.nodeBefore || $from.nodeAfter) === null || _ref === void 0 ? void 0 : _ref.marks.find((mark) => mark.type.spec.code))) return false;
|
|
46731
|
-
let matched = false;
|
|
46732
47596
|
const textBefore = getTextContentFromNodes($from) + text;
|
|
46733
|
-
|
|
46734
|
-
if (matched) return;
|
|
47597
|
+
for (const rule of rules) {
|
|
46735
47598
|
const match = inputRuleMatcherHandler(textBefore, rule.find);
|
|
46736
|
-
if (!match)
|
|
46737
|
-
|
|
46738
|
-
if (matchedDocLength > 0) {
|
|
46739
|
-
const matchStartOffset = $from.parentOffset - matchedDocLength;
|
|
46740
|
-
if (matchStartOffset < 0 || $from.parent.textBetween(matchStartOffset, $from.parentOffset) !== match[0].slice(0, matchedDocLength)) return;
|
|
46741
|
-
}
|
|
46742
|
-
const tr = view.state.tr;
|
|
46743
|
-
const state = createChainableState({
|
|
46744
|
-
state: view.state,
|
|
46745
|
-
transaction: tr
|
|
46746
|
-
});
|
|
46747
|
-
const range = {
|
|
46748
|
-
from: from - (match[0].length - text.length),
|
|
46749
|
-
to
|
|
46750
|
-
};
|
|
46751
|
-
const { commands, chain, can } = new CommandManager({
|
|
47599
|
+
if (!match || !matchesDocument($from, match, text)) continue;
|
|
47600
|
+
if (applyRule({
|
|
46752
47601
|
editor,
|
|
46753
|
-
state
|
|
46754
|
-
});
|
|
46755
|
-
if (rule.handler({
|
|
46756
|
-
state,
|
|
46757
|
-
range,
|
|
46758
|
-
match,
|
|
46759
|
-
commands,
|
|
46760
|
-
chain,
|
|
46761
|
-
can
|
|
46762
|
-
}) === null || !tr.steps.length) return;
|
|
46763
|
-
if (rule.undoable) tr.setMeta(plugin, {
|
|
46764
|
-
transform: tr,
|
|
46765
47602
|
from,
|
|
46766
47603
|
to,
|
|
46767
|
-
text
|
|
46768
|
-
|
|
46769
|
-
|
|
46770
|
-
|
|
46771
|
-
|
|
46772
|
-
|
|
47604
|
+
text,
|
|
47605
|
+
rule,
|
|
47606
|
+
match,
|
|
47607
|
+
plugin,
|
|
47608
|
+
insertText
|
|
47609
|
+
})) return true;
|
|
47610
|
+
}
|
|
47611
|
+
return false;
|
|
46773
47612
|
}
|
|
46774
47613
|
/**
|
|
46775
47614
|
* Create an input rules plugin. When enabled, it will cause text
|
|
@@ -46813,7 +47652,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
46813
47652
|
to,
|
|
46814
47653
|
text,
|
|
46815
47654
|
rules,
|
|
46816
|
-
plugin
|
|
47655
|
+
plugin,
|
|
47656
|
+
insertText: true
|
|
46817
47657
|
});
|
|
46818
47658
|
},
|
|
46819
47659
|
handleDOMEvents: { compositionend: (view) => {
|
|
@@ -47049,6 +47889,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
47049
47889
|
pasteEvent = typeof ClipboardEvent !== "undefined" ? new ClipboardEvent("paste") : null;
|
|
47050
47890
|
return tr;
|
|
47051
47891
|
};
|
|
47892
|
+
editor.on("destroy", () => {
|
|
47893
|
+
if (tiptapDragFromOtherEditor === editor) tiptapDragFromOtherEditor = null;
|
|
47894
|
+
});
|
|
47052
47895
|
return rules.map((rule) => {
|
|
47053
47896
|
return new Plugin({
|
|
47054
47897
|
view(view) {
|
|
@@ -47074,6 +47917,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
47074
47917
|
if (!isDroppedFromProseMirror) {
|
|
47075
47918
|
const dragFromOtherEditor = tiptapDragFromOtherEditor;
|
|
47076
47919
|
if (dragFromOtherEditor === null || dragFromOtherEditor === void 0 ? void 0 : dragFromOtherEditor.isEditable) setTimeout(() => {
|
|
47920
|
+
if (dragFromOtherEditor.isDestroyed) return;
|
|
47077
47921
|
const selection = dragFromOtherEditor.state.selection;
|
|
47078
47922
|
if (selection) dragFromOtherEditor.commands.deleteRange({
|
|
47079
47923
|
from: selection.from,
|
|
@@ -48243,7 +49087,10 @@ img.ProseMirror-separator {
|
|
|
48243
49087
|
...options
|
|
48244
49088
|
};
|
|
48245
49089
|
if (!this.editorView || !this.state || this.isDestroyed) return;
|
|
48246
|
-
if (this.options.editorProps) this.view.setProps(
|
|
49090
|
+
if (this.options.editorProps) this.view.setProps({
|
|
49091
|
+
...this.options.editorProps,
|
|
49092
|
+
attributes: this.getEditorViewAttributes()
|
|
49093
|
+
});
|
|
48247
49094
|
this.view.updateState(this.state);
|
|
48248
49095
|
}
|
|
48249
49096
|
/**
|
|
@@ -48399,6 +49246,23 @@ img.ProseMirror-separator {
|
|
|
48399
49246
|
return doc;
|
|
48400
49247
|
}
|
|
48401
49248
|
/**
|
|
49249
|
+
* Returns the attributes for the editor element.
|
|
49250
|
+
* Merges the default `role="textbox"` with the attributes from `editorProps`,
|
|
49251
|
+
* so the role is kept no matter when the props are applied.
|
|
49252
|
+
*/
|
|
49253
|
+
getEditorViewAttributes() {
|
|
49254
|
+
var _this$options$editorP;
|
|
49255
|
+
const attributes = (_this$options$editorP = this.options.editorProps) === null || _this$options$editorP === void 0 ? void 0 : _this$options$editorP.attributes;
|
|
49256
|
+
if (isFunction$3(attributes)) return (state) => ({
|
|
49257
|
+
role: "textbox",
|
|
49258
|
+
...attributes(state)
|
|
49259
|
+
});
|
|
49260
|
+
return {
|
|
49261
|
+
role: "textbox",
|
|
49262
|
+
...attributes
|
|
49263
|
+
};
|
|
49264
|
+
}
|
|
49265
|
+
/**
|
|
48402
49266
|
* Creates a ProseMirror view.
|
|
48403
49267
|
*/
|
|
48404
49268
|
createView(element) {
|
|
@@ -48409,10 +49273,7 @@ img.ProseMirror-separator {
|
|
|
48409
49273
|
const transformPastedHTML = this.extensionManager.transformPastedHTML(baseTransformPastedHTML);
|
|
48410
49274
|
this.editorView = new EditorView(element, {
|
|
48411
49275
|
...editorProps,
|
|
48412
|
-
attributes:
|
|
48413
|
-
role: "textbox",
|
|
48414
|
-
...editorProps === null || editorProps === void 0 ? void 0 : editorProps.attributes
|
|
48415
|
-
},
|
|
49276
|
+
attributes: this.getEditorViewAttributes(),
|
|
48416
49277
|
dispatchTransaction: dispatch,
|
|
48417
49278
|
transformPastedHTML,
|
|
48418
49279
|
state: this.editorState,
|
|
@@ -58115,7 +58976,7 @@ img.ProseMirror-separator {
|
|
|
58115
58976
|
toDOM() { return ["div", ["hr"]]; }
|
|
58116
58977
|
},
|
|
58117
58978
|
heading: {
|
|
58118
|
-
attrs: { level: { default: 1 } },
|
|
58979
|
+
attrs: { level: { default: 1, validate: "number" } },
|
|
58119
58980
|
content: "(text | image)*",
|
|
58120
58981
|
group: "block",
|
|
58121
58982
|
defining: true,
|
|
@@ -58125,7 +58986,7 @@ img.ProseMirror-separator {
|
|
|
58125
58986
|
{ tag: "h4", attrs: { level: 4 } },
|
|
58126
58987
|
{ tag: "h5", attrs: { level: 5 } },
|
|
58127
58988
|
{ tag: "h6", attrs: { level: 6 } }],
|
|
58128
|
-
toDOM(node) { return ["h" + node.attrs.level, 0]; }
|
|
58989
|
+
toDOM(node) { return ["h" + +node.attrs.level, 0]; }
|
|
58129
58990
|
},
|
|
58130
58991
|
code_block: {
|
|
58131
58992
|
content: "text*",
|
|
@@ -61622,8 +62483,27 @@ img.ProseMirror-separator {
|
|
|
61622
62483
|
const UNICODE_WHITESPACE_PATTERN = "[\0- \xA0 -\u2029 ]";
|
|
61623
62484
|
const UNICODE_WHITESPACE_REGEX = new RegExp(UNICODE_WHITESPACE_PATTERN);
|
|
61624
62485
|
const UNICODE_WHITESPACE_REGEX_END = new RegExp(`${UNICODE_WHITESPACE_PATTERN}$`);
|
|
62486
|
+
const UNICODE_WHITESPACE_REGEX_TRAILING = new RegExp(`${UNICODE_WHITESPACE_PATTERN}+$`);
|
|
61625
62487
|
const UNICODE_WHITESPACE_REGEX_GLOBAL = new RegExp(UNICODE_WHITESPACE_PATTERN, "g");
|
|
61626
62488
|
//#endregion
|
|
62489
|
+
//#region src/helpers/unlinkTrailingWhitespace.ts
|
|
62490
|
+
function unlinkTrailingWhitespace(tr, range, type) {
|
|
62491
|
+
var _rangeEnd$nodeBefore, _insertedText$match;
|
|
62492
|
+
const rangeEnd = tr.doc.resolve(range.to);
|
|
62493
|
+
if (!((_rangeEnd$nodeBefore = rangeEnd.nodeBefore) === null || _rangeEnd$nodeBefore === void 0 ? void 0 : _rangeEnd$nodeBefore.isText)) return;
|
|
62494
|
+
const trailingWhitespace = (_insertedText$match = tr.doc.textBetween(range.from, range.to, "", "").match(UNICODE_WHITESPACE_REGEX_TRAILING)) === null || _insertedText$match === void 0 ? void 0 : _insertedText$match[0];
|
|
62495
|
+
if (!trailingWhitespace) return;
|
|
62496
|
+
const whitespaceFrom = range.to - trailingWhitespace.length;
|
|
62497
|
+
const linkMarks = getMarksBetween(whitespaceFrom, range.to, tr.doc).filter((item) => item.mark.type === type);
|
|
62498
|
+
if (!linkMarks.length) return;
|
|
62499
|
+
const { nodeAfter } = rangeEnd;
|
|
62500
|
+
if (!!nodeAfter && linkMarks.some((item) => item.mark.isInSet(nodeAfter.marks))) return;
|
|
62501
|
+
const storedMarks = tr.storedMarks;
|
|
62502
|
+
tr.removeMark(whitespaceFrom, range.to, type);
|
|
62503
|
+
tr.setStoredMarks(storedMarks);
|
|
62504
|
+
if (tr.selection.empty && tr.selection.from === range.to) tr.removeStoredMark(type);
|
|
62505
|
+
}
|
|
62506
|
+
//#endregion
|
|
61627
62507
|
//#region src/helpers/autolink.ts
|
|
61628
62508
|
/**
|
|
61629
62509
|
* Check if the provided tokens form a valid link structure, which can either be a single link token
|
|
@@ -61664,6 +62544,21 @@ img.ProseMirror-separator {
|
|
|
61664
62544
|
if (!docChanges || preventAutolink) return;
|
|
61665
62545
|
const { tr } = newState;
|
|
61666
62546
|
const transform = combineTransactionSteps(oldState.doc, [...transactions]);
|
|
62547
|
+
if (!transactions.some(isHistoryTransaction)) {
|
|
62548
|
+
const insertedRanges = [];
|
|
62549
|
+
transform.steps.forEach((step, index) => {
|
|
62550
|
+
if (!(step instanceof ReplaceStep) || !step.slice.size) return;
|
|
62551
|
+
const mapping = transform.mapping.slice(index + 1);
|
|
62552
|
+
const from = mapping.map(step.from, 1);
|
|
62553
|
+
const to = mapping.map(step.from + step.slice.size, -1);
|
|
62554
|
+
if (from < to) insertedRanges.push({
|
|
62555
|
+
from,
|
|
62556
|
+
to
|
|
62557
|
+
});
|
|
62558
|
+
});
|
|
62559
|
+
insertedRanges.sort((left, right) => right.to - left.to);
|
|
62560
|
+
insertedRanges.forEach((range) => unlinkTrailingWhitespace(tr, range, options.type));
|
|
62561
|
+
}
|
|
61667
62562
|
getChangedRanges(transform).forEach(({ newRange }) => {
|
|
61668
62563
|
const nodesInChangedRanges = findChildrenInRange(newState.doc, newRange, (node) => node.isTextblock);
|
|
61669
62564
|
let textBlock;
|
|
@@ -63050,6 +63945,54 @@ img.ProseMirror-separator {
|
|
|
63050
63945
|
});
|
|
63051
63946
|
}
|
|
63052
63947
|
//#endregion
|
|
63948
|
+
//#region src/ordered-list/collectOrderedListItemsFromSource.ts
|
|
63949
|
+
const ORDERED_LIST_SCAN_WINDOW = 64;
|
|
63950
|
+
function takeLines(source, max) {
|
|
63951
|
+
const lines = [];
|
|
63952
|
+
let start = 0;
|
|
63953
|
+
while (lines.length < max) {
|
|
63954
|
+
const lineEnd = source.indexOf("\n", start);
|
|
63955
|
+
if (lineEnd === -1) {
|
|
63956
|
+
lines.push(source.slice(start));
|
|
63957
|
+
return lines;
|
|
63958
|
+
}
|
|
63959
|
+
lines.push(source.slice(start, lineEnd));
|
|
63960
|
+
start = lineEnd + 1;
|
|
63961
|
+
}
|
|
63962
|
+
return lines;
|
|
63963
|
+
}
|
|
63964
|
+
/**
|
|
63965
|
+
* Collect ordered list items from the start of `source`, reading only the lines the list needs.
|
|
63966
|
+
*
|
|
63967
|
+
* @param source Markdown beginning at a block boundary.
|
|
63968
|
+
* @returns The items, how many lines they consumed, and the lines that were read.
|
|
63969
|
+
* @example
|
|
63970
|
+
* collectOrderedListItemsFromSource('1. one\n2. two\n\nAfter')
|
|
63971
|
+
* // → [[item, item], 3, ['1. one', '2. two', '', 'After']]
|
|
63972
|
+
*/
|
|
63973
|
+
function collectOrderedListItemsFromSource(source) {
|
|
63974
|
+
const firstLineEnd = source.indexOf("\n");
|
|
63975
|
+
const firstLine = firstLineEnd === -1 ? source : source.slice(0, firstLineEnd);
|
|
63976
|
+
if (!ORDERED_LIST_ITEM_REGEX.test(firstLine)) return [
|
|
63977
|
+
[],
|
|
63978
|
+
0,
|
|
63979
|
+
[]
|
|
63980
|
+
];
|
|
63981
|
+
let windowSize = ORDERED_LIST_SCAN_WINDOW;
|
|
63982
|
+
let lines = takeLines(source, windowSize);
|
|
63983
|
+
let collected = collectOrderedListItems(lines);
|
|
63984
|
+
while (collected[1] === lines.length && lines.length === windowSize) {
|
|
63985
|
+
windowSize *= 2;
|
|
63986
|
+
lines = takeLines(source, windowSize);
|
|
63987
|
+
collected = collectOrderedListItems(lines);
|
|
63988
|
+
}
|
|
63989
|
+
return [
|
|
63990
|
+
collected[0],
|
|
63991
|
+
collected[1],
|
|
63992
|
+
lines
|
|
63993
|
+
];
|
|
63994
|
+
}
|
|
63995
|
+
//#endregion
|
|
63053
63996
|
//#region src/ordered-list/ordered-list.ts
|
|
63054
63997
|
const ListItemName = "listItem";
|
|
63055
63998
|
const TextStyleName = "textStyle";
|
|
@@ -63168,8 +64111,7 @@ img.ProseMirror-separator {
|
|
|
63168
64111
|
start: () => -1,
|
|
63169
64112
|
tokenize: (src, _tokens, lexer) => {
|
|
63170
64113
|
var _listItems$, _listItems$2;
|
|
63171
|
-
const lines = src
|
|
63172
|
-
const [listItems, consumed] = collectOrderedListItems(lines);
|
|
64114
|
+
const [listItems, consumed, lines] = collectOrderedListItemsFromSource(src);
|
|
63173
64115
|
if (listItems.length === 0) return;
|
|
63174
64116
|
const items = buildNestedStructure(listItems, listItems[0].indent, lexer);
|
|
63175
64117
|
if (items.length === 0) return;
|
|
@@ -65942,1026 +66884,412 @@ img.ProseMirror-separator {
|
|
|
65942
66884
|
* This extension allows you to create text nodes.
|
|
65943
66885
|
* @see https://www.tiptap.dev/api/nodes/text
|
|
65944
66886
|
*/
|
|
65945
|
-
const Text = Node$1.create({
|
|
65946
|
-
name: "text",
|
|
65947
|
-
group: "inline",
|
|
65948
|
-
parseMarkdown: (token) => {
|
|
65949
|
-
return {
|
|
65950
|
-
type: "text",
|
|
65951
|
-
text: token.text || ""
|
|
65952
|
-
};
|
|
65953
|
-
},
|
|
65954
|
-
renderMarkdown: (node) => node.text || ""
|
|
65955
|
-
});
|
|
65956
|
-
//#endregion
|
|
65957
|
-
//#region src/index.ts
|
|
65958
|
-
var src_default = Text;
|
|
65959
|
-
|
|
65960
|
-
/**
|
|
65961
|
-
Create a plugin that, when added to a ProseMirror instance,
|
|
65962
|
-
causes a decoration to show up at the drop position when something
|
|
65963
|
-
is dragged over the editor.
|
|
65964
|
-
|
|
65965
|
-
Nodes may add a `disableDropCursor` property to their spec to
|
|
65966
|
-
control the showing of a drop cursor inside them. This may be a
|
|
65967
|
-
boolean or a function, which will be called with a view and a
|
|
65968
|
-
position, and should return a boolean.
|
|
65969
|
-
*/
|
|
65970
|
-
function dropCursor(options = {}) {
|
|
65971
|
-
return new Plugin({
|
|
65972
|
-
view(editorView) { return new DropCursorView(editorView, options); }
|
|
65973
|
-
});
|
|
65974
|
-
}
|
|
65975
|
-
class DropCursorView {
|
|
65976
|
-
constructor(editorView, options) {
|
|
65977
|
-
var _a;
|
|
65978
|
-
this.editorView = editorView;
|
|
65979
|
-
this.cursorPos = null;
|
|
65980
|
-
this.element = null;
|
|
65981
|
-
this.timeout = -1;
|
|
65982
|
-
this.lastDragEvent = null;
|
|
65983
|
-
this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
|
|
65984
|
-
this.color = options.color === false ? undefined : (options.color || "black");
|
|
65985
|
-
this.class = options.class;
|
|
65986
|
-
this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(name => {
|
|
65987
|
-
let handler = (e) => { this[name](e); };
|
|
65988
|
-
editorView.dom.addEventListener(name, handler);
|
|
65989
|
-
return { name, handler };
|
|
65990
|
-
});
|
|
65991
|
-
}
|
|
65992
|
-
destroy() {
|
|
65993
|
-
this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
|
|
65994
|
-
}
|
|
65995
|
-
update(editorView, prevState) {
|
|
65996
|
-
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
|
|
65997
|
-
// if we currently have an on-going drag event
|
|
65998
|
-
// we need to update the cursor position again and update the overlay
|
|
65999
|
-
if (this.lastDragEvent) {
|
|
66000
|
-
let target = this.computeTarget(this.lastDragEvent);
|
|
66001
|
-
if (target == this.cursorPos)
|
|
66002
|
-
this.updateOverlay();
|
|
66003
|
-
else
|
|
66004
|
-
this.setCursor(target);
|
|
66005
|
-
}
|
|
66006
|
-
else {
|
|
66007
|
-
this.updateOverlay();
|
|
66008
|
-
}
|
|
66009
|
-
}
|
|
66010
|
-
}
|
|
66011
|
-
setCursor(pos) {
|
|
66012
|
-
if (pos == this.cursorPos)
|
|
66013
|
-
return;
|
|
66014
|
-
this.cursorPos = pos;
|
|
66015
|
-
if (pos == null) {
|
|
66016
|
-
this.element.parentNode.removeChild(this.element);
|
|
66017
|
-
this.element = null;
|
|
66018
|
-
}
|
|
66019
|
-
else {
|
|
66020
|
-
this.updateOverlay();
|
|
66021
|
-
}
|
|
66022
|
-
}
|
|
66023
|
-
updateOverlay() {
|
|
66024
|
-
let $pos = this.editorView.state.doc.resolve(this.cursorPos);
|
|
66025
|
-
let isBlock = !$pos.parent.inlineContent, rect;
|
|
66026
|
-
let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
|
|
66027
|
-
let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
|
|
66028
|
-
if (isBlock) {
|
|
66029
|
-
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
66030
|
-
if (before || after) {
|
|
66031
|
-
let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
|
|
66032
|
-
if (node) {
|
|
66033
|
-
let nodeRect = node.getBoundingClientRect();
|
|
66034
|
-
let top = before ? nodeRect.bottom : nodeRect.top;
|
|
66035
|
-
if (before && after)
|
|
66036
|
-
top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
|
|
66037
|
-
let halfWidth = (this.width / 2) * scaleY;
|
|
66038
|
-
rect = { left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth };
|
|
66039
|
-
}
|
|
66040
|
-
}
|
|
66041
|
-
}
|
|
66042
|
-
if (!rect) {
|
|
66043
|
-
let coords = this.editorView.coordsAtPos(this.cursorPos);
|
|
66044
|
-
let halfWidth = (this.width / 2) * scaleX;
|
|
66045
|
-
rect = { left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom };
|
|
66046
|
-
}
|
|
66047
|
-
let parent = this.editorView.dom.offsetParent;
|
|
66048
|
-
if (!this.element) {
|
|
66049
|
-
this.element = parent.appendChild(document.createElement("div"));
|
|
66050
|
-
if (this.class)
|
|
66051
|
-
this.element.className = this.class;
|
|
66052
|
-
this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
|
|
66053
|
-
if (this.color) {
|
|
66054
|
-
this.element.style.backgroundColor = this.color;
|
|
66055
|
-
}
|
|
66056
|
-
}
|
|
66057
|
-
this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
|
|
66058
|
-
this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
|
|
66059
|
-
let parentLeft, parentTop;
|
|
66060
|
-
if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
|
|
66061
|
-
parentLeft = -pageXOffset;
|
|
66062
|
-
parentTop = -pageYOffset;
|
|
66063
|
-
}
|
|
66064
|
-
else {
|
|
66065
|
-
let rect = parent.getBoundingClientRect();
|
|
66066
|
-
let parentScaleX = rect.width / parent.offsetWidth, parentScaleY = rect.height / parent.offsetHeight;
|
|
66067
|
-
parentLeft = rect.left - parent.scrollLeft * parentScaleX;
|
|
66068
|
-
parentTop = rect.top - parent.scrollTop * parentScaleY;
|
|
66069
|
-
}
|
|
66070
|
-
this.element.style.left = (rect.left - parentLeft) / scaleX + "px";
|
|
66071
|
-
this.element.style.top = (rect.top - parentTop) / scaleY + "px";
|
|
66072
|
-
this.element.style.width = (rect.right - rect.left) / scaleX + "px";
|
|
66073
|
-
this.element.style.height = (rect.bottom - rect.top) / scaleY + "px";
|
|
66074
|
-
}
|
|
66075
|
-
scheduleRemoval(timeout) {
|
|
66076
|
-
clearTimeout(this.timeout);
|
|
66077
|
-
this.timeout = setTimeout(() => this.setCursor(null), timeout);
|
|
66078
|
-
}
|
|
66079
|
-
computeTarget(event) {
|
|
66080
|
-
let pos = this.editorView.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
66081
|
-
let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
|
|
66082
|
-
let disableDropCursor = node && node.type.spec.disableDropCursor;
|
|
66083
|
-
let disabled = typeof disableDropCursor == "function"
|
|
66084
|
-
? disableDropCursor(this.editorView, pos, event)
|
|
66085
|
-
: disableDropCursor;
|
|
66086
|
-
if (!pos || disabled)
|
|
66087
|
-
return null;
|
|
66088
|
-
let target = pos.pos;
|
|
66089
|
-
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
66090
|
-
let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
|
|
66091
|
-
if (point != null)
|
|
66092
|
-
target = point;
|
|
66093
|
-
}
|
|
66094
|
-
return target;
|
|
66095
|
-
}
|
|
66096
|
-
dragover(event) {
|
|
66097
|
-
if (!this.editorView.editable)
|
|
66098
|
-
return;
|
|
66099
|
-
this.lastDragEvent = event;
|
|
66100
|
-
let target = this.computeTarget(event);
|
|
66101
|
-
if (target != null) {
|
|
66102
|
-
this.setCursor(target);
|
|
66103
|
-
this.scheduleRemoval(5000);
|
|
66104
|
-
}
|
|
66105
|
-
}
|
|
66106
|
-
dragend() {
|
|
66107
|
-
this.scheduleRemoval(20);
|
|
66108
|
-
}
|
|
66109
|
-
drop() {
|
|
66110
|
-
this.scheduleRemoval(20);
|
|
66111
|
-
}
|
|
66112
|
-
dragleave(event) {
|
|
66113
|
-
if (!this.editorView.dom.contains(event.relatedTarget))
|
|
66114
|
-
this.setCursor(null);
|
|
66115
|
-
}
|
|
66116
|
-
}
|
|
66117
|
-
|
|
66118
|
-
/**
|
|
66119
|
-
Gap cursor selections are represented using this class. Its
|
|
66120
|
-
`$anchor` and `$head` properties both point at the cursor position.
|
|
66121
|
-
*/
|
|
66122
|
-
class GapCursor extends Selection$2 {
|
|
66123
|
-
/**
|
|
66124
|
-
Create a gap cursor.
|
|
66125
|
-
*/
|
|
66126
|
-
constructor($pos) {
|
|
66127
|
-
super($pos, $pos);
|
|
66128
|
-
}
|
|
66129
|
-
map(doc, mapping) {
|
|
66130
|
-
let $pos = doc.resolve(mapping.map(this.head));
|
|
66131
|
-
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
66132
|
-
}
|
|
66133
|
-
content() { return Slice.empty; }
|
|
66134
|
-
eq(other) {
|
|
66135
|
-
return other instanceof GapCursor && other.head == this.head;
|
|
66136
|
-
}
|
|
66137
|
-
toJSON() {
|
|
66138
|
-
return { type: "gapcursor", pos: this.head };
|
|
66139
|
-
}
|
|
66140
|
-
/**
|
|
66141
|
-
@internal
|
|
66142
|
-
*/
|
|
66143
|
-
static fromJSON(doc, json) {
|
|
66144
|
-
if (typeof json.pos != "number")
|
|
66145
|
-
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
66146
|
-
return new GapCursor(doc.resolve(json.pos));
|
|
66147
|
-
}
|
|
66148
|
-
/**
|
|
66149
|
-
@internal
|
|
66150
|
-
*/
|
|
66151
|
-
getBookmark() { return new GapBookmark(this.anchor); }
|
|
66152
|
-
/**
|
|
66153
|
-
@internal
|
|
66154
|
-
*/
|
|
66155
|
-
static valid($pos) {
|
|
66156
|
-
let parent = $pos.parent;
|
|
66157
|
-
if (parent.inlineContent || !closedBefore($pos) || !closedAfter($pos))
|
|
66158
|
-
return false;
|
|
66159
|
-
let override = parent.type.spec.allowGapCursor;
|
|
66160
|
-
if (override != null)
|
|
66161
|
-
return override;
|
|
66162
|
-
let deflt = parent.contentMatchAt($pos.index()).defaultType;
|
|
66163
|
-
return deflt && deflt.isTextblock;
|
|
66164
|
-
}
|
|
66165
|
-
/**
|
|
66166
|
-
@internal
|
|
66167
|
-
*/
|
|
66168
|
-
static findGapCursorFrom($pos, dir, mustMove = false) {
|
|
66169
|
-
search: for (;;) {
|
|
66170
|
-
if (!mustMove && GapCursor.valid($pos))
|
|
66171
|
-
return $pos;
|
|
66172
|
-
let pos = $pos.pos, next = null;
|
|
66173
|
-
// Scan up from this position
|
|
66174
|
-
for (let d = $pos.depth;; d--) {
|
|
66175
|
-
let parent = $pos.node(d);
|
|
66176
|
-
if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
|
|
66177
|
-
next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
|
|
66178
|
-
break;
|
|
66179
|
-
}
|
|
66180
|
-
else if (d == 0) {
|
|
66181
|
-
return null;
|
|
66182
|
-
}
|
|
66183
|
-
pos += dir;
|
|
66184
|
-
let $cur = $pos.doc.resolve(pos);
|
|
66185
|
-
if (GapCursor.valid($cur))
|
|
66186
|
-
return $cur;
|
|
66187
|
-
}
|
|
66188
|
-
// And then down into the next node
|
|
66189
|
-
for (;;) {
|
|
66190
|
-
let inside = dir > 0 ? next.firstChild : next.lastChild;
|
|
66191
|
-
if (!inside) {
|
|
66192
|
-
if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
|
|
66193
|
-
$pos = $pos.doc.resolve(pos + next.nodeSize * dir);
|
|
66194
|
-
mustMove = false;
|
|
66195
|
-
continue search;
|
|
66196
|
-
}
|
|
66197
|
-
break;
|
|
66198
|
-
}
|
|
66199
|
-
next = inside;
|
|
66200
|
-
pos += dir;
|
|
66201
|
-
let $cur = $pos.doc.resolve(pos);
|
|
66202
|
-
if (GapCursor.valid($cur))
|
|
66203
|
-
return $cur;
|
|
66204
|
-
}
|
|
66205
|
-
return null;
|
|
66206
|
-
}
|
|
66207
|
-
}
|
|
66208
|
-
}
|
|
66209
|
-
GapCursor.prototype.visible = false;
|
|
66210
|
-
GapCursor.findFrom = GapCursor.findGapCursorFrom;
|
|
66211
|
-
Selection$2.jsonID("gapcursor", GapCursor);
|
|
66212
|
-
class GapBookmark {
|
|
66213
|
-
constructor(pos) {
|
|
66214
|
-
this.pos = pos;
|
|
66215
|
-
}
|
|
66216
|
-
map(mapping) {
|
|
66217
|
-
return new GapBookmark(mapping.map(this.pos));
|
|
66218
|
-
}
|
|
66219
|
-
resolve(doc) {
|
|
66220
|
-
let $pos = doc.resolve(this.pos);
|
|
66221
|
-
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
66222
|
-
}
|
|
66223
|
-
}
|
|
66224
|
-
function needsGap(type) {
|
|
66225
|
-
return type.isAtom || type.spec.isolating || type.spec.createGapCursor;
|
|
66226
|
-
}
|
|
66227
|
-
function closedBefore($pos) {
|
|
66228
|
-
for (let d = $pos.depth; d >= 0; d--) {
|
|
66229
|
-
let index = $pos.index(d), parent = $pos.node(d);
|
|
66230
|
-
// At the start of this parent, look at next one
|
|
66231
|
-
if (index == 0) {
|
|
66232
|
-
if (parent.type.spec.isolating)
|
|
66233
|
-
return true;
|
|
66234
|
-
continue;
|
|
66235
|
-
}
|
|
66236
|
-
// See if the node before (or its first ancestor) is closed
|
|
66237
|
-
for (let before = parent.child(index - 1);; before = before.lastChild) {
|
|
66238
|
-
if ((before.childCount == 0 && !before.inlineContent) || needsGap(before.type))
|
|
66239
|
-
return true;
|
|
66240
|
-
if (before.inlineContent)
|
|
66241
|
-
return false;
|
|
66242
|
-
}
|
|
66243
|
-
}
|
|
66244
|
-
// Hit start of document
|
|
66245
|
-
return true;
|
|
66246
|
-
}
|
|
66247
|
-
function closedAfter($pos) {
|
|
66248
|
-
for (let d = $pos.depth; d >= 0; d--) {
|
|
66249
|
-
let index = $pos.indexAfter(d), parent = $pos.node(d);
|
|
66250
|
-
if (index == parent.childCount) {
|
|
66251
|
-
if (parent.type.spec.isolating)
|
|
66252
|
-
return true;
|
|
66253
|
-
continue;
|
|
66254
|
-
}
|
|
66255
|
-
for (let after = parent.child(index);; after = after.firstChild) {
|
|
66256
|
-
if ((after.childCount == 0 && !after.inlineContent) || needsGap(after.type))
|
|
66257
|
-
return true;
|
|
66258
|
-
if (after.inlineContent)
|
|
66259
|
-
return false;
|
|
66260
|
-
}
|
|
66261
|
-
}
|
|
66262
|
-
return true;
|
|
66263
|
-
}
|
|
66887
|
+
const Text = Node$1.create({
|
|
66888
|
+
name: "text",
|
|
66889
|
+
group: "inline",
|
|
66890
|
+
parseMarkdown: (token) => {
|
|
66891
|
+
return {
|
|
66892
|
+
type: "text",
|
|
66893
|
+
text: token.text || ""
|
|
66894
|
+
};
|
|
66895
|
+
},
|
|
66896
|
+
renderMarkdown: (node) => node.text || ""
|
|
66897
|
+
});
|
|
66898
|
+
//#endregion
|
|
66899
|
+
//#region src/index.ts
|
|
66900
|
+
var src_default = Text;
|
|
66264
66901
|
|
|
66265
66902
|
/**
|
|
66266
|
-
Create a
|
|
66267
|
-
|
|
66268
|
-
|
|
66269
|
-
|
|
66270
|
-
`
|
|
66271
|
-
|
|
66272
|
-
|
|
66903
|
+
Create a plugin that, when added to a ProseMirror instance,
|
|
66904
|
+
causes a decoration to show up at the drop position when something
|
|
66905
|
+
is dragged over the editor.
|
|
66906
|
+
|
|
66907
|
+
Nodes may add a `disableDropCursor` property to their spec to
|
|
66908
|
+
control the showing of a drop cursor inside them. This may be a
|
|
66909
|
+
boolean or a function, which will be called with a view and a
|
|
66910
|
+
position, and should return a boolean.
|
|
66273
66911
|
*/
|
|
66274
|
-
function
|
|
66912
|
+
function dropCursor(options = {}) {
|
|
66275
66913
|
return new Plugin({
|
|
66276
|
-
|
|
66277
|
-
decorations: drawGapCursor,
|
|
66278
|
-
createSelectionBetween(_view, $anchor, $head) {
|
|
66279
|
-
return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
|
|
66280
|
-
},
|
|
66281
|
-
handleClick,
|
|
66282
|
-
handleKeyDown,
|
|
66283
|
-
handleDOMEvents: { beforeinput: beforeinput }
|
|
66284
|
-
}
|
|
66914
|
+
view(editorView) { return new DropCursorView(editorView, options); }
|
|
66285
66915
|
});
|
|
66286
66916
|
}
|
|
66287
|
-
|
|
66288
|
-
|
|
66289
|
-
|
|
66290
|
-
|
|
66291
|
-
|
|
66292
|
-
|
|
66293
|
-
|
|
66294
|
-
|
|
66295
|
-
|
|
66296
|
-
|
|
66297
|
-
|
|
66298
|
-
|
|
66299
|
-
|
|
66300
|
-
|
|
66301
|
-
|
|
66302
|
-
|
|
66303
|
-
}
|
|
66304
|
-
let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
|
|
66305
|
-
if (!$found)
|
|
66306
|
-
return false;
|
|
66307
|
-
if (dispatch)
|
|
66308
|
-
dispatch(state.tr.setSelection(new GapCursor($found)));
|
|
66309
|
-
return true;
|
|
66310
|
-
};
|
|
66311
|
-
}
|
|
66312
|
-
function handleClick(view, pos, event) {
|
|
66313
|
-
if (!view || !view.editable)
|
|
66314
|
-
return false;
|
|
66315
|
-
let $pos = view.state.doc.resolve(pos);
|
|
66316
|
-
if (!GapCursor.valid($pos))
|
|
66317
|
-
return false;
|
|
66318
|
-
let clickPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
66319
|
-
if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside)))
|
|
66320
|
-
return false;
|
|
66321
|
-
view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
|
|
66322
|
-
return true;
|
|
66323
|
-
}
|
|
66324
|
-
// This is a hack that, when a composition starts while a gap cursor
|
|
66325
|
-
// is active, quickly creates an inline context for the composition to
|
|
66326
|
-
// happen in, to avoid it being aborted by the DOM selection being
|
|
66327
|
-
// moved into a valid position.
|
|
66328
|
-
function beforeinput(view, event) {
|
|
66329
|
-
if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor))
|
|
66330
|
-
return false;
|
|
66331
|
-
let { $from } = view.state.selection;
|
|
66332
|
-
let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
|
|
66333
|
-
if (!insert)
|
|
66334
|
-
return false;
|
|
66335
|
-
let frag = Fragment.empty;
|
|
66336
|
-
for (let i = insert.length - 1; i >= 0; i--)
|
|
66337
|
-
frag = Fragment.from(insert[i].createAndFill(null, frag));
|
|
66338
|
-
let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
|
|
66339
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
|
|
66340
|
-
view.dispatch(tr);
|
|
66341
|
-
return false;
|
|
66342
|
-
}
|
|
66343
|
-
function drawGapCursor(state) {
|
|
66344
|
-
if (!(state.selection instanceof GapCursor))
|
|
66345
|
-
return null;
|
|
66346
|
-
let node = document.createElement("div");
|
|
66347
|
-
node.className = "ProseMirror-gapcursor";
|
|
66348
|
-
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
|
|
66349
|
-
}
|
|
66350
|
-
|
|
66351
|
-
var GOOD_LEAF_SIZE = 200;
|
|
66352
|
-
|
|
66353
|
-
// :: class<T> A rope sequence is a persistent sequence data structure
|
|
66354
|
-
// that supports appending, prepending, and slicing without doing a
|
|
66355
|
-
// full copy. It is represented as a mostly-balanced tree.
|
|
66356
|
-
var RopeSequence = function RopeSequence () {};
|
|
66357
|
-
|
|
66358
|
-
RopeSequence.prototype.append = function append (other) {
|
|
66359
|
-
if (!other.length) { return this }
|
|
66360
|
-
other = RopeSequence.from(other);
|
|
66361
|
-
|
|
66362
|
-
return (!this.length && other) ||
|
|
66363
|
-
(other.length < GOOD_LEAF_SIZE && this.leafAppend(other)) ||
|
|
66364
|
-
(this.length < GOOD_LEAF_SIZE && other.leafPrepend(this)) ||
|
|
66365
|
-
this.appendInner(other)
|
|
66366
|
-
};
|
|
66367
|
-
|
|
66368
|
-
// :: (union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
66369
|
-
// Prepend an array or other rope to this one, returning a new rope.
|
|
66370
|
-
RopeSequence.prototype.prepend = function prepend (other) {
|
|
66371
|
-
if (!other.length) { return this }
|
|
66372
|
-
return RopeSequence.from(other).append(this)
|
|
66373
|
-
};
|
|
66374
|
-
|
|
66375
|
-
RopeSequence.prototype.appendInner = function appendInner (other) {
|
|
66376
|
-
return new Append(this, other)
|
|
66377
|
-
};
|
|
66378
|
-
|
|
66379
|
-
// :: (?number, ?number) → RopeSequence<T>
|
|
66380
|
-
// Create a rope repesenting a sub-sequence of this rope.
|
|
66381
|
-
RopeSequence.prototype.slice = function slice (from, to) {
|
|
66382
|
-
if ( from === void 0 ) from = 0;
|
|
66383
|
-
if ( to === void 0 ) to = this.length;
|
|
66384
|
-
|
|
66385
|
-
if (from >= to) { return RopeSequence.empty }
|
|
66386
|
-
return this.sliceInner(Math.max(0, from), Math.min(this.length, to))
|
|
66387
|
-
};
|
|
66388
|
-
|
|
66389
|
-
// :: (number) → T
|
|
66390
|
-
// Retrieve the element at the given position from this rope.
|
|
66391
|
-
RopeSequence.prototype.get = function get (i) {
|
|
66392
|
-
if (i < 0 || i >= this.length) { return undefined }
|
|
66393
|
-
return this.getInner(i)
|
|
66394
|
-
};
|
|
66395
|
-
|
|
66396
|
-
// :: ((element: T, index: number) → ?bool, ?number, ?number)
|
|
66397
|
-
// Call the given function for each element between the given
|
|
66398
|
-
// indices. This tends to be more efficient than looping over the
|
|
66399
|
-
// indices and calling `get`, because it doesn't have to descend the
|
|
66400
|
-
// tree for every element.
|
|
66401
|
-
RopeSequence.prototype.forEach = function forEach (f, from, to) {
|
|
66402
|
-
if ( from === void 0 ) from = 0;
|
|
66403
|
-
if ( to === void 0 ) to = this.length;
|
|
66404
|
-
|
|
66405
|
-
if (from <= to)
|
|
66406
|
-
{ this.forEachInner(f, from, to, 0); }
|
|
66407
|
-
else
|
|
66408
|
-
{ this.forEachInvertedInner(f, from, to, 0); }
|
|
66409
|
-
};
|
|
66410
|
-
|
|
66411
|
-
// :: ((element: T, index: number) → U, ?number, ?number) → [U]
|
|
66412
|
-
// Map the given functions over the elements of the rope, producing
|
|
66413
|
-
// a flat array.
|
|
66414
|
-
RopeSequence.prototype.map = function map (f, from, to) {
|
|
66415
|
-
if ( from === void 0 ) from = 0;
|
|
66416
|
-
if ( to === void 0 ) to = this.length;
|
|
66417
|
-
|
|
66418
|
-
var result = [];
|
|
66419
|
-
this.forEach(function (elt, i) { return result.push(f(elt, i)); }, from, to);
|
|
66420
|
-
return result
|
|
66421
|
-
};
|
|
66422
|
-
|
|
66423
|
-
// :: (?union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
66424
|
-
// Create a rope representing the given array, or return the rope
|
|
66425
|
-
// itself if a rope was given.
|
|
66426
|
-
RopeSequence.from = function from (values) {
|
|
66427
|
-
if (values instanceof RopeSequence) { return values }
|
|
66428
|
-
return values && values.length ? new Leaf(values) : RopeSequence.empty
|
|
66429
|
-
};
|
|
66430
|
-
|
|
66431
|
-
var Leaf = /*@__PURE__*/(function (RopeSequence) {
|
|
66432
|
-
function Leaf(values) {
|
|
66433
|
-
RopeSequence.call(this);
|
|
66434
|
-
this.values = values;
|
|
66435
|
-
}
|
|
66436
|
-
|
|
66437
|
-
if ( RopeSequence ) Leaf.__proto__ = RopeSequence;
|
|
66438
|
-
Leaf.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
66439
|
-
Leaf.prototype.constructor = Leaf;
|
|
66440
|
-
|
|
66441
|
-
var prototypeAccessors = { length: { configurable: true },depth: { configurable: true } };
|
|
66442
|
-
|
|
66443
|
-
Leaf.prototype.flatten = function flatten () {
|
|
66444
|
-
return this.values
|
|
66445
|
-
};
|
|
66446
|
-
|
|
66447
|
-
Leaf.prototype.sliceInner = function sliceInner (from, to) {
|
|
66448
|
-
if (from == 0 && to == this.length) { return this }
|
|
66449
|
-
return new Leaf(this.values.slice(from, to))
|
|
66450
|
-
};
|
|
66451
|
-
|
|
66452
|
-
Leaf.prototype.getInner = function getInner (i) {
|
|
66453
|
-
return this.values[i]
|
|
66454
|
-
};
|
|
66455
|
-
|
|
66456
|
-
Leaf.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
66457
|
-
for (var i = from; i < to; i++)
|
|
66458
|
-
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
66459
|
-
};
|
|
66460
|
-
|
|
66461
|
-
Leaf.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
66462
|
-
for (var i = from - 1; i >= to; i--)
|
|
66463
|
-
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
66464
|
-
};
|
|
66465
|
-
|
|
66466
|
-
Leaf.prototype.leafAppend = function leafAppend (other) {
|
|
66467
|
-
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
66468
|
-
{ return new Leaf(this.values.concat(other.flatten())) }
|
|
66469
|
-
};
|
|
66470
|
-
|
|
66471
|
-
Leaf.prototype.leafPrepend = function leafPrepend (other) {
|
|
66472
|
-
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
66473
|
-
{ return new Leaf(other.flatten().concat(this.values)) }
|
|
66474
|
-
};
|
|
66475
|
-
|
|
66476
|
-
prototypeAccessors.length.get = function () { return this.values.length };
|
|
66477
|
-
|
|
66478
|
-
prototypeAccessors.depth.get = function () { return 0 };
|
|
66479
|
-
|
|
66480
|
-
Object.defineProperties( Leaf.prototype, prototypeAccessors );
|
|
66481
|
-
|
|
66482
|
-
return Leaf;
|
|
66483
|
-
}(RopeSequence));
|
|
66484
|
-
|
|
66485
|
-
// :: RopeSequence
|
|
66486
|
-
// The empty rope sequence.
|
|
66487
|
-
RopeSequence.empty = new Leaf([]);
|
|
66488
|
-
|
|
66489
|
-
var Append = /*@__PURE__*/(function (RopeSequence) {
|
|
66490
|
-
function Append(left, right) {
|
|
66491
|
-
RopeSequence.call(this);
|
|
66492
|
-
this.left = left;
|
|
66493
|
-
this.right = right;
|
|
66494
|
-
this.length = left.length + right.length;
|
|
66495
|
-
this.depth = Math.max(left.depth, right.depth) + 1;
|
|
66496
|
-
}
|
|
66497
|
-
|
|
66498
|
-
if ( RopeSequence ) Append.__proto__ = RopeSequence;
|
|
66499
|
-
Append.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
66500
|
-
Append.prototype.constructor = Append;
|
|
66501
|
-
|
|
66502
|
-
Append.prototype.flatten = function flatten () {
|
|
66503
|
-
return this.left.flatten().concat(this.right.flatten())
|
|
66504
|
-
};
|
|
66505
|
-
|
|
66506
|
-
Append.prototype.getInner = function getInner (i) {
|
|
66507
|
-
return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length)
|
|
66508
|
-
};
|
|
66509
|
-
|
|
66510
|
-
Append.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
66511
|
-
var leftLen = this.left.length;
|
|
66512
|
-
if (from < leftLen &&
|
|
66513
|
-
this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false)
|
|
66514
|
-
{ return false }
|
|
66515
|
-
if (to > leftLen &&
|
|
66516
|
-
this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false)
|
|
66517
|
-
{ return false }
|
|
66518
|
-
};
|
|
66519
|
-
|
|
66520
|
-
Append.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
66521
|
-
var leftLen = this.left.length;
|
|
66522
|
-
if (from > leftLen &&
|
|
66523
|
-
this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false)
|
|
66524
|
-
{ return false }
|
|
66525
|
-
if (to < leftLen &&
|
|
66526
|
-
this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false)
|
|
66527
|
-
{ return false }
|
|
66528
|
-
};
|
|
66529
|
-
|
|
66530
|
-
Append.prototype.sliceInner = function sliceInner (from, to) {
|
|
66531
|
-
if (from == 0 && to == this.length) { return this }
|
|
66532
|
-
var leftLen = this.left.length;
|
|
66533
|
-
if (to <= leftLen) { return this.left.slice(from, to) }
|
|
66534
|
-
if (from >= leftLen) { return this.right.slice(from - leftLen, to - leftLen) }
|
|
66535
|
-
return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen))
|
|
66536
|
-
};
|
|
66537
|
-
|
|
66538
|
-
Append.prototype.leafAppend = function leafAppend (other) {
|
|
66539
|
-
var inner = this.right.leafAppend(other);
|
|
66540
|
-
if (inner) { return new Append(this.left, inner) }
|
|
66541
|
-
};
|
|
66542
|
-
|
|
66543
|
-
Append.prototype.leafPrepend = function leafPrepend (other) {
|
|
66544
|
-
var inner = this.left.leafPrepend(other);
|
|
66545
|
-
if (inner) { return new Append(inner, this.right) }
|
|
66546
|
-
};
|
|
66547
|
-
|
|
66548
|
-
Append.prototype.appendInner = function appendInner (other) {
|
|
66549
|
-
if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1)
|
|
66550
|
-
{ return new Append(this.left, new Append(this.right, other)) }
|
|
66551
|
-
return new Append(this, other)
|
|
66552
|
-
};
|
|
66553
|
-
|
|
66554
|
-
return Append;
|
|
66555
|
-
}(RopeSequence));
|
|
66556
|
-
|
|
66557
|
-
// ProseMirror's history isn't simply a way to roll back to a previous
|
|
66558
|
-
// state, because ProseMirror supports applying changes without adding
|
|
66559
|
-
// them to the history (for example during collaboration).
|
|
66560
|
-
//
|
|
66561
|
-
// To this end, each 'Branch' (one for the undo history and one for
|
|
66562
|
-
// the redo history) keeps an array of 'Items', which can optionally
|
|
66563
|
-
// hold a step (an actual undoable change), and always hold a position
|
|
66564
|
-
// map (which is needed to move changes below them to apply to the
|
|
66565
|
-
// current document).
|
|
66566
|
-
//
|
|
66567
|
-
// An item that has both a step and a selection bookmark is the start
|
|
66568
|
-
// of an 'event' — a group of changes that will be undone or redone at
|
|
66569
|
-
// once. (It stores only the bookmark, since that way we don't have to
|
|
66570
|
-
// provide a document until the selection is actually applied, which
|
|
66571
|
-
// is useful when compressing.)
|
|
66572
|
-
// Used to schedule history compression
|
|
66573
|
-
const max_empty_items = 500;
|
|
66574
|
-
class Branch {
|
|
66575
|
-
constructor(items, eventCount) {
|
|
66576
|
-
this.items = items;
|
|
66577
|
-
this.eventCount = eventCount;
|
|
66578
|
-
}
|
|
66579
|
-
// Pop the latest event off the branch's history and apply it
|
|
66580
|
-
// to a document transform.
|
|
66581
|
-
popEvent(state, preserveItems) {
|
|
66582
|
-
if (this.eventCount == 0)
|
|
66583
|
-
return null;
|
|
66584
|
-
let end = this.items.length;
|
|
66585
|
-
for (;; end--) {
|
|
66586
|
-
let next = this.items.get(end - 1);
|
|
66587
|
-
if (next.selection) {
|
|
66588
|
-
--end;
|
|
66589
|
-
break;
|
|
66590
|
-
}
|
|
66591
|
-
}
|
|
66592
|
-
let remap, mapFrom;
|
|
66593
|
-
if (preserveItems) {
|
|
66594
|
-
remap = this.remapping(end, this.items.length);
|
|
66595
|
-
mapFrom = remap.maps.length;
|
|
66596
|
-
}
|
|
66597
|
-
let transform = state.tr;
|
|
66598
|
-
let selection, remaining;
|
|
66599
|
-
let addAfter = [], addBefore = [];
|
|
66600
|
-
this.items.forEach((item, i) => {
|
|
66601
|
-
if (!item.step) {
|
|
66602
|
-
if (!remap) {
|
|
66603
|
-
remap = this.remapping(end, i + 1);
|
|
66604
|
-
mapFrom = remap.maps.length;
|
|
66605
|
-
}
|
|
66606
|
-
mapFrom--;
|
|
66607
|
-
addBefore.push(item);
|
|
66608
|
-
return;
|
|
66609
|
-
}
|
|
66610
|
-
if (remap) {
|
|
66611
|
-
addBefore.push(new Item(item.map));
|
|
66612
|
-
let step = item.step.map(remap.slice(mapFrom)), map;
|
|
66613
|
-
if (step && transform.maybeStep(step).doc) {
|
|
66614
|
-
map = transform.mapping.maps[transform.mapping.maps.length - 1];
|
|
66615
|
-
addAfter.push(new Item(map, undefined, undefined, addAfter.length + addBefore.length));
|
|
66616
|
-
}
|
|
66617
|
-
mapFrom--;
|
|
66618
|
-
if (map)
|
|
66619
|
-
remap.appendMap(map, mapFrom);
|
|
66620
|
-
}
|
|
66621
|
-
else {
|
|
66622
|
-
transform.maybeStep(item.step);
|
|
66623
|
-
}
|
|
66624
|
-
if (item.selection) {
|
|
66625
|
-
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
|
|
66626
|
-
remaining = new Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
|
|
66627
|
-
return false;
|
|
66628
|
-
}
|
|
66629
|
-
}, this.items.length, 0);
|
|
66630
|
-
return { remaining: remaining, transform, selection: selection };
|
|
66631
|
-
}
|
|
66632
|
-
// Create a new branch with the given transform added.
|
|
66633
|
-
addTransform(transform, selection, histOptions, preserveItems) {
|
|
66634
|
-
let newItems = [], eventCount = this.eventCount;
|
|
66635
|
-
let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
|
|
66636
|
-
for (let i = 0; i < transform.steps.length; i++) {
|
|
66637
|
-
let step = transform.steps[i].invert(transform.docs[i]);
|
|
66638
|
-
let item = new Item(transform.mapping.maps[i], step, selection), merged;
|
|
66639
|
-
if (merged = lastItem && lastItem.merge(item)) {
|
|
66640
|
-
item = merged;
|
|
66641
|
-
if (i)
|
|
66642
|
-
newItems.pop();
|
|
66643
|
-
else
|
|
66644
|
-
oldItems = oldItems.slice(0, oldItems.length - 1);
|
|
66645
|
-
}
|
|
66646
|
-
newItems.push(item);
|
|
66647
|
-
if (selection) {
|
|
66648
|
-
eventCount++;
|
|
66649
|
-
selection = undefined;
|
|
66650
|
-
}
|
|
66651
|
-
if (!preserveItems)
|
|
66652
|
-
lastItem = item;
|
|
66653
|
-
}
|
|
66654
|
-
let overflow = eventCount - histOptions.depth;
|
|
66655
|
-
if (overflow > DEPTH_OVERFLOW) {
|
|
66656
|
-
oldItems = cutOffEvents(oldItems, overflow);
|
|
66657
|
-
eventCount -= overflow;
|
|
66658
|
-
}
|
|
66659
|
-
return new Branch(oldItems.append(newItems), eventCount);
|
|
66660
|
-
}
|
|
66661
|
-
remapping(from, to) {
|
|
66662
|
-
let maps = new Mapping;
|
|
66663
|
-
this.items.forEach((item, i) => {
|
|
66664
|
-
let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from
|
|
66665
|
-
? maps.maps.length - item.mirrorOffset : undefined;
|
|
66666
|
-
maps.appendMap(item.map, mirrorPos);
|
|
66667
|
-
}, from, to);
|
|
66668
|
-
return maps;
|
|
66669
|
-
}
|
|
66670
|
-
addMaps(array) {
|
|
66671
|
-
if (this.eventCount == 0)
|
|
66672
|
-
return this;
|
|
66673
|
-
return new Branch(this.items.append(array.map(map => new Item(map))), this.eventCount);
|
|
66674
|
-
}
|
|
66675
|
-
// When the collab module receives remote changes, the history has
|
|
66676
|
-
// to know about those, so that it can adjust the steps that were
|
|
66677
|
-
// rebased on top of the remote changes, and include the position
|
|
66678
|
-
// maps for the remote changes in its array of items.
|
|
66679
|
-
rebased(rebasedTransform, rebasedCount) {
|
|
66680
|
-
if (!this.eventCount)
|
|
66681
|
-
return this;
|
|
66682
|
-
let rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount);
|
|
66683
|
-
let mapping = rebasedTransform.mapping;
|
|
66684
|
-
let newUntil = rebasedTransform.steps.length;
|
|
66685
|
-
let eventCount = this.eventCount;
|
|
66686
|
-
this.items.forEach(item => { if (item.selection)
|
|
66687
|
-
eventCount--; }, start);
|
|
66688
|
-
let iRebased = rebasedCount;
|
|
66689
|
-
this.items.forEach(item => {
|
|
66690
|
-
let pos = mapping.getMirror(--iRebased);
|
|
66691
|
-
if (pos == null)
|
|
66692
|
-
return;
|
|
66693
|
-
newUntil = Math.min(newUntil, pos);
|
|
66694
|
-
let map = mapping.maps[pos];
|
|
66695
|
-
if (item.step) {
|
|
66696
|
-
let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
|
|
66697
|
-
let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
|
|
66698
|
-
if (selection)
|
|
66699
|
-
eventCount++;
|
|
66700
|
-
rebasedItems.push(new Item(map, step, selection));
|
|
66701
|
-
}
|
|
66702
|
-
else {
|
|
66703
|
-
rebasedItems.push(new Item(map));
|
|
66704
|
-
}
|
|
66705
|
-
}, start);
|
|
66706
|
-
let newMaps = [];
|
|
66707
|
-
for (let i = rebasedCount; i < newUntil; i++)
|
|
66708
|
-
newMaps.push(new Item(mapping.maps[i]));
|
|
66709
|
-
let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
|
|
66710
|
-
let branch = new Branch(items, eventCount);
|
|
66711
|
-
if (branch.emptyItemCount() > max_empty_items)
|
|
66712
|
-
branch = branch.compress(this.items.length - rebasedItems.length);
|
|
66713
|
-
return branch;
|
|
66917
|
+
class DropCursorView {
|
|
66918
|
+
constructor(editorView, options) {
|
|
66919
|
+
var _a;
|
|
66920
|
+
this.editorView = editorView;
|
|
66921
|
+
this.cursorPos = null;
|
|
66922
|
+
this.element = null;
|
|
66923
|
+
this.timeout = -1;
|
|
66924
|
+
this.lastDragEvent = null;
|
|
66925
|
+
this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
|
|
66926
|
+
this.color = options.color === false ? undefined : (options.color || "black");
|
|
66927
|
+
this.class = options.class;
|
|
66928
|
+
this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(name => {
|
|
66929
|
+
let handler = (e) => { this[name](e); };
|
|
66930
|
+
editorView.dom.addEventListener(name, handler);
|
|
66931
|
+
return { name, handler };
|
|
66932
|
+
});
|
|
66714
66933
|
}
|
|
66715
|
-
|
|
66716
|
-
|
|
66717
|
-
this.
|
|
66718
|
-
count++; });
|
|
66719
|
-
return count;
|
|
66934
|
+
destroy() {
|
|
66935
|
+
this.setCursor(null);
|
|
66936
|
+
this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
|
|
66720
66937
|
}
|
|
66721
|
-
|
|
66722
|
-
|
|
66723
|
-
|
|
66724
|
-
|
|
66725
|
-
|
|
66726
|
-
|
|
66727
|
-
|
|
66728
|
-
|
|
66729
|
-
|
|
66730
|
-
|
|
66731
|
-
if (i >= upto) {
|
|
66732
|
-
items.push(item);
|
|
66733
|
-
if (item.selection)
|
|
66734
|
-
events++;
|
|
66938
|
+
update(editorView, prevState) {
|
|
66939
|
+
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
|
|
66940
|
+
// if we currently have an on-going drag event
|
|
66941
|
+
// we need to update the cursor position again and update the overlay
|
|
66942
|
+
if (this.lastDragEvent) {
|
|
66943
|
+
let target = this.computeTarget(this.lastDragEvent);
|
|
66944
|
+
if (target == this.cursorPos)
|
|
66945
|
+
this.updateOverlay();
|
|
66946
|
+
else
|
|
66947
|
+
this.setCursor(target);
|
|
66735
66948
|
}
|
|
66736
|
-
else
|
|
66737
|
-
|
|
66738
|
-
|
|
66739
|
-
|
|
66740
|
-
|
|
66741
|
-
|
|
66742
|
-
|
|
66743
|
-
|
|
66744
|
-
|
|
66745
|
-
|
|
66746
|
-
|
|
66747
|
-
|
|
66748
|
-
|
|
66749
|
-
|
|
66949
|
+
else {
|
|
66950
|
+
this.updateOverlay();
|
|
66951
|
+
}
|
|
66952
|
+
}
|
|
66953
|
+
}
|
|
66954
|
+
setCursor(pos) {
|
|
66955
|
+
if (pos == this.cursorPos)
|
|
66956
|
+
return;
|
|
66957
|
+
this.cursorPos = pos;
|
|
66958
|
+
if (pos == null) {
|
|
66959
|
+
this.element.parentNode.removeChild(this.element);
|
|
66960
|
+
this.element = null;
|
|
66961
|
+
}
|
|
66962
|
+
else {
|
|
66963
|
+
this.updateOverlay();
|
|
66964
|
+
}
|
|
66965
|
+
}
|
|
66966
|
+
updateOverlay() {
|
|
66967
|
+
let $pos = this.editorView.state.doc.resolve(this.cursorPos);
|
|
66968
|
+
let isBlock = !$pos.parent.inlineContent, rect;
|
|
66969
|
+
let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
|
|
66970
|
+
let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
|
|
66971
|
+
if (isBlock) {
|
|
66972
|
+
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
66973
|
+
if (before || after) {
|
|
66974
|
+
let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
|
|
66975
|
+
if (node) {
|
|
66976
|
+
let nodeRect = node.getBoundingClientRect();
|
|
66977
|
+
let top = before ? nodeRect.bottom : nodeRect.top;
|
|
66978
|
+
if (before && after)
|
|
66979
|
+
top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
|
|
66980
|
+
let halfWidth = (this.width / 2) * scaleY;
|
|
66981
|
+
rect = { left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth };
|
|
66750
66982
|
}
|
|
66751
66983
|
}
|
|
66752
|
-
|
|
66753
|
-
|
|
66984
|
+
}
|
|
66985
|
+
if (!rect) {
|
|
66986
|
+
let coords = this.editorView.coordsAtPos(this.cursorPos);
|
|
66987
|
+
let halfWidth = (this.width / 2) * scaleX;
|
|
66988
|
+
rect = { left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom };
|
|
66989
|
+
}
|
|
66990
|
+
let parent = this.editorView.dom.offsetParent;
|
|
66991
|
+
if (!this.element) {
|
|
66992
|
+
this.element = parent.appendChild(document.createElement("div"));
|
|
66993
|
+
if (this.class)
|
|
66994
|
+
this.element.className = this.class;
|
|
66995
|
+
this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
|
|
66996
|
+
if (this.color) {
|
|
66997
|
+
this.element.style.backgroundColor = this.color;
|
|
66754
66998
|
}
|
|
66755
|
-
}
|
|
66756
|
-
|
|
66999
|
+
}
|
|
67000
|
+
this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
|
|
67001
|
+
this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
|
|
67002
|
+
let parentLeft, parentTop;
|
|
67003
|
+
if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
|
|
67004
|
+
parentLeft = -pageXOffset;
|
|
67005
|
+
parentTop = -pageYOffset;
|
|
67006
|
+
}
|
|
67007
|
+
else {
|
|
67008
|
+
let rect = parent.getBoundingClientRect();
|
|
67009
|
+
let parentScaleX = rect.width / parent.offsetWidth, parentScaleY = rect.height / parent.offsetHeight;
|
|
67010
|
+
parentLeft = rect.left - parent.scrollLeft * parentScaleX;
|
|
67011
|
+
parentTop = rect.top - parent.scrollTop * parentScaleY;
|
|
67012
|
+
}
|
|
67013
|
+
this.element.style.left = (rect.left - parentLeft) / scaleX + "px";
|
|
67014
|
+
this.element.style.top = (rect.top - parentTop) / scaleY + "px";
|
|
67015
|
+
this.element.style.width = (rect.right - rect.left) / scaleX + "px";
|
|
67016
|
+
this.element.style.height = (rect.bottom - rect.top) / scaleY + "px";
|
|
66757
67017
|
}
|
|
66758
|
-
|
|
66759
|
-
|
|
66760
|
-
|
|
66761
|
-
|
|
66762
|
-
|
|
66763
|
-
|
|
66764
|
-
|
|
66765
|
-
|
|
67018
|
+
scheduleRemoval(timeout) {
|
|
67019
|
+
clearTimeout(this.timeout);
|
|
67020
|
+
this.timeout = setTimeout(() => this.setCursor(null), timeout);
|
|
67021
|
+
}
|
|
67022
|
+
computeTarget(event) {
|
|
67023
|
+
let pos = this.editorView.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
67024
|
+
let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
|
|
67025
|
+
let disableDropCursor = node && node.type.spec.disableDropCursor;
|
|
67026
|
+
let disabled = typeof disableDropCursor == "function"
|
|
67027
|
+
? disableDropCursor(this.editorView, pos, event)
|
|
67028
|
+
: disableDropCursor;
|
|
67029
|
+
if (!pos || disabled)
|
|
67030
|
+
return null;
|
|
67031
|
+
let target = pos.pos;
|
|
67032
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
67033
|
+
let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
|
|
67034
|
+
if (point != null)
|
|
67035
|
+
target = point;
|
|
66766
67036
|
}
|
|
66767
|
-
|
|
66768
|
-
return items.slice(cutPoint);
|
|
66769
|
-
}
|
|
66770
|
-
class Item {
|
|
66771
|
-
constructor(
|
|
66772
|
-
// The (forward) step map for this item.
|
|
66773
|
-
map,
|
|
66774
|
-
// The inverted step
|
|
66775
|
-
step,
|
|
66776
|
-
// If this is non-null, this item is the start of a group, and
|
|
66777
|
-
// this selection is the starting selection for the group (the one
|
|
66778
|
-
// that was active before the first step was applied)
|
|
66779
|
-
selection,
|
|
66780
|
-
// If this item is the inverse of a previous mapping on the stack,
|
|
66781
|
-
// this points at the inverse's offset
|
|
66782
|
-
mirrorOffset) {
|
|
66783
|
-
this.map = map;
|
|
66784
|
-
this.step = step;
|
|
66785
|
-
this.selection = selection;
|
|
66786
|
-
this.mirrorOffset = mirrorOffset;
|
|
67037
|
+
return target;
|
|
66787
67038
|
}
|
|
66788
|
-
|
|
66789
|
-
if (this.
|
|
66790
|
-
|
|
66791
|
-
|
|
66792
|
-
|
|
67039
|
+
dragover(event) {
|
|
67040
|
+
if (!this.editorView.editable)
|
|
67041
|
+
return;
|
|
67042
|
+
this.lastDragEvent = event;
|
|
67043
|
+
let target = this.computeTarget(event);
|
|
67044
|
+
if (target != null) {
|
|
67045
|
+
this.setCursor(target);
|
|
67046
|
+
this.scheduleRemoval(5000);
|
|
66793
67047
|
}
|
|
66794
67048
|
}
|
|
66795
|
-
|
|
66796
|
-
|
|
66797
|
-
|
|
66798
|
-
|
|
66799
|
-
|
|
66800
|
-
|
|
66801
|
-
|
|
66802
|
-
this.
|
|
66803
|
-
|
|
66804
|
-
this.prevTime = prevTime;
|
|
66805
|
-
this.prevComposition = prevComposition;
|
|
67049
|
+
dragend() {
|
|
67050
|
+
this.scheduleRemoval(20);
|
|
67051
|
+
}
|
|
67052
|
+
drop() {
|
|
67053
|
+
this.scheduleRemoval(20);
|
|
67054
|
+
}
|
|
67055
|
+
dragleave(event) {
|
|
67056
|
+
if (!this.editorView.dom.contains(event.relatedTarget))
|
|
67057
|
+
this.setCursor(null);
|
|
66806
67058
|
}
|
|
66807
67059
|
}
|
|
66808
|
-
|
|
66809
|
-
|
|
66810
|
-
|
|
66811
|
-
|
|
66812
|
-
|
|
66813
|
-
|
|
66814
|
-
|
|
66815
|
-
|
|
66816
|
-
|
|
66817
|
-
|
|
66818
|
-
|
|
67060
|
+
|
|
67061
|
+
/**
|
|
67062
|
+
Gap cursor selections are represented using this class. Its
|
|
67063
|
+
`$anchor` and `$head` properties both point at the cursor position.
|
|
67064
|
+
*/
|
|
67065
|
+
class GapCursor extends Selection$2 {
|
|
67066
|
+
/**
|
|
67067
|
+
Create a gap cursor.
|
|
67068
|
+
*/
|
|
67069
|
+
constructor($pos) {
|
|
67070
|
+
super($pos, $pos);
|
|
66819
67071
|
}
|
|
66820
|
-
|
|
66821
|
-
|
|
66822
|
-
|
|
66823
|
-
else
|
|
66824
|
-
return new HistoryState(history.done, history.undone.addTransform(tr, undefined, options, mustPreserveItems(state)), null, history.prevTime, history.prevComposition);
|
|
67072
|
+
map(doc, mapping) {
|
|
67073
|
+
let $pos = doc.resolve(mapping.map(this.head));
|
|
67074
|
+
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
66825
67075
|
}
|
|
66826
|
-
|
|
66827
|
-
|
|
66828
|
-
|
|
66829
|
-
let newGroup = history.prevTime == 0 ||
|
|
66830
|
-
(!appended && history.prevComposition != composition &&
|
|
66831
|
-
(history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history.prevRanges)));
|
|
66832
|
-
let prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps);
|
|
66833
|
-
return new HistoryState(history.done.addTransform(tr, newGroup ? state.selection.getBookmark() : undefined, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time, composition == null ? history.prevComposition : composition);
|
|
67076
|
+
content() { return Slice.empty; }
|
|
67077
|
+
eq(other) {
|
|
67078
|
+
return other instanceof GapCursor && other.head == this.head;
|
|
66834
67079
|
}
|
|
66835
|
-
|
|
66836
|
-
|
|
66837
|
-
// content has been rebased.
|
|
66838
|
-
return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);
|
|
67080
|
+
toJSON() {
|
|
67081
|
+
return { type: "gapcursor", pos: this.head };
|
|
66839
67082
|
}
|
|
66840
|
-
|
|
66841
|
-
|
|
67083
|
+
/**
|
|
67084
|
+
@internal
|
|
67085
|
+
*/
|
|
67086
|
+
static fromJSON(doc, json) {
|
|
67087
|
+
if (typeof json.pos != "number")
|
|
67088
|
+
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
67089
|
+
return new GapCursor(doc.resolve(json.pos));
|
|
67090
|
+
}
|
|
67091
|
+
/**
|
|
67092
|
+
@internal
|
|
67093
|
+
*/
|
|
67094
|
+
getBookmark() { return new GapBookmark(this.anchor); }
|
|
67095
|
+
/**
|
|
67096
|
+
@internal
|
|
67097
|
+
*/
|
|
67098
|
+
static valid($pos) {
|
|
67099
|
+
let parent = $pos.parent;
|
|
67100
|
+
if (parent.inlineContent || !closedBefore($pos) || !closedAfter($pos))
|
|
67101
|
+
return false;
|
|
67102
|
+
let override = parent.type.spec.allowGapCursor;
|
|
67103
|
+
if (override != null)
|
|
67104
|
+
return override;
|
|
67105
|
+
let deflt = parent.contentMatchAt($pos.index()).defaultType;
|
|
67106
|
+
return deflt && deflt.isTextblock;
|
|
67107
|
+
}
|
|
67108
|
+
/**
|
|
67109
|
+
@internal
|
|
67110
|
+
*/
|
|
67111
|
+
static findGapCursorFrom($pos, dir, mustMove = false) {
|
|
67112
|
+
search: for (;;) {
|
|
67113
|
+
if (!mustMove && GapCursor.valid($pos))
|
|
67114
|
+
return $pos;
|
|
67115
|
+
let pos = $pos.pos, next = null;
|
|
67116
|
+
// Scan up from this position
|
|
67117
|
+
for (let d = $pos.depth;; d--) {
|
|
67118
|
+
let parent = $pos.node(d);
|
|
67119
|
+
if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
|
|
67120
|
+
next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
|
|
67121
|
+
break;
|
|
67122
|
+
}
|
|
67123
|
+
else if (d == 0) {
|
|
67124
|
+
return null;
|
|
67125
|
+
}
|
|
67126
|
+
pos += dir;
|
|
67127
|
+
let $cur = $pos.doc.resolve(pos);
|
|
67128
|
+
if (GapCursor.valid($cur))
|
|
67129
|
+
return $cur;
|
|
67130
|
+
}
|
|
67131
|
+
// And then down into the next node
|
|
67132
|
+
for (;;) {
|
|
67133
|
+
let inside = dir > 0 ? next.firstChild : next.lastChild;
|
|
67134
|
+
if (!inside) {
|
|
67135
|
+
if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
|
|
67136
|
+
$pos = $pos.doc.resolve(pos + next.nodeSize * dir);
|
|
67137
|
+
mustMove = false;
|
|
67138
|
+
continue search;
|
|
67139
|
+
}
|
|
67140
|
+
break;
|
|
67141
|
+
}
|
|
67142
|
+
next = inside;
|
|
67143
|
+
pos += dir;
|
|
67144
|
+
let $cur = $pos.doc.resolve(pos);
|
|
67145
|
+
if (GapCursor.valid($cur))
|
|
67146
|
+
return $cur;
|
|
67147
|
+
}
|
|
67148
|
+
return null;
|
|
67149
|
+
}
|
|
66842
67150
|
}
|
|
66843
67151
|
}
|
|
66844
|
-
|
|
66845
|
-
|
|
66846
|
-
|
|
66847
|
-
|
|
66848
|
-
|
|
66849
|
-
|
|
66850
|
-
|
|
66851
|
-
|
|
66852
|
-
|
|
66853
|
-
|
|
66854
|
-
|
|
66855
|
-
|
|
67152
|
+
GapCursor.prototype.visible = false;
|
|
67153
|
+
GapCursor.findFrom = GapCursor.findGapCursorFrom;
|
|
67154
|
+
Selection$2.jsonID("gapcursor", GapCursor);
|
|
67155
|
+
class GapBookmark {
|
|
67156
|
+
constructor(pos) {
|
|
67157
|
+
this.pos = pos;
|
|
67158
|
+
}
|
|
67159
|
+
map(mapping) {
|
|
67160
|
+
return new GapBookmark(mapping.map(this.pos));
|
|
67161
|
+
}
|
|
67162
|
+
resolve(doc) {
|
|
67163
|
+
let $pos = doc.resolve(this.pos);
|
|
67164
|
+
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
67165
|
+
}
|
|
66856
67166
|
}
|
|
66857
|
-
function
|
|
66858
|
-
|
|
66859
|
-
for (let i = maps.length - 1; i >= 0 && result.length == 0; i--)
|
|
66860
|
-
maps[i].forEach((_from, _to, from, to) => result.push(from, to));
|
|
66861
|
-
return result;
|
|
67167
|
+
function needsGap(type) {
|
|
67168
|
+
return type.isAtom || type.spec.isolating || type.spec.createGapCursor;
|
|
66862
67169
|
}
|
|
66863
|
-
function
|
|
66864
|
-
|
|
66865
|
-
|
|
66866
|
-
|
|
66867
|
-
|
|
66868
|
-
|
|
66869
|
-
|
|
66870
|
-
|
|
67170
|
+
function closedBefore($pos) {
|
|
67171
|
+
for (let d = $pos.depth; d >= 0; d--) {
|
|
67172
|
+
let index = $pos.index(d), parent = $pos.node(d);
|
|
67173
|
+
// At the start of this parent, look at next one
|
|
67174
|
+
if (index == 0) {
|
|
67175
|
+
if (parent.type.spec.isolating)
|
|
67176
|
+
return true;
|
|
67177
|
+
continue;
|
|
67178
|
+
}
|
|
67179
|
+
// See if the node before (or its first ancestor) is closed
|
|
67180
|
+
for (let before = parent.child(index - 1);; before = before.lastChild) {
|
|
67181
|
+
if ((before.childCount == 0 && !before.inlineContent) || needsGap(before.type))
|
|
67182
|
+
return true;
|
|
67183
|
+
if (before.inlineContent)
|
|
67184
|
+
return false;
|
|
67185
|
+
}
|
|
66871
67186
|
}
|
|
66872
|
-
|
|
66873
|
-
|
|
66874
|
-
// Apply the latest event from one branch to the document and shift the event
|
|
66875
|
-
// onto the other branch.
|
|
66876
|
-
function histTransaction(history, state, redo) {
|
|
66877
|
-
let preserveItems = mustPreserveItems(state);
|
|
66878
|
-
let histOptions = historyKey.get(state).spec.config;
|
|
66879
|
-
let pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);
|
|
66880
|
-
if (!pop)
|
|
66881
|
-
return null;
|
|
66882
|
-
let selection = pop.selection.resolve(pop.transform.doc);
|
|
66883
|
-
let added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
|
|
66884
|
-
let newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0, -1);
|
|
66885
|
-
return pop.transform.setSelection(selection).setMeta(historyKey, { redo, historyState: newHist });
|
|
67187
|
+
// Hit start of document
|
|
67188
|
+
return true;
|
|
66886
67189
|
}
|
|
66887
|
-
|
|
66888
|
-
|
|
66889
|
-
|
|
66890
|
-
|
|
66891
|
-
|
|
66892
|
-
|
|
66893
|
-
|
|
66894
|
-
|
|
66895
|
-
|
|
66896
|
-
|
|
66897
|
-
|
|
66898
|
-
if (
|
|
66899
|
-
|
|
66900
|
-
|
|
66901
|
-
}
|
|
67190
|
+
function closedAfter($pos) {
|
|
67191
|
+
for (let d = $pos.depth; d >= 0; d--) {
|
|
67192
|
+
let index = $pos.indexAfter(d), parent = $pos.node(d);
|
|
67193
|
+
if (index == parent.childCount) {
|
|
67194
|
+
if (parent.type.spec.isolating)
|
|
67195
|
+
return true;
|
|
67196
|
+
continue;
|
|
67197
|
+
}
|
|
67198
|
+
for (let after = parent.child(index);; after = after.firstChild) {
|
|
67199
|
+
if ((after.childCount == 0 && !after.inlineContent) || needsGap(after.type))
|
|
67200
|
+
return true;
|
|
67201
|
+
if (after.inlineContent)
|
|
67202
|
+
return false;
|
|
67203
|
+
}
|
|
66902
67204
|
}
|
|
66903
|
-
return
|
|
67205
|
+
return true;
|
|
66904
67206
|
}
|
|
66905
|
-
const historyKey = new PluginKey("history");
|
|
66906
|
-
const closeHistoryKey = new PluginKey("closeHistory");
|
|
66907
|
-
/**
|
|
66908
|
-
Returns a plugin that enables the undo history for an editor. The
|
|
66909
|
-
plugin will track undo and redo stacks, which can be used with the
|
|
66910
|
-
[`undo`](https://prosemirror.net/docs/ref/#history.undo) and [`redo`](https://prosemirror.net/docs/ref/#history.redo) commands.
|
|
66911
67207
|
|
|
66912
|
-
|
|
66913
|
-
|
|
66914
|
-
|
|
67208
|
+
/**
|
|
67209
|
+
Create a gap cursor plugin. When enabled, this will capture clicks
|
|
67210
|
+
near and arrow-key-motion past places that don't have a normally
|
|
67211
|
+
selectable position nearby, and create a gap cursor selection for
|
|
67212
|
+
them. The cursor is drawn as an element with class
|
|
67213
|
+
`ProseMirror-gapcursor`. You can either include
|
|
67214
|
+
`style/gapcursor.css` from the package's directory or add your own
|
|
67215
|
+
styles to make it visible.
|
|
66915
67216
|
*/
|
|
66916
|
-
function
|
|
66917
|
-
config = { depth: config.depth || 100,
|
|
66918
|
-
newGroupDelay: config.newGroupDelay || 500 };
|
|
67217
|
+
function gapCursor() {
|
|
66919
67218
|
return new Plugin({
|
|
66920
|
-
key: historyKey,
|
|
66921
|
-
state: {
|
|
66922
|
-
init() {
|
|
66923
|
-
return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
|
|
66924
|
-
},
|
|
66925
|
-
apply(tr, hist, state) {
|
|
66926
|
-
return applyTransaction(hist, state, tr, config);
|
|
66927
|
-
}
|
|
66928
|
-
},
|
|
66929
|
-
config,
|
|
66930
67219
|
props: {
|
|
66931
|
-
|
|
66932
|
-
|
|
66933
|
-
|
|
66934
|
-
|
|
66935
|
-
|
|
66936
|
-
|
|
66937
|
-
|
|
66938
|
-
return command(view.state, view.dispatch);
|
|
66939
|
-
}
|
|
66940
|
-
}
|
|
67220
|
+
decorations: drawGapCursor,
|
|
67221
|
+
createSelectionBetween(_view, $anchor, $head) {
|
|
67222
|
+
return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
|
|
67223
|
+
},
|
|
67224
|
+
handleClick,
|
|
67225
|
+
handleKeyDown,
|
|
67226
|
+
handleDOMEvents: { beforeinput: beforeinput }
|
|
66941
67227
|
}
|
|
66942
67228
|
});
|
|
66943
67229
|
}
|
|
66944
|
-
|
|
66945
|
-
|
|
66946
|
-
|
|
66947
|
-
|
|
66948
|
-
|
|
66949
|
-
|
|
66950
|
-
|
|
66951
|
-
|
|
66952
|
-
|
|
67230
|
+
const handleKeyDown = keydownHandler({
|
|
67231
|
+
"ArrowLeft": arrow("horiz", -1),
|
|
67232
|
+
"ArrowRight": arrow("horiz", 1),
|
|
67233
|
+
"ArrowUp": arrow("vert", -1),
|
|
67234
|
+
"ArrowDown": arrow("vert", 1)
|
|
67235
|
+
});
|
|
67236
|
+
function arrow(axis, dir) {
|
|
67237
|
+
const dirStr = axis == "vert" ? (dir > 0 ? "down" : "up") : (dir > 0 ? "right" : "left");
|
|
67238
|
+
return function (state, dispatch, view) {
|
|
67239
|
+
let sel = state.selection;
|
|
67240
|
+
let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
|
|
67241
|
+
if (sel instanceof TextSelection) {
|
|
67242
|
+
if (!view.endOfTextblock(dirStr) || $start.depth == 0)
|
|
67243
|
+
return false;
|
|
67244
|
+
mustMove = false;
|
|
67245
|
+
$start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
|
|
66953
67246
|
}
|
|
67247
|
+
let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
|
|
67248
|
+
if (!$found)
|
|
67249
|
+
return false;
|
|
67250
|
+
if (dispatch)
|
|
67251
|
+
dispatch(state.tr.setSelection(new GapCursor($found)));
|
|
66954
67252
|
return true;
|
|
66955
67253
|
};
|
|
66956
67254
|
}
|
|
66957
|
-
|
|
66958
|
-
|
|
66959
|
-
|
|
66960
|
-
|
|
66961
|
-
|
|
66962
|
-
|
|
66963
|
-
|
|
66964
|
-
|
|
67255
|
+
function handleClick(view, pos, event) {
|
|
67256
|
+
if (!view || !view.editable)
|
|
67257
|
+
return false;
|
|
67258
|
+
let $pos = view.state.doc.resolve(pos);
|
|
67259
|
+
if (!GapCursor.valid($pos))
|
|
67260
|
+
return false;
|
|
67261
|
+
let clickPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
67262
|
+
if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside)))
|
|
67263
|
+
return false;
|
|
67264
|
+
view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
|
|
67265
|
+
return true;
|
|
67266
|
+
}
|
|
67267
|
+
// This is a hack that, when a composition starts while a gap cursor
|
|
67268
|
+
// is active, quickly creates an inline context for the composition to
|
|
67269
|
+
// happen in, to avoid it being aborted by the DOM selection being
|
|
67270
|
+
// moved into a valid position.
|
|
67271
|
+
function beforeinput(view, event) {
|
|
67272
|
+
if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor))
|
|
67273
|
+
return false;
|
|
67274
|
+
let { $from } = view.state.selection;
|
|
67275
|
+
let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
|
|
67276
|
+
if (!insert)
|
|
67277
|
+
return false;
|
|
67278
|
+
let frag = Fragment.empty;
|
|
67279
|
+
for (let i = insert.length - 1; i >= 0; i--)
|
|
67280
|
+
frag = Fragment.from(insert[i].createAndFill(null, frag));
|
|
67281
|
+
let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
|
|
67282
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
|
|
67283
|
+
view.dispatch(tr);
|
|
67284
|
+
return false;
|
|
67285
|
+
}
|
|
67286
|
+
function drawGapCursor(state) {
|
|
67287
|
+
if (!(state.selection instanceof GapCursor))
|
|
67288
|
+
return null;
|
|
67289
|
+
let node = document.createElement("div");
|
|
67290
|
+
node.className = "ProseMirror-gapcursor";
|
|
67291
|
+
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
|
|
67292
|
+
}
|
|
66965
67293
|
|
|
66966
67294
|
//#region src/character-count/character-count.ts
|
|
66967
67295
|
/**
|
|
@@ -97557,12 +97885,12 @@ focus outline in that case.
|
|
|
97557
97885
|
toDOMStream(options) {
|
|
97558
97886
|
return streamAdapters.toDOMStream((this._closedPromiseResolve || this._error)
|
|
97559
97887
|
? this
|
|
97560
|
-
: this._values
|
|
97888
|
+
: this._values);
|
|
97561
97889
|
}
|
|
97562
97890
|
toNodeStream(options) {
|
|
97563
97891
|
return streamAdapters.toNodeStream((this._closedPromiseResolve || this._error)
|
|
97564
97892
|
? this
|
|
97565
|
-
: this._values
|
|
97893
|
+
: this._values);
|
|
97566
97894
|
}
|
|
97567
97895
|
throw(_) {
|
|
97568
97896
|
return __awaiter(this, void 0, void 0, function* () { yield this.abort(_); return ITERATOR_DONE; });
|
|
@@ -99953,7 +100281,7 @@ focus outline in that case.
|
|
|
99953
100281
|
toNodeStream() {
|
|
99954
100282
|
return streamAdapters.toNodeStream((this.isSync()
|
|
99955
100283
|
? { [Symbol.iterator]: () => this }
|
|
99956
|
-
: { [Symbol.asyncIterator]: () => this })
|
|
100284
|
+
: { [Symbol.asyncIterator]: () => this }));
|
|
99957
100285
|
}
|
|
99958
100286
|
/** @nocollapse */
|
|
99959
100287
|
// @ts-ignore
|
|
@@ -106622,15 +106950,17 @@ focus outline in that case.
|
|
|
106622
106950
|
id="${(_, c) => `${c.parent.menuId}-option-${c.index}`}"
|
|
106623
106951
|
class="chip-selector-option"
|
|
106624
106952
|
data-option-value="${x => x}"
|
|
106953
|
+
aria-selected="${(_, c) => String(c.index === c.parent.activeOptionIndex)}"
|
|
106625
106954
|
>
|
|
106626
106955
|
${x => x}
|
|
106627
106956
|
</${menuItemTag}>
|
|
106628
|
-
|
|
106957
|
+
`, { positioning: true })}
|
|
106629
106958
|
${when(x => x.customValueCandidate.length > 0, html `
|
|
106630
106959
|
<${menuItemTag}
|
|
106631
106960
|
id="${x => `${x.menuId}-option-create`}"
|
|
106632
106961
|
class="chip-selector-option chip-selector-create-option"
|
|
106633
106962
|
data-option-value="${x => x.customValueCandidate}"
|
|
106963
|
+
aria-selected="${x => String(x.activeOptionIndex === x.visibleOptionList.length)}"
|
|
106634
106964
|
>
|
|
106635
106965
|
${x => x.createOptionLabel}
|
|
106636
106966
|
</${menuItemTag}>
|
|
@@ -106895,10 +107225,6 @@ focus outline in that case.
|
|
|
106895
107225
|
}
|
|
106896
107226
|
}
|
|
106897
107227
|
syncActiveOption() {
|
|
106898
|
-
const options = Array.from(this.shadowRoot?.querySelectorAll('.chip-selector-option') ?? []);
|
|
106899
|
-
options.forEach((option, index) => {
|
|
106900
|
-
option.setAttribute('aria-selected', String(index === this.activeOptionIndex));
|
|
106901
|
-
});
|
|
106902
107228
|
if (this.activeOptionIndex < 0) {
|
|
106903
107229
|
this.activeOptionId = null;
|
|
106904
107230
|
}
|