@ni/nimble-components 35.14.1 → 35.15.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 +1850 -1522
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +4618 -4579
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/custom-elements.json +96 -96
- package/dist/custom-elements.md +21 -21
- package/dist/esm/icons/all-icons.d.ts +7 -0
- package/dist/esm/icons/all-icons.js +7 -0
- package/dist/esm/icons/all-icons.js.map +1 -1
- package/dist/esm/icons/file-clock/index.d.ts +13 -0
- package/dist/esm/icons/file-clock/index.js +15 -0
- package/dist/esm/icons/file-clock/index.js.map +1 -0
- package/dist/esm/icons/file-plus/index.d.ts +13 -0
- package/dist/esm/icons/file-plus/index.js +15 -0
- package/dist/esm/icons/file-plus/index.js.map +1 -0
- package/dist/esm/icons/file-star/index.d.ts +13 -0
- package/dist/esm/icons/file-star/index.js +15 -0
- package/dist/esm/icons/file-star/index.js.map +1 -0
- package/dist/esm/icons/folder-clock/index.d.ts +13 -0
- package/dist/esm/icons/folder-clock/index.js +15 -0
- package/dist/esm/icons/folder-clock/index.js.map +1 -0
- package/dist/esm/icons/folder-plus/index.d.ts +13 -0
- package/dist/esm/icons/folder-plus/index.js +15 -0
- package/dist/esm/icons/folder-plus/index.js.map +1 -0
- package/dist/esm/icons/folder-star/index.d.ts +13 -0
- package/dist/esm/icons/folder-star/index.js +15 -0
- package/dist/esm/icons/folder-star/index.js.map +1 -0
- package/dist/esm/icons/scissors/index.d.ts +13 -0
- package/dist/esm/icons/scissors/index.js +15 -0
- package/dist/esm/icons/scissors/index.js.map +1 -0
- 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',
|
|
@@ -25216,6 +25244,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25216
25244
|
}
|
|
25217
25245
|
registerIconSvg('icon-file-arrow-curved-right', IconFileArrowCurvedRight);
|
|
25218
25246
|
|
|
25247
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25248
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25249
|
+
/**
|
|
25250
|
+
* The icon component for the 'fileClock' icon
|
|
25251
|
+
*/
|
|
25252
|
+
class IconFileClock extends IconSvg {
|
|
25253
|
+
constructor() {
|
|
25254
|
+
super(fileClock16X16);
|
|
25255
|
+
}
|
|
25256
|
+
}
|
|
25257
|
+
registerIconSvg('icon-file-clock', IconFileClock);
|
|
25258
|
+
|
|
25219
25259
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25220
25260
|
// See generation source in nimble-components/build/generate-icons
|
|
25221
25261
|
/**
|
|
@@ -25228,6 +25268,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25228
25268
|
}
|
|
25229
25269
|
registerIconSvg('icon-file-drawer', IconFileDrawer);
|
|
25230
25270
|
|
|
25271
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25272
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25273
|
+
/**
|
|
25274
|
+
* The icon component for the 'filePlus' icon
|
|
25275
|
+
*/
|
|
25276
|
+
class IconFilePlus extends IconSvg {
|
|
25277
|
+
constructor() {
|
|
25278
|
+
super(filePlus16X16);
|
|
25279
|
+
}
|
|
25280
|
+
}
|
|
25281
|
+
registerIconSvg('icon-file-plus', IconFilePlus);
|
|
25282
|
+
|
|
25231
25283
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25232
25284
|
// See generation source in nimble-components/build/generate-icons
|
|
25233
25285
|
/**
|
|
@@ -25240,6 +25292,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25240
25292
|
}
|
|
25241
25293
|
registerIconSvg('icon-file-search', IconFileSearch);
|
|
25242
25294
|
|
|
25295
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25296
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25297
|
+
/**
|
|
25298
|
+
* The icon component for the 'fileStar' icon
|
|
25299
|
+
*/
|
|
25300
|
+
class IconFileStar extends IconSvg {
|
|
25301
|
+
constructor() {
|
|
25302
|
+
super(fileStar16X16);
|
|
25303
|
+
}
|
|
25304
|
+
}
|
|
25305
|
+
registerIconSvg('icon-file-star', IconFileStar);
|
|
25306
|
+
|
|
25243
25307
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25244
25308
|
// See generation source in nimble-components/build/generate-icons
|
|
25245
25309
|
/**
|
|
@@ -25324,6 +25388,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25324
25388
|
}
|
|
25325
25389
|
registerIconSvg('icon-folder', IconFolder);
|
|
25326
25390
|
|
|
25391
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25392
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25393
|
+
/**
|
|
25394
|
+
* The icon component for the 'folderClock' icon
|
|
25395
|
+
*/
|
|
25396
|
+
class IconFolderClock extends IconSvg {
|
|
25397
|
+
constructor() {
|
|
25398
|
+
super(folderClock16X16);
|
|
25399
|
+
}
|
|
25400
|
+
}
|
|
25401
|
+
registerIconSvg('icon-folder-clock', IconFolderClock);
|
|
25402
|
+
|
|
25327
25403
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25328
25404
|
// See generation source in nimble-components/build/generate-icons
|
|
25329
25405
|
/**
|
|
@@ -25336,6 +25412,30 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
25336
25412
|
}
|
|
25337
25413
|
registerIconSvg('icon-folder-open', IconFolderOpen);
|
|
25338
25414
|
|
|
25415
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25416
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25417
|
+
/**
|
|
25418
|
+
* The icon component for the 'folderPlus' icon
|
|
25419
|
+
*/
|
|
25420
|
+
class IconFolderPlus extends IconSvg {
|
|
25421
|
+
constructor() {
|
|
25422
|
+
super(folderPlus16X16);
|
|
25423
|
+
}
|
|
25424
|
+
}
|
|
25425
|
+
registerIconSvg('icon-folder-plus', IconFolderPlus);
|
|
25426
|
+
|
|
25427
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25428
|
+
// See generation source in nimble-components/build/generate-icons
|
|
25429
|
+
/**
|
|
25430
|
+
* The icon component for the 'folderStar' icon
|
|
25431
|
+
*/
|
|
25432
|
+
class IconFolderStar extends IconSvg {
|
|
25433
|
+
constructor() {
|
|
25434
|
+
super(folderStar16X16);
|
|
25435
|
+
}
|
|
25436
|
+
}
|
|
25437
|
+
registerIconSvg('icon-folder-star', IconFolderStar);
|
|
25438
|
+
|
|
25339
25439
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
25340
25440
|
// See generation source in nimble-components/build/generate-icons
|
|
25341
25441
|
/**
|
|
@@ -26061,6 +26161,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
26061
26161
|
}
|
|
26062
26162
|
registerIconSvg('icon-scanner-gun', IconScannerGun);
|
|
26063
26163
|
|
|
26164
|
+
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
26165
|
+
// See generation source in nimble-components/build/generate-icons
|
|
26166
|
+
/**
|
|
26167
|
+
* The icon component for the 'scissors' icon
|
|
26168
|
+
*/
|
|
26169
|
+
class IconScissors extends IconSvg {
|
|
26170
|
+
constructor() {
|
|
26171
|
+
super(scissors16X16);
|
|
26172
|
+
}
|
|
26173
|
+
}
|
|
26174
|
+
registerIconSvg('icon-scissors', IconScissors);
|
|
26175
|
+
|
|
26064
26176
|
// AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
|
|
26065
26177
|
// See generation source in nimble-components/build/generate-icons
|
|
26066
26178
|
/**
|
|
@@ -29683,7 +29795,6 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
29683
29795
|
if (!type)
|
|
29684
29796
|
throw new RangeError(`There is no mark type ${json.type} in this schema`);
|
|
29685
29797
|
let mark = type.create(json.attrs);
|
|
29686
|
-
type.checkAttrs(mark.attrs);
|
|
29687
29798
|
return mark;
|
|
29688
29799
|
}
|
|
29689
29800
|
/**
|
|
@@ -30663,11 +30774,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
30663
30774
|
*/
|
|
30664
30775
|
check() {
|
|
30665
30776
|
this.type.checkContent(this.content);
|
|
30666
|
-
this.type.
|
|
30777
|
+
checkAttrs(this.type.attrs, this.attrs, "node", this.type.name);
|
|
30667
30778
|
let copy = Mark$1.none;
|
|
30668
30779
|
for (let i = 0; i < this.marks.length; i++) {
|
|
30669
30780
|
let mark = this.marks[i];
|
|
30670
|
-
mark.type.
|
|
30781
|
+
checkAttrs(mark.type.attrs, mark.attrs, "mark", mark.type.name);
|
|
30671
30782
|
copy = mark.addToSet(copy);
|
|
30672
30783
|
}
|
|
30673
30784
|
if (!Mark$1.sameSet(copy, this.marks))
|
|
@@ -30708,7 +30819,6 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
30708
30819
|
}
|
|
30709
30820
|
let content = Fragment.fromJSON(schema, json.content);
|
|
30710
30821
|
let node = schema.nodeType(json.type).create(json.attrs, content, marks);
|
|
30711
|
-
node.type.checkAttrs(node.attrs);
|
|
30712
30822
|
return node;
|
|
30713
30823
|
}
|
|
30714
30824
|
};
|
|
@@ -30758,6 +30868,15 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
30758
30868
|
str = marks[i].type.name + "(" + str + ")";
|
|
30759
30869
|
return str;
|
|
30760
30870
|
}
|
|
30871
|
+
function checkAttrs(attrs, values, type, name) {
|
|
30872
|
+
for (let attr in values)
|
|
30873
|
+
if (!(attr in attrs))
|
|
30874
|
+
throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
30875
|
+
for (let attr in attrs) {
|
|
30876
|
+
if (attrs[attr].validate)
|
|
30877
|
+
attrs[attr].validate(values[attr]);
|
|
30878
|
+
}
|
|
30879
|
+
}
|
|
30761
30880
|
|
|
30762
30881
|
/**
|
|
30763
30882
|
Instances of this class represent a match state of a node type's
|
|
@@ -31212,27 +31331,21 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
31212
31331
|
function computeAttrs(attrs, value) {
|
|
31213
31332
|
let built = Object.create(null);
|
|
31214
31333
|
for (let name in attrs) {
|
|
31334
|
+
let attr = attrs[name];
|
|
31215
31335
|
let given = value && value[name];
|
|
31216
31336
|
if (given === undefined) {
|
|
31217
|
-
let attr = attrs[name];
|
|
31218
31337
|
if (attr.hasDefault)
|
|
31219
31338
|
given = attr.default;
|
|
31220
31339
|
else
|
|
31221
31340
|
throw new RangeError("No value supplied for attribute " + name);
|
|
31222
31341
|
}
|
|
31342
|
+
else if (attr.validate) {
|
|
31343
|
+
attr.validate(given);
|
|
31344
|
+
}
|
|
31223
31345
|
built[name] = given;
|
|
31224
31346
|
}
|
|
31225
31347
|
return built;
|
|
31226
31348
|
}
|
|
31227
|
-
function checkAttrs(attrs, values, type, name) {
|
|
31228
|
-
for (let attr in values)
|
|
31229
|
-
if (!(attr in attrs))
|
|
31230
|
-
throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
31231
|
-
for (let attr in attrs) {
|
|
31232
|
-
if (attrs[attr].validate)
|
|
31233
|
-
attrs[attr].validate(values[attr]);
|
|
31234
|
-
}
|
|
31235
|
-
}
|
|
31236
31349
|
function initAttrs(typeName, attrs) {
|
|
31237
31350
|
let result = Object.create(null);
|
|
31238
31351
|
if (attrs)
|
|
@@ -31404,11 +31517,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
31404
31517
|
throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
|
|
31405
31518
|
}
|
|
31406
31519
|
/**
|
|
31407
|
-
@internal
|
|
31520
|
+
@internal no longer useful, but called by old prosemirror-view versions
|
|
31408
31521
|
*/
|
|
31409
|
-
checkAttrs(attrs) {
|
|
31410
|
-
checkAttrs(this.attrs, attrs, "node", this.name);
|
|
31411
|
-
}
|
|
31522
|
+
checkAttrs(attrs) { }
|
|
31412
31523
|
/**
|
|
31413
31524
|
Check whether the given mark type is allowed in this node.
|
|
31414
31525
|
*/
|
|
@@ -31555,12 +31666,6 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
31555
31666
|
return set[i];
|
|
31556
31667
|
}
|
|
31557
31668
|
/**
|
|
31558
|
-
@internal
|
|
31559
|
-
*/
|
|
31560
|
-
checkAttrs(attrs) {
|
|
31561
|
-
checkAttrs(this.attrs, attrs, "mark", this.name);
|
|
31562
|
-
}
|
|
31563
|
-
/**
|
|
31564
31669
|
Queries whether a given mark type is
|
|
31565
31670
|
[excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
|
|
31566
31671
|
*/
|
|
@@ -32751,9 +32856,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
32751
32856
|
if (simple)
|
|
32752
32857
|
return result;
|
|
32753
32858
|
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
32754
|
-
let del =
|
|
32755
|
-
if (
|
|
32756
|
-
del |=
|
|
32859
|
+
let del = 0;
|
|
32860
|
+
if (oldSize) {
|
|
32861
|
+
del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
32862
|
+
if (assoc < 0 ? pos != start : pos != end)
|
|
32863
|
+
del |= DEL_SIDE;
|
|
32864
|
+
}
|
|
32757
32865
|
return new MapResult(result, del, recover);
|
|
32758
32866
|
}
|
|
32759
32867
|
diff += newSize - oldSize;
|
|
@@ -36691,15 +36799,15 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36691
36799
|
return true;
|
|
36692
36800
|
if (off == (dir < 0 ? 0 : nodeSize(node))) {
|
|
36693
36801
|
let parent = node.parentNode;
|
|
36694
|
-
if (!parent || parent
|
|
36802
|
+
if (!parent || !isElt(parent) || hasBlockDesc(node) || atomElements.test(node.nodeName) ||
|
|
36695
36803
|
node.contentEditable == "false")
|
|
36696
36804
|
return false;
|
|
36697
36805
|
off = domIndex(node) + (dir < 0 ? 0 : 1);
|
|
36698
36806
|
node = parent;
|
|
36699
36807
|
}
|
|
36700
|
-
else if (node
|
|
36808
|
+
else if (isElt(node)) {
|
|
36701
36809
|
let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
|
|
36702
|
-
if (child
|
|
36810
|
+
if (isElt(child) && child.contentEditable == "false") {
|
|
36703
36811
|
if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection)
|
|
36704
36812
|
off += dir;
|
|
36705
36813
|
else
|
|
@@ -36718,11 +36826,16 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36718
36826
|
function nodeSize(node) {
|
|
36719
36827
|
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
36720
36828
|
}
|
|
36829
|
+
function isElt(node) { return node.nodeType == 1; }
|
|
36830
|
+
function isText(node) { return node.nodeType == 3; }
|
|
36831
|
+
function contains(parent, child) {
|
|
36832
|
+
return child ? parent.contains(isElt(child) ? child : child.parentNode) : false;
|
|
36833
|
+
}
|
|
36721
36834
|
function textNodeBefore$1(node, offset) {
|
|
36722
36835
|
for (;;) {
|
|
36723
|
-
if (node
|
|
36836
|
+
if (isText(node) && offset)
|
|
36724
36837
|
return node;
|
|
36725
|
-
if (node
|
|
36838
|
+
if (isElt(node) && offset > 0) {
|
|
36726
36839
|
if (node.contentEditable == "false")
|
|
36727
36840
|
return null;
|
|
36728
36841
|
node = node.childNodes[offset - 1];
|
|
@@ -36739,9 +36852,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36739
36852
|
}
|
|
36740
36853
|
function textNodeAfter$1(node, offset) {
|
|
36741
36854
|
for (;;) {
|
|
36742
|
-
if (node
|
|
36855
|
+
if (isText(node) && offset < node.nodeValue.length)
|
|
36743
36856
|
return node;
|
|
36744
|
-
if (node
|
|
36857
|
+
if (isElt(node) && offset < node.childNodes.length) {
|
|
36745
36858
|
if (node.contentEditable == "false")
|
|
36746
36859
|
return null;
|
|
36747
36860
|
node = node.childNodes[offset];
|
|
@@ -36865,13 +36978,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36865
36978
|
for (let parent = startDOM || view.dom;;) {
|
|
36866
36979
|
if (!parent)
|
|
36867
36980
|
break;
|
|
36868
|
-
if (parent
|
|
36981
|
+
if (!isElt(parent)) {
|
|
36869
36982
|
parent = parentNode(parent);
|
|
36870
36983
|
continue;
|
|
36871
36984
|
}
|
|
36872
|
-
let
|
|
36873
|
-
let
|
|
36874
|
-
let bounding = atTop ? windowRect(doc) : clientRect(elt);
|
|
36985
|
+
let atTop = parent == doc.body;
|
|
36986
|
+
let bounding = atTop ? windowRect(doc) : clientRect(parent);
|
|
36875
36987
|
let moveX = 0, moveY = 0;
|
|
36876
36988
|
if (rect.top < bounding.top + getSide$1(scrollThreshold, "top"))
|
|
36877
36989
|
moveY = -(bounding.top - rect.top + getSide$1(scrollMargin, "top"));
|
|
@@ -36888,12 +37000,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36888
37000
|
doc.defaultView.scrollBy(moveX, moveY);
|
|
36889
37001
|
}
|
|
36890
37002
|
else {
|
|
36891
|
-
let startX =
|
|
37003
|
+
let startX = parent.scrollLeft, startY = parent.scrollTop;
|
|
36892
37004
|
if (moveY)
|
|
36893
|
-
|
|
37005
|
+
parent.scrollTop += moveY;
|
|
36894
37006
|
if (moveX)
|
|
36895
|
-
|
|
36896
|
-
let dX =
|
|
37007
|
+
parent.scrollLeft += moveX;
|
|
37008
|
+
let dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
|
|
36897
37009
|
rect = { left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY };
|
|
36898
37010
|
}
|
|
36899
37011
|
}
|
|
@@ -36968,14 +37080,15 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36968
37080
|
}
|
|
36969
37081
|
}
|
|
36970
37082
|
function findOffsetInNode(node, coords) {
|
|
36971
|
-
let closest
|
|
37083
|
+
let closest;
|
|
37084
|
+
let dxClosest = 2e8, coordsClosest, offset = 0;
|
|
36972
37085
|
let rowBot = coords.top, rowTop = coords.top;
|
|
36973
37086
|
let firstBelow, coordsBelow;
|
|
36974
37087
|
for (let child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {
|
|
36975
37088
|
let rects;
|
|
36976
|
-
if (child
|
|
37089
|
+
if (isElt(child))
|
|
36977
37090
|
rects = child.getClientRects();
|
|
36978
|
-
else if (child
|
|
37091
|
+
else if (isText(child))
|
|
36979
37092
|
rects = textRange(child).getClientRects();
|
|
36980
37093
|
else
|
|
36981
37094
|
continue;
|
|
@@ -36989,11 +37102,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
36989
37102
|
if (dx < dxClosest) {
|
|
36990
37103
|
closest = child;
|
|
36991
37104
|
dxClosest = dx;
|
|
36992
|
-
coordsClosest = dx && closest
|
|
37105
|
+
coordsClosest = dx && isText(closest) ? {
|
|
36993
37106
|
left: rect.right < coords.left ? rect.right : rect.left,
|
|
36994
37107
|
top: coords.top
|
|
36995
37108
|
} : coords;
|
|
36996
|
-
if (child
|
|
37109
|
+
if (isElt(child) && dx)
|
|
36997
37110
|
offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
|
|
36998
37111
|
continue;
|
|
36999
37112
|
}
|
|
@@ -37012,9 +37125,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37012
37125
|
coordsClosest = coordsBelow;
|
|
37013
37126
|
dxClosest = 0;
|
|
37014
37127
|
}
|
|
37015
|
-
if (closest && closest
|
|
37128
|
+
if (closest && isText(closest))
|
|
37016
37129
|
return findOffsetInText(closest, coordsClosest);
|
|
37017
|
-
if (!closest ||
|
|
37130
|
+
if (!closest || dxClosest)
|
|
37018
37131
|
return { node, offset };
|
|
37019
37132
|
return findOffsetInNode(closest, coordsClosest);
|
|
37020
37133
|
}
|
|
@@ -37047,7 +37160,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37047
37160
|
}
|
|
37048
37161
|
function posFromElement(view, elt, coords) {
|
|
37049
37162
|
let { node, offset } = findOffsetInNode(elt, coords), bias = -1;
|
|
37050
|
-
if (node
|
|
37163
|
+
if (isElt(node) && !node.firstChild) {
|
|
37051
37164
|
let rect = node.getBoundingClientRect();
|
|
37052
37165
|
bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
|
|
37053
37166
|
}
|
|
@@ -37067,7 +37180,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37067
37180
|
let desc = view.docView.nearestDesc(cur, true), rect;
|
|
37068
37181
|
if (!desc)
|
|
37069
37182
|
return null;
|
|
37070
|
-
if (desc.dom
|
|
37183
|
+
if (isElt(desc.dom) && (desc.node.isBlock && desc.parent || !desc.contentDOM) &&
|
|
37071
37184
|
// Ignore elements with zero-size bounding rectangles
|
|
37072
37185
|
((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
|
|
37073
37186
|
if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {
|
|
@@ -37094,7 +37207,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37094
37207
|
if (len && box.top < box.bottom) {
|
|
37095
37208
|
for (let startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {
|
|
37096
37209
|
let child = element.childNodes[i];
|
|
37097
|
-
if (child
|
|
37210
|
+
if (isElt(child)) {
|
|
37098
37211
|
let rects = child.getClientRects();
|
|
37099
37212
|
for (let j = 0; j < rects.length; j++) {
|
|
37100
37213
|
let rect = rects[j];
|
|
@@ -37117,7 +37230,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37117
37230
|
let elt = (view.root.elementFromPoint ? view.root : doc)
|
|
37118
37231
|
.elementFromPoint(coords.left, coords.top);
|
|
37119
37232
|
let pos;
|
|
37120
|
-
if (!elt || !view.dom.contains(elt
|
|
37233
|
+
if (!elt || !view.dom.contains(elt)) {
|
|
37121
37234
|
let box = view.dom.getBoundingClientRect();
|
|
37122
37235
|
if (!inRect(coords, box))
|
|
37123
37236
|
return null;
|
|
@@ -37133,7 +37246,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37133
37246
|
}
|
|
37134
37247
|
elt = targetKludge(elt, coords);
|
|
37135
37248
|
if (node) {
|
|
37136
|
-
if (gecko && node
|
|
37249
|
+
if (gecko && isElt(node)) {
|
|
37137
37250
|
// Firefox will sometimes return offsets into <input> nodes, which
|
|
37138
37251
|
// have no actual children, from caretPositionFromPoint (#953)
|
|
37139
37252
|
offset = Math.min(offset, node.childNodes.length);
|
|
@@ -37148,18 +37261,18 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37148
37261
|
}
|
|
37149
37262
|
let prev;
|
|
37150
37263
|
// When clicking above the right side of an uneditable node, Chrome will report a cursor position after that node.
|
|
37151
|
-
if (webkit && offset && node
|
|
37264
|
+
if (webkit && offset && isElt(node) && isElt(prev = node.childNodes[offset - 1]) &&
|
|
37152
37265
|
prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top)
|
|
37153
37266
|
offset--;
|
|
37154
37267
|
// Suspiciously specific kludge to work around caret*FromPoint
|
|
37155
37268
|
// never returning a position at the end of the document
|
|
37156
|
-
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild
|
|
37269
|
+
if (node == view.dom && offset == node.childNodes.length - 1 && isElt(node.lastChild) &&
|
|
37157
37270
|
coords.top > node.lastChild.getBoundingClientRect().bottom)
|
|
37158
37271
|
pos = view.state.doc.content.size;
|
|
37159
37272
|
// Ignore positions directly after a BR, since caret*FromPoint
|
|
37160
37273
|
// 'round up' positions that would be more accurately placed
|
|
37161
37274
|
// before the BR node.
|
|
37162
|
-
else if (offset == 0 || node
|
|
37275
|
+
else if (offset == 0 || !isElt(node) || node.childNodes[offset - 1].nodeName != "BR")
|
|
37163
37276
|
pos = posFromCaret(view, node, offset, coords);
|
|
37164
37277
|
}
|
|
37165
37278
|
if (pos == null)
|
|
@@ -37185,7 +37298,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37185
37298
|
function coordsAtPos(view, pos, side) {
|
|
37186
37299
|
let { node, offset, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
|
|
37187
37300
|
let supportEmptyRange = webkit || gecko;
|
|
37188
|
-
if (node
|
|
37301
|
+
if (isText(node)) {
|
|
37189
37302
|
// These browsers support querying empty text ranges. Prefer that in
|
|
37190
37303
|
// bidi context or when at the end of a node.
|
|
37191
37304
|
if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
|
|
@@ -37227,12 +37340,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37227
37340
|
if (!$dom.parent.inlineContent) {
|
|
37228
37341
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
37229
37342
|
let before = node.childNodes[offset - 1];
|
|
37230
|
-
if (before
|
|
37343
|
+
if (isElt(before))
|
|
37231
37344
|
return flattenH(before.getBoundingClientRect(), false);
|
|
37232
37345
|
}
|
|
37233
37346
|
if (atom == null && offset < nodeSize(node)) {
|
|
37234
37347
|
let after = node.childNodes[offset];
|
|
37235
|
-
if (after
|
|
37348
|
+
if (isElt(after))
|
|
37236
37349
|
return flattenH(after.getBoundingClientRect(), true);
|
|
37237
37350
|
}
|
|
37238
37351
|
return flattenH(node.getBoundingClientRect(), side >= 0);
|
|
@@ -37240,10 +37353,10 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37240
37353
|
// Inline, not in text node (this is not Bidi-safe)
|
|
37241
37354
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
37242
37355
|
let before = node.childNodes[offset - 1];
|
|
37243
|
-
let target = before
|
|
37356
|
+
let target = isText(before) ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1))
|
|
37244
37357
|
// BR nodes tend to only return the rectangle before them.
|
|
37245
37358
|
// Only use them if they are the last element in their parent
|
|
37246
|
-
: before
|
|
37359
|
+
: isElt(before) && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
|
|
37247
37360
|
if (target)
|
|
37248
37361
|
return flattenV(singleRect(target, 1), false);
|
|
37249
37362
|
}
|
|
@@ -37251,13 +37364,13 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37251
37364
|
let after = node.childNodes[offset];
|
|
37252
37365
|
while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords)
|
|
37253
37366
|
after = after.nextSibling;
|
|
37254
|
-
let target = !after ? null : after
|
|
37255
|
-
: after
|
|
37367
|
+
let target = !after ? null : isText(after) ? textRange(after, 0, (supportEmptyRange ? 0 : 1))
|
|
37368
|
+
: isElt(after) ? after : null;
|
|
37256
37369
|
if (target)
|
|
37257
37370
|
return flattenV(singleRect(target, -1), true);
|
|
37258
37371
|
}
|
|
37259
37372
|
// All else failed, just try to get a rectangle for the target node
|
|
37260
|
-
return flattenV(singleRect(node
|
|
37373
|
+
return flattenV(singleRect(isText(node) ? textRange(node) : node, -side), side >= 0);
|
|
37261
37374
|
}
|
|
37262
37375
|
function flattenV(rect, left) {
|
|
37263
37376
|
if (rect.width == 0)
|
|
@@ -37307,9 +37420,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37307
37420
|
let coords = coordsAtPos(view, $pos.pos, 1);
|
|
37308
37421
|
for (let child = dom.firstChild; child; child = child.nextSibling) {
|
|
37309
37422
|
let boxes;
|
|
37310
|
-
if (child
|
|
37423
|
+
if (isElt(child))
|
|
37311
37424
|
boxes = child.getClientRects();
|
|
37312
|
-
else if (child
|
|
37425
|
+
else if (isText(child))
|
|
37313
37426
|
boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
|
|
37314
37427
|
else
|
|
37315
37428
|
continue;
|
|
@@ -37349,8 +37462,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37349
37462
|
sel.modify("move", dir, "character");
|
|
37350
37463
|
let parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;
|
|
37351
37464
|
let { focusNode: newNode, focusOffset: newOff } = view.domSelectionRange();
|
|
37352
|
-
let result = newNode && !
|
|
37353
|
-
(oldNode == newNode && oldOff == newOff);
|
|
37465
|
+
let result = newNode && !contains(parentDOM, newNode) || (oldNode == newNode && oldOff == newOff);
|
|
37354
37466
|
// Restore the previous selection
|
|
37355
37467
|
try {
|
|
37356
37468
|
sel.collapse(anchorNode, anchorOffset);
|
|
@@ -37458,7 +37570,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37458
37570
|
localPosFromDOM(dom, offset, bias) {
|
|
37459
37571
|
// If the DOM position is in the content, use the child desc after
|
|
37460
37572
|
// it to figure out a position.
|
|
37461
|
-
if (this.contentDOM && this.contentDOM
|
|
37573
|
+
if (this.contentDOM && contains(this.contentDOM, dom)) {
|
|
37462
37574
|
if (bias < 0) {
|
|
37463
37575
|
let domBefore, desc;
|
|
37464
37576
|
if (dom == this.contentDOM) {
|
|
@@ -37496,7 +37608,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37496
37608
|
atEnd = offset > domIndex(this.contentDOM);
|
|
37497
37609
|
}
|
|
37498
37610
|
else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {
|
|
37499
|
-
atEnd = dom.compareDocumentPosition(this.contentDOM) &
|
|
37611
|
+
atEnd = !!(dom.compareDocumentPosition(this.contentDOM) & 4);
|
|
37500
37612
|
}
|
|
37501
37613
|
else if (this.dom.firstChild) {
|
|
37502
37614
|
if (offset == 0)
|
|
@@ -37526,7 +37638,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37526
37638
|
if (desc && (!onlyNodes || desc.node)) {
|
|
37527
37639
|
// If dom is outside of this desc's nodeDOM, don't count it.
|
|
37528
37640
|
if (first && (nodeDOM = desc.nodeDOM) &&
|
|
37529
|
-
!(nodeDOM
|
|
37641
|
+
!(isElt(nodeDOM) ? contains(nodeDOM, dom) : nodeDOM == dom))
|
|
37530
37642
|
first = false;
|
|
37531
37643
|
else
|
|
37532
37644
|
return desc;
|
|
@@ -37576,7 +37688,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37576
37688
|
let i = 0, offset = 0;
|
|
37577
37689
|
for (let curPos = 0; i < this.children.length; i++) {
|
|
37578
37690
|
let child = this.children[i], end = curPos + child.size;
|
|
37579
|
-
if (end > pos
|
|
37691
|
+
if (end > pos) {
|
|
37580
37692
|
offset = pos - curPos;
|
|
37581
37693
|
break;
|
|
37582
37694
|
}
|
|
@@ -37586,7 +37698,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37586
37698
|
if (offset)
|
|
37587
37699
|
return this.children[i].domFromPos(offset - this.children[i].border, side);
|
|
37588
37700
|
// Go back if there were any zero-length widgets with side >= 0 before this point
|
|
37589
|
-
for (
|
|
37701
|
+
for (; i > 0; i--) {
|
|
37702
|
+
let prev = this.children[i - 1];
|
|
37703
|
+
if (prev.size || !(prev instanceof BufferHackViewDesc || prev instanceof WidgetViewDesc && prev.side >= 0))
|
|
37704
|
+
break;
|
|
37705
|
+
}
|
|
37590
37706
|
// Scan towards the first useable node
|
|
37591
37707
|
if (side <= 0) {
|
|
37592
37708
|
let prev, enter = true;
|
|
@@ -37663,7 +37779,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37663
37779
|
}
|
|
37664
37780
|
domAfterPos(pos) {
|
|
37665
37781
|
let { node, offset } = this.domFromPos(pos, 0);
|
|
37666
|
-
if (node
|
|
37782
|
+
if (!isElt(node) || offset == node.childNodes.length)
|
|
37667
37783
|
throw new RangeError("No node after pos " + pos);
|
|
37668
37784
|
return node.childNodes[offset];
|
|
37669
37785
|
}
|
|
@@ -37692,7 +37808,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37692
37808
|
// reported position in such situations (#1092).
|
|
37693
37809
|
if ((gecko || safari) && anchor == head) {
|
|
37694
37810
|
let { node, offset } = anchorDOM;
|
|
37695
|
-
if (node
|
|
37811
|
+
if (isText(node)) {
|
|
37696
37812
|
brKludge = !!(offset && node.nodeValue[offset - 1] == "\n");
|
|
37697
37813
|
// Issue #1128
|
|
37698
37814
|
if (brKludge && offset == node.nodeValue.length) {
|
|
@@ -37715,7 +37831,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37715
37831
|
}
|
|
37716
37832
|
// Firefox can act strangely when the selection is in front of an
|
|
37717
37833
|
// uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536
|
|
37718
|
-
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode
|
|
37834
|
+
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && isElt(selRange.focusNode)) {
|
|
37719
37835
|
let after = selRange.focusNode.childNodes[selRange.focusOffset];
|
|
37720
37836
|
if (after && after.contentEditable == "false")
|
|
37721
37837
|
force = true;
|
|
@@ -37814,14 +37930,12 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37814
37930
|
return self.parent.posBeforeChild(self);
|
|
37815
37931
|
});
|
|
37816
37932
|
if (!widget.type.spec.raw) {
|
|
37817
|
-
|
|
37818
|
-
|
|
37819
|
-
|
|
37820
|
-
|
|
37821
|
-
|
|
37822
|
-
|
|
37823
|
-
dom.contentEditable = "false";
|
|
37824
|
-
dom.classList.add("ProseMirror-widget");
|
|
37933
|
+
let elt = isElt(dom) ? dom : document.createElement("span");
|
|
37934
|
+
if (elt != dom)
|
|
37935
|
+
elt.appendChild(dom);
|
|
37936
|
+
if (!elt.hasAttribute("contenteditable"))
|
|
37937
|
+
elt.contentEditable = "false";
|
|
37938
|
+
elt.classList.add("ProseMirror-widget");
|
|
37825
37939
|
}
|
|
37826
37940
|
super(parent, [], dom, null);
|
|
37827
37941
|
this.widget = widget;
|
|
@@ -37957,7 +38071,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
37957
38071
|
if (node.isText) {
|
|
37958
38072
|
if (!dom)
|
|
37959
38073
|
dom = document.createTextNode(node.text);
|
|
37960
|
-
else if (dom
|
|
38074
|
+
else if (!isText(dom))
|
|
37961
38075
|
throw new RangeError("Text must be rendered as a DOM text node");
|
|
37962
38076
|
}
|
|
37963
38077
|
else if (!dom) {
|
|
@@ -38009,7 +38123,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38009
38123
|
}
|
|
38010
38124
|
if (!rule.contentElement) {
|
|
38011
38125
|
let found = addedNodes &&
|
|
38012
|
-
addedNodes.find(n => n
|
|
38126
|
+
addedNodes.find(n => isElt(n) && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
|
|
38013
38127
|
if (found)
|
|
38014
38128
|
rule.contentElement = found;
|
|
38015
38129
|
else
|
|
@@ -38034,6 +38148,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38034
38148
|
let localComposition = composition && composition.pos > -1 ? composition : null;
|
|
38035
38149
|
let compositionInChild = composition && composition.pos < 0;
|
|
38036
38150
|
let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
|
|
38151
|
+
let addBuffers = this.node.inlineContent, atBufferPos = addBuffers && this.node.isBlock;
|
|
38037
38152
|
iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
|
|
38038
38153
|
if (widget.spec.marks)
|
|
38039
38154
|
updater.syncToMarks(widget.spec.marks, inline, view, i);
|
|
@@ -38045,6 +38160,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38045
38160
|
}, (child, outerDeco, innerDeco, i) => {
|
|
38046
38161
|
// Make sure the wrapping mark descs match the node's marks.
|
|
38047
38162
|
updater.syncToMarks(child.marks, inline, view, i);
|
|
38163
|
+
if (atBufferPos && child.isAtom && !child.isText)
|
|
38164
|
+
updater.addHackNode("IMG", updater.top);
|
|
38048
38165
|
// Try several strategies for drawing this node
|
|
38049
38166
|
let compIndex;
|
|
38050
38167
|
if (updater.findNodeMatch(child, outerDeco, innerDeco, i)) ;
|
|
@@ -38058,6 +38175,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38058
38175
|
updater.addNode(child, outerDeco, innerDeco, view, off);
|
|
38059
38176
|
}
|
|
38060
38177
|
off += child.nodeSize;
|
|
38178
|
+
if (addBuffers)
|
|
38179
|
+
atBufferPos = child.isAtom && !child.isText;
|
|
38061
38180
|
});
|
|
38062
38181
|
// Drop all remaining descs after the current position.
|
|
38063
38182
|
updater.syncToMarks([], inline, view, 0);
|
|
@@ -38136,7 +38255,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38136
38255
|
updateOuterDeco(outerDeco) {
|
|
38137
38256
|
if (sameOuterDeco(outerDeco, this.outerDeco))
|
|
38138
38257
|
return;
|
|
38139
|
-
let needsWrap = this.nodeDOM
|
|
38258
|
+
let needsWrap = !isElt(this.nodeDOM);
|
|
38140
38259
|
let oldDOM = this.dom;
|
|
38141
38260
|
this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
|
|
38142
38261
|
if (this.dom != oldDOM) {
|
|
@@ -38147,7 +38266,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38147
38266
|
}
|
|
38148
38267
|
// Mark this node as being the selected node.
|
|
38149
38268
|
selectNode() {
|
|
38150
|
-
if (this.nodeDOM
|
|
38269
|
+
if (isElt(this.nodeDOM)) {
|
|
38151
38270
|
this.nodeDOM.classList.add("ProseMirror-selectednode");
|
|
38152
38271
|
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
38153
38272
|
this.nodeDOM.draggable = true;
|
|
@@ -38155,7 +38274,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38155
38274
|
}
|
|
38156
38275
|
// Remove selected node marking from this node.
|
|
38157
38276
|
deselectNode() {
|
|
38158
|
-
if (this.nodeDOM
|
|
38277
|
+
if (isElt(this.nodeDOM)) {
|
|
38159
38278
|
this.nodeDOM.classList.remove("ProseMirror-selectednode");
|
|
38160
38279
|
if (this.contentDOM || !this.node.type.spec.draggable)
|
|
38161
38280
|
this.nodeDOM.removeAttribute("draggable");
|
|
@@ -38226,9 +38345,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38226
38345
|
get domAtom() { return false; }
|
|
38227
38346
|
isText(text) { return this.node.text == text; }
|
|
38228
38347
|
}
|
|
38229
|
-
// A dummy desc used to tag
|
|
38348
|
+
// A dummy desc used to tag extra BR or IMG nodes created to work
|
|
38230
38349
|
// around contentEditable terribleness.
|
|
38231
|
-
class
|
|
38350
|
+
class BufferHackViewDesc extends ViewDesc {
|
|
38232
38351
|
parseRule() { return { ignore: true }; }
|
|
38233
38352
|
matchesHack(nodeName) { return this.dirty == NOT_DIRTY && this.dom.nodeName == nodeName; }
|
|
38234
38353
|
get domAtom() { return true; }
|
|
@@ -38401,7 +38520,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38401
38520
|
}
|
|
38402
38521
|
}
|
|
38403
38522
|
function applyOuterDeco(dom, deco, node) {
|
|
38404
|
-
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom
|
|
38523
|
+
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, !isElt(dom)));
|
|
38405
38524
|
}
|
|
38406
38525
|
function sameOuterDeco(a, b) {
|
|
38407
38526
|
if (a.length != b.length)
|
|
@@ -38664,7 +38783,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38664
38783
|
}
|
|
38665
38784
|
if (nodeName == "BR")
|
|
38666
38785
|
dom.className = "ProseMirror-trailingBreak";
|
|
38667
|
-
let hack = new
|
|
38786
|
+
let hack = new BufferHackViewDesc(this.top, [], dom, null);
|
|
38668
38787
|
if (parent != this.top)
|
|
38669
38788
|
parent.children.push(hack);
|
|
38670
38789
|
else
|
|
@@ -38673,7 +38792,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38673
38792
|
}
|
|
38674
38793
|
}
|
|
38675
38794
|
isLocked(node) {
|
|
38676
|
-
return this.lock && (node == this.lock || node
|
|
38795
|
+
return this.lock && (node == this.lock || isElt(node) && node.contains(this.lock.parentNode));
|
|
38677
38796
|
}
|
|
38678
38797
|
}
|
|
38679
38798
|
// Iterate from the end of the fragment and array of descs to find
|
|
@@ -38875,12 +38994,27 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
38875
38994
|
anchor = head;
|
|
38876
38995
|
while (nearestDesc && !nearestDesc.node)
|
|
38877
38996
|
nearestDesc = nearestDesc.parent;
|
|
38878
|
-
|
|
38879
|
-
|
|
38880
|
-
|
|
38997
|
+
if (nearestDesc && nearestDesc.node.isAtom && NodeSelection.isSelectable(nearestDesc.node) &&
|
|
38998
|
+
nearestDesc.parent &&
|
|
38999
|
+
!(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
|
|
38881
39000
|
let pos = nearestDesc.posBefore;
|
|
38882
39001
|
selection = new NodeSelection(head == pos ? $head : doc.resolve(pos));
|
|
38883
39002
|
}
|
|
39003
|
+
else if (gecko && origin == "key" && head > view.state.selection.to &&
|
|
39004
|
+
isElt(domSel.focusNode) && domSel.focusOffset == domSel.focusNode.childNodes.length &&
|
|
39005
|
+
nearestDesc && nearestDesc.posAtStart > view.state.selection.to) {
|
|
39006
|
+
// Firefox will jump across scrollable wrapper nodes on keyboard
|
|
39007
|
+
// cursor motion (#1594). This tries to detect this situation
|
|
39008
|
+
// and work around it.
|
|
39009
|
+
for (let scan = domSel.focusNode;; scan = scan.parentNode) {
|
|
39010
|
+
if (getComputedStyle(scan).overflow != "visible") {
|
|
39011
|
+
selection = Selection$2.findFrom(doc.resolve(nearestDesc.posAtStart), 1);
|
|
39012
|
+
break;
|
|
39013
|
+
}
|
|
39014
|
+
if (scan == nearestDesc.dom || scan.nextSibling || !scan.parentNode || !isElt(scan.parentNode))
|
|
39015
|
+
break;
|
|
39016
|
+
}
|
|
39017
|
+
}
|
|
38884
39018
|
}
|
|
38885
39019
|
else {
|
|
38886
39020
|
if (domSel instanceof view.dom.ownerDocument.defaultView.Selection && domSel.rangeCount > 1) {
|
|
@@ -39066,8 +39200,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39066
39200
|
// Firefox will raise 'permission denied' errors when accessing
|
|
39067
39201
|
// properties of `sel.anchorNode` when it's in a generated CSS
|
|
39068
39202
|
// element.
|
|
39069
|
-
return view.dom
|
|
39070
|
-
(view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode));
|
|
39203
|
+
return contains(view.dom, sel.anchorNode) && (view.editable || contains(view.dom, sel.focusNode));
|
|
39071
39204
|
}
|
|
39072
39205
|
catch (_) {
|
|
39073
39206
|
return false;
|
|
@@ -39118,15 +39251,14 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39118
39251
|
if (NodeSelection.isSelectable(node)) {
|
|
39119
39252
|
return apply(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head));
|
|
39120
39253
|
}
|
|
39121
|
-
else
|
|
39254
|
+
else {
|
|
39122
39255
|
// Chrome and Safari will introduce extra pointless cursor
|
|
39123
|
-
// positions around inline uneditable nodes,
|
|
39124
|
-
//
|
|
39256
|
+
// positions around inline uneditable nodes (#937), and
|
|
39257
|
+
// Firefox will sometimes just plain refuse to move across
|
|
39258
|
+
// them (#1592), so in this situation we move the cursor
|
|
39259
|
+
// ourselves.
|
|
39125
39260
|
return apply(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
|
|
39126
39261
|
}
|
|
39127
|
-
else {
|
|
39128
|
-
return false;
|
|
39129
|
-
}
|
|
39130
39262
|
}
|
|
39131
39263
|
}
|
|
39132
39264
|
else if (sel instanceof NodeSelection && sel.node.isInline) {
|
|
@@ -39139,12 +39271,10 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39139
39271
|
return false;
|
|
39140
39272
|
}
|
|
39141
39273
|
}
|
|
39142
|
-
function nodeLen(node) {
|
|
39143
|
-
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
39144
|
-
}
|
|
39145
39274
|
function isIgnorable(dom, dir) {
|
|
39146
39275
|
let desc = dom.pmViewDesc;
|
|
39147
|
-
return desc
|
|
39276
|
+
return desc ? desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR")
|
|
39277
|
+
: isElt(dom) && dom.contentEditable == "false";
|
|
39148
39278
|
}
|
|
39149
39279
|
function skipIgnoredNodes(view, dir) {
|
|
39150
39280
|
return dir < 0 ? skipIgnoredNodesBefore(view) : skipIgnoredNodesAfter(view);
|
|
@@ -39160,25 +39290,23 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39160
39290
|
// Gecko will do odd things when the selection is directly in front
|
|
39161
39291
|
// of a non-editable node, so in that case, move it into the next
|
|
39162
39292
|
// node if possible. Issue prosemirror/prosemirror#832.
|
|
39163
|
-
if (gecko && node
|
|
39293
|
+
if (gecko && isElt(node) && offset < nodeSize(node) && isIgnorable(node.childNodes[offset], -1))
|
|
39164
39294
|
force = true;
|
|
39165
39295
|
for (;;) {
|
|
39166
39296
|
if (offset > 0) {
|
|
39167
|
-
if (node
|
|
39297
|
+
if (!isElt(node))
|
|
39168
39298
|
break;
|
|
39299
|
+
let before = node.childNodes[offset - 1];
|
|
39300
|
+
if (isIgnorable(before, -1)) {
|
|
39301
|
+
moveNode = node;
|
|
39302
|
+
moveOffset = --offset;
|
|
39303
|
+
}
|
|
39304
|
+
else if (isText(before)) {
|
|
39305
|
+
node = before;
|
|
39306
|
+
offset = node.nodeValue.length;
|
|
39169
39307
|
}
|
|
39170
39308
|
else {
|
|
39171
|
-
|
|
39172
|
-
if (isIgnorable(before, -1)) {
|
|
39173
|
-
moveNode = node;
|
|
39174
|
-
moveOffset = --offset;
|
|
39175
|
-
}
|
|
39176
|
-
else if (before.nodeType == 3) {
|
|
39177
|
-
node = before;
|
|
39178
|
-
offset = node.nodeValue.length;
|
|
39179
|
-
}
|
|
39180
|
-
else
|
|
39181
|
-
break;
|
|
39309
|
+
break;
|
|
39182
39310
|
}
|
|
39183
39311
|
}
|
|
39184
39312
|
else if (isBlockNode(node)) {
|
|
@@ -39199,7 +39327,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39199
39327
|
}
|
|
39200
39328
|
else {
|
|
39201
39329
|
node = prev;
|
|
39202
|
-
offset =
|
|
39330
|
+
offset = nodeSize(node);
|
|
39203
39331
|
}
|
|
39204
39332
|
}
|
|
39205
39333
|
}
|
|
@@ -39215,19 +39343,20 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39215
39343
|
let node = sel.focusNode, offset = sel.focusOffset;
|
|
39216
39344
|
if (!node)
|
|
39217
39345
|
return;
|
|
39218
|
-
let len =
|
|
39346
|
+
let len = nodeSize(node);
|
|
39219
39347
|
let moveNode, moveOffset;
|
|
39220
39348
|
for (;;) {
|
|
39221
39349
|
if (offset < len) {
|
|
39222
|
-
if (node
|
|
39350
|
+
if (!isElt(node))
|
|
39223
39351
|
break;
|
|
39224
39352
|
let after = node.childNodes[offset];
|
|
39225
39353
|
if (isIgnorable(after, 1)) {
|
|
39226
39354
|
moveNode = node;
|
|
39227
39355
|
moveOffset = ++offset;
|
|
39228
39356
|
}
|
|
39229
|
-
else
|
|
39357
|
+
else {
|
|
39230
39358
|
break;
|
|
39359
|
+
}
|
|
39231
39360
|
}
|
|
39232
39361
|
else if (isBlockNode(node)) {
|
|
39233
39362
|
break;
|
|
@@ -39248,7 +39377,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39248
39377
|
else {
|
|
39249
39378
|
node = next;
|
|
39250
39379
|
offset = 0;
|
|
39251
|
-
len =
|
|
39380
|
+
len = nodeSize(node);
|
|
39252
39381
|
}
|
|
39253
39382
|
}
|
|
39254
39383
|
}
|
|
@@ -39266,9 +39395,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39266
39395
|
}
|
|
39267
39396
|
while (node && offset < node.childNodes.length) {
|
|
39268
39397
|
let next = node.childNodes[offset];
|
|
39269
|
-
if (next
|
|
39398
|
+
if (isText(next))
|
|
39270
39399
|
return next;
|
|
39271
|
-
if (next
|
|
39400
|
+
if (isElt(next) && next.contentEditable == "false")
|
|
39272
39401
|
break;
|
|
39273
39402
|
node = next;
|
|
39274
39403
|
offset = 0;
|
|
@@ -39281,16 +39410,16 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39281
39410
|
}
|
|
39282
39411
|
while (node && offset) {
|
|
39283
39412
|
let next = node.childNodes[offset - 1];
|
|
39284
|
-
if (next
|
|
39413
|
+
if (isText(next))
|
|
39285
39414
|
return next;
|
|
39286
|
-
if (next
|
|
39415
|
+
if (isElt(next) && next.contentEditable == "false")
|
|
39287
39416
|
break;
|
|
39288
39417
|
node = next;
|
|
39289
39418
|
offset = node.childNodes.length;
|
|
39290
39419
|
}
|
|
39291
39420
|
}
|
|
39292
39421
|
function setSelFocus(view, node, offset) {
|
|
39293
|
-
if (node
|
|
39422
|
+
if (!isText(node)) {
|
|
39294
39423
|
let before, after;
|
|
39295
39424
|
if (after = textNodeAfter(node, offset)) {
|
|
39296
39425
|
node = after;
|
|
@@ -39400,8 +39529,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39400
39529
|
if (!safari || view.state.selection.$head.parentOffset > 0)
|
|
39401
39530
|
return false;
|
|
39402
39531
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
39403
|
-
if (focusNode && focusNode
|
|
39404
|
-
focusNode.firstChild && focusNode.firstChild.contentEditable == "false") {
|
|
39532
|
+
if (focusNode && isElt(focusNode) && focusOffset == 0 &&
|
|
39533
|
+
focusNode.firstChild && isElt(focusNode.firstChild) && focusNode.firstChild.contentEditable == "false") {
|
|
39405
39534
|
let child = focusNode.firstChild;
|
|
39406
39535
|
switchEditable(view, child, "true");
|
|
39407
39536
|
setTimeout(() => switchEditable(view, child, "false"), 20);
|
|
@@ -39472,7 +39601,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39472
39601
|
let doc = detachedDoc(), wrap = doc.createElement("div");
|
|
39473
39602
|
wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
|
|
39474
39603
|
let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
|
|
39475
|
-
while (firstChild && firstChild
|
|
39604
|
+
while (firstChild && isElt(firstChild) && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
|
|
39476
39605
|
for (let i = needsWrap.length - 1; i >= 0; i--) {
|
|
39477
39606
|
let wrapper = doc.createElement(needsWrap[i]);
|
|
39478
39607
|
while (wrap.firstChild)
|
|
@@ -39482,7 +39611,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39482
39611
|
}
|
|
39483
39612
|
firstChild = wrap.firstChild;
|
|
39484
39613
|
}
|
|
39485
|
-
if (firstChild && firstChild
|
|
39614
|
+
if (firstChild && isElt(firstChild))
|
|
39486
39615
|
firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
|
|
39487
39616
|
let text = view.someProp("clipboardTextSerializer", f => f(slice, view)) ||
|
|
39488
39617
|
slice.content.textBetween(0, slice.content.size, "\n\n");
|
|
@@ -39528,7 +39657,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39528
39657
|
if (sliceData && sliceData[3])
|
|
39529
39658
|
for (let i = +sliceData[3]; i > 0; i--) {
|
|
39530
39659
|
let child = dom.firstChild;
|
|
39531
|
-
while (child && child
|
|
39660
|
+
while (child && !isElt(child))
|
|
39532
39661
|
child = child.nextSibling;
|
|
39533
39662
|
if (!child)
|
|
39534
39663
|
break;
|
|
@@ -39733,12 +39862,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
39733
39862
|
if (!type || type.hasRequiredAttrs())
|
|
39734
39863
|
break;
|
|
39735
39864
|
try {
|
|
39736
|
-
type.
|
|
39865
|
+
content = Fragment.from(type.create(array[i + 1], content));
|
|
39737
39866
|
}
|
|
39738
39867
|
catch (e) {
|
|
39739
39868
|
break;
|
|
39740
39869
|
}
|
|
39741
|
-
content = Fragment.from(type.create(array[i + 1], content));
|
|
39742
39870
|
openStart++;
|
|
39743
39871
|
openEnd++;
|
|
39744
39872
|
}
|
|
@@ -40070,7 +40198,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40070
40198
|
}
|
|
40071
40199
|
const target = flushed ? null : event.target;
|
|
40072
40200
|
const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
40073
|
-
this.target = targetDesc && targetDesc.nodeDOM
|
|
40201
|
+
this.target = targetDesc && isElt(targetDesc.nodeDOM) ? targetDesc.nodeDOM : null;
|
|
40074
40202
|
let { selection } = view.state;
|
|
40075
40203
|
if (event.button == 0 &&
|
|
40076
40204
|
(targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
@@ -40218,7 +40346,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40218
40346
|
if (!view.composing) {
|
|
40219
40347
|
view.domObserver.flush();
|
|
40220
40348
|
let { state } = view, $pos = state.selection.$to;
|
|
40221
|
-
if (state.selection instanceof TextSelection &&
|
|
40349
|
+
if (state.selection instanceof TextSelection && state.selection.empty &&
|
|
40222
40350
|
(state.storedMarks ||
|
|
40223
40351
|
(!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(m => m.type.spec.inclusive === false)) ||
|
|
40224
40352
|
chrome && windows$1 && selectionBeforeUneditable(view))) { // Issue #1500
|
|
@@ -40234,11 +40362,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40234
40362
|
// inside if necessary.
|
|
40235
40363
|
if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
|
|
40236
40364
|
let sel = view.domSelectionRange();
|
|
40237
|
-
for (let node = sel.focusNode, offset = sel.focusOffset; node && node
|
|
40365
|
+
for (let node = sel.focusNode, offset = sel.focusOffset; node && isElt(node) && offset != 0;) {
|
|
40238
40366
|
let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
|
|
40239
40367
|
if (!before)
|
|
40240
40368
|
break;
|
|
40241
|
-
if (before
|
|
40369
|
+
if (isText(before)) {
|
|
40242
40370
|
let sel = view.domSelection();
|
|
40243
40371
|
if (sel)
|
|
40244
40372
|
sel.collapse(before, before.nodeValue.length);
|
|
@@ -40257,10 +40385,10 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40257
40385
|
};
|
|
40258
40386
|
function selectionBeforeUneditable(view) {
|
|
40259
40387
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
40260
|
-
if (!focusNode || focusNode
|
|
40388
|
+
if (!focusNode || !isElt(focusNode) || focusOffset >= focusNode.childNodes.length)
|
|
40261
40389
|
return false;
|
|
40262
40390
|
let next = focusNode.childNodes[focusOffset];
|
|
40263
|
-
return next
|
|
40391
|
+
return isElt(next) && next.contentEditable == "false";
|
|
40264
40392
|
}
|
|
40265
40393
|
editHandlers.compositionend = (view, event) => {
|
|
40266
40394
|
if (view.composing) {
|
|
@@ -40462,7 +40590,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
40462
40590
|
else if (mouseDown && mouseDown.mightDrag) {
|
|
40463
40591
|
node = NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);
|
|
40464
40592
|
}
|
|
40465
|
-
else if (event.target && event.target
|
|
40593
|
+
else if (event.target && isElt(event.target)) {
|
|
40466
40594
|
let desc = view.docView.nearestDesc(event.target, true);
|
|
40467
40595
|
if (desc && desc.node.type.spec.draggable && desc != view.docView)
|
|
40468
40596
|
node = NodeSelection.create(view.state.doc, desc.posBefore);
|
|
@@ -41433,7 +41561,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41433
41561
|
let desc = container && this.view.docView.nearestDesc(container);
|
|
41434
41562
|
if (desc && desc.ignoreMutation({
|
|
41435
41563
|
type: "selection",
|
|
41436
|
-
target: container
|
|
41564
|
+
target: isText(container) ? container.parentNode : container
|
|
41437
41565
|
})) {
|
|
41438
41566
|
this.setCurSelection();
|
|
41439
41567
|
return true;
|
|
@@ -41475,7 +41603,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41475
41603
|
for (let node of added)
|
|
41476
41604
|
if (node.nodeName == "BR" && node.parentNode) {
|
|
41477
41605
|
let after = node.nextSibling;
|
|
41478
|
-
while (after && after
|
|
41606
|
+
while (after && isElt(after)) {
|
|
41479
41607
|
if (after.contentEditable == "false") {
|
|
41480
41608
|
node.parentNode.removeChild(node);
|
|
41481
41609
|
break;
|
|
@@ -41548,7 +41676,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41548
41676
|
for (let i = 0; i < mut.addedNodes.length; i++) {
|
|
41549
41677
|
let node = mut.addedNodes[i];
|
|
41550
41678
|
added.push(node);
|
|
41551
|
-
if (node
|
|
41679
|
+
if (isText(node))
|
|
41552
41680
|
this.lastChangedTextNode = node;
|
|
41553
41681
|
}
|
|
41554
41682
|
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
|
|
@@ -41663,8 +41791,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41663
41791
|
let parent = nextCell;
|
|
41664
41792
|
for (;;) {
|
|
41665
41793
|
let first = parent.firstChild;
|
|
41666
|
-
if (!first || first
|
|
41667
|
-
/^(BR|IMG)$/.test(first.nodeName))
|
|
41794
|
+
if (!first || !isElt(first) || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName))
|
|
41668
41795
|
break;
|
|
41669
41796
|
parent = first;
|
|
41670
41797
|
}
|
|
@@ -41689,7 +41816,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41689
41816
|
let domSel = view.domSelectionRange();
|
|
41690
41817
|
let find;
|
|
41691
41818
|
let anchor = domSel.anchorNode;
|
|
41692
|
-
if (anchor && view.dom
|
|
41819
|
+
if (anchor && contains(view.dom, anchor)) {
|
|
41693
41820
|
find = [{ node: anchor, offset: domSel.anchorOffset }];
|
|
41694
41821
|
if (!selectionCollapsed(domSel))
|
|
41695
41822
|
find.push({ node: domSel.focusNode, offset: domSel.focusOffset });
|
|
@@ -41797,7 +41924,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41797
41924
|
if (change)
|
|
41798
41925
|
view.input.domChangeCount++;
|
|
41799
41926
|
if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) &&
|
|
41800
|
-
addedNodes.some(n => n
|
|
41927
|
+
addedNodes.some(n => isElt(n) && !isInline.test(n.nodeName)) &&
|
|
41801
41928
|
(!change || change.endA >= change.endB) &&
|
|
41802
41929
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
41803
41930
|
view.input.lastIOSEnter = 0;
|
|
@@ -41855,9 +41982,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
41855
41982
|
// as being an iOS enter press), just dispatch an Enter key instead.
|
|
41856
41983
|
if (((ios && view.input.lastIOSEnter > Date.now() - 225 &&
|
|
41857
41984
|
(!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
|
|
41858
|
-
(!inlineChange && $from.pos
|
|
41859
|
-
(!$from.sameParent($to) || !$from.parent.inlineContent) &&
|
|
41860
|
-
$from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")))) &&
|
|
41985
|
+
(!inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos))) &&
|
|
41861
41986
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
41862
41987
|
view.input.lastIOSEnter = 0;
|
|
41863
41988
|
return;
|
|
@@ -42008,6 +42133,16 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42008
42133
|
// The fragments after the join point must match
|
|
42009
42134
|
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
|
|
42010
42135
|
}
|
|
42136
|
+
function looksLikeEnter(content, from, to) {
|
|
42137
|
+
let newTextlines = 0, newLeaves = 0;
|
|
42138
|
+
content.nodesBetween(from, to, (node, pos) => {
|
|
42139
|
+
if (node.isTextblock && pos >= from && pos < to)
|
|
42140
|
+
newTextlines++;
|
|
42141
|
+
else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf)
|
|
42142
|
+
newLeaves++;
|
|
42143
|
+
});
|
|
42144
|
+
return newLeaves == 0 && newTextlines == 1;
|
|
42145
|
+
}
|
|
42011
42146
|
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
42012
42147
|
let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;
|
|
42013
42148
|
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
|
|
@@ -42268,11 +42403,11 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42268
42403
|
*/
|
|
42269
42404
|
scrollToSelection() {
|
|
42270
42405
|
let startDOM = this.domSelectionRange().focusNode;
|
|
42271
|
-
if (!startDOM || !this.dom
|
|
42406
|
+
if (!startDOM || !contains(this.dom, startDOM)) ;
|
|
42272
42407
|
else if (this.someProp("handleScrollToSelection", f => f(this))) ;
|
|
42273
42408
|
else if (this.state.selection instanceof NodeSelection) {
|
|
42274
42409
|
let target = this.docView.domAfterPos(this.state.selection.from);
|
|
42275
|
-
if (target
|
|
42410
|
+
if (isElt(target))
|
|
42276
42411
|
scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
|
|
42277
42412
|
}
|
|
42278
42413
|
else {
|
|
@@ -42537,7 +42672,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42537
42672
|
@internal
|
|
42538
42673
|
*/
|
|
42539
42674
|
domSelectionRange() {
|
|
42540
|
-
let sel = this.domSelection();
|
|
42675
|
+
let sel = this.dom.isConnected !== false && this.domSelection();
|
|
42541
42676
|
if (!sel)
|
|
42542
42677
|
return { focusNode: null, focusOffset: 0, anchorNode: null, anchorOffset: 0 };
|
|
42543
42678
|
return safari && this.root.nodeType === 11 &&
|
|
@@ -42868,336 +43003,967 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
42868
43003
|
};
|
|
42869
43004
|
}
|
|
42870
43005
|
|
|
42871
|
-
|
|
42872
|
-
|
|
42873
|
-
|
|
42874
|
-
|
|
42875
|
-
|
|
42876
|
-
|
|
42877
|
-
|
|
42878
|
-
|
|
42879
|
-
|
|
42880
|
-
|
|
42881
|
-
|
|
42882
|
-
|
|
42883
|
-
|
|
42884
|
-
|
|
42885
|
-
|
|
42886
|
-
plugins: state.plugins,
|
|
42887
|
-
schema: state.schema,
|
|
42888
|
-
reconfigure: state.reconfigure.bind(state),
|
|
42889
|
-
toJSON: state.toJSON.bind(state),
|
|
42890
|
-
get storedMarks() {
|
|
42891
|
-
return storedMarks;
|
|
42892
|
-
},
|
|
42893
|
-
get selection() {
|
|
42894
|
-
return selection;
|
|
42895
|
-
},
|
|
42896
|
-
get doc() {
|
|
42897
|
-
return doc;
|
|
42898
|
-
},
|
|
42899
|
-
get tr() {
|
|
42900
|
-
selection = transaction.selection;
|
|
42901
|
-
doc = transaction.doc;
|
|
42902
|
-
storedMarks = transaction.storedMarks;
|
|
42903
|
-
return transaction;
|
|
42904
|
-
}
|
|
42905
|
-
};
|
|
42906
|
-
}
|
|
42907
|
-
//#endregion
|
|
42908
|
-
//#region src/CommandManager.ts
|
|
42909
|
-
var CommandManager = class CommandManager {
|
|
42910
|
-
constructor(props) {
|
|
42911
|
-
this.editor = props.editor;
|
|
42912
|
-
this.rawCommands = this.editor.extensionManager.commands;
|
|
42913
|
-
this.customState = props.state;
|
|
42914
|
-
}
|
|
42915
|
-
get hasCustomState() {
|
|
42916
|
-
return !!this.customState;
|
|
42917
|
-
}
|
|
42918
|
-
get state() {
|
|
42919
|
-
return this.customState || this.editor.state;
|
|
42920
|
-
}
|
|
42921
|
-
get commands() {
|
|
42922
|
-
const { rawCommands, editor, state } = this;
|
|
42923
|
-
const { view } = editor;
|
|
42924
|
-
const { tr } = state;
|
|
42925
|
-
const props = this.buildProps(tr);
|
|
42926
|
-
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
42927
|
-
const method = (...args) => {
|
|
42928
|
-
const callback = command(...args)(props);
|
|
42929
|
-
if (!tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
42930
|
-
return callback;
|
|
42931
|
-
};
|
|
42932
|
-
return [name, method];
|
|
42933
|
-
}));
|
|
42934
|
-
}
|
|
42935
|
-
get chain() {
|
|
42936
|
-
return () => this.createChain();
|
|
42937
|
-
}
|
|
42938
|
-
get can() {
|
|
42939
|
-
return () => this.createCan();
|
|
42940
|
-
}
|
|
42941
|
-
createChain(startTr, shouldDispatch = true) {
|
|
42942
|
-
const { rawCommands, editor, state } = this;
|
|
42943
|
-
const { view } = editor;
|
|
42944
|
-
const callbacks = [];
|
|
42945
|
-
const hasStartTransaction = !!startTr;
|
|
42946
|
-
const tr = startTr || state.tr;
|
|
42947
|
-
const run = () => {
|
|
42948
|
-
if (!hasStartTransaction && shouldDispatch && !tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
42949
|
-
return callbacks.every((callback) => callback === true);
|
|
42950
|
-
};
|
|
42951
|
-
const chain = {
|
|
42952
|
-
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
42953
|
-
const chainedCommand = (...args) => {
|
|
42954
|
-
const props = this.buildProps(tr, shouldDispatch);
|
|
42955
|
-
const callback = command(...args)(props);
|
|
42956
|
-
callbacks.push(callback);
|
|
42957
|
-
return chain;
|
|
42958
|
-
};
|
|
42959
|
-
return [name, chainedCommand];
|
|
42960
|
-
})),
|
|
42961
|
-
run
|
|
42962
|
-
};
|
|
42963
|
-
return chain;
|
|
42964
|
-
}
|
|
42965
|
-
/**
|
|
42966
|
-
* Creates a chain that safely returns `false` when run.
|
|
42967
|
-
* @returns A non-dispatching command chain.
|
|
42968
|
-
* @example
|
|
42969
|
-
* const chain = CommandManager.createFakeChain()
|
|
42970
|
-
* chain.focus().run() // false
|
|
42971
|
-
*/
|
|
42972
|
-
static createFakeChain() {
|
|
42973
|
-
const chain = new Proxy({}, { get: (_target, property) => {
|
|
42974
|
-
if (property === "then") return;
|
|
42975
|
-
if (property === "run") return () => false;
|
|
42976
|
-
return () => chain;
|
|
42977
|
-
} });
|
|
42978
|
-
return chain;
|
|
42979
|
-
}
|
|
42980
|
-
createCan(startTr) {
|
|
42981
|
-
const { rawCommands, state } = this;
|
|
42982
|
-
const dispatch = false;
|
|
42983
|
-
const tr = startTr || state.tr;
|
|
42984
|
-
const props = this.buildProps(tr, dispatch);
|
|
42985
|
-
return {
|
|
42986
|
-
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
42987
|
-
return [name, (...args) => command(...args)({
|
|
42988
|
-
...props,
|
|
42989
|
-
dispatch: void 0
|
|
42990
|
-
})];
|
|
42991
|
-
})),
|
|
42992
|
-
chain: () => this.createChain(tr, dispatch)
|
|
42993
|
-
};
|
|
42994
|
-
}
|
|
42995
|
-
/**
|
|
42996
|
-
* Creates capability checks that safely return `false`.
|
|
42997
|
-
* @returns A non-dispatching capability checker.
|
|
42998
|
-
* @example
|
|
42999
|
-
* const can = CommandManager.createFallbackCan()
|
|
43000
|
-
* can.focus() // false
|
|
43001
|
-
*/
|
|
43002
|
-
static createFallbackCan() {
|
|
43003
|
-
const chain = CommandManager.createFakeChain();
|
|
43004
|
-
return new Proxy({ chain: () => chain }, { get: (target, property) => {
|
|
43005
|
-
if (property === "then") return;
|
|
43006
|
-
if (property === "chain") return target.chain;
|
|
43007
|
-
return () => false;
|
|
43008
|
-
} });
|
|
43009
|
-
}
|
|
43010
|
-
buildProps(tr, shouldDispatch = true) {
|
|
43011
|
-
const { rawCommands, editor, state } = this;
|
|
43012
|
-
const { view } = editor;
|
|
43013
|
-
const props = {
|
|
43014
|
-
tr,
|
|
43015
|
-
editor,
|
|
43016
|
-
view,
|
|
43017
|
-
state: createChainableState({
|
|
43018
|
-
state,
|
|
43019
|
-
transaction: tr
|
|
43020
|
-
}),
|
|
43021
|
-
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
43022
|
-
chain: () => this.createChain(tr, shouldDispatch),
|
|
43023
|
-
can: () => this.createCan(tr),
|
|
43024
|
-
get commands() {
|
|
43025
|
-
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43026
|
-
return [name, (...args) => command(...args)(props)];
|
|
43027
|
-
}));
|
|
43028
|
-
}
|
|
43029
|
-
};
|
|
43030
|
-
return props;
|
|
43031
|
-
}
|
|
43032
|
-
};
|
|
43033
|
-
//#endregion
|
|
43034
|
-
//#region src/commands/blur.ts
|
|
43035
|
-
const blur = () => ({ editor, view }) => {
|
|
43036
|
-
requestAnimationFrame(() => {
|
|
43037
|
-
if (!editor.isDestroyed) {
|
|
43038
|
-
var _window;
|
|
43039
|
-
view.dom.blur();
|
|
43040
|
-
(_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 || _window.removeAllRanges();
|
|
43041
|
-
}
|
|
43042
|
-
});
|
|
43043
|
-
return true;
|
|
43044
|
-
};
|
|
43045
|
-
//#endregion
|
|
43046
|
-
//#region src/commands/clearContent.ts
|
|
43047
|
-
const clearContent = (emitUpdate = true) => ({ commands }) => {
|
|
43048
|
-
return commands.setContent("", { emitUpdate });
|
|
43049
|
-
};
|
|
43050
|
-
//#endregion
|
|
43051
|
-
//#region src/commands/clearNodes.ts
|
|
43052
|
-
const clearNodes = () => ({ state, tr, dispatch }) => {
|
|
43053
|
-
const { selection } = tr;
|
|
43054
|
-
const { ranges } = selection;
|
|
43055
|
-
if (!dispatch) return true;
|
|
43056
|
-
ranges.forEach(({ $from, $to }) => {
|
|
43057
|
-
state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
43058
|
-
if (node.type.isText) return;
|
|
43059
|
-
const { doc, mapping } = tr;
|
|
43060
|
-
const $mappedFrom = doc.resolve(mapping.map(pos));
|
|
43061
|
-
const $mappedTo = doc.resolve(mapping.map(pos + node.nodeSize));
|
|
43062
|
-
const nodeRange = $mappedFrom.blockRange($mappedTo);
|
|
43063
|
-
if (!nodeRange) return;
|
|
43064
|
-
const targetLiftDepth = liftTarget(nodeRange);
|
|
43065
|
-
if (node.type.isTextblock) {
|
|
43066
|
-
const { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index());
|
|
43067
|
-
tr.setNodeMarkup(nodeRange.start, defaultType);
|
|
43068
|
-
}
|
|
43069
|
-
if (targetLiftDepth || targetLiftDepth === 0) tr.lift(nodeRange, targetLiftDepth);
|
|
43070
|
-
});
|
|
43071
|
-
});
|
|
43072
|
-
return true;
|
|
43073
|
-
};
|
|
43074
|
-
//#endregion
|
|
43075
|
-
//#region src/commands/command.ts
|
|
43076
|
-
const command = (fn) => (props) => {
|
|
43077
|
-
return fn(props);
|
|
43078
|
-
};
|
|
43079
|
-
//#endregion
|
|
43080
|
-
//#region src/commands/createParagraphNear.ts
|
|
43081
|
-
const createParagraphNear$1 = () => ({ state, dispatch }) => {
|
|
43082
|
-
return createParagraphNear(state, dispatch);
|
|
43083
|
-
};
|
|
43084
|
-
//#endregion
|
|
43085
|
-
//#region src/commands/cut.ts
|
|
43086
|
-
const cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
43087
|
-
const { state } = editor;
|
|
43088
|
-
const contentSlice = state.doc.slice(originRange.from, originRange.to);
|
|
43089
|
-
tr.deleteRange(originRange.from, originRange.to);
|
|
43090
|
-
const newPos = tr.mapping.map(targetPos);
|
|
43091
|
-
tr.insert(newPos, contentSlice.content);
|
|
43092
|
-
tr.setSelection(new TextSelection(tr.doc.resolve(Math.max(newPos - 1, 0))));
|
|
43093
|
-
return true;
|
|
43006
|
+
var GOOD_LEAF_SIZE = 200;
|
|
43007
|
+
|
|
43008
|
+
// :: class<T> A rope sequence is a persistent sequence data structure
|
|
43009
|
+
// that supports appending, prepending, and slicing without doing a
|
|
43010
|
+
// full copy. It is represented as a mostly-balanced tree.
|
|
43011
|
+
var RopeSequence = function RopeSequence () {};
|
|
43012
|
+
|
|
43013
|
+
RopeSequence.prototype.append = function append (other) {
|
|
43014
|
+
if (!other.length) { return this }
|
|
43015
|
+
other = RopeSequence.from(other);
|
|
43016
|
+
|
|
43017
|
+
return (!this.length && other) ||
|
|
43018
|
+
(other.length < GOOD_LEAF_SIZE && this.leafAppend(other)) ||
|
|
43019
|
+
(this.length < GOOD_LEAF_SIZE && other.leafPrepend(this)) ||
|
|
43020
|
+
this.appendInner(other)
|
|
43094
43021
|
};
|
|
43095
|
-
|
|
43096
|
-
|
|
43097
|
-
|
|
43098
|
-
|
|
43099
|
-
|
|
43100
|
-
|
|
43101
|
-
const $pos = tr.selection.$anchor;
|
|
43102
|
-
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === currentNode.type) {
|
|
43103
|
-
if (dispatch) {
|
|
43104
|
-
const from = $pos.before(depth);
|
|
43105
|
-
const to = $pos.after(depth);
|
|
43106
|
-
tr.delete(from, to).scrollIntoView();
|
|
43107
|
-
}
|
|
43108
|
-
return true;
|
|
43109
|
-
}
|
|
43110
|
-
return false;
|
|
43022
|
+
|
|
43023
|
+
// :: (union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
43024
|
+
// Prepend an array or other rope to this one, returning a new rope.
|
|
43025
|
+
RopeSequence.prototype.prepend = function prepend (other) {
|
|
43026
|
+
if (!other.length) { return this }
|
|
43027
|
+
return RopeSequence.from(other).append(this)
|
|
43111
43028
|
};
|
|
43112
|
-
|
|
43113
|
-
|
|
43114
|
-
|
|
43115
|
-
if (typeof nameOrType === "string") {
|
|
43116
|
-
if (!schema.nodes[nameOrType]) throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`);
|
|
43117
|
-
return schema.nodes[nameOrType];
|
|
43118
|
-
}
|
|
43119
|
-
return nameOrType;
|
|
43120
|
-
}
|
|
43121
|
-
//#endregion
|
|
43122
|
-
//#region src/commands/deleteNode.ts
|
|
43123
|
-
const deleteNode = (typeOrName) => ({ tr, state, dispatch }) => {
|
|
43124
|
-
const type = getNodeType(typeOrName, state.schema);
|
|
43125
|
-
const $pos = tr.selection.$anchor;
|
|
43126
|
-
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === type) {
|
|
43127
|
-
if (dispatch) {
|
|
43128
|
-
const from = $pos.before(depth);
|
|
43129
|
-
const to = $pos.after(depth);
|
|
43130
|
-
tr.delete(from, to).scrollIntoView();
|
|
43131
|
-
}
|
|
43132
|
-
return true;
|
|
43133
|
-
}
|
|
43134
|
-
return false;
|
|
43029
|
+
|
|
43030
|
+
RopeSequence.prototype.appendInner = function appendInner (other) {
|
|
43031
|
+
return new Append(this, other)
|
|
43135
43032
|
};
|
|
43136
|
-
|
|
43137
|
-
|
|
43138
|
-
|
|
43139
|
-
|
|
43140
|
-
|
|
43141
|
-
|
|
43033
|
+
|
|
43034
|
+
// :: (?number, ?number) → RopeSequence<T>
|
|
43035
|
+
// Create a rope repesenting a sub-sequence of this rope.
|
|
43036
|
+
RopeSequence.prototype.slice = function slice (from, to) {
|
|
43037
|
+
if ( from === void 0 ) from = 0;
|
|
43038
|
+
if ( to === void 0 ) to = this.length;
|
|
43039
|
+
|
|
43040
|
+
if (from >= to) { return RopeSequence.empty }
|
|
43041
|
+
return this.sliceInner(Math.max(0, from), Math.min(this.length, to))
|
|
43142
43042
|
};
|
|
43143
|
-
|
|
43144
|
-
|
|
43145
|
-
|
|
43146
|
-
|
|
43147
|
-
|
|
43148
|
-
|
|
43149
|
-
const hasTextContent = (nodeSpec) => {
|
|
43150
|
-
if (!nodeSpec.content) return false;
|
|
43151
|
-
return /^text(\*|\+)/.test(nodeSpec.content);
|
|
43043
|
+
|
|
43044
|
+
// :: (number) → T
|
|
43045
|
+
// Retrieve the element at the given position from this rope.
|
|
43046
|
+
RopeSequence.prototype.get = function get (i) {
|
|
43047
|
+
if (i < 0 || i >= this.length) { return undefined }
|
|
43048
|
+
return this.getInner(i)
|
|
43152
43049
|
};
|
|
43153
|
-
|
|
43154
|
-
|
|
43155
|
-
|
|
43156
|
-
|
|
43157
|
-
|
|
43158
|
-
|
|
43159
|
-
|
|
43160
|
-
|
|
43161
|
-
|
|
43162
|
-
|
|
43163
|
-
|
|
43164
|
-
|
|
43165
|
-
|
|
43166
|
-
|
|
43167
|
-
return side === "left" ? $pos.start() - 1 : $pos.end() + 1;
|
|
43050
|
+
|
|
43051
|
+
// :: ((element: T, index: number) → ?bool, ?number, ?number)
|
|
43052
|
+
// Call the given function for each element between the given
|
|
43053
|
+
// indices. This tends to be more efficient than looping over the
|
|
43054
|
+
// indices and calling `get`, because it doesn't have to descend the
|
|
43055
|
+
// tree for every element.
|
|
43056
|
+
RopeSequence.prototype.forEach = function forEach (f, from, to) {
|
|
43057
|
+
if ( from === void 0 ) from = 0;
|
|
43058
|
+
if ( to === void 0 ) to = this.length;
|
|
43059
|
+
|
|
43060
|
+
if (from <= to)
|
|
43061
|
+
{ this.forEachInner(f, from, to, 0); }
|
|
43062
|
+
else
|
|
43063
|
+
{ this.forEachInvertedInner(f, from, to, 0); }
|
|
43168
43064
|
};
|
|
43169
|
-
|
|
43170
|
-
|
|
43171
|
-
|
|
43172
|
-
|
|
43173
|
-
|
|
43174
|
-
|
|
43175
|
-
|
|
43176
|
-
|
|
43177
|
-
|
|
43178
|
-
|
|
43179
|
-
|
|
43065
|
+
|
|
43066
|
+
// :: ((element: T, index: number) → U, ?number, ?number) → [U]
|
|
43067
|
+
// Map the given functions over the elements of the rope, producing
|
|
43068
|
+
// a flat array.
|
|
43069
|
+
RopeSequence.prototype.map = function map (f, from, to) {
|
|
43070
|
+
if ( from === void 0 ) from = 0;
|
|
43071
|
+
if ( to === void 0 ) to = this.length;
|
|
43072
|
+
|
|
43073
|
+
var result = [];
|
|
43074
|
+
this.forEach(function (elt, i) { return result.push(f(elt, i)); }, from, to);
|
|
43075
|
+
return result
|
|
43180
43076
|
};
|
|
43181
|
-
|
|
43182
|
-
|
|
43183
|
-
|
|
43184
|
-
|
|
43185
|
-
|
|
43186
|
-
|
|
43187
|
-
|
|
43188
|
-
const mapping = tr.mapping.slice(mapFrom);
|
|
43189
|
-
const $from = tr.doc.resolve(mapping.map(range.$from.pos));
|
|
43190
|
-
const $to = tr.doc.resolve(mapping.map(range.$to.pos));
|
|
43191
|
-
const { from, to } = expandSelectionForInlineText($from, $to, state.schema);
|
|
43192
|
-
tr.deleteRange(from, to);
|
|
43193
|
-
});
|
|
43194
|
-
if (!tr.selection.empty) tr.setSelection(TextSelection.near(tr.doc.resolve(tr.selection.from)));
|
|
43195
|
-
tr.scrollIntoView();
|
|
43196
|
-
dispatch(tr);
|
|
43197
|
-
}
|
|
43198
|
-
return true;
|
|
43077
|
+
|
|
43078
|
+
// :: (?union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
43079
|
+
// Create a rope representing the given array, or return the rope
|
|
43080
|
+
// itself if a rope was given.
|
|
43081
|
+
RopeSequence.from = function from (values) {
|
|
43082
|
+
if (values instanceof RopeSequence) { return values }
|
|
43083
|
+
return values && values.length ? new Leaf(values) : RopeSequence.empty
|
|
43199
43084
|
};
|
|
43200
|
-
|
|
43085
|
+
|
|
43086
|
+
var Leaf = /*@__PURE__*/(function (RopeSequence) {
|
|
43087
|
+
function Leaf(values) {
|
|
43088
|
+
RopeSequence.call(this);
|
|
43089
|
+
this.values = values;
|
|
43090
|
+
}
|
|
43091
|
+
|
|
43092
|
+
if ( RopeSequence ) Leaf.__proto__ = RopeSequence;
|
|
43093
|
+
Leaf.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
43094
|
+
Leaf.prototype.constructor = Leaf;
|
|
43095
|
+
|
|
43096
|
+
var prototypeAccessors = { length: { configurable: true },depth: { configurable: true } };
|
|
43097
|
+
|
|
43098
|
+
Leaf.prototype.flatten = function flatten () {
|
|
43099
|
+
return this.values
|
|
43100
|
+
};
|
|
43101
|
+
|
|
43102
|
+
Leaf.prototype.sliceInner = function sliceInner (from, to) {
|
|
43103
|
+
if (from == 0 && to == this.length) { return this }
|
|
43104
|
+
return new Leaf(this.values.slice(from, to))
|
|
43105
|
+
};
|
|
43106
|
+
|
|
43107
|
+
Leaf.prototype.getInner = function getInner (i) {
|
|
43108
|
+
return this.values[i]
|
|
43109
|
+
};
|
|
43110
|
+
|
|
43111
|
+
Leaf.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
43112
|
+
for (var i = from; i < to; i++)
|
|
43113
|
+
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
43114
|
+
};
|
|
43115
|
+
|
|
43116
|
+
Leaf.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
43117
|
+
for (var i = from - 1; i >= to; i--)
|
|
43118
|
+
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
43119
|
+
};
|
|
43120
|
+
|
|
43121
|
+
Leaf.prototype.leafAppend = function leafAppend (other) {
|
|
43122
|
+
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
43123
|
+
{ return new Leaf(this.values.concat(other.flatten())) }
|
|
43124
|
+
};
|
|
43125
|
+
|
|
43126
|
+
Leaf.prototype.leafPrepend = function leafPrepend (other) {
|
|
43127
|
+
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
43128
|
+
{ return new Leaf(other.flatten().concat(this.values)) }
|
|
43129
|
+
};
|
|
43130
|
+
|
|
43131
|
+
prototypeAccessors.length.get = function () { return this.values.length };
|
|
43132
|
+
|
|
43133
|
+
prototypeAccessors.depth.get = function () { return 0 };
|
|
43134
|
+
|
|
43135
|
+
Object.defineProperties( Leaf.prototype, prototypeAccessors );
|
|
43136
|
+
|
|
43137
|
+
return Leaf;
|
|
43138
|
+
}(RopeSequence));
|
|
43139
|
+
|
|
43140
|
+
// :: RopeSequence
|
|
43141
|
+
// The empty rope sequence.
|
|
43142
|
+
RopeSequence.empty = new Leaf([]);
|
|
43143
|
+
|
|
43144
|
+
var Append = /*@__PURE__*/(function (RopeSequence) {
|
|
43145
|
+
function Append(left, right) {
|
|
43146
|
+
RopeSequence.call(this);
|
|
43147
|
+
this.left = left;
|
|
43148
|
+
this.right = right;
|
|
43149
|
+
this.length = left.length + right.length;
|
|
43150
|
+
this.depth = Math.max(left.depth, right.depth) + 1;
|
|
43151
|
+
}
|
|
43152
|
+
|
|
43153
|
+
if ( RopeSequence ) Append.__proto__ = RopeSequence;
|
|
43154
|
+
Append.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
43155
|
+
Append.prototype.constructor = Append;
|
|
43156
|
+
|
|
43157
|
+
Append.prototype.flatten = function flatten () {
|
|
43158
|
+
return this.left.flatten().concat(this.right.flatten())
|
|
43159
|
+
};
|
|
43160
|
+
|
|
43161
|
+
Append.prototype.getInner = function getInner (i) {
|
|
43162
|
+
return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length)
|
|
43163
|
+
};
|
|
43164
|
+
|
|
43165
|
+
Append.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
43166
|
+
var leftLen = this.left.length;
|
|
43167
|
+
if (from < leftLen &&
|
|
43168
|
+
this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false)
|
|
43169
|
+
{ return false }
|
|
43170
|
+
if (to > leftLen &&
|
|
43171
|
+
this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false)
|
|
43172
|
+
{ return false }
|
|
43173
|
+
};
|
|
43174
|
+
|
|
43175
|
+
Append.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
43176
|
+
var leftLen = this.left.length;
|
|
43177
|
+
if (from > leftLen &&
|
|
43178
|
+
this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false)
|
|
43179
|
+
{ return false }
|
|
43180
|
+
if (to < leftLen &&
|
|
43181
|
+
this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false)
|
|
43182
|
+
{ return false }
|
|
43183
|
+
};
|
|
43184
|
+
|
|
43185
|
+
Append.prototype.sliceInner = function sliceInner (from, to) {
|
|
43186
|
+
if (from == 0 && to == this.length) { return this }
|
|
43187
|
+
var leftLen = this.left.length;
|
|
43188
|
+
if (to <= leftLen) { return this.left.slice(from, to) }
|
|
43189
|
+
if (from >= leftLen) { return this.right.slice(from - leftLen, to - leftLen) }
|
|
43190
|
+
return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen))
|
|
43191
|
+
};
|
|
43192
|
+
|
|
43193
|
+
Append.prototype.leafAppend = function leafAppend (other) {
|
|
43194
|
+
var inner = this.right.leafAppend(other);
|
|
43195
|
+
if (inner) { return new Append(this.left, inner) }
|
|
43196
|
+
};
|
|
43197
|
+
|
|
43198
|
+
Append.prototype.leafPrepend = function leafPrepend (other) {
|
|
43199
|
+
var inner = this.left.leafPrepend(other);
|
|
43200
|
+
if (inner) { return new Append(inner, this.right) }
|
|
43201
|
+
};
|
|
43202
|
+
|
|
43203
|
+
Append.prototype.appendInner = function appendInner (other) {
|
|
43204
|
+
if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1)
|
|
43205
|
+
{ return new Append(this.left, new Append(this.right, other)) }
|
|
43206
|
+
return new Append(this, other)
|
|
43207
|
+
};
|
|
43208
|
+
|
|
43209
|
+
return Append;
|
|
43210
|
+
}(RopeSequence));
|
|
43211
|
+
|
|
43212
|
+
// ProseMirror's history isn't simply a way to roll back to a previous
|
|
43213
|
+
// state, because ProseMirror supports applying changes without adding
|
|
43214
|
+
// them to the history (for example during collaboration).
|
|
43215
|
+
//
|
|
43216
|
+
// To this end, each 'Branch' (one for the undo history and one for
|
|
43217
|
+
// the redo history) keeps an array of 'Items', which can optionally
|
|
43218
|
+
// hold a step (an actual undoable change), and always hold a position
|
|
43219
|
+
// map (which is needed to move changes below them to apply to the
|
|
43220
|
+
// current document).
|
|
43221
|
+
//
|
|
43222
|
+
// An item that has both a step and a selection bookmark is the start
|
|
43223
|
+
// of an 'event' — a group of changes that will be undone or redone at
|
|
43224
|
+
// once. (It stores only the bookmark, since that way we don't have to
|
|
43225
|
+
// provide a document until the selection is actually applied, which
|
|
43226
|
+
// is useful when compressing.)
|
|
43227
|
+
// Used to schedule history compression
|
|
43228
|
+
const max_empty_items = 500;
|
|
43229
|
+
class Branch {
|
|
43230
|
+
constructor(items, eventCount) {
|
|
43231
|
+
this.items = items;
|
|
43232
|
+
this.eventCount = eventCount;
|
|
43233
|
+
}
|
|
43234
|
+
// Pop the latest event off the branch's history and apply it
|
|
43235
|
+
// to a document transform.
|
|
43236
|
+
popEvent(state, preserveItems) {
|
|
43237
|
+
if (this.eventCount == 0)
|
|
43238
|
+
return null;
|
|
43239
|
+
let end = this.items.length;
|
|
43240
|
+
for (;; end--) {
|
|
43241
|
+
let next = this.items.get(end - 1);
|
|
43242
|
+
if (next.selection) {
|
|
43243
|
+
--end;
|
|
43244
|
+
break;
|
|
43245
|
+
}
|
|
43246
|
+
}
|
|
43247
|
+
let remap, mapFrom;
|
|
43248
|
+
if (preserveItems) {
|
|
43249
|
+
remap = this.remapping(end, this.items.length);
|
|
43250
|
+
mapFrom = remap.maps.length;
|
|
43251
|
+
}
|
|
43252
|
+
let transform = state.tr;
|
|
43253
|
+
let selection, remaining;
|
|
43254
|
+
let addAfter = [], addBefore = [];
|
|
43255
|
+
this.items.forEach((item, i) => {
|
|
43256
|
+
if (!item.step) {
|
|
43257
|
+
if (!remap) {
|
|
43258
|
+
remap = this.remapping(end, i + 1);
|
|
43259
|
+
mapFrom = remap.maps.length;
|
|
43260
|
+
}
|
|
43261
|
+
mapFrom--;
|
|
43262
|
+
addBefore.push(item);
|
|
43263
|
+
return;
|
|
43264
|
+
}
|
|
43265
|
+
if (remap) {
|
|
43266
|
+
addBefore.push(new Item(item.map));
|
|
43267
|
+
let step = item.step.map(remap.slice(mapFrom)), map;
|
|
43268
|
+
if (step && transform.maybeStep(step).doc) {
|
|
43269
|
+
map = transform.mapping.maps[transform.mapping.maps.length - 1];
|
|
43270
|
+
addAfter.push(new Item(map, undefined, undefined, addAfter.length + addBefore.length));
|
|
43271
|
+
}
|
|
43272
|
+
mapFrom--;
|
|
43273
|
+
if (map)
|
|
43274
|
+
remap.appendMap(map, mapFrom);
|
|
43275
|
+
}
|
|
43276
|
+
else {
|
|
43277
|
+
transform.maybeStep(item.step);
|
|
43278
|
+
}
|
|
43279
|
+
if (item.selection) {
|
|
43280
|
+
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
|
|
43281
|
+
remaining = new Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
|
|
43282
|
+
return false;
|
|
43283
|
+
}
|
|
43284
|
+
}, this.items.length, 0);
|
|
43285
|
+
return { remaining: remaining, transform, selection: selection };
|
|
43286
|
+
}
|
|
43287
|
+
// Create a new branch with the given transform added.
|
|
43288
|
+
addTransform(transform, selection, histOptions, preserveItems) {
|
|
43289
|
+
let newItems = [], eventCount = this.eventCount;
|
|
43290
|
+
let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
|
|
43291
|
+
for (let i = 0; i < transform.steps.length; i++) {
|
|
43292
|
+
let step = transform.steps[i].invert(transform.docs[i]);
|
|
43293
|
+
let item = new Item(transform.mapping.maps[i], step, selection), merged;
|
|
43294
|
+
if (merged = lastItem && lastItem.merge(item)) {
|
|
43295
|
+
item = merged;
|
|
43296
|
+
if (i)
|
|
43297
|
+
newItems.pop();
|
|
43298
|
+
else
|
|
43299
|
+
oldItems = oldItems.slice(0, oldItems.length - 1);
|
|
43300
|
+
}
|
|
43301
|
+
newItems.push(item);
|
|
43302
|
+
if (selection) {
|
|
43303
|
+
eventCount++;
|
|
43304
|
+
selection = undefined;
|
|
43305
|
+
}
|
|
43306
|
+
if (!preserveItems)
|
|
43307
|
+
lastItem = item;
|
|
43308
|
+
}
|
|
43309
|
+
let overflow = eventCount - histOptions.depth;
|
|
43310
|
+
if (overflow > DEPTH_OVERFLOW) {
|
|
43311
|
+
oldItems = cutOffEvents(oldItems, overflow);
|
|
43312
|
+
eventCount -= overflow;
|
|
43313
|
+
}
|
|
43314
|
+
return new Branch(oldItems.append(newItems), eventCount);
|
|
43315
|
+
}
|
|
43316
|
+
remapping(from, to) {
|
|
43317
|
+
let maps = new Mapping;
|
|
43318
|
+
this.items.forEach((item, i) => {
|
|
43319
|
+
let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from
|
|
43320
|
+
? maps.maps.length - item.mirrorOffset : undefined;
|
|
43321
|
+
maps.appendMap(item.map, mirrorPos);
|
|
43322
|
+
}, from, to);
|
|
43323
|
+
return maps;
|
|
43324
|
+
}
|
|
43325
|
+
addMaps(array) {
|
|
43326
|
+
if (this.eventCount == 0)
|
|
43327
|
+
return this;
|
|
43328
|
+
return new Branch(this.items.append(array.map(map => new Item(map))), this.eventCount);
|
|
43329
|
+
}
|
|
43330
|
+
// When the collab module receives remote changes, the history has
|
|
43331
|
+
// to know about those, so that it can adjust the steps that were
|
|
43332
|
+
// rebased on top of the remote changes, and include the position
|
|
43333
|
+
// maps for the remote changes in its array of items.
|
|
43334
|
+
rebased(rebasedTransform, rebasedCount) {
|
|
43335
|
+
if (!this.eventCount)
|
|
43336
|
+
return this;
|
|
43337
|
+
rebasedCount = Math.min(this.items.length, rebasedCount);
|
|
43338
|
+
let rebasedItems = [], start = this.items.length - rebasedCount;
|
|
43339
|
+
let mapping = rebasedTransform.mapping;
|
|
43340
|
+
let newUntil = rebasedTransform.steps.length;
|
|
43341
|
+
let eventCount = this.eventCount;
|
|
43342
|
+
this.items.forEach(item => { if (item.selection)
|
|
43343
|
+
eventCount--; }, start);
|
|
43344
|
+
let iRebased = rebasedCount;
|
|
43345
|
+
this.items.forEach(item => {
|
|
43346
|
+
let pos = mapping.getMirror(--iRebased);
|
|
43347
|
+
if (pos == null)
|
|
43348
|
+
return;
|
|
43349
|
+
newUntil = Math.min(newUntil, pos);
|
|
43350
|
+
let map = mapping.maps[pos];
|
|
43351
|
+
if (item.step) {
|
|
43352
|
+
let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
|
|
43353
|
+
let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
|
|
43354
|
+
if (selection)
|
|
43355
|
+
eventCount++;
|
|
43356
|
+
rebasedItems.push(new Item(map, step, selection));
|
|
43357
|
+
}
|
|
43358
|
+
else {
|
|
43359
|
+
rebasedItems.push(new Item(map));
|
|
43360
|
+
}
|
|
43361
|
+
}, start);
|
|
43362
|
+
let newMaps = [];
|
|
43363
|
+
for (let i = rebasedCount; i < newUntil; i++)
|
|
43364
|
+
newMaps.push(new Item(mapping.maps[i]));
|
|
43365
|
+
let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
|
|
43366
|
+
let branch = new Branch(items, eventCount);
|
|
43367
|
+
if (branch.emptyItemCount() > max_empty_items)
|
|
43368
|
+
branch = branch.compress(this.items.length - rebasedItems.length);
|
|
43369
|
+
return branch;
|
|
43370
|
+
}
|
|
43371
|
+
emptyItemCount() {
|
|
43372
|
+
let count = 0;
|
|
43373
|
+
this.items.forEach(item => { if (!item.step)
|
|
43374
|
+
count++; });
|
|
43375
|
+
return count;
|
|
43376
|
+
}
|
|
43377
|
+
// Compressing a branch means rewriting it to push the air (map-only
|
|
43378
|
+
// items) out. During collaboration, these naturally accumulate
|
|
43379
|
+
// because each remote change adds one. The `upto` argument is used
|
|
43380
|
+
// to ensure that only the items below a given level are compressed,
|
|
43381
|
+
// because `rebased` relies on a clean, untouched set of items in
|
|
43382
|
+
// order to associate old items with rebased steps.
|
|
43383
|
+
compress(upto = this.items.length) {
|
|
43384
|
+
let remap = this.remapping(0, upto), mapFrom = remap.maps.length;
|
|
43385
|
+
let items = [], events = 0;
|
|
43386
|
+
this.items.forEach((item, i) => {
|
|
43387
|
+
if (i >= upto) {
|
|
43388
|
+
items.push(item);
|
|
43389
|
+
if (item.selection)
|
|
43390
|
+
events++;
|
|
43391
|
+
}
|
|
43392
|
+
else if (item.step) {
|
|
43393
|
+
let step = item.step.map(remap.slice(mapFrom)), map = step && step.getMap();
|
|
43394
|
+
mapFrom--;
|
|
43395
|
+
if (map)
|
|
43396
|
+
remap.appendMap(map, mapFrom);
|
|
43397
|
+
if (step) {
|
|
43398
|
+
let selection = item.selection && item.selection.map(remap.slice(mapFrom));
|
|
43399
|
+
if (selection)
|
|
43400
|
+
events++;
|
|
43401
|
+
let newItem = new Item(map.invert(), step, selection), merged, last = items.length - 1;
|
|
43402
|
+
if (merged = items.length && items[last].merge(newItem))
|
|
43403
|
+
items[last] = merged;
|
|
43404
|
+
else
|
|
43405
|
+
items.push(newItem);
|
|
43406
|
+
}
|
|
43407
|
+
}
|
|
43408
|
+
else if (item.map) {
|
|
43409
|
+
mapFrom--;
|
|
43410
|
+
}
|
|
43411
|
+
}, this.items.length, 0);
|
|
43412
|
+
return new Branch(RopeSequence.from(items.reverse()), events);
|
|
43413
|
+
}
|
|
43414
|
+
}
|
|
43415
|
+
Branch.empty = new Branch(RopeSequence.empty, 0);
|
|
43416
|
+
function cutOffEvents(items, n) {
|
|
43417
|
+
let cutPoint;
|
|
43418
|
+
items.forEach((item, i) => {
|
|
43419
|
+
if (item.selection && (n-- == 0)) {
|
|
43420
|
+
cutPoint = i;
|
|
43421
|
+
return false;
|
|
43422
|
+
}
|
|
43423
|
+
});
|
|
43424
|
+
return items.slice(cutPoint);
|
|
43425
|
+
}
|
|
43426
|
+
class Item {
|
|
43427
|
+
constructor(
|
|
43428
|
+
// The (forward) step map for this item.
|
|
43429
|
+
map,
|
|
43430
|
+
// The inverted step
|
|
43431
|
+
step,
|
|
43432
|
+
// If this is non-null, this item is the start of a group, and
|
|
43433
|
+
// this selection is the starting selection for the group (the one
|
|
43434
|
+
// that was active before the first step was applied)
|
|
43435
|
+
selection,
|
|
43436
|
+
// If this item is the inverse of a previous mapping on the stack,
|
|
43437
|
+
// this points at the inverse's offset
|
|
43438
|
+
mirrorOffset) {
|
|
43439
|
+
this.map = map;
|
|
43440
|
+
this.step = step;
|
|
43441
|
+
this.selection = selection;
|
|
43442
|
+
this.mirrorOffset = mirrorOffset;
|
|
43443
|
+
}
|
|
43444
|
+
merge(other) {
|
|
43445
|
+
if (this.step && other.step && !other.selection) {
|
|
43446
|
+
let step = other.step.merge(this.step);
|
|
43447
|
+
if (step)
|
|
43448
|
+
return new Item(step.getMap().invert(), step, this.selection);
|
|
43449
|
+
}
|
|
43450
|
+
}
|
|
43451
|
+
}
|
|
43452
|
+
// The value of the state field that tracks undo/redo history for that
|
|
43453
|
+
// state. Will be stored in the plugin state when the history plugin
|
|
43454
|
+
// is active.
|
|
43455
|
+
class HistoryState {
|
|
43456
|
+
constructor(done, undone, prevRanges, prevTime, prevComposition) {
|
|
43457
|
+
this.done = done;
|
|
43458
|
+
this.undone = undone;
|
|
43459
|
+
this.prevRanges = prevRanges;
|
|
43460
|
+
this.prevTime = prevTime;
|
|
43461
|
+
this.prevComposition = prevComposition;
|
|
43462
|
+
}
|
|
43463
|
+
}
|
|
43464
|
+
const DEPTH_OVERFLOW = 20;
|
|
43465
|
+
// Record a transformation in undo history.
|
|
43466
|
+
function applyTransaction(history, state, tr, options) {
|
|
43467
|
+
let historyTr = tr.getMeta(historyKey), rebased;
|
|
43468
|
+
if (historyTr)
|
|
43469
|
+
return historyTr.historyState;
|
|
43470
|
+
if (tr.getMeta(closeHistoryKey))
|
|
43471
|
+
history = new HistoryState(history.done, history.undone, null, 0, -1);
|
|
43472
|
+
let appended = tr.getMeta("appendedTransaction");
|
|
43473
|
+
if (tr.steps.length == 0) {
|
|
43474
|
+
return history;
|
|
43475
|
+
}
|
|
43476
|
+
else if (appended && appended.getMeta(historyKey)) {
|
|
43477
|
+
if (appended.getMeta(historyKey).redo)
|
|
43478
|
+
return new HistoryState(history.done.addTransform(tr, undefined, options, mustPreserveItems(state)), history.undone, rangesFor(tr.mapping.maps), history.prevTime, history.prevComposition);
|
|
43479
|
+
else
|
|
43480
|
+
return new HistoryState(history.done, history.undone.addTransform(tr, undefined, options, mustPreserveItems(state)), null, history.prevTime, history.prevComposition);
|
|
43481
|
+
}
|
|
43482
|
+
else if (tr.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
|
|
43483
|
+
// Group transforms that occur in quick succession into one event.
|
|
43484
|
+
let composition = tr.getMeta("composition");
|
|
43485
|
+
let newGroup = history.prevTime == 0 ||
|
|
43486
|
+
(!appended && history.prevComposition != composition &&
|
|
43487
|
+
(history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history.prevRanges)));
|
|
43488
|
+
let prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps);
|
|
43489
|
+
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);
|
|
43490
|
+
}
|
|
43491
|
+
else if (rebased = tr.getMeta("rebased")) {
|
|
43492
|
+
// Used by the collab module to tell the history that some of its
|
|
43493
|
+
// content has been rebased.
|
|
43494
|
+
return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);
|
|
43495
|
+
}
|
|
43496
|
+
else {
|
|
43497
|
+
return new HistoryState(history.done.addMaps(tr.mapping.maps), history.undone.addMaps(tr.mapping.maps), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);
|
|
43498
|
+
}
|
|
43499
|
+
}
|
|
43500
|
+
function isAdjacentTo(transform, prevRanges) {
|
|
43501
|
+
if (!prevRanges)
|
|
43502
|
+
return false;
|
|
43503
|
+
if (!transform.docChanged)
|
|
43504
|
+
return true;
|
|
43505
|
+
let adjacent = false;
|
|
43506
|
+
transform.mapping.maps[0].forEach((start, end) => {
|
|
43507
|
+
for (let i = 0; i < prevRanges.length; i += 2)
|
|
43508
|
+
if (start <= prevRanges[i + 1] && end >= prevRanges[i])
|
|
43509
|
+
adjacent = true;
|
|
43510
|
+
});
|
|
43511
|
+
return adjacent;
|
|
43512
|
+
}
|
|
43513
|
+
function rangesFor(maps) {
|
|
43514
|
+
let result = [];
|
|
43515
|
+
for (let i = maps.length - 1; i >= 0 && result.length == 0; i--)
|
|
43516
|
+
maps[i].forEach((_from, _to, from, to) => result.push(from, to));
|
|
43517
|
+
return result;
|
|
43518
|
+
}
|
|
43519
|
+
function mapRanges(ranges, mapping) {
|
|
43520
|
+
if (!ranges)
|
|
43521
|
+
return null;
|
|
43522
|
+
let result = [];
|
|
43523
|
+
for (let i = 0; i < ranges.length; i += 2) {
|
|
43524
|
+
let from = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1);
|
|
43525
|
+
if (from <= to)
|
|
43526
|
+
result.push(from, to);
|
|
43527
|
+
}
|
|
43528
|
+
return result;
|
|
43529
|
+
}
|
|
43530
|
+
// Apply the latest event from one branch to the document and shift the event
|
|
43531
|
+
// onto the other branch.
|
|
43532
|
+
function histTransaction(history, state, redo) {
|
|
43533
|
+
let preserveItems = mustPreserveItems(state);
|
|
43534
|
+
let histOptions = historyKey.get(state).spec.config;
|
|
43535
|
+
let pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);
|
|
43536
|
+
if (!pop)
|
|
43537
|
+
return null;
|
|
43538
|
+
let selection = pop.selection.resolve(pop.transform.doc);
|
|
43539
|
+
let added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
|
|
43540
|
+
let newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0, -1);
|
|
43541
|
+
return pop.transform.setSelection(selection).setMeta(historyKey, { redo, historyState: newHist });
|
|
43542
|
+
}
|
|
43543
|
+
let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
|
|
43544
|
+
// Check whether any plugin in the given state has a
|
|
43545
|
+
// `historyPreserveItems` property in its spec, in which case we must
|
|
43546
|
+
// preserve steps exactly as they came in, so that they can be
|
|
43547
|
+
// rebased.
|
|
43548
|
+
function mustPreserveItems(state) {
|
|
43549
|
+
let plugins = state.plugins;
|
|
43550
|
+
if (cachedPreserveItemsPlugins != plugins) {
|
|
43551
|
+
cachedPreserveItems = false;
|
|
43552
|
+
cachedPreserveItemsPlugins = plugins;
|
|
43553
|
+
for (let i = 0; i < plugins.length; i++)
|
|
43554
|
+
if (plugins[i].spec.historyPreserveItems) {
|
|
43555
|
+
cachedPreserveItems = true;
|
|
43556
|
+
break;
|
|
43557
|
+
}
|
|
43558
|
+
}
|
|
43559
|
+
return cachedPreserveItems;
|
|
43560
|
+
}
|
|
43561
|
+
/**
|
|
43562
|
+
Set a flag on the given transaction that will prevent further steps
|
|
43563
|
+
from being appended to an existing history event (so that they
|
|
43564
|
+
require a separate undo command to undo).
|
|
43565
|
+
*/
|
|
43566
|
+
function closeHistory(tr) {
|
|
43567
|
+
return tr.setMeta(closeHistoryKey, true);
|
|
43568
|
+
}
|
|
43569
|
+
const historyKey = new PluginKey("history");
|
|
43570
|
+
const closeHistoryKey = new PluginKey("closeHistory");
|
|
43571
|
+
/**
|
|
43572
|
+
Returns a plugin that enables the undo history for an editor. The
|
|
43573
|
+
plugin will track undo and redo stacks, which can be used with the
|
|
43574
|
+
[`undo`](https://prosemirror.net/docs/ref/#history.undo) and [`redo`](https://prosemirror.net/docs/ref/#history.redo) commands.
|
|
43575
|
+
|
|
43576
|
+
You can set an `"addToHistory"` [metadata
|
|
43577
|
+
property](https://prosemirror.net/docs/ref/#state.Transaction.setMeta) of `false` on a transaction
|
|
43578
|
+
to prevent it from being rolled back by undo.
|
|
43579
|
+
*/
|
|
43580
|
+
function history(config = {}) {
|
|
43581
|
+
config = { depth: config.depth || 100,
|
|
43582
|
+
newGroupDelay: config.newGroupDelay || 500 };
|
|
43583
|
+
return new Plugin({
|
|
43584
|
+
key: historyKey,
|
|
43585
|
+
state: {
|
|
43586
|
+
init() {
|
|
43587
|
+
return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
|
|
43588
|
+
},
|
|
43589
|
+
apply(tr, hist, state) {
|
|
43590
|
+
return applyTransaction(hist, state, tr, config);
|
|
43591
|
+
}
|
|
43592
|
+
},
|
|
43593
|
+
config,
|
|
43594
|
+
props: {
|
|
43595
|
+
handleDOMEvents: {
|
|
43596
|
+
beforeinput(view, e) {
|
|
43597
|
+
let inputType = e.inputType;
|
|
43598
|
+
let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
|
|
43599
|
+
if (!command || !view.editable)
|
|
43600
|
+
return false;
|
|
43601
|
+
e.preventDefault();
|
|
43602
|
+
return command(view.state, view.dispatch);
|
|
43603
|
+
}
|
|
43604
|
+
}
|
|
43605
|
+
}
|
|
43606
|
+
});
|
|
43607
|
+
}
|
|
43608
|
+
function buildCommand(redo, scroll) {
|
|
43609
|
+
return (state, dispatch) => {
|
|
43610
|
+
let hist = historyKey.getState(state);
|
|
43611
|
+
if (!hist || (redo ? hist.undone : hist.done).eventCount == 0)
|
|
43612
|
+
return false;
|
|
43613
|
+
if (dispatch) {
|
|
43614
|
+
let tr = histTransaction(hist, state, redo);
|
|
43615
|
+
if (tr)
|
|
43616
|
+
dispatch(scroll ? tr.scrollIntoView() : tr);
|
|
43617
|
+
}
|
|
43618
|
+
return true;
|
|
43619
|
+
};
|
|
43620
|
+
}
|
|
43621
|
+
/**
|
|
43622
|
+
A command function that undoes the last change, if any.
|
|
43623
|
+
*/
|
|
43624
|
+
const undo = buildCommand(false, true);
|
|
43625
|
+
/**
|
|
43626
|
+
A command function that redoes the last undone change, if any.
|
|
43627
|
+
*/
|
|
43628
|
+
const redo = buildCommand(true, true);
|
|
43629
|
+
/**
|
|
43630
|
+
Returns true if the given transaction was generated by the history
|
|
43631
|
+
plugin.
|
|
43632
|
+
*/
|
|
43633
|
+
function isHistoryTransaction(tr) {
|
|
43634
|
+
return tr.getMeta(historyKey) != null;
|
|
43635
|
+
}
|
|
43636
|
+
|
|
43637
|
+
//#region src/helpers/createChainableState.ts
|
|
43638
|
+
/**
|
|
43639
|
+
* Takes a Transaction & Editor State and turns it into a chainable state object
|
|
43640
|
+
* @param config The transaction and state to create the chainable state from
|
|
43641
|
+
* @returns A chainable Editor state object
|
|
43642
|
+
*/
|
|
43643
|
+
function createChainableState(config) {
|
|
43644
|
+
const { state, transaction } = config;
|
|
43645
|
+
let { selection } = transaction;
|
|
43646
|
+
let { doc } = transaction;
|
|
43647
|
+
let { storedMarks } = transaction;
|
|
43648
|
+
return {
|
|
43649
|
+
...state,
|
|
43650
|
+
apply: state.apply.bind(state),
|
|
43651
|
+
applyTransaction: state.applyTransaction.bind(state),
|
|
43652
|
+
plugins: state.plugins,
|
|
43653
|
+
schema: state.schema,
|
|
43654
|
+
reconfigure: state.reconfigure.bind(state),
|
|
43655
|
+
toJSON: state.toJSON.bind(state),
|
|
43656
|
+
get storedMarks() {
|
|
43657
|
+
return storedMarks;
|
|
43658
|
+
},
|
|
43659
|
+
get selection() {
|
|
43660
|
+
return selection;
|
|
43661
|
+
},
|
|
43662
|
+
get doc() {
|
|
43663
|
+
return doc;
|
|
43664
|
+
},
|
|
43665
|
+
get tr() {
|
|
43666
|
+
selection = transaction.selection;
|
|
43667
|
+
doc = transaction.doc;
|
|
43668
|
+
storedMarks = transaction.storedMarks;
|
|
43669
|
+
return transaction;
|
|
43670
|
+
}
|
|
43671
|
+
};
|
|
43672
|
+
}
|
|
43673
|
+
//#endregion
|
|
43674
|
+
//#region src/CommandManager.ts
|
|
43675
|
+
var CommandManager = class CommandManager {
|
|
43676
|
+
constructor(props) {
|
|
43677
|
+
this.editor = props.editor;
|
|
43678
|
+
this.rawCommands = this.editor.extensionManager.commands;
|
|
43679
|
+
this.customState = props.state;
|
|
43680
|
+
}
|
|
43681
|
+
get hasCustomState() {
|
|
43682
|
+
return !!this.customState;
|
|
43683
|
+
}
|
|
43684
|
+
get state() {
|
|
43685
|
+
return this.customState || this.editor.state;
|
|
43686
|
+
}
|
|
43687
|
+
get commands() {
|
|
43688
|
+
const { rawCommands, editor, state } = this;
|
|
43689
|
+
const { view } = editor;
|
|
43690
|
+
const { tr } = state;
|
|
43691
|
+
const props = this.buildProps(tr);
|
|
43692
|
+
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43693
|
+
const method = (...args) => {
|
|
43694
|
+
const callback = command(...args)(props);
|
|
43695
|
+
if (!tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
43696
|
+
return callback;
|
|
43697
|
+
};
|
|
43698
|
+
return [name, method];
|
|
43699
|
+
}));
|
|
43700
|
+
}
|
|
43701
|
+
get chain() {
|
|
43702
|
+
return () => this.createChain();
|
|
43703
|
+
}
|
|
43704
|
+
get can() {
|
|
43705
|
+
return () => this.createCan();
|
|
43706
|
+
}
|
|
43707
|
+
createChain(startTr, shouldDispatch = true) {
|
|
43708
|
+
const { rawCommands, editor, state } = this;
|
|
43709
|
+
const { view } = editor;
|
|
43710
|
+
const callbacks = [];
|
|
43711
|
+
const hasStartTransaction = !!startTr;
|
|
43712
|
+
const tr = startTr || state.tr;
|
|
43713
|
+
const run = () => {
|
|
43714
|
+
if (!hasStartTransaction && shouldDispatch && !tr.getMeta("preventDispatch") && !this.hasCustomState) view.dispatch(tr);
|
|
43715
|
+
return callbacks.every((callback) => callback === true);
|
|
43716
|
+
};
|
|
43717
|
+
const chain = {
|
|
43718
|
+
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43719
|
+
const chainedCommand = (...args) => {
|
|
43720
|
+
const props = this.buildProps(tr, shouldDispatch);
|
|
43721
|
+
const callback = command(...args)(props);
|
|
43722
|
+
callbacks.push(callback);
|
|
43723
|
+
return chain;
|
|
43724
|
+
};
|
|
43725
|
+
return [name, chainedCommand];
|
|
43726
|
+
})),
|
|
43727
|
+
run
|
|
43728
|
+
};
|
|
43729
|
+
return chain;
|
|
43730
|
+
}
|
|
43731
|
+
/**
|
|
43732
|
+
* Creates a chain that safely returns `false` when run.
|
|
43733
|
+
* @returns A non-dispatching command chain.
|
|
43734
|
+
* @example
|
|
43735
|
+
* const chain = CommandManager.createFakeChain()
|
|
43736
|
+
* chain.focus().run() // false
|
|
43737
|
+
*/
|
|
43738
|
+
static createFakeChain() {
|
|
43739
|
+
const chain = new Proxy({}, { get: (_target, property) => {
|
|
43740
|
+
if (property === "then") return;
|
|
43741
|
+
if (property === "run") return () => false;
|
|
43742
|
+
return () => chain;
|
|
43743
|
+
} });
|
|
43744
|
+
return chain;
|
|
43745
|
+
}
|
|
43746
|
+
createCan(startTr) {
|
|
43747
|
+
const { rawCommands, state } = this;
|
|
43748
|
+
const dispatch = false;
|
|
43749
|
+
const tr = startTr || state.tr;
|
|
43750
|
+
const props = this.buildProps(tr, dispatch);
|
|
43751
|
+
return {
|
|
43752
|
+
...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43753
|
+
return [name, (...args) => command(...args)({
|
|
43754
|
+
...props,
|
|
43755
|
+
dispatch: void 0
|
|
43756
|
+
})];
|
|
43757
|
+
})),
|
|
43758
|
+
chain: () => this.createChain(tr, dispatch)
|
|
43759
|
+
};
|
|
43760
|
+
}
|
|
43761
|
+
/**
|
|
43762
|
+
* Creates capability checks that safely return `false`.
|
|
43763
|
+
* @returns A non-dispatching capability checker.
|
|
43764
|
+
* @example
|
|
43765
|
+
* const can = CommandManager.createFallbackCan()
|
|
43766
|
+
* can.focus() // false
|
|
43767
|
+
*/
|
|
43768
|
+
static createFallbackCan() {
|
|
43769
|
+
const chain = CommandManager.createFakeChain();
|
|
43770
|
+
return new Proxy({ chain: () => chain }, { get: (target, property) => {
|
|
43771
|
+
if (property === "then") return;
|
|
43772
|
+
if (property === "chain") return target.chain;
|
|
43773
|
+
return () => false;
|
|
43774
|
+
} });
|
|
43775
|
+
}
|
|
43776
|
+
buildProps(tr, shouldDispatch = true) {
|
|
43777
|
+
const { rawCommands, editor, state } = this;
|
|
43778
|
+
const { view } = editor;
|
|
43779
|
+
const props = {
|
|
43780
|
+
tr,
|
|
43781
|
+
editor,
|
|
43782
|
+
view,
|
|
43783
|
+
state: createChainableState({
|
|
43784
|
+
state,
|
|
43785
|
+
transaction: tr
|
|
43786
|
+
}),
|
|
43787
|
+
dispatch: shouldDispatch ? () => void 0 : void 0,
|
|
43788
|
+
chain: () => this.createChain(tr, shouldDispatch),
|
|
43789
|
+
can: () => this.createCan(tr),
|
|
43790
|
+
get commands() {
|
|
43791
|
+
return Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {
|
|
43792
|
+
return [name, (...args) => command(...args)(props)];
|
|
43793
|
+
}));
|
|
43794
|
+
}
|
|
43795
|
+
};
|
|
43796
|
+
return props;
|
|
43797
|
+
}
|
|
43798
|
+
};
|
|
43799
|
+
//#endregion
|
|
43800
|
+
//#region src/commands/blur.ts
|
|
43801
|
+
const blur = () => ({ editor, view }) => {
|
|
43802
|
+
requestAnimationFrame(() => {
|
|
43803
|
+
if (!editor.isDestroyed) {
|
|
43804
|
+
var _window;
|
|
43805
|
+
view.dom.blur();
|
|
43806
|
+
(_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 || _window.removeAllRanges();
|
|
43807
|
+
}
|
|
43808
|
+
});
|
|
43809
|
+
return true;
|
|
43810
|
+
};
|
|
43811
|
+
//#endregion
|
|
43812
|
+
//#region src/commands/clearContent.ts
|
|
43813
|
+
const clearContent = (emitUpdate = true) => ({ commands }) => {
|
|
43814
|
+
return commands.setContent("", { emitUpdate });
|
|
43815
|
+
};
|
|
43816
|
+
//#endregion
|
|
43817
|
+
//#region src/commands/clearNodes.ts
|
|
43818
|
+
const clearNodes = () => ({ state, tr, dispatch }) => {
|
|
43819
|
+
const { selection } = tr;
|
|
43820
|
+
const { ranges } = selection;
|
|
43821
|
+
if (!dispatch) return true;
|
|
43822
|
+
ranges.forEach(({ $from, $to }) => {
|
|
43823
|
+
state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {
|
|
43824
|
+
if (node.type.isText) return;
|
|
43825
|
+
const { doc, mapping } = tr;
|
|
43826
|
+
const $mappedFrom = doc.resolve(mapping.map(pos));
|
|
43827
|
+
const $mappedTo = doc.resolve(mapping.map(pos + node.nodeSize));
|
|
43828
|
+
const nodeRange = $mappedFrom.blockRange($mappedTo);
|
|
43829
|
+
if (!nodeRange) return;
|
|
43830
|
+
const targetLiftDepth = liftTarget(nodeRange);
|
|
43831
|
+
if (node.type.isTextblock) {
|
|
43832
|
+
const { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index());
|
|
43833
|
+
tr.setNodeMarkup(nodeRange.start, defaultType);
|
|
43834
|
+
}
|
|
43835
|
+
if (targetLiftDepth || targetLiftDepth === 0) tr.lift(nodeRange, targetLiftDepth);
|
|
43836
|
+
});
|
|
43837
|
+
});
|
|
43838
|
+
return true;
|
|
43839
|
+
};
|
|
43840
|
+
//#endregion
|
|
43841
|
+
//#region src/commands/command.ts
|
|
43842
|
+
const command = (fn) => (props) => {
|
|
43843
|
+
return fn(props);
|
|
43844
|
+
};
|
|
43845
|
+
//#endregion
|
|
43846
|
+
//#region src/commands/createParagraphNear.ts
|
|
43847
|
+
const createParagraphNear$1 = () => ({ state, dispatch }) => {
|
|
43848
|
+
return createParagraphNear(state, dispatch);
|
|
43849
|
+
};
|
|
43850
|
+
//#endregion
|
|
43851
|
+
//#region src/commands/cut.ts
|
|
43852
|
+
const cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
43853
|
+
const { state } = editor;
|
|
43854
|
+
const contentSlice = state.doc.slice(originRange.from, originRange.to);
|
|
43855
|
+
tr.deleteRange(originRange.from, originRange.to);
|
|
43856
|
+
const newPos = tr.mapping.map(targetPos);
|
|
43857
|
+
tr.insert(newPos, contentSlice.content);
|
|
43858
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(Math.max(newPos - 1, 0))));
|
|
43859
|
+
return true;
|
|
43860
|
+
};
|
|
43861
|
+
//#endregion
|
|
43862
|
+
//#region src/commands/deleteCurrentNode.ts
|
|
43863
|
+
const deleteCurrentNode = () => ({ tr, dispatch }) => {
|
|
43864
|
+
const { selection } = tr;
|
|
43865
|
+
const currentNode = selection.$anchor.node();
|
|
43866
|
+
if (currentNode.content.size > 0) return false;
|
|
43867
|
+
const $pos = tr.selection.$anchor;
|
|
43868
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === currentNode.type) {
|
|
43869
|
+
if (dispatch) {
|
|
43870
|
+
const from = $pos.before(depth);
|
|
43871
|
+
const to = $pos.after(depth);
|
|
43872
|
+
tr.delete(from, to).scrollIntoView();
|
|
43873
|
+
}
|
|
43874
|
+
return true;
|
|
43875
|
+
}
|
|
43876
|
+
return false;
|
|
43877
|
+
};
|
|
43878
|
+
//#endregion
|
|
43879
|
+
//#region src/helpers/getNodeType.ts
|
|
43880
|
+
function getNodeType(nameOrType, schema) {
|
|
43881
|
+
if (typeof nameOrType === "string") {
|
|
43882
|
+
if (!schema.nodes[nameOrType]) throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`);
|
|
43883
|
+
return schema.nodes[nameOrType];
|
|
43884
|
+
}
|
|
43885
|
+
return nameOrType;
|
|
43886
|
+
}
|
|
43887
|
+
//#endregion
|
|
43888
|
+
//#region src/commands/deleteNode.ts
|
|
43889
|
+
const deleteNode = (typeOrName) => ({ tr, state, dispatch }) => {
|
|
43890
|
+
const type = getNodeType(typeOrName, state.schema);
|
|
43891
|
+
const $pos = tr.selection.$anchor;
|
|
43892
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === type) {
|
|
43893
|
+
if (dispatch) {
|
|
43894
|
+
const from = $pos.before(depth);
|
|
43895
|
+
const to = $pos.after(depth);
|
|
43896
|
+
tr.delete(from, to).scrollIntoView();
|
|
43897
|
+
}
|
|
43898
|
+
return true;
|
|
43899
|
+
}
|
|
43900
|
+
return false;
|
|
43901
|
+
};
|
|
43902
|
+
//#endregion
|
|
43903
|
+
//#region src/commands/deleteRange.ts
|
|
43904
|
+
const deleteRange = (range) => ({ tr, dispatch }) => {
|
|
43905
|
+
const { from, to } = range;
|
|
43906
|
+
if (dispatch) tr.delete(from, to);
|
|
43907
|
+
return true;
|
|
43908
|
+
};
|
|
43909
|
+
//#endregion
|
|
43910
|
+
//#region src/commands/deleteSelection.ts
|
|
43911
|
+
/**
|
|
43912
|
+
* Check if a node has text content based on its content specification.
|
|
43913
|
+
* Returns true if the node's content spec matches text* or text+ patterns.
|
|
43914
|
+
*/
|
|
43915
|
+
const hasTextContent = (nodeSpec) => {
|
|
43916
|
+
if (!nodeSpec.content) return false;
|
|
43917
|
+
return /^text(\*|\+)/.test(nodeSpec.content);
|
|
43918
|
+
};
|
|
43919
|
+
/**
|
|
43920
|
+
* Expand selection position for a specific side (left or right) to handle inline text nodes.
|
|
43921
|
+
* This function checks if the position is within an inline node with text content and
|
|
43922
|
+
* expands it to include the entire node boundaries for proper deletion.
|
|
43923
|
+
* @param $pos - The resolved position to expand
|
|
43924
|
+
* @param schema - The ProseMirror schema
|
|
43925
|
+
* @param side - Which side to expand ('left' or 'right')
|
|
43926
|
+
* @returns The expanded position for deletion
|
|
43927
|
+
*/
|
|
43928
|
+
const expandSelectionForSide = ($pos, schema, side) => {
|
|
43929
|
+
if (!$pos.parent.isInline) return $pos.pos;
|
|
43930
|
+
if (side === "left" && $pos.pos > $pos.start() || side === "right" && $pos.pos < $pos.end()) return $pos.pos;
|
|
43931
|
+
const parentContent = schema.nodes[$pos.parent.type.name].spec;
|
|
43932
|
+
if (!hasTextContent(parentContent)) return $pos.pos;
|
|
43933
|
+
return side === "left" ? $pos.start() - 1 : $pos.end() + 1;
|
|
43934
|
+
};
|
|
43935
|
+
/**
|
|
43936
|
+
* Expand selection range to properly handle deletion of inline text nodes.
|
|
43937
|
+
* Inline text nodes don't collapse correctly when text inside is deleted,
|
|
43938
|
+
* so we need to expand the selection to include the entire node.
|
|
43939
|
+
* See: https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1365
|
|
43940
|
+
*/
|
|
43941
|
+
const expandSelectionForInlineText = ($from, $to, schema) => {
|
|
43942
|
+
return {
|
|
43943
|
+
from: expandSelectionForSide($from, schema, "left"),
|
|
43944
|
+
to: expandSelectionForSide($to, schema, "right")
|
|
43945
|
+
};
|
|
43946
|
+
};
|
|
43947
|
+
const deleteSelection = () => ({ state, dispatch }) => {
|
|
43948
|
+
if (state.selection.empty) return false;
|
|
43949
|
+
if (dispatch) {
|
|
43950
|
+
const tr = state.tr;
|
|
43951
|
+
const { ranges } = state.selection;
|
|
43952
|
+
const mapFrom = tr.steps.length;
|
|
43953
|
+
ranges.forEach((range) => {
|
|
43954
|
+
const mapping = tr.mapping.slice(mapFrom);
|
|
43955
|
+
const $from = tr.doc.resolve(mapping.map(range.$from.pos));
|
|
43956
|
+
const $to = tr.doc.resolve(mapping.map(range.$to.pos));
|
|
43957
|
+
const { from, to } = expandSelectionForInlineText($from, $to, state.schema);
|
|
43958
|
+
tr.deleteRange(from, to);
|
|
43959
|
+
});
|
|
43960
|
+
if (!tr.selection.empty) tr.setSelection(TextSelection.near(tr.doc.resolve(tr.selection.from)));
|
|
43961
|
+
tr.scrollIntoView();
|
|
43962
|
+
dispatch(tr);
|
|
43963
|
+
}
|
|
43964
|
+
return true;
|
|
43965
|
+
};
|
|
43966
|
+
//#endregion
|
|
43201
43967
|
//#region src/commands/enter.ts
|
|
43202
43968
|
const enter = () => ({ commands }) => {
|
|
43203
43969
|
return commands.keyboardShortcut("Enter");
|
|
@@ -43670,11 +44436,21 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
43670
44436
|
return joinForward(state, dispatch);
|
|
43671
44437
|
};
|
|
43672
44438
|
//#endregion
|
|
44439
|
+
//#region src/commands/canJoinItemsAt.ts
|
|
44440
|
+
const canJoinItemsAt = (doc, pos) => {
|
|
44441
|
+
const $pos = doc.resolve(pos);
|
|
44442
|
+
const before = $pos.nodeBefore;
|
|
44443
|
+
const after = $pos.nodeAfter;
|
|
44444
|
+
if (!before || !after) return false;
|
|
44445
|
+
return !before.type.spec.isolating && !after.type.spec.isolating;
|
|
44446
|
+
};
|
|
44447
|
+
//#endregion
|
|
43673
44448
|
//#region src/commands/joinItemBackward.ts
|
|
43674
44449
|
const joinItemBackward = () => ({ state, dispatch, tr }) => {
|
|
43675
44450
|
try {
|
|
43676
44451
|
const point = joinPoint(state.doc, state.selection.$from.pos, -1);
|
|
43677
44452
|
if (point === null || point === void 0) return false;
|
|
44453
|
+
if (!canJoinItemsAt(state.doc, point)) return false;
|
|
43678
44454
|
tr.join(point, 2);
|
|
43679
44455
|
if (dispatch) dispatch(tr);
|
|
43680
44456
|
return true;
|
|
@@ -43688,6 +44464,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
43688
44464
|
try {
|
|
43689
44465
|
const point = joinPoint(state.doc, state.selection.$from.pos, 1);
|
|
43690
44466
|
if (point === null || point === void 0) return false;
|
|
44467
|
+
if (!canJoinItemsAt(state.doc, point)) return false;
|
|
43691
44468
|
tr.join(point, 2);
|
|
43692
44469
|
if (dispatch) dispatch(tr);
|
|
43693
44470
|
return true;
|
|
@@ -45094,8 +45871,14 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45094
45871
|
type: deflt,
|
|
45095
45872
|
attrs: newAttributes
|
|
45096
45873
|
}] : void 0;
|
|
45097
|
-
|
|
45098
|
-
|
|
45874
|
+
const deletedTr = selection instanceof TextSelection && !selection.empty ? EditorState.create({
|
|
45875
|
+
doc: tr.doc,
|
|
45876
|
+
selection
|
|
45877
|
+
}).tr.deleteSelection() : null;
|
|
45878
|
+
const splitDoc = deletedTr ? deletedTr.doc : tr.doc;
|
|
45879
|
+
const splitPos = deletedTr ? deletedTr.mapping.map($from.pos) : $from.pos;
|
|
45880
|
+
let can = canSplit(splitDoc, splitPos, 1, types);
|
|
45881
|
+
if (!types && !can && canSplit(splitDoc, splitPos, 1, deflt ? [{ type: deflt }] : void 0)) {
|
|
45099
45882
|
can = true;
|
|
45100
45883
|
types = deflt ? [{
|
|
45101
45884
|
type: deflt,
|
|
@@ -45104,12 +45887,13 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45104
45887
|
}
|
|
45105
45888
|
if (dispatch) {
|
|
45106
45889
|
if (can) {
|
|
45890
|
+
const mapFrom = tr.steps.length;
|
|
45107
45891
|
if (selection instanceof TextSelection) tr.deleteSelection();
|
|
45108
|
-
tr.split(tr.mapping.map($from.pos), 1, types);
|
|
45892
|
+
tr.split(tr.mapping.slice(mapFrom).map($from.pos), 1, types);
|
|
45109
45893
|
if (deflt && !atEnd && !$from.parentOffset && $from.parent.type !== deflt) {
|
|
45110
|
-
const first = tr.mapping.map($from.before());
|
|
45894
|
+
const first = tr.mapping.slice(mapFrom).map($from.before());
|
|
45111
45895
|
const $first = tr.doc.resolve(first);
|
|
45112
|
-
if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(tr.mapping.map($from.before()), deflt);
|
|
45896
|
+
if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(tr.mapping.slice(mapFrom).map($from.before()), deflt);
|
|
45113
45897
|
}
|
|
45114
45898
|
}
|
|
45115
45899
|
if (keepMarks) ensureMarks(state, editor.extensionManager.splittableMarks);
|
|
@@ -45162,16 +45946,19 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45162
45946
|
...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),
|
|
45163
45947
|
...overrideAttrs
|
|
45164
45948
|
};
|
|
45949
|
+
const splitsAtStartOfItem = $from.parentOffset === 0 && $from.index(-1) === 0;
|
|
45950
|
+
const itemStart = $from.before(-1);
|
|
45165
45951
|
tr.delete($from.pos, $to.pos);
|
|
45952
|
+
const trailingTypeAttributes = splitsAtStartOfItem ? grandParent.attrs : newTypeAttributes;
|
|
45166
45953
|
const types = nextType ? [{
|
|
45167
45954
|
type,
|
|
45168
|
-
attrs:
|
|
45955
|
+
attrs: trailingTypeAttributes
|
|
45169
45956
|
}, {
|
|
45170
45957
|
type: nextType,
|
|
45171
45958
|
attrs: newNextTypeAttributes
|
|
45172
45959
|
}] : [{
|
|
45173
45960
|
type,
|
|
45174
|
-
attrs:
|
|
45961
|
+
attrs: trailingTypeAttributes
|
|
45175
45962
|
}];
|
|
45176
45963
|
if (!canSplit(tr.doc, $from.pos, 2)) return false;
|
|
45177
45964
|
if (dispatch) {
|
|
@@ -45179,6 +45966,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
45179
45966
|
const { splittableMarks } = editor.extensionManager;
|
|
45180
45967
|
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
|
|
45181
45968
|
tr.split($from.pos, 2, types).scrollIntoView();
|
|
45969
|
+
if (splitsAtStartOfItem) tr.setNodeMarkup(itemStart, void 0, newTypeAttributes);
|
|
45182
45970
|
if (!marks || !dispatch) return true;
|
|
45183
45971
|
const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
|
|
45184
45972
|
tr.ensureMarks(filteredMarks);
|
|
@@ -46711,55 +47499,106 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
46711
47499
|
}
|
|
46712
47500
|
return result;
|
|
46713
47501
|
};
|
|
47502
|
+
/**
|
|
47503
|
+
* Prepares the typed text so the rule handler can inspect the resulting document.
|
|
47504
|
+
*/
|
|
47505
|
+
function createRuleTransaction(config) {
|
|
47506
|
+
const { editor, from, to, text, insertText } = config;
|
|
47507
|
+
if (!insertText) return {
|
|
47508
|
+
inputTransaction: null,
|
|
47509
|
+
tr: editor.view.state.tr
|
|
47510
|
+
};
|
|
47511
|
+
const inputTransaction = editor.view.state.tr.insertText(text, from, to);
|
|
47512
|
+
return {
|
|
47513
|
+
inputTransaction,
|
|
47514
|
+
tr: EditorState.create({
|
|
47515
|
+
doc: inputTransaction.doc,
|
|
47516
|
+
selection: inputTransaction.selection,
|
|
47517
|
+
storedMarks: inputTransaction.storedMarks
|
|
47518
|
+
}).tr
|
|
47519
|
+
};
|
|
47520
|
+
}
|
|
47521
|
+
/**
|
|
47522
|
+
* Runs a matching rule and dispatches the typed text before its conversion.
|
|
47523
|
+
*/
|
|
47524
|
+
function applyRule(config) {
|
|
47525
|
+
const { editor, from, to, text, rule, match, plugin, insertText } = config;
|
|
47526
|
+
const { view } = editor;
|
|
47527
|
+
const { inputTransaction, tr } = createRuleTransaction({
|
|
47528
|
+
editor,
|
|
47529
|
+
from,
|
|
47530
|
+
to,
|
|
47531
|
+
text,
|
|
47532
|
+
insertText
|
|
47533
|
+
});
|
|
47534
|
+
const inputEnd = inputTransaction ? from + text.length : to;
|
|
47535
|
+
const state = createChainableState({
|
|
47536
|
+
state: view.state,
|
|
47537
|
+
transaction: tr
|
|
47538
|
+
});
|
|
47539
|
+
const range = {
|
|
47540
|
+
from: from - (match[0].length - text.length),
|
|
47541
|
+
to: inputEnd
|
|
47542
|
+
};
|
|
47543
|
+
const { commands, chain, can } = new CommandManager({
|
|
47544
|
+
editor,
|
|
47545
|
+
state
|
|
47546
|
+
});
|
|
47547
|
+
if (rule.handler({
|
|
47548
|
+
state,
|
|
47549
|
+
range,
|
|
47550
|
+
match,
|
|
47551
|
+
commands,
|
|
47552
|
+
chain,
|
|
47553
|
+
can
|
|
47554
|
+
}) === null || !tr.steps.length) return false;
|
|
47555
|
+
if (inputTransaction) {
|
|
47556
|
+
view.dispatch(inputTransaction);
|
|
47557
|
+
if (!view.state.doc.eq(inputTransaction.doc)) return true;
|
|
47558
|
+
}
|
|
47559
|
+
closeHistory(tr);
|
|
47560
|
+
tr.setMeta("inputRule", true);
|
|
47561
|
+
if (rule.undoable) tr.setMeta(plugin, {
|
|
47562
|
+
transform: tr,
|
|
47563
|
+
from,
|
|
47564
|
+
to: inputEnd,
|
|
47565
|
+
text
|
|
47566
|
+
});
|
|
47567
|
+
view.dispatch(tr);
|
|
47568
|
+
return true;
|
|
47569
|
+
}
|
|
47570
|
+
/**
|
|
47571
|
+
* Checks that the part of a match already in the document has matching positions.
|
|
47572
|
+
*/
|
|
47573
|
+
function matchesDocument($from, match, text) {
|
|
47574
|
+
const matchedDocLength = match[0].length - text.length;
|
|
47575
|
+
if (matchedDocLength <= 0) return true;
|
|
47576
|
+
const matchStartOffset = $from.parentOffset - matchedDocLength;
|
|
47577
|
+
return matchStartOffset >= 0 && $from.parent.textBetween(matchStartOffset, $from.parentOffset) === match[0].slice(0, matchedDocLength);
|
|
47578
|
+
}
|
|
46714
47579
|
function run$1$1(config) {
|
|
46715
47580
|
var _ref;
|
|
46716
|
-
const { editor, from, to, text, rules, plugin } = config;
|
|
47581
|
+
const { editor, from, to, text, rules, plugin, insertText } = config;
|
|
46717
47582
|
const { view } = editor;
|
|
46718
47583
|
if (view.composing) return false;
|
|
46719
47584
|
const $from = view.state.doc.resolve(from);
|
|
46720
47585
|
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;
|
|
46721
|
-
let matched = false;
|
|
46722
47586
|
const textBefore = getTextContentFromNodes($from) + text;
|
|
46723
|
-
|
|
46724
|
-
if (matched) return;
|
|
47587
|
+
for (const rule of rules) {
|
|
46725
47588
|
const match = inputRuleMatcherHandler(textBefore, rule.find);
|
|
46726
|
-
if (!match)
|
|
46727
|
-
|
|
46728
|
-
if (matchedDocLength > 0) {
|
|
46729
|
-
const matchStartOffset = $from.parentOffset - matchedDocLength;
|
|
46730
|
-
if (matchStartOffset < 0 || $from.parent.textBetween(matchStartOffset, $from.parentOffset) !== match[0].slice(0, matchedDocLength)) return;
|
|
46731
|
-
}
|
|
46732
|
-
const tr = view.state.tr;
|
|
46733
|
-
const state = createChainableState({
|
|
46734
|
-
state: view.state,
|
|
46735
|
-
transaction: tr
|
|
46736
|
-
});
|
|
46737
|
-
const range = {
|
|
46738
|
-
from: from - (match[0].length - text.length),
|
|
46739
|
-
to
|
|
46740
|
-
};
|
|
46741
|
-
const { commands, chain, can } = new CommandManager({
|
|
47589
|
+
if (!match || !matchesDocument($from, match, text)) continue;
|
|
47590
|
+
if (applyRule({
|
|
46742
47591
|
editor,
|
|
46743
|
-
state
|
|
46744
|
-
});
|
|
46745
|
-
if (rule.handler({
|
|
46746
|
-
state,
|
|
46747
|
-
range,
|
|
46748
|
-
match,
|
|
46749
|
-
commands,
|
|
46750
|
-
chain,
|
|
46751
|
-
can
|
|
46752
|
-
}) === null || !tr.steps.length) return;
|
|
46753
|
-
if (rule.undoable) tr.setMeta(plugin, {
|
|
46754
|
-
transform: tr,
|
|
46755
47592
|
from,
|
|
46756
47593
|
to,
|
|
46757
|
-
text
|
|
46758
|
-
|
|
46759
|
-
|
|
46760
|
-
|
|
46761
|
-
|
|
46762
|
-
|
|
47594
|
+
text,
|
|
47595
|
+
rule,
|
|
47596
|
+
match,
|
|
47597
|
+
plugin,
|
|
47598
|
+
insertText
|
|
47599
|
+
})) return true;
|
|
47600
|
+
}
|
|
47601
|
+
return false;
|
|
46763
47602
|
}
|
|
46764
47603
|
/**
|
|
46765
47604
|
* Create an input rules plugin. When enabled, it will cause text
|
|
@@ -46803,7 +47642,8 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
46803
47642
|
to,
|
|
46804
47643
|
text,
|
|
46805
47644
|
rules,
|
|
46806
|
-
plugin
|
|
47645
|
+
plugin,
|
|
47646
|
+
insertText: true
|
|
46807
47647
|
});
|
|
46808
47648
|
},
|
|
46809
47649
|
handleDOMEvents: { compositionend: (view) => {
|
|
@@ -47039,6 +47879,9 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
47039
47879
|
pasteEvent = typeof ClipboardEvent !== "undefined" ? new ClipboardEvent("paste") : null;
|
|
47040
47880
|
return tr;
|
|
47041
47881
|
};
|
|
47882
|
+
editor.on("destroy", () => {
|
|
47883
|
+
if (tiptapDragFromOtherEditor === editor) tiptapDragFromOtherEditor = null;
|
|
47884
|
+
});
|
|
47042
47885
|
return rules.map((rule) => {
|
|
47043
47886
|
return new Plugin({
|
|
47044
47887
|
view(view) {
|
|
@@ -47064,6 +47907,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
47064
47907
|
if (!isDroppedFromProseMirror) {
|
|
47065
47908
|
const dragFromOtherEditor = tiptapDragFromOtherEditor;
|
|
47066
47909
|
if (dragFromOtherEditor === null || dragFromOtherEditor === void 0 ? void 0 : dragFromOtherEditor.isEditable) setTimeout(() => {
|
|
47910
|
+
if (dragFromOtherEditor.isDestroyed) return;
|
|
47067
47911
|
const selection = dragFromOtherEditor.state.selection;
|
|
47068
47912
|
if (selection) dragFromOtherEditor.commands.deleteRange({
|
|
47069
47913
|
from: selection.from,
|
|
@@ -48233,7 +49077,10 @@ img.ProseMirror-separator {
|
|
|
48233
49077
|
...options
|
|
48234
49078
|
};
|
|
48235
49079
|
if (!this.editorView || !this.state || this.isDestroyed) return;
|
|
48236
|
-
if (this.options.editorProps) this.view.setProps(
|
|
49080
|
+
if (this.options.editorProps) this.view.setProps({
|
|
49081
|
+
...this.options.editorProps,
|
|
49082
|
+
attributes: this.getEditorViewAttributes()
|
|
49083
|
+
});
|
|
48237
49084
|
this.view.updateState(this.state);
|
|
48238
49085
|
}
|
|
48239
49086
|
/**
|
|
@@ -48389,6 +49236,23 @@ img.ProseMirror-separator {
|
|
|
48389
49236
|
return doc;
|
|
48390
49237
|
}
|
|
48391
49238
|
/**
|
|
49239
|
+
* Returns the attributes for the editor element.
|
|
49240
|
+
* Merges the default `role="textbox"` with the attributes from `editorProps`,
|
|
49241
|
+
* so the role is kept no matter when the props are applied.
|
|
49242
|
+
*/
|
|
49243
|
+
getEditorViewAttributes() {
|
|
49244
|
+
var _this$options$editorP;
|
|
49245
|
+
const attributes = (_this$options$editorP = this.options.editorProps) === null || _this$options$editorP === void 0 ? void 0 : _this$options$editorP.attributes;
|
|
49246
|
+
if (isFunction$3(attributes)) return (state) => ({
|
|
49247
|
+
role: "textbox",
|
|
49248
|
+
...attributes(state)
|
|
49249
|
+
});
|
|
49250
|
+
return {
|
|
49251
|
+
role: "textbox",
|
|
49252
|
+
...attributes
|
|
49253
|
+
};
|
|
49254
|
+
}
|
|
49255
|
+
/**
|
|
48392
49256
|
* Creates a ProseMirror view.
|
|
48393
49257
|
*/
|
|
48394
49258
|
createView(element) {
|
|
@@ -48399,10 +49263,7 @@ img.ProseMirror-separator {
|
|
|
48399
49263
|
const transformPastedHTML = this.extensionManager.transformPastedHTML(baseTransformPastedHTML);
|
|
48400
49264
|
this.editorView = new EditorView(element, {
|
|
48401
49265
|
...editorProps,
|
|
48402
|
-
attributes:
|
|
48403
|
-
role: "textbox",
|
|
48404
|
-
...editorProps === null || editorProps === void 0 ? void 0 : editorProps.attributes
|
|
48405
|
-
},
|
|
49266
|
+
attributes: this.getEditorViewAttributes(),
|
|
48406
49267
|
dispatchTransaction: dispatch,
|
|
48407
49268
|
transformPastedHTML,
|
|
48408
49269
|
state: this.editorState,
|
|
@@ -58105,7 +58966,7 @@ img.ProseMirror-separator {
|
|
|
58105
58966
|
toDOM() { return ["div", ["hr"]]; }
|
|
58106
58967
|
},
|
|
58107
58968
|
heading: {
|
|
58108
|
-
attrs: { level: { default: 1 } },
|
|
58969
|
+
attrs: { level: { default: 1, validate: "number" } },
|
|
58109
58970
|
content: "(text | image)*",
|
|
58110
58971
|
group: "block",
|
|
58111
58972
|
defining: true,
|
|
@@ -58115,7 +58976,7 @@ img.ProseMirror-separator {
|
|
|
58115
58976
|
{ tag: "h4", attrs: { level: 4 } },
|
|
58116
58977
|
{ tag: "h5", attrs: { level: 5 } },
|
|
58117
58978
|
{ tag: "h6", attrs: { level: 6 } }],
|
|
58118
|
-
toDOM(node) { return ["h" + node.attrs.level, 0]; }
|
|
58979
|
+
toDOM(node) { return ["h" + +node.attrs.level, 0]; }
|
|
58119
58980
|
},
|
|
58120
58981
|
code_block: {
|
|
58121
58982
|
content: "text*",
|
|
@@ -61612,8 +62473,27 @@ img.ProseMirror-separator {
|
|
|
61612
62473
|
const UNICODE_WHITESPACE_PATTERN = "[\0- \xA0 -\u2029 ]";
|
|
61613
62474
|
const UNICODE_WHITESPACE_REGEX = new RegExp(UNICODE_WHITESPACE_PATTERN);
|
|
61614
62475
|
const UNICODE_WHITESPACE_REGEX_END = new RegExp(`${UNICODE_WHITESPACE_PATTERN}$`);
|
|
62476
|
+
const UNICODE_WHITESPACE_REGEX_TRAILING = new RegExp(`${UNICODE_WHITESPACE_PATTERN}+$`);
|
|
61615
62477
|
const UNICODE_WHITESPACE_REGEX_GLOBAL = new RegExp(UNICODE_WHITESPACE_PATTERN, "g");
|
|
61616
62478
|
//#endregion
|
|
62479
|
+
//#region src/helpers/unlinkTrailingWhitespace.ts
|
|
62480
|
+
function unlinkTrailingWhitespace(tr, range, type) {
|
|
62481
|
+
var _rangeEnd$nodeBefore, _insertedText$match;
|
|
62482
|
+
const rangeEnd = tr.doc.resolve(range.to);
|
|
62483
|
+
if (!((_rangeEnd$nodeBefore = rangeEnd.nodeBefore) === null || _rangeEnd$nodeBefore === void 0 ? void 0 : _rangeEnd$nodeBefore.isText)) return;
|
|
62484
|
+
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];
|
|
62485
|
+
if (!trailingWhitespace) return;
|
|
62486
|
+
const whitespaceFrom = range.to - trailingWhitespace.length;
|
|
62487
|
+
const linkMarks = getMarksBetween(whitespaceFrom, range.to, tr.doc).filter((item) => item.mark.type === type);
|
|
62488
|
+
if (!linkMarks.length) return;
|
|
62489
|
+
const { nodeAfter } = rangeEnd;
|
|
62490
|
+
if (!!nodeAfter && linkMarks.some((item) => item.mark.isInSet(nodeAfter.marks))) return;
|
|
62491
|
+
const storedMarks = tr.storedMarks;
|
|
62492
|
+
tr.removeMark(whitespaceFrom, range.to, type);
|
|
62493
|
+
tr.setStoredMarks(storedMarks);
|
|
62494
|
+
if (tr.selection.empty && tr.selection.from === range.to) tr.removeStoredMark(type);
|
|
62495
|
+
}
|
|
62496
|
+
//#endregion
|
|
61617
62497
|
//#region src/helpers/autolink.ts
|
|
61618
62498
|
/**
|
|
61619
62499
|
* Check if the provided tokens form a valid link structure, which can either be a single link token
|
|
@@ -61654,6 +62534,21 @@ img.ProseMirror-separator {
|
|
|
61654
62534
|
if (!docChanges || preventAutolink) return;
|
|
61655
62535
|
const { tr } = newState;
|
|
61656
62536
|
const transform = combineTransactionSteps(oldState.doc, [...transactions]);
|
|
62537
|
+
if (!transactions.some(isHistoryTransaction)) {
|
|
62538
|
+
const insertedRanges = [];
|
|
62539
|
+
transform.steps.forEach((step, index) => {
|
|
62540
|
+
if (!(step instanceof ReplaceStep) || !step.slice.size) return;
|
|
62541
|
+
const mapping = transform.mapping.slice(index + 1);
|
|
62542
|
+
const from = mapping.map(step.from, 1);
|
|
62543
|
+
const to = mapping.map(step.from + step.slice.size, -1);
|
|
62544
|
+
if (from < to) insertedRanges.push({
|
|
62545
|
+
from,
|
|
62546
|
+
to
|
|
62547
|
+
});
|
|
62548
|
+
});
|
|
62549
|
+
insertedRanges.sort((left, right) => right.to - left.to);
|
|
62550
|
+
insertedRanges.forEach((range) => unlinkTrailingWhitespace(tr, range, options.type));
|
|
62551
|
+
}
|
|
61657
62552
|
getChangedRanges(transform).forEach(({ newRange }) => {
|
|
61658
62553
|
const nodesInChangedRanges = findChildrenInRange(newState.doc, newRange, (node) => node.isTextblock);
|
|
61659
62554
|
let textBlock;
|
|
@@ -63040,6 +63935,54 @@ img.ProseMirror-separator {
|
|
|
63040
63935
|
});
|
|
63041
63936
|
}
|
|
63042
63937
|
//#endregion
|
|
63938
|
+
//#region src/ordered-list/collectOrderedListItemsFromSource.ts
|
|
63939
|
+
const ORDERED_LIST_SCAN_WINDOW = 64;
|
|
63940
|
+
function takeLines(source, max) {
|
|
63941
|
+
const lines = [];
|
|
63942
|
+
let start = 0;
|
|
63943
|
+
while (lines.length < max) {
|
|
63944
|
+
const lineEnd = source.indexOf("\n", start);
|
|
63945
|
+
if (lineEnd === -1) {
|
|
63946
|
+
lines.push(source.slice(start));
|
|
63947
|
+
return lines;
|
|
63948
|
+
}
|
|
63949
|
+
lines.push(source.slice(start, lineEnd));
|
|
63950
|
+
start = lineEnd + 1;
|
|
63951
|
+
}
|
|
63952
|
+
return lines;
|
|
63953
|
+
}
|
|
63954
|
+
/**
|
|
63955
|
+
* Collect ordered list items from the start of `source`, reading only the lines the list needs.
|
|
63956
|
+
*
|
|
63957
|
+
* @param source Markdown beginning at a block boundary.
|
|
63958
|
+
* @returns The items, how many lines they consumed, and the lines that were read.
|
|
63959
|
+
* @example
|
|
63960
|
+
* collectOrderedListItemsFromSource('1. one\n2. two\n\nAfter')
|
|
63961
|
+
* // → [[item, item], 3, ['1. one', '2. two', '', 'After']]
|
|
63962
|
+
*/
|
|
63963
|
+
function collectOrderedListItemsFromSource(source) {
|
|
63964
|
+
const firstLineEnd = source.indexOf("\n");
|
|
63965
|
+
const firstLine = firstLineEnd === -1 ? source : source.slice(0, firstLineEnd);
|
|
63966
|
+
if (!ORDERED_LIST_ITEM_REGEX.test(firstLine)) return [
|
|
63967
|
+
[],
|
|
63968
|
+
0,
|
|
63969
|
+
[]
|
|
63970
|
+
];
|
|
63971
|
+
let windowSize = ORDERED_LIST_SCAN_WINDOW;
|
|
63972
|
+
let lines = takeLines(source, windowSize);
|
|
63973
|
+
let collected = collectOrderedListItems(lines);
|
|
63974
|
+
while (collected[1] === lines.length && lines.length === windowSize) {
|
|
63975
|
+
windowSize *= 2;
|
|
63976
|
+
lines = takeLines(source, windowSize);
|
|
63977
|
+
collected = collectOrderedListItems(lines);
|
|
63978
|
+
}
|
|
63979
|
+
return [
|
|
63980
|
+
collected[0],
|
|
63981
|
+
collected[1],
|
|
63982
|
+
lines
|
|
63983
|
+
];
|
|
63984
|
+
}
|
|
63985
|
+
//#endregion
|
|
63043
63986
|
//#region src/ordered-list/ordered-list.ts
|
|
63044
63987
|
const ListItemName = "listItem";
|
|
63045
63988
|
const TextStyleName = "textStyle";
|
|
@@ -63158,8 +64101,7 @@ img.ProseMirror-separator {
|
|
|
63158
64101
|
start: () => -1,
|
|
63159
64102
|
tokenize: (src, _tokens, lexer) => {
|
|
63160
64103
|
var _listItems$, _listItems$2;
|
|
63161
|
-
const lines = src
|
|
63162
|
-
const [listItems, consumed] = collectOrderedListItems(lines);
|
|
64104
|
+
const [listItems, consumed, lines] = collectOrderedListItemsFromSource(src);
|
|
63163
64105
|
if (listItems.length === 0) return;
|
|
63164
64106
|
const items = buildNestedStructure(listItems, listItems[0].indent, lexer);
|
|
63165
64107
|
if (items.length === 0) return;
|
|
@@ -65930,1028 +66872,414 @@ img.ProseMirror-separator {
|
|
|
65930
66872
|
//#region src/text.ts
|
|
65931
66873
|
/**
|
|
65932
66874
|
* This extension allows you to create text nodes.
|
|
65933
|
-
* @see https://www.tiptap.dev/api/nodes/text
|
|
65934
|
-
*/
|
|
65935
|
-
const Text = Node$1.create({
|
|
65936
|
-
name: "text",
|
|
65937
|
-
group: "inline",
|
|
65938
|
-
parseMarkdown: (token) => {
|
|
65939
|
-
return {
|
|
65940
|
-
type: "text",
|
|
65941
|
-
text: token.text || ""
|
|
65942
|
-
};
|
|
65943
|
-
},
|
|
65944
|
-
renderMarkdown: (node) => node.text || ""
|
|
65945
|
-
});
|
|
65946
|
-
//#endregion
|
|
65947
|
-
//#region src/index.ts
|
|
65948
|
-
var src_default = Text;
|
|
65949
|
-
|
|
65950
|
-
/**
|
|
65951
|
-
Create a plugin that, when added to a ProseMirror instance,
|
|
65952
|
-
causes a decoration to show up at the drop position when something
|
|
65953
|
-
is dragged over the editor.
|
|
65954
|
-
|
|
65955
|
-
Nodes may add a `disableDropCursor` property to their spec to
|
|
65956
|
-
control the showing of a drop cursor inside them. This may be a
|
|
65957
|
-
boolean or a function, which will be called with a view and a
|
|
65958
|
-
position, and should return a boolean.
|
|
65959
|
-
*/
|
|
65960
|
-
function dropCursor(options = {}) {
|
|
65961
|
-
return new Plugin({
|
|
65962
|
-
view(editorView) { return new DropCursorView(editorView, options); }
|
|
65963
|
-
});
|
|
65964
|
-
}
|
|
65965
|
-
class DropCursorView {
|
|
65966
|
-
constructor(editorView, options) {
|
|
65967
|
-
var _a;
|
|
65968
|
-
this.editorView = editorView;
|
|
65969
|
-
this.cursorPos = null;
|
|
65970
|
-
this.element = null;
|
|
65971
|
-
this.timeout = -1;
|
|
65972
|
-
this.lastDragEvent = null;
|
|
65973
|
-
this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
|
|
65974
|
-
this.color = options.color === false ? undefined : (options.color || "black");
|
|
65975
|
-
this.class = options.class;
|
|
65976
|
-
this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(name => {
|
|
65977
|
-
let handler = (e) => { this[name](e); };
|
|
65978
|
-
editorView.dom.addEventListener(name, handler);
|
|
65979
|
-
return { name, handler };
|
|
65980
|
-
});
|
|
65981
|
-
}
|
|
65982
|
-
destroy() {
|
|
65983
|
-
this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
|
|
65984
|
-
}
|
|
65985
|
-
update(editorView, prevState) {
|
|
65986
|
-
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
|
|
65987
|
-
// if we currently have an on-going drag event
|
|
65988
|
-
// we need to update the cursor position again and update the overlay
|
|
65989
|
-
if (this.lastDragEvent) {
|
|
65990
|
-
let target = this.computeTarget(this.lastDragEvent);
|
|
65991
|
-
if (target == this.cursorPos)
|
|
65992
|
-
this.updateOverlay();
|
|
65993
|
-
else
|
|
65994
|
-
this.setCursor(target);
|
|
65995
|
-
}
|
|
65996
|
-
else {
|
|
65997
|
-
this.updateOverlay();
|
|
65998
|
-
}
|
|
65999
|
-
}
|
|
66000
|
-
}
|
|
66001
|
-
setCursor(pos) {
|
|
66002
|
-
if (pos == this.cursorPos)
|
|
66003
|
-
return;
|
|
66004
|
-
this.cursorPos = pos;
|
|
66005
|
-
if (pos == null) {
|
|
66006
|
-
this.element.parentNode.removeChild(this.element);
|
|
66007
|
-
this.element = null;
|
|
66008
|
-
}
|
|
66009
|
-
else {
|
|
66010
|
-
this.updateOverlay();
|
|
66011
|
-
}
|
|
66012
|
-
}
|
|
66013
|
-
updateOverlay() {
|
|
66014
|
-
let $pos = this.editorView.state.doc.resolve(this.cursorPos);
|
|
66015
|
-
let isBlock = !$pos.parent.inlineContent, rect;
|
|
66016
|
-
let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
|
|
66017
|
-
let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
|
|
66018
|
-
if (isBlock) {
|
|
66019
|
-
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
66020
|
-
if (before || after) {
|
|
66021
|
-
let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
|
|
66022
|
-
if (node) {
|
|
66023
|
-
let nodeRect = node.getBoundingClientRect();
|
|
66024
|
-
let top = before ? nodeRect.bottom : nodeRect.top;
|
|
66025
|
-
if (before && after)
|
|
66026
|
-
top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
|
|
66027
|
-
let halfWidth = (this.width / 2) * scaleY;
|
|
66028
|
-
rect = { left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth };
|
|
66029
|
-
}
|
|
66030
|
-
}
|
|
66031
|
-
}
|
|
66032
|
-
if (!rect) {
|
|
66033
|
-
let coords = this.editorView.coordsAtPos(this.cursorPos);
|
|
66034
|
-
let halfWidth = (this.width / 2) * scaleX;
|
|
66035
|
-
rect = { left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom };
|
|
66036
|
-
}
|
|
66037
|
-
let parent = this.editorView.dom.offsetParent;
|
|
66038
|
-
if (!this.element) {
|
|
66039
|
-
this.element = parent.appendChild(document.createElement("div"));
|
|
66040
|
-
if (this.class)
|
|
66041
|
-
this.element.className = this.class;
|
|
66042
|
-
this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
|
|
66043
|
-
if (this.color) {
|
|
66044
|
-
this.element.style.backgroundColor = this.color;
|
|
66045
|
-
}
|
|
66046
|
-
}
|
|
66047
|
-
this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
|
|
66048
|
-
this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
|
|
66049
|
-
let parentLeft, parentTop;
|
|
66050
|
-
if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
|
|
66051
|
-
parentLeft = -pageXOffset;
|
|
66052
|
-
parentTop = -pageYOffset;
|
|
66053
|
-
}
|
|
66054
|
-
else {
|
|
66055
|
-
let rect = parent.getBoundingClientRect();
|
|
66056
|
-
let parentScaleX = rect.width / parent.offsetWidth, parentScaleY = rect.height / parent.offsetHeight;
|
|
66057
|
-
parentLeft = rect.left - parent.scrollLeft * parentScaleX;
|
|
66058
|
-
parentTop = rect.top - parent.scrollTop * parentScaleY;
|
|
66059
|
-
}
|
|
66060
|
-
this.element.style.left = (rect.left - parentLeft) / scaleX + "px";
|
|
66061
|
-
this.element.style.top = (rect.top - parentTop) / scaleY + "px";
|
|
66062
|
-
this.element.style.width = (rect.right - rect.left) / scaleX + "px";
|
|
66063
|
-
this.element.style.height = (rect.bottom - rect.top) / scaleY + "px";
|
|
66064
|
-
}
|
|
66065
|
-
scheduleRemoval(timeout) {
|
|
66066
|
-
clearTimeout(this.timeout);
|
|
66067
|
-
this.timeout = setTimeout(() => this.setCursor(null), timeout);
|
|
66068
|
-
}
|
|
66069
|
-
computeTarget(event) {
|
|
66070
|
-
let pos = this.editorView.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
66071
|
-
let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
|
|
66072
|
-
let disableDropCursor = node && node.type.spec.disableDropCursor;
|
|
66073
|
-
let disabled = typeof disableDropCursor == "function"
|
|
66074
|
-
? disableDropCursor(this.editorView, pos, event)
|
|
66075
|
-
: disableDropCursor;
|
|
66076
|
-
if (!pos || disabled)
|
|
66077
|
-
return null;
|
|
66078
|
-
let target = pos.pos;
|
|
66079
|
-
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
66080
|
-
let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
|
|
66081
|
-
if (point != null)
|
|
66082
|
-
target = point;
|
|
66083
|
-
}
|
|
66084
|
-
return target;
|
|
66085
|
-
}
|
|
66086
|
-
dragover(event) {
|
|
66087
|
-
if (!this.editorView.editable)
|
|
66088
|
-
return;
|
|
66089
|
-
this.lastDragEvent = event;
|
|
66090
|
-
let target = this.computeTarget(event);
|
|
66091
|
-
if (target != null) {
|
|
66092
|
-
this.setCursor(target);
|
|
66093
|
-
this.scheduleRemoval(5000);
|
|
66094
|
-
}
|
|
66095
|
-
}
|
|
66096
|
-
dragend() {
|
|
66097
|
-
this.scheduleRemoval(20);
|
|
66098
|
-
}
|
|
66099
|
-
drop() {
|
|
66100
|
-
this.scheduleRemoval(20);
|
|
66101
|
-
}
|
|
66102
|
-
dragleave(event) {
|
|
66103
|
-
if (!this.editorView.dom.contains(event.relatedTarget))
|
|
66104
|
-
this.setCursor(null);
|
|
66105
|
-
}
|
|
66106
|
-
}
|
|
66107
|
-
|
|
66108
|
-
/**
|
|
66109
|
-
Gap cursor selections are represented using this class. Its
|
|
66110
|
-
`$anchor` and `$head` properties both point at the cursor position.
|
|
66111
|
-
*/
|
|
66112
|
-
class GapCursor extends Selection$2 {
|
|
66113
|
-
/**
|
|
66114
|
-
Create a gap cursor.
|
|
66115
|
-
*/
|
|
66116
|
-
constructor($pos) {
|
|
66117
|
-
super($pos, $pos);
|
|
66118
|
-
}
|
|
66119
|
-
map(doc, mapping) {
|
|
66120
|
-
let $pos = doc.resolve(mapping.map(this.head));
|
|
66121
|
-
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
66122
|
-
}
|
|
66123
|
-
content() { return Slice.empty; }
|
|
66124
|
-
eq(other) {
|
|
66125
|
-
return other instanceof GapCursor && other.head == this.head;
|
|
66126
|
-
}
|
|
66127
|
-
toJSON() {
|
|
66128
|
-
return { type: "gapcursor", pos: this.head };
|
|
66129
|
-
}
|
|
66130
|
-
/**
|
|
66131
|
-
@internal
|
|
66132
|
-
*/
|
|
66133
|
-
static fromJSON(doc, json) {
|
|
66134
|
-
if (typeof json.pos != "number")
|
|
66135
|
-
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
66136
|
-
return new GapCursor(doc.resolve(json.pos));
|
|
66137
|
-
}
|
|
66138
|
-
/**
|
|
66139
|
-
@internal
|
|
66140
|
-
*/
|
|
66141
|
-
getBookmark() { return new GapBookmark(this.anchor); }
|
|
66142
|
-
/**
|
|
66143
|
-
@internal
|
|
66144
|
-
*/
|
|
66145
|
-
static valid($pos) {
|
|
66146
|
-
let parent = $pos.parent;
|
|
66147
|
-
if (parent.inlineContent || !closedBefore($pos) || !closedAfter($pos))
|
|
66148
|
-
return false;
|
|
66149
|
-
let override = parent.type.spec.allowGapCursor;
|
|
66150
|
-
if (override != null)
|
|
66151
|
-
return override;
|
|
66152
|
-
let deflt = parent.contentMatchAt($pos.index()).defaultType;
|
|
66153
|
-
return deflt && deflt.isTextblock;
|
|
66154
|
-
}
|
|
66155
|
-
/**
|
|
66156
|
-
@internal
|
|
66157
|
-
*/
|
|
66158
|
-
static findGapCursorFrom($pos, dir, mustMove = false) {
|
|
66159
|
-
search: for (;;) {
|
|
66160
|
-
if (!mustMove && GapCursor.valid($pos))
|
|
66161
|
-
return $pos;
|
|
66162
|
-
let pos = $pos.pos, next = null;
|
|
66163
|
-
// Scan up from this position
|
|
66164
|
-
for (let d = $pos.depth;; d--) {
|
|
66165
|
-
let parent = $pos.node(d);
|
|
66166
|
-
if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
|
|
66167
|
-
next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
|
|
66168
|
-
break;
|
|
66169
|
-
}
|
|
66170
|
-
else if (d == 0) {
|
|
66171
|
-
return null;
|
|
66172
|
-
}
|
|
66173
|
-
pos += dir;
|
|
66174
|
-
let $cur = $pos.doc.resolve(pos);
|
|
66175
|
-
if (GapCursor.valid($cur))
|
|
66176
|
-
return $cur;
|
|
66177
|
-
}
|
|
66178
|
-
// And then down into the next node
|
|
66179
|
-
for (;;) {
|
|
66180
|
-
let inside = dir > 0 ? next.firstChild : next.lastChild;
|
|
66181
|
-
if (!inside) {
|
|
66182
|
-
if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
|
|
66183
|
-
$pos = $pos.doc.resolve(pos + next.nodeSize * dir);
|
|
66184
|
-
mustMove = false;
|
|
66185
|
-
continue search;
|
|
66186
|
-
}
|
|
66187
|
-
break;
|
|
66188
|
-
}
|
|
66189
|
-
next = inside;
|
|
66190
|
-
pos += dir;
|
|
66191
|
-
let $cur = $pos.doc.resolve(pos);
|
|
66192
|
-
if (GapCursor.valid($cur))
|
|
66193
|
-
return $cur;
|
|
66194
|
-
}
|
|
66195
|
-
return null;
|
|
66196
|
-
}
|
|
66197
|
-
}
|
|
66198
|
-
}
|
|
66199
|
-
GapCursor.prototype.visible = false;
|
|
66200
|
-
GapCursor.findFrom = GapCursor.findGapCursorFrom;
|
|
66201
|
-
Selection$2.jsonID("gapcursor", GapCursor);
|
|
66202
|
-
class GapBookmark {
|
|
66203
|
-
constructor(pos) {
|
|
66204
|
-
this.pos = pos;
|
|
66205
|
-
}
|
|
66206
|
-
map(mapping) {
|
|
66207
|
-
return new GapBookmark(mapping.map(this.pos));
|
|
66208
|
-
}
|
|
66209
|
-
resolve(doc) {
|
|
66210
|
-
let $pos = doc.resolve(this.pos);
|
|
66211
|
-
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
66212
|
-
}
|
|
66213
|
-
}
|
|
66214
|
-
function needsGap(type) {
|
|
66215
|
-
return type.isAtom || type.spec.isolating || type.spec.createGapCursor;
|
|
66216
|
-
}
|
|
66217
|
-
function closedBefore($pos) {
|
|
66218
|
-
for (let d = $pos.depth; d >= 0; d--) {
|
|
66219
|
-
let index = $pos.index(d), parent = $pos.node(d);
|
|
66220
|
-
// At the start of this parent, look at next one
|
|
66221
|
-
if (index == 0) {
|
|
66222
|
-
if (parent.type.spec.isolating)
|
|
66223
|
-
return true;
|
|
66224
|
-
continue;
|
|
66225
|
-
}
|
|
66226
|
-
// See if the node before (or its first ancestor) is closed
|
|
66227
|
-
for (let before = parent.child(index - 1);; before = before.lastChild) {
|
|
66228
|
-
if ((before.childCount == 0 && !before.inlineContent) || needsGap(before.type))
|
|
66229
|
-
return true;
|
|
66230
|
-
if (before.inlineContent)
|
|
66231
|
-
return false;
|
|
66232
|
-
}
|
|
66233
|
-
}
|
|
66234
|
-
// Hit start of document
|
|
66235
|
-
return true;
|
|
66236
|
-
}
|
|
66237
|
-
function closedAfter($pos) {
|
|
66238
|
-
for (let d = $pos.depth; d >= 0; d--) {
|
|
66239
|
-
let index = $pos.indexAfter(d), parent = $pos.node(d);
|
|
66240
|
-
if (index == parent.childCount) {
|
|
66241
|
-
if (parent.type.spec.isolating)
|
|
66242
|
-
return true;
|
|
66243
|
-
continue;
|
|
66244
|
-
}
|
|
66245
|
-
for (let after = parent.child(index);; after = after.firstChild) {
|
|
66246
|
-
if ((after.childCount == 0 && !after.inlineContent) || needsGap(after.type))
|
|
66247
|
-
return true;
|
|
66248
|
-
if (after.inlineContent)
|
|
66249
|
-
return false;
|
|
66250
|
-
}
|
|
66251
|
-
}
|
|
66252
|
-
return true;
|
|
66253
|
-
}
|
|
66875
|
+
* @see https://www.tiptap.dev/api/nodes/text
|
|
66876
|
+
*/
|
|
66877
|
+
const Text = Node$1.create({
|
|
66878
|
+
name: "text",
|
|
66879
|
+
group: "inline",
|
|
66880
|
+
parseMarkdown: (token) => {
|
|
66881
|
+
return {
|
|
66882
|
+
type: "text",
|
|
66883
|
+
text: token.text || ""
|
|
66884
|
+
};
|
|
66885
|
+
},
|
|
66886
|
+
renderMarkdown: (node) => node.text || ""
|
|
66887
|
+
});
|
|
66888
|
+
//#endregion
|
|
66889
|
+
//#region src/index.ts
|
|
66890
|
+
var src_default = Text;
|
|
66254
66891
|
|
|
66255
66892
|
/**
|
|
66256
|
-
Create a
|
|
66257
|
-
|
|
66258
|
-
|
|
66259
|
-
|
|
66260
|
-
`
|
|
66261
|
-
|
|
66262
|
-
|
|
66893
|
+
Create a plugin that, when added to a ProseMirror instance,
|
|
66894
|
+
causes a decoration to show up at the drop position when something
|
|
66895
|
+
is dragged over the editor.
|
|
66896
|
+
|
|
66897
|
+
Nodes may add a `disableDropCursor` property to their spec to
|
|
66898
|
+
control the showing of a drop cursor inside them. This may be a
|
|
66899
|
+
boolean or a function, which will be called with a view and a
|
|
66900
|
+
position, and should return a boolean.
|
|
66263
66901
|
*/
|
|
66264
|
-
function
|
|
66902
|
+
function dropCursor(options = {}) {
|
|
66265
66903
|
return new Plugin({
|
|
66266
|
-
|
|
66267
|
-
decorations: drawGapCursor,
|
|
66268
|
-
createSelectionBetween(_view, $anchor, $head) {
|
|
66269
|
-
return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
|
|
66270
|
-
},
|
|
66271
|
-
handleClick,
|
|
66272
|
-
handleKeyDown,
|
|
66273
|
-
handleDOMEvents: { beforeinput: beforeinput }
|
|
66274
|
-
}
|
|
66904
|
+
view(editorView) { return new DropCursorView(editorView, options); }
|
|
66275
66905
|
});
|
|
66276
66906
|
}
|
|
66277
|
-
|
|
66278
|
-
|
|
66279
|
-
|
|
66280
|
-
|
|
66281
|
-
|
|
66282
|
-
|
|
66283
|
-
|
|
66284
|
-
|
|
66285
|
-
|
|
66286
|
-
|
|
66287
|
-
|
|
66288
|
-
|
|
66289
|
-
|
|
66290
|
-
|
|
66291
|
-
|
|
66292
|
-
|
|
66293
|
-
}
|
|
66294
|
-
let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
|
|
66295
|
-
if (!$found)
|
|
66296
|
-
return false;
|
|
66297
|
-
if (dispatch)
|
|
66298
|
-
dispatch(state.tr.setSelection(new GapCursor($found)));
|
|
66299
|
-
return true;
|
|
66300
|
-
};
|
|
66301
|
-
}
|
|
66302
|
-
function handleClick(view, pos, event) {
|
|
66303
|
-
if (!view || !view.editable)
|
|
66304
|
-
return false;
|
|
66305
|
-
let $pos = view.state.doc.resolve(pos);
|
|
66306
|
-
if (!GapCursor.valid($pos))
|
|
66307
|
-
return false;
|
|
66308
|
-
let clickPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
66309
|
-
if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside)))
|
|
66310
|
-
return false;
|
|
66311
|
-
view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
|
|
66312
|
-
return true;
|
|
66313
|
-
}
|
|
66314
|
-
// This is a hack that, when a composition starts while a gap cursor
|
|
66315
|
-
// is active, quickly creates an inline context for the composition to
|
|
66316
|
-
// happen in, to avoid it being aborted by the DOM selection being
|
|
66317
|
-
// moved into a valid position.
|
|
66318
|
-
function beforeinput(view, event) {
|
|
66319
|
-
if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor))
|
|
66320
|
-
return false;
|
|
66321
|
-
let { $from } = view.state.selection;
|
|
66322
|
-
let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
|
|
66323
|
-
if (!insert)
|
|
66324
|
-
return false;
|
|
66325
|
-
let frag = Fragment.empty;
|
|
66326
|
-
for (let i = insert.length - 1; i >= 0; i--)
|
|
66327
|
-
frag = Fragment.from(insert[i].createAndFill(null, frag));
|
|
66328
|
-
let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
|
|
66329
|
-
tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
|
|
66330
|
-
view.dispatch(tr);
|
|
66331
|
-
return false;
|
|
66332
|
-
}
|
|
66333
|
-
function drawGapCursor(state) {
|
|
66334
|
-
if (!(state.selection instanceof GapCursor))
|
|
66335
|
-
return null;
|
|
66336
|
-
let node = document.createElement("div");
|
|
66337
|
-
node.className = "ProseMirror-gapcursor";
|
|
66338
|
-
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
|
|
66339
|
-
}
|
|
66340
|
-
|
|
66341
|
-
var GOOD_LEAF_SIZE = 200;
|
|
66342
|
-
|
|
66343
|
-
// :: class<T> A rope sequence is a persistent sequence data structure
|
|
66344
|
-
// that supports appending, prepending, and slicing without doing a
|
|
66345
|
-
// full copy. It is represented as a mostly-balanced tree.
|
|
66346
|
-
var RopeSequence = function RopeSequence () {};
|
|
66347
|
-
|
|
66348
|
-
RopeSequence.prototype.append = function append (other) {
|
|
66349
|
-
if (!other.length) { return this }
|
|
66350
|
-
other = RopeSequence.from(other);
|
|
66351
|
-
|
|
66352
|
-
return (!this.length && other) ||
|
|
66353
|
-
(other.length < GOOD_LEAF_SIZE && this.leafAppend(other)) ||
|
|
66354
|
-
(this.length < GOOD_LEAF_SIZE && other.leafPrepend(this)) ||
|
|
66355
|
-
this.appendInner(other)
|
|
66356
|
-
};
|
|
66357
|
-
|
|
66358
|
-
// :: (union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
66359
|
-
// Prepend an array or other rope to this one, returning a new rope.
|
|
66360
|
-
RopeSequence.prototype.prepend = function prepend (other) {
|
|
66361
|
-
if (!other.length) { return this }
|
|
66362
|
-
return RopeSequence.from(other).append(this)
|
|
66363
|
-
};
|
|
66364
|
-
|
|
66365
|
-
RopeSequence.prototype.appendInner = function appendInner (other) {
|
|
66366
|
-
return new Append(this, other)
|
|
66367
|
-
};
|
|
66368
|
-
|
|
66369
|
-
// :: (?number, ?number) → RopeSequence<T>
|
|
66370
|
-
// Create a rope repesenting a sub-sequence of this rope.
|
|
66371
|
-
RopeSequence.prototype.slice = function slice (from, to) {
|
|
66372
|
-
if ( from === void 0 ) from = 0;
|
|
66373
|
-
if ( to === void 0 ) to = this.length;
|
|
66374
|
-
|
|
66375
|
-
if (from >= to) { return RopeSequence.empty }
|
|
66376
|
-
return this.sliceInner(Math.max(0, from), Math.min(this.length, to))
|
|
66377
|
-
};
|
|
66378
|
-
|
|
66379
|
-
// :: (number) → T
|
|
66380
|
-
// Retrieve the element at the given position from this rope.
|
|
66381
|
-
RopeSequence.prototype.get = function get (i) {
|
|
66382
|
-
if (i < 0 || i >= this.length) { return undefined }
|
|
66383
|
-
return this.getInner(i)
|
|
66384
|
-
};
|
|
66385
|
-
|
|
66386
|
-
// :: ((element: T, index: number) → ?bool, ?number, ?number)
|
|
66387
|
-
// Call the given function for each element between the given
|
|
66388
|
-
// indices. This tends to be more efficient than looping over the
|
|
66389
|
-
// indices and calling `get`, because it doesn't have to descend the
|
|
66390
|
-
// tree for every element.
|
|
66391
|
-
RopeSequence.prototype.forEach = function forEach (f, from, to) {
|
|
66392
|
-
if ( from === void 0 ) from = 0;
|
|
66393
|
-
if ( to === void 0 ) to = this.length;
|
|
66394
|
-
|
|
66395
|
-
if (from <= to)
|
|
66396
|
-
{ this.forEachInner(f, from, to, 0); }
|
|
66397
|
-
else
|
|
66398
|
-
{ this.forEachInvertedInner(f, from, to, 0); }
|
|
66399
|
-
};
|
|
66400
|
-
|
|
66401
|
-
// :: ((element: T, index: number) → U, ?number, ?number) → [U]
|
|
66402
|
-
// Map the given functions over the elements of the rope, producing
|
|
66403
|
-
// a flat array.
|
|
66404
|
-
RopeSequence.prototype.map = function map (f, from, to) {
|
|
66405
|
-
if ( from === void 0 ) from = 0;
|
|
66406
|
-
if ( to === void 0 ) to = this.length;
|
|
66407
|
-
|
|
66408
|
-
var result = [];
|
|
66409
|
-
this.forEach(function (elt, i) { return result.push(f(elt, i)); }, from, to);
|
|
66410
|
-
return result
|
|
66411
|
-
};
|
|
66412
|
-
|
|
66413
|
-
// :: (?union<[T], RopeSequence<T>>) → RopeSequence<T>
|
|
66414
|
-
// Create a rope representing the given array, or return the rope
|
|
66415
|
-
// itself if a rope was given.
|
|
66416
|
-
RopeSequence.from = function from (values) {
|
|
66417
|
-
if (values instanceof RopeSequence) { return values }
|
|
66418
|
-
return values && values.length ? new Leaf(values) : RopeSequence.empty
|
|
66419
|
-
};
|
|
66420
|
-
|
|
66421
|
-
var Leaf = /*@__PURE__*/(function (RopeSequence) {
|
|
66422
|
-
function Leaf(values) {
|
|
66423
|
-
RopeSequence.call(this);
|
|
66424
|
-
this.values = values;
|
|
66425
|
-
}
|
|
66426
|
-
|
|
66427
|
-
if ( RopeSequence ) Leaf.__proto__ = RopeSequence;
|
|
66428
|
-
Leaf.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
66429
|
-
Leaf.prototype.constructor = Leaf;
|
|
66430
|
-
|
|
66431
|
-
var prototypeAccessors = { length: { configurable: true },depth: { configurable: true } };
|
|
66432
|
-
|
|
66433
|
-
Leaf.prototype.flatten = function flatten () {
|
|
66434
|
-
return this.values
|
|
66435
|
-
};
|
|
66436
|
-
|
|
66437
|
-
Leaf.prototype.sliceInner = function sliceInner (from, to) {
|
|
66438
|
-
if (from == 0 && to == this.length) { return this }
|
|
66439
|
-
return new Leaf(this.values.slice(from, to))
|
|
66440
|
-
};
|
|
66441
|
-
|
|
66442
|
-
Leaf.prototype.getInner = function getInner (i) {
|
|
66443
|
-
return this.values[i]
|
|
66444
|
-
};
|
|
66445
|
-
|
|
66446
|
-
Leaf.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
66447
|
-
for (var i = from; i < to; i++)
|
|
66448
|
-
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
66449
|
-
};
|
|
66450
|
-
|
|
66451
|
-
Leaf.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
66452
|
-
for (var i = from - 1; i >= to; i--)
|
|
66453
|
-
{ if (f(this.values[i], start + i) === false) { return false } }
|
|
66454
|
-
};
|
|
66455
|
-
|
|
66456
|
-
Leaf.prototype.leafAppend = function leafAppend (other) {
|
|
66457
|
-
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
66458
|
-
{ return new Leaf(this.values.concat(other.flatten())) }
|
|
66459
|
-
};
|
|
66460
|
-
|
|
66461
|
-
Leaf.prototype.leafPrepend = function leafPrepend (other) {
|
|
66462
|
-
if (this.length + other.length <= GOOD_LEAF_SIZE)
|
|
66463
|
-
{ return new Leaf(other.flatten().concat(this.values)) }
|
|
66464
|
-
};
|
|
66465
|
-
|
|
66466
|
-
prototypeAccessors.length.get = function () { return this.values.length };
|
|
66467
|
-
|
|
66468
|
-
prototypeAccessors.depth.get = function () { return 0 };
|
|
66469
|
-
|
|
66470
|
-
Object.defineProperties( Leaf.prototype, prototypeAccessors );
|
|
66471
|
-
|
|
66472
|
-
return Leaf;
|
|
66473
|
-
}(RopeSequence));
|
|
66474
|
-
|
|
66475
|
-
// :: RopeSequence
|
|
66476
|
-
// The empty rope sequence.
|
|
66477
|
-
RopeSequence.empty = new Leaf([]);
|
|
66478
|
-
|
|
66479
|
-
var Append = /*@__PURE__*/(function (RopeSequence) {
|
|
66480
|
-
function Append(left, right) {
|
|
66481
|
-
RopeSequence.call(this);
|
|
66482
|
-
this.left = left;
|
|
66483
|
-
this.right = right;
|
|
66484
|
-
this.length = left.length + right.length;
|
|
66485
|
-
this.depth = Math.max(left.depth, right.depth) + 1;
|
|
66486
|
-
}
|
|
66487
|
-
|
|
66488
|
-
if ( RopeSequence ) Append.__proto__ = RopeSequence;
|
|
66489
|
-
Append.prototype = Object.create( RopeSequence && RopeSequence.prototype );
|
|
66490
|
-
Append.prototype.constructor = Append;
|
|
66491
|
-
|
|
66492
|
-
Append.prototype.flatten = function flatten () {
|
|
66493
|
-
return this.left.flatten().concat(this.right.flatten())
|
|
66494
|
-
};
|
|
66495
|
-
|
|
66496
|
-
Append.prototype.getInner = function getInner (i) {
|
|
66497
|
-
return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length)
|
|
66498
|
-
};
|
|
66499
|
-
|
|
66500
|
-
Append.prototype.forEachInner = function forEachInner (f, from, to, start) {
|
|
66501
|
-
var leftLen = this.left.length;
|
|
66502
|
-
if (from < leftLen &&
|
|
66503
|
-
this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false)
|
|
66504
|
-
{ return false }
|
|
66505
|
-
if (to > leftLen &&
|
|
66506
|
-
this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false)
|
|
66507
|
-
{ return false }
|
|
66508
|
-
};
|
|
66509
|
-
|
|
66510
|
-
Append.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {
|
|
66511
|
-
var leftLen = this.left.length;
|
|
66512
|
-
if (from > leftLen &&
|
|
66513
|
-
this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false)
|
|
66514
|
-
{ return false }
|
|
66515
|
-
if (to < leftLen &&
|
|
66516
|
-
this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false)
|
|
66517
|
-
{ return false }
|
|
66518
|
-
};
|
|
66519
|
-
|
|
66520
|
-
Append.prototype.sliceInner = function sliceInner (from, to) {
|
|
66521
|
-
if (from == 0 && to == this.length) { return this }
|
|
66522
|
-
var leftLen = this.left.length;
|
|
66523
|
-
if (to <= leftLen) { return this.left.slice(from, to) }
|
|
66524
|
-
if (from >= leftLen) { return this.right.slice(from - leftLen, to - leftLen) }
|
|
66525
|
-
return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen))
|
|
66526
|
-
};
|
|
66527
|
-
|
|
66528
|
-
Append.prototype.leafAppend = function leafAppend (other) {
|
|
66529
|
-
var inner = this.right.leafAppend(other);
|
|
66530
|
-
if (inner) { return new Append(this.left, inner) }
|
|
66531
|
-
};
|
|
66532
|
-
|
|
66533
|
-
Append.prototype.leafPrepend = function leafPrepend (other) {
|
|
66534
|
-
var inner = this.left.leafPrepend(other);
|
|
66535
|
-
if (inner) { return new Append(inner, this.right) }
|
|
66536
|
-
};
|
|
66537
|
-
|
|
66538
|
-
Append.prototype.appendInner = function appendInner (other) {
|
|
66539
|
-
if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1)
|
|
66540
|
-
{ return new Append(this.left, new Append(this.right, other)) }
|
|
66541
|
-
return new Append(this, other)
|
|
66542
|
-
};
|
|
66543
|
-
|
|
66544
|
-
return Append;
|
|
66545
|
-
}(RopeSequence));
|
|
66546
|
-
|
|
66547
|
-
// ProseMirror's history isn't simply a way to roll back to a previous
|
|
66548
|
-
// state, because ProseMirror supports applying changes without adding
|
|
66549
|
-
// them to the history (for example during collaboration).
|
|
66550
|
-
//
|
|
66551
|
-
// To this end, each 'Branch' (one for the undo history and one for
|
|
66552
|
-
// the redo history) keeps an array of 'Items', which can optionally
|
|
66553
|
-
// hold a step (an actual undoable change), and always hold a position
|
|
66554
|
-
// map (which is needed to move changes below them to apply to the
|
|
66555
|
-
// current document).
|
|
66556
|
-
//
|
|
66557
|
-
// An item that has both a step and a selection bookmark is the start
|
|
66558
|
-
// of an 'event' — a group of changes that will be undone or redone at
|
|
66559
|
-
// once. (It stores only the bookmark, since that way we don't have to
|
|
66560
|
-
// provide a document until the selection is actually applied, which
|
|
66561
|
-
// is useful when compressing.)
|
|
66562
|
-
// Used to schedule history compression
|
|
66563
|
-
const max_empty_items = 500;
|
|
66564
|
-
class Branch {
|
|
66565
|
-
constructor(items, eventCount) {
|
|
66566
|
-
this.items = items;
|
|
66567
|
-
this.eventCount = eventCount;
|
|
66568
|
-
}
|
|
66569
|
-
// Pop the latest event off the branch's history and apply it
|
|
66570
|
-
// to a document transform.
|
|
66571
|
-
popEvent(state, preserveItems) {
|
|
66572
|
-
if (this.eventCount == 0)
|
|
66573
|
-
return null;
|
|
66574
|
-
let end = this.items.length;
|
|
66575
|
-
for (;; end--) {
|
|
66576
|
-
let next = this.items.get(end - 1);
|
|
66577
|
-
if (next.selection) {
|
|
66578
|
-
--end;
|
|
66579
|
-
break;
|
|
66580
|
-
}
|
|
66581
|
-
}
|
|
66582
|
-
let remap, mapFrom;
|
|
66583
|
-
if (preserveItems) {
|
|
66584
|
-
remap = this.remapping(end, this.items.length);
|
|
66585
|
-
mapFrom = remap.maps.length;
|
|
66586
|
-
}
|
|
66587
|
-
let transform = state.tr;
|
|
66588
|
-
let selection, remaining;
|
|
66589
|
-
let addAfter = [], addBefore = [];
|
|
66590
|
-
this.items.forEach((item, i) => {
|
|
66591
|
-
if (!item.step) {
|
|
66592
|
-
if (!remap) {
|
|
66593
|
-
remap = this.remapping(end, i + 1);
|
|
66594
|
-
mapFrom = remap.maps.length;
|
|
66595
|
-
}
|
|
66596
|
-
mapFrom--;
|
|
66597
|
-
addBefore.push(item);
|
|
66598
|
-
return;
|
|
66599
|
-
}
|
|
66600
|
-
if (remap) {
|
|
66601
|
-
addBefore.push(new Item(item.map));
|
|
66602
|
-
let step = item.step.map(remap.slice(mapFrom)), map;
|
|
66603
|
-
if (step && transform.maybeStep(step).doc) {
|
|
66604
|
-
map = transform.mapping.maps[transform.mapping.maps.length - 1];
|
|
66605
|
-
addAfter.push(new Item(map, undefined, undefined, addAfter.length + addBefore.length));
|
|
66606
|
-
}
|
|
66607
|
-
mapFrom--;
|
|
66608
|
-
if (map)
|
|
66609
|
-
remap.appendMap(map, mapFrom);
|
|
66610
|
-
}
|
|
66611
|
-
else {
|
|
66612
|
-
transform.maybeStep(item.step);
|
|
66613
|
-
}
|
|
66614
|
-
if (item.selection) {
|
|
66615
|
-
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
|
|
66616
|
-
remaining = new Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
|
|
66617
|
-
return false;
|
|
66618
|
-
}
|
|
66619
|
-
}, this.items.length, 0);
|
|
66620
|
-
return { remaining: remaining, transform, selection: selection };
|
|
66621
|
-
}
|
|
66622
|
-
// Create a new branch with the given transform added.
|
|
66623
|
-
addTransform(transform, selection, histOptions, preserveItems) {
|
|
66624
|
-
let newItems = [], eventCount = this.eventCount;
|
|
66625
|
-
let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
|
|
66626
|
-
for (let i = 0; i < transform.steps.length; i++) {
|
|
66627
|
-
let step = transform.steps[i].invert(transform.docs[i]);
|
|
66628
|
-
let item = new Item(transform.mapping.maps[i], step, selection), merged;
|
|
66629
|
-
if (merged = lastItem && lastItem.merge(item)) {
|
|
66630
|
-
item = merged;
|
|
66631
|
-
if (i)
|
|
66632
|
-
newItems.pop();
|
|
66633
|
-
else
|
|
66634
|
-
oldItems = oldItems.slice(0, oldItems.length - 1);
|
|
66635
|
-
}
|
|
66636
|
-
newItems.push(item);
|
|
66637
|
-
if (selection) {
|
|
66638
|
-
eventCount++;
|
|
66639
|
-
selection = undefined;
|
|
66640
|
-
}
|
|
66641
|
-
if (!preserveItems)
|
|
66642
|
-
lastItem = item;
|
|
66643
|
-
}
|
|
66644
|
-
let overflow = eventCount - histOptions.depth;
|
|
66645
|
-
if (overflow > DEPTH_OVERFLOW) {
|
|
66646
|
-
oldItems = cutOffEvents(oldItems, overflow);
|
|
66647
|
-
eventCount -= overflow;
|
|
66648
|
-
}
|
|
66649
|
-
return new Branch(oldItems.append(newItems), eventCount);
|
|
66650
|
-
}
|
|
66651
|
-
remapping(from, to) {
|
|
66652
|
-
let maps = new Mapping;
|
|
66653
|
-
this.items.forEach((item, i) => {
|
|
66654
|
-
let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from
|
|
66655
|
-
? maps.maps.length - item.mirrorOffset : undefined;
|
|
66656
|
-
maps.appendMap(item.map, mirrorPos);
|
|
66657
|
-
}, from, to);
|
|
66658
|
-
return maps;
|
|
66659
|
-
}
|
|
66660
|
-
addMaps(array) {
|
|
66661
|
-
if (this.eventCount == 0)
|
|
66662
|
-
return this;
|
|
66663
|
-
return new Branch(this.items.append(array.map(map => new Item(map))), this.eventCount);
|
|
66664
|
-
}
|
|
66665
|
-
// When the collab module receives remote changes, the history has
|
|
66666
|
-
// to know about those, so that it can adjust the steps that were
|
|
66667
|
-
// rebased on top of the remote changes, and include the position
|
|
66668
|
-
// maps for the remote changes in its array of items.
|
|
66669
|
-
rebased(rebasedTransform, rebasedCount) {
|
|
66670
|
-
if (!this.eventCount)
|
|
66671
|
-
return this;
|
|
66672
|
-
let rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount);
|
|
66673
|
-
let mapping = rebasedTransform.mapping;
|
|
66674
|
-
let newUntil = rebasedTransform.steps.length;
|
|
66675
|
-
let eventCount = this.eventCount;
|
|
66676
|
-
this.items.forEach(item => { if (item.selection)
|
|
66677
|
-
eventCount--; }, start);
|
|
66678
|
-
let iRebased = rebasedCount;
|
|
66679
|
-
this.items.forEach(item => {
|
|
66680
|
-
let pos = mapping.getMirror(--iRebased);
|
|
66681
|
-
if (pos == null)
|
|
66682
|
-
return;
|
|
66683
|
-
newUntil = Math.min(newUntil, pos);
|
|
66684
|
-
let map = mapping.maps[pos];
|
|
66685
|
-
if (item.step) {
|
|
66686
|
-
let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
|
|
66687
|
-
let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
|
|
66688
|
-
if (selection)
|
|
66689
|
-
eventCount++;
|
|
66690
|
-
rebasedItems.push(new Item(map, step, selection));
|
|
66691
|
-
}
|
|
66692
|
-
else {
|
|
66693
|
-
rebasedItems.push(new Item(map));
|
|
66694
|
-
}
|
|
66695
|
-
}, start);
|
|
66696
|
-
let newMaps = [];
|
|
66697
|
-
for (let i = rebasedCount; i < newUntil; i++)
|
|
66698
|
-
newMaps.push(new Item(mapping.maps[i]));
|
|
66699
|
-
let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
|
|
66700
|
-
let branch = new Branch(items, eventCount);
|
|
66701
|
-
if (branch.emptyItemCount() > max_empty_items)
|
|
66702
|
-
branch = branch.compress(this.items.length - rebasedItems.length);
|
|
66703
|
-
return branch;
|
|
66907
|
+
class DropCursorView {
|
|
66908
|
+
constructor(editorView, options) {
|
|
66909
|
+
var _a;
|
|
66910
|
+
this.editorView = editorView;
|
|
66911
|
+
this.cursorPos = null;
|
|
66912
|
+
this.element = null;
|
|
66913
|
+
this.timeout = -1;
|
|
66914
|
+
this.lastDragEvent = null;
|
|
66915
|
+
this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;
|
|
66916
|
+
this.color = options.color === false ? undefined : (options.color || "black");
|
|
66917
|
+
this.class = options.class;
|
|
66918
|
+
this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(name => {
|
|
66919
|
+
let handler = (e) => { this[name](e); };
|
|
66920
|
+
editorView.dom.addEventListener(name, handler);
|
|
66921
|
+
return { name, handler };
|
|
66922
|
+
});
|
|
66704
66923
|
}
|
|
66705
|
-
|
|
66706
|
-
|
|
66707
|
-
this.
|
|
66708
|
-
count++; });
|
|
66709
|
-
return count;
|
|
66924
|
+
destroy() {
|
|
66925
|
+
this.setCursor(null);
|
|
66926
|
+
this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
|
|
66710
66927
|
}
|
|
66711
|
-
|
|
66712
|
-
|
|
66713
|
-
|
|
66714
|
-
|
|
66715
|
-
|
|
66716
|
-
|
|
66717
|
-
|
|
66718
|
-
|
|
66719
|
-
|
|
66720
|
-
|
|
66721
|
-
if (i >= upto) {
|
|
66722
|
-
items.push(item);
|
|
66723
|
-
if (item.selection)
|
|
66724
|
-
events++;
|
|
66928
|
+
update(editorView, prevState) {
|
|
66929
|
+
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
|
|
66930
|
+
// if we currently have an on-going drag event
|
|
66931
|
+
// we need to update the cursor position again and update the overlay
|
|
66932
|
+
if (this.lastDragEvent) {
|
|
66933
|
+
let target = this.computeTarget(this.lastDragEvent);
|
|
66934
|
+
if (target == this.cursorPos)
|
|
66935
|
+
this.updateOverlay();
|
|
66936
|
+
else
|
|
66937
|
+
this.setCursor(target);
|
|
66725
66938
|
}
|
|
66726
|
-
else
|
|
66727
|
-
|
|
66728
|
-
|
|
66729
|
-
|
|
66730
|
-
|
|
66731
|
-
|
|
66732
|
-
|
|
66733
|
-
|
|
66734
|
-
|
|
66735
|
-
|
|
66736
|
-
|
|
66737
|
-
|
|
66738
|
-
|
|
66739
|
-
|
|
66939
|
+
else {
|
|
66940
|
+
this.updateOverlay();
|
|
66941
|
+
}
|
|
66942
|
+
}
|
|
66943
|
+
}
|
|
66944
|
+
setCursor(pos) {
|
|
66945
|
+
if (pos == this.cursorPos)
|
|
66946
|
+
return;
|
|
66947
|
+
this.cursorPos = pos;
|
|
66948
|
+
if (pos == null) {
|
|
66949
|
+
this.element.parentNode.removeChild(this.element);
|
|
66950
|
+
this.element = null;
|
|
66951
|
+
}
|
|
66952
|
+
else {
|
|
66953
|
+
this.updateOverlay();
|
|
66954
|
+
}
|
|
66955
|
+
}
|
|
66956
|
+
updateOverlay() {
|
|
66957
|
+
let $pos = this.editorView.state.doc.resolve(this.cursorPos);
|
|
66958
|
+
let isBlock = !$pos.parent.inlineContent, rect;
|
|
66959
|
+
let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
|
|
66960
|
+
let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
|
|
66961
|
+
if (isBlock) {
|
|
66962
|
+
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
66963
|
+
if (before || after) {
|
|
66964
|
+
let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
|
|
66965
|
+
if (node) {
|
|
66966
|
+
let nodeRect = node.getBoundingClientRect();
|
|
66967
|
+
let top = before ? nodeRect.bottom : nodeRect.top;
|
|
66968
|
+
if (before && after)
|
|
66969
|
+
top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
|
|
66970
|
+
let halfWidth = (this.width / 2) * scaleY;
|
|
66971
|
+
rect = { left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth };
|
|
66740
66972
|
}
|
|
66741
66973
|
}
|
|
66742
|
-
|
|
66743
|
-
|
|
66974
|
+
}
|
|
66975
|
+
if (!rect) {
|
|
66976
|
+
let coords = this.editorView.coordsAtPos(this.cursorPos);
|
|
66977
|
+
let halfWidth = (this.width / 2) * scaleX;
|
|
66978
|
+
rect = { left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom };
|
|
66979
|
+
}
|
|
66980
|
+
let parent = this.editorView.dom.offsetParent;
|
|
66981
|
+
if (!this.element) {
|
|
66982
|
+
this.element = parent.appendChild(document.createElement("div"));
|
|
66983
|
+
if (this.class)
|
|
66984
|
+
this.element.className = this.class;
|
|
66985
|
+
this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
|
|
66986
|
+
if (this.color) {
|
|
66987
|
+
this.element.style.backgroundColor = this.color;
|
|
66744
66988
|
}
|
|
66745
|
-
}
|
|
66746
|
-
|
|
66989
|
+
}
|
|
66990
|
+
this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
|
|
66991
|
+
this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
|
|
66992
|
+
let parentLeft, parentTop;
|
|
66993
|
+
if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
|
|
66994
|
+
parentLeft = -pageXOffset;
|
|
66995
|
+
parentTop = -pageYOffset;
|
|
66996
|
+
}
|
|
66997
|
+
else {
|
|
66998
|
+
let rect = parent.getBoundingClientRect();
|
|
66999
|
+
let parentScaleX = rect.width / parent.offsetWidth, parentScaleY = rect.height / parent.offsetHeight;
|
|
67000
|
+
parentLeft = rect.left - parent.scrollLeft * parentScaleX;
|
|
67001
|
+
parentTop = rect.top - parent.scrollTop * parentScaleY;
|
|
67002
|
+
}
|
|
67003
|
+
this.element.style.left = (rect.left - parentLeft) / scaleX + "px";
|
|
67004
|
+
this.element.style.top = (rect.top - parentTop) / scaleY + "px";
|
|
67005
|
+
this.element.style.width = (rect.right - rect.left) / scaleX + "px";
|
|
67006
|
+
this.element.style.height = (rect.bottom - rect.top) / scaleY + "px";
|
|
66747
67007
|
}
|
|
66748
|
-
|
|
66749
|
-
|
|
66750
|
-
|
|
66751
|
-
|
|
66752
|
-
|
|
66753
|
-
|
|
66754
|
-
|
|
66755
|
-
|
|
67008
|
+
scheduleRemoval(timeout) {
|
|
67009
|
+
clearTimeout(this.timeout);
|
|
67010
|
+
this.timeout = setTimeout(() => this.setCursor(null), timeout);
|
|
67011
|
+
}
|
|
67012
|
+
computeTarget(event) {
|
|
67013
|
+
let pos = this.editorView.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
67014
|
+
let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
|
|
67015
|
+
let disableDropCursor = node && node.type.spec.disableDropCursor;
|
|
67016
|
+
let disabled = typeof disableDropCursor == "function"
|
|
67017
|
+
? disableDropCursor(this.editorView, pos, event)
|
|
67018
|
+
: disableDropCursor;
|
|
67019
|
+
if (!pos || disabled)
|
|
67020
|
+
return null;
|
|
67021
|
+
let target = pos.pos;
|
|
67022
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
67023
|
+
let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
|
|
67024
|
+
if (point != null)
|
|
67025
|
+
target = point;
|
|
66756
67026
|
}
|
|
66757
|
-
|
|
66758
|
-
return items.slice(cutPoint);
|
|
66759
|
-
}
|
|
66760
|
-
class Item {
|
|
66761
|
-
constructor(
|
|
66762
|
-
// The (forward) step map for this item.
|
|
66763
|
-
map,
|
|
66764
|
-
// The inverted step
|
|
66765
|
-
step,
|
|
66766
|
-
// If this is non-null, this item is the start of a group, and
|
|
66767
|
-
// this selection is the starting selection for the group (the one
|
|
66768
|
-
// that was active before the first step was applied)
|
|
66769
|
-
selection,
|
|
66770
|
-
// If this item is the inverse of a previous mapping on the stack,
|
|
66771
|
-
// this points at the inverse's offset
|
|
66772
|
-
mirrorOffset) {
|
|
66773
|
-
this.map = map;
|
|
66774
|
-
this.step = step;
|
|
66775
|
-
this.selection = selection;
|
|
66776
|
-
this.mirrorOffset = mirrorOffset;
|
|
67027
|
+
return target;
|
|
66777
67028
|
}
|
|
66778
|
-
|
|
66779
|
-
if (this.
|
|
66780
|
-
|
|
66781
|
-
|
|
66782
|
-
|
|
67029
|
+
dragover(event) {
|
|
67030
|
+
if (!this.editorView.editable)
|
|
67031
|
+
return;
|
|
67032
|
+
this.lastDragEvent = event;
|
|
67033
|
+
let target = this.computeTarget(event);
|
|
67034
|
+
if (target != null) {
|
|
67035
|
+
this.setCursor(target);
|
|
67036
|
+
this.scheduleRemoval(5000);
|
|
66783
67037
|
}
|
|
66784
67038
|
}
|
|
66785
|
-
|
|
66786
|
-
|
|
66787
|
-
|
|
66788
|
-
|
|
66789
|
-
|
|
66790
|
-
|
|
66791
|
-
|
|
66792
|
-
this.
|
|
66793
|
-
|
|
66794
|
-
this.prevTime = prevTime;
|
|
66795
|
-
this.prevComposition = prevComposition;
|
|
67039
|
+
dragend() {
|
|
67040
|
+
this.scheduleRemoval(20);
|
|
67041
|
+
}
|
|
67042
|
+
drop() {
|
|
67043
|
+
this.scheduleRemoval(20);
|
|
67044
|
+
}
|
|
67045
|
+
dragleave(event) {
|
|
67046
|
+
if (!this.editorView.dom.contains(event.relatedTarget))
|
|
67047
|
+
this.setCursor(null);
|
|
66796
67048
|
}
|
|
66797
67049
|
}
|
|
66798
|
-
|
|
66799
|
-
|
|
66800
|
-
|
|
66801
|
-
|
|
66802
|
-
|
|
66803
|
-
|
|
66804
|
-
|
|
66805
|
-
|
|
66806
|
-
|
|
66807
|
-
|
|
66808
|
-
|
|
67050
|
+
|
|
67051
|
+
/**
|
|
67052
|
+
Gap cursor selections are represented using this class. Its
|
|
67053
|
+
`$anchor` and `$head` properties both point at the cursor position.
|
|
67054
|
+
*/
|
|
67055
|
+
class GapCursor extends Selection$2 {
|
|
67056
|
+
/**
|
|
67057
|
+
Create a gap cursor.
|
|
67058
|
+
*/
|
|
67059
|
+
constructor($pos) {
|
|
67060
|
+
super($pos, $pos);
|
|
66809
67061
|
}
|
|
66810
|
-
|
|
66811
|
-
|
|
66812
|
-
|
|
66813
|
-
else
|
|
66814
|
-
return new HistoryState(history.done, history.undone.addTransform(tr, undefined, options, mustPreserveItems(state)), null, history.prevTime, history.prevComposition);
|
|
67062
|
+
map(doc, mapping) {
|
|
67063
|
+
let $pos = doc.resolve(mapping.map(this.head));
|
|
67064
|
+
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
66815
67065
|
}
|
|
66816
|
-
|
|
66817
|
-
|
|
66818
|
-
|
|
66819
|
-
let newGroup = history.prevTime == 0 ||
|
|
66820
|
-
(!appended && history.prevComposition != composition &&
|
|
66821
|
-
(history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history.prevRanges)));
|
|
66822
|
-
let prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps);
|
|
66823
|
-
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);
|
|
67066
|
+
content() { return Slice.empty; }
|
|
67067
|
+
eq(other) {
|
|
67068
|
+
return other instanceof GapCursor && other.head == this.head;
|
|
66824
67069
|
}
|
|
66825
|
-
|
|
66826
|
-
|
|
66827
|
-
// content has been rebased.
|
|
66828
|
-
return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);
|
|
67070
|
+
toJSON() {
|
|
67071
|
+
return { type: "gapcursor", pos: this.head };
|
|
66829
67072
|
}
|
|
66830
|
-
|
|
66831
|
-
|
|
67073
|
+
/**
|
|
67074
|
+
@internal
|
|
67075
|
+
*/
|
|
67076
|
+
static fromJSON(doc, json) {
|
|
67077
|
+
if (typeof json.pos != "number")
|
|
67078
|
+
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
67079
|
+
return new GapCursor(doc.resolve(json.pos));
|
|
67080
|
+
}
|
|
67081
|
+
/**
|
|
67082
|
+
@internal
|
|
67083
|
+
*/
|
|
67084
|
+
getBookmark() { return new GapBookmark(this.anchor); }
|
|
67085
|
+
/**
|
|
67086
|
+
@internal
|
|
67087
|
+
*/
|
|
67088
|
+
static valid($pos) {
|
|
67089
|
+
let parent = $pos.parent;
|
|
67090
|
+
if (parent.inlineContent || !closedBefore($pos) || !closedAfter($pos))
|
|
67091
|
+
return false;
|
|
67092
|
+
let override = parent.type.spec.allowGapCursor;
|
|
67093
|
+
if (override != null)
|
|
67094
|
+
return override;
|
|
67095
|
+
let deflt = parent.contentMatchAt($pos.index()).defaultType;
|
|
67096
|
+
return deflt && deflt.isTextblock;
|
|
67097
|
+
}
|
|
67098
|
+
/**
|
|
67099
|
+
@internal
|
|
67100
|
+
*/
|
|
67101
|
+
static findGapCursorFrom($pos, dir, mustMove = false) {
|
|
67102
|
+
search: for (;;) {
|
|
67103
|
+
if (!mustMove && GapCursor.valid($pos))
|
|
67104
|
+
return $pos;
|
|
67105
|
+
let pos = $pos.pos, next = null;
|
|
67106
|
+
// Scan up from this position
|
|
67107
|
+
for (let d = $pos.depth;; d--) {
|
|
67108
|
+
let parent = $pos.node(d);
|
|
67109
|
+
if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
|
|
67110
|
+
next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
|
|
67111
|
+
break;
|
|
67112
|
+
}
|
|
67113
|
+
else if (d == 0) {
|
|
67114
|
+
return null;
|
|
67115
|
+
}
|
|
67116
|
+
pos += dir;
|
|
67117
|
+
let $cur = $pos.doc.resolve(pos);
|
|
67118
|
+
if (GapCursor.valid($cur))
|
|
67119
|
+
return $cur;
|
|
67120
|
+
}
|
|
67121
|
+
// And then down into the next node
|
|
67122
|
+
for (;;) {
|
|
67123
|
+
let inside = dir > 0 ? next.firstChild : next.lastChild;
|
|
67124
|
+
if (!inside) {
|
|
67125
|
+
if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
|
|
67126
|
+
$pos = $pos.doc.resolve(pos + next.nodeSize * dir);
|
|
67127
|
+
mustMove = false;
|
|
67128
|
+
continue search;
|
|
67129
|
+
}
|
|
67130
|
+
break;
|
|
67131
|
+
}
|
|
67132
|
+
next = inside;
|
|
67133
|
+
pos += dir;
|
|
67134
|
+
let $cur = $pos.doc.resolve(pos);
|
|
67135
|
+
if (GapCursor.valid($cur))
|
|
67136
|
+
return $cur;
|
|
67137
|
+
}
|
|
67138
|
+
return null;
|
|
67139
|
+
}
|
|
66832
67140
|
}
|
|
66833
67141
|
}
|
|
66834
|
-
|
|
66835
|
-
|
|
66836
|
-
|
|
66837
|
-
|
|
66838
|
-
|
|
66839
|
-
|
|
66840
|
-
|
|
66841
|
-
|
|
66842
|
-
|
|
66843
|
-
|
|
66844
|
-
|
|
66845
|
-
|
|
67142
|
+
GapCursor.prototype.visible = false;
|
|
67143
|
+
GapCursor.findFrom = GapCursor.findGapCursorFrom;
|
|
67144
|
+
Selection$2.jsonID("gapcursor", GapCursor);
|
|
67145
|
+
class GapBookmark {
|
|
67146
|
+
constructor(pos) {
|
|
67147
|
+
this.pos = pos;
|
|
67148
|
+
}
|
|
67149
|
+
map(mapping) {
|
|
67150
|
+
return new GapBookmark(mapping.map(this.pos));
|
|
67151
|
+
}
|
|
67152
|
+
resolve(doc) {
|
|
67153
|
+
let $pos = doc.resolve(this.pos);
|
|
67154
|
+
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection$2.near($pos);
|
|
67155
|
+
}
|
|
66846
67156
|
}
|
|
66847
|
-
function
|
|
66848
|
-
|
|
66849
|
-
for (let i = maps.length - 1; i >= 0 && result.length == 0; i--)
|
|
66850
|
-
maps[i].forEach((_from, _to, from, to) => result.push(from, to));
|
|
66851
|
-
return result;
|
|
67157
|
+
function needsGap(type) {
|
|
67158
|
+
return type.isAtom || type.spec.isolating || type.spec.createGapCursor;
|
|
66852
67159
|
}
|
|
66853
|
-
function
|
|
66854
|
-
|
|
66855
|
-
|
|
66856
|
-
|
|
66857
|
-
|
|
66858
|
-
|
|
66859
|
-
|
|
66860
|
-
|
|
67160
|
+
function closedBefore($pos) {
|
|
67161
|
+
for (let d = $pos.depth; d >= 0; d--) {
|
|
67162
|
+
let index = $pos.index(d), parent = $pos.node(d);
|
|
67163
|
+
// At the start of this parent, look at next one
|
|
67164
|
+
if (index == 0) {
|
|
67165
|
+
if (parent.type.spec.isolating)
|
|
67166
|
+
return true;
|
|
67167
|
+
continue;
|
|
67168
|
+
}
|
|
67169
|
+
// See if the node before (or its first ancestor) is closed
|
|
67170
|
+
for (let before = parent.child(index - 1);; before = before.lastChild) {
|
|
67171
|
+
if ((before.childCount == 0 && !before.inlineContent) || needsGap(before.type))
|
|
67172
|
+
return true;
|
|
67173
|
+
if (before.inlineContent)
|
|
67174
|
+
return false;
|
|
67175
|
+
}
|
|
66861
67176
|
}
|
|
66862
|
-
|
|
66863
|
-
|
|
66864
|
-
// Apply the latest event from one branch to the document and shift the event
|
|
66865
|
-
// onto the other branch.
|
|
66866
|
-
function histTransaction(history, state, redo) {
|
|
66867
|
-
let preserveItems = mustPreserveItems(state);
|
|
66868
|
-
let histOptions = historyKey.get(state).spec.config;
|
|
66869
|
-
let pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);
|
|
66870
|
-
if (!pop)
|
|
66871
|
-
return null;
|
|
66872
|
-
let selection = pop.selection.resolve(pop.transform.doc);
|
|
66873
|
-
let added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
|
|
66874
|
-
let newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0, -1);
|
|
66875
|
-
return pop.transform.setSelection(selection).setMeta(historyKey, { redo, historyState: newHist });
|
|
67177
|
+
// Hit start of document
|
|
67178
|
+
return true;
|
|
66876
67179
|
}
|
|
66877
|
-
|
|
66878
|
-
|
|
66879
|
-
|
|
66880
|
-
|
|
66881
|
-
|
|
66882
|
-
|
|
66883
|
-
|
|
66884
|
-
|
|
66885
|
-
|
|
66886
|
-
|
|
66887
|
-
|
|
66888
|
-
if (
|
|
66889
|
-
|
|
66890
|
-
|
|
66891
|
-
}
|
|
67180
|
+
function closedAfter($pos) {
|
|
67181
|
+
for (let d = $pos.depth; d >= 0; d--) {
|
|
67182
|
+
let index = $pos.indexAfter(d), parent = $pos.node(d);
|
|
67183
|
+
if (index == parent.childCount) {
|
|
67184
|
+
if (parent.type.spec.isolating)
|
|
67185
|
+
return true;
|
|
67186
|
+
continue;
|
|
67187
|
+
}
|
|
67188
|
+
for (let after = parent.child(index);; after = after.firstChild) {
|
|
67189
|
+
if ((after.childCount == 0 && !after.inlineContent) || needsGap(after.type))
|
|
67190
|
+
return true;
|
|
67191
|
+
if (after.inlineContent)
|
|
67192
|
+
return false;
|
|
67193
|
+
}
|
|
66892
67194
|
}
|
|
66893
|
-
return
|
|
67195
|
+
return true;
|
|
66894
67196
|
}
|
|
66895
|
-
const historyKey = new PluginKey("history");
|
|
66896
|
-
const closeHistoryKey = new PluginKey("closeHistory");
|
|
66897
|
-
/**
|
|
66898
|
-
Returns a plugin that enables the undo history for an editor. The
|
|
66899
|
-
plugin will track undo and redo stacks, which can be used with the
|
|
66900
|
-
[`undo`](https://prosemirror.net/docs/ref/#history.undo) and [`redo`](https://prosemirror.net/docs/ref/#history.redo) commands.
|
|
66901
67197
|
|
|
66902
|
-
|
|
66903
|
-
|
|
66904
|
-
|
|
67198
|
+
/**
|
|
67199
|
+
Create a gap cursor plugin. When enabled, this will capture clicks
|
|
67200
|
+
near and arrow-key-motion past places that don't have a normally
|
|
67201
|
+
selectable position nearby, and create a gap cursor selection for
|
|
67202
|
+
them. The cursor is drawn as an element with class
|
|
67203
|
+
`ProseMirror-gapcursor`. You can either include
|
|
67204
|
+
`style/gapcursor.css` from the package's directory or add your own
|
|
67205
|
+
styles to make it visible.
|
|
66905
67206
|
*/
|
|
66906
|
-
function
|
|
66907
|
-
config = { depth: config.depth || 100,
|
|
66908
|
-
newGroupDelay: config.newGroupDelay || 500 };
|
|
67207
|
+
function gapCursor() {
|
|
66909
67208
|
return new Plugin({
|
|
66910
|
-
key: historyKey,
|
|
66911
|
-
state: {
|
|
66912
|
-
init() {
|
|
66913
|
-
return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
|
|
66914
|
-
},
|
|
66915
|
-
apply(tr, hist, state) {
|
|
66916
|
-
return applyTransaction(hist, state, tr, config);
|
|
66917
|
-
}
|
|
66918
|
-
},
|
|
66919
|
-
config,
|
|
66920
67209
|
props: {
|
|
66921
|
-
|
|
66922
|
-
|
|
66923
|
-
|
|
66924
|
-
|
|
66925
|
-
|
|
66926
|
-
|
|
66927
|
-
|
|
66928
|
-
return command(view.state, view.dispatch);
|
|
66929
|
-
}
|
|
66930
|
-
}
|
|
67210
|
+
decorations: drawGapCursor,
|
|
67211
|
+
createSelectionBetween(_view, $anchor, $head) {
|
|
67212
|
+
return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
|
|
67213
|
+
},
|
|
67214
|
+
handleClick,
|
|
67215
|
+
handleKeyDown,
|
|
67216
|
+
handleDOMEvents: { beforeinput: beforeinput }
|
|
66931
67217
|
}
|
|
66932
67218
|
});
|
|
66933
67219
|
}
|
|
66934
|
-
|
|
66935
|
-
|
|
66936
|
-
|
|
66937
|
-
|
|
66938
|
-
|
|
66939
|
-
|
|
66940
|
-
|
|
66941
|
-
|
|
66942
|
-
|
|
67220
|
+
const handleKeyDown = keydownHandler({
|
|
67221
|
+
"ArrowLeft": arrow("horiz", -1),
|
|
67222
|
+
"ArrowRight": arrow("horiz", 1),
|
|
67223
|
+
"ArrowUp": arrow("vert", -1),
|
|
67224
|
+
"ArrowDown": arrow("vert", 1)
|
|
67225
|
+
});
|
|
67226
|
+
function arrow(axis, dir) {
|
|
67227
|
+
const dirStr = axis == "vert" ? (dir > 0 ? "down" : "up") : (dir > 0 ? "right" : "left");
|
|
67228
|
+
return function (state, dispatch, view) {
|
|
67229
|
+
let sel = state.selection;
|
|
67230
|
+
let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
|
|
67231
|
+
if (sel instanceof TextSelection) {
|
|
67232
|
+
if (!view.endOfTextblock(dirStr) || $start.depth == 0)
|
|
67233
|
+
return false;
|
|
67234
|
+
mustMove = false;
|
|
67235
|
+
$start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
|
|
66943
67236
|
}
|
|
67237
|
+
let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
|
|
67238
|
+
if (!$found)
|
|
67239
|
+
return false;
|
|
67240
|
+
if (dispatch)
|
|
67241
|
+
dispatch(state.tr.setSelection(new GapCursor($found)));
|
|
66944
67242
|
return true;
|
|
66945
67243
|
};
|
|
66946
67244
|
}
|
|
66947
|
-
|
|
66948
|
-
|
|
66949
|
-
|
|
66950
|
-
|
|
66951
|
-
|
|
66952
|
-
|
|
66953
|
-
|
|
66954
|
-
|
|
67245
|
+
function handleClick(view, pos, event) {
|
|
67246
|
+
if (!view || !view.editable)
|
|
67247
|
+
return false;
|
|
67248
|
+
let $pos = view.state.doc.resolve(pos);
|
|
67249
|
+
if (!GapCursor.valid($pos))
|
|
67250
|
+
return false;
|
|
67251
|
+
let clickPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
67252
|
+
if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside)))
|
|
67253
|
+
return false;
|
|
67254
|
+
view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
|
|
67255
|
+
return true;
|
|
67256
|
+
}
|
|
67257
|
+
// This is a hack that, when a composition starts while a gap cursor
|
|
67258
|
+
// is active, quickly creates an inline context for the composition to
|
|
67259
|
+
// happen in, to avoid it being aborted by the DOM selection being
|
|
67260
|
+
// moved into a valid position.
|
|
67261
|
+
function beforeinput(view, event) {
|
|
67262
|
+
if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor))
|
|
67263
|
+
return false;
|
|
67264
|
+
let { $from } = view.state.selection;
|
|
67265
|
+
let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
|
|
67266
|
+
if (!insert)
|
|
67267
|
+
return false;
|
|
67268
|
+
let frag = Fragment.empty;
|
|
67269
|
+
for (let i = insert.length - 1; i >= 0; i--)
|
|
67270
|
+
frag = Fragment.from(insert[i].createAndFill(null, frag));
|
|
67271
|
+
let tr = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
|
|
67272
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve($from.pos + 1)));
|
|
67273
|
+
view.dispatch(tr);
|
|
67274
|
+
return false;
|
|
67275
|
+
}
|
|
67276
|
+
function drawGapCursor(state) {
|
|
67277
|
+
if (!(state.selection instanceof GapCursor))
|
|
67278
|
+
return null;
|
|
67279
|
+
let node = document.createElement("div");
|
|
67280
|
+
node.className = "ProseMirror-gapcursor";
|
|
67281
|
+
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
|
|
67282
|
+
}
|
|
66955
67283
|
|
|
66956
67284
|
//#region src/character-count/character-count.ts
|
|
66957
67285
|
/**
|
|
@@ -97546,12 +97874,12 @@ focus outline in that case.
|
|
|
97546
97874
|
toDOMStream(options) {
|
|
97547
97875
|
return streamAdapters.toDOMStream((this._closedPromiseResolve || this._error)
|
|
97548
97876
|
? this
|
|
97549
|
-
: this._values
|
|
97877
|
+
: this._values);
|
|
97550
97878
|
}
|
|
97551
97879
|
toNodeStream(options) {
|
|
97552
97880
|
return streamAdapters.toNodeStream((this._closedPromiseResolve || this._error)
|
|
97553
97881
|
? this
|
|
97554
|
-
: this._values
|
|
97882
|
+
: this._values);
|
|
97555
97883
|
}
|
|
97556
97884
|
throw(_) {
|
|
97557
97885
|
return __awaiter(this, void 0, void 0, function* () { yield this.abort(_); return ITERATOR_DONE; });
|
|
@@ -99942,7 +100270,7 @@ focus outline in that case.
|
|
|
99942
100270
|
toNodeStream() {
|
|
99943
100271
|
return streamAdapters.toNodeStream((this.isSync()
|
|
99944
100272
|
? { [Symbol.iterator]: () => this }
|
|
99945
|
-
: { [Symbol.asyncIterator]: () => this })
|
|
100273
|
+
: { [Symbol.asyncIterator]: () => this }));
|
|
99946
100274
|
}
|
|
99947
100275
|
/** @nocollapse */
|
|
99948
100276
|
// @ts-ignore
|