@krainovsd/markdown-editor 0.4.0 → 0.4.2
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/lib/cjs/{index-Dj0jRUGF.js → index-Df0WnJ4c.js} +49 -47
- package/lib/cjs/index-Df0WnJ4c.js.map +1 -0
- package/lib/cjs/{index-CXENq_0E.js → index-Ne5xJkxS.js} +2 -2
- package/lib/cjs/{index-CXENq_0E.js.map → index-Ne5xJkxS.js.map} +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/esm/extensions/auto-completes/custom/tag-auto-complete.js.map +1 -1
- package/lib/esm/extensions/init-extensions.js +2 -2
- package/lib/esm/extensions/init-extensions.js.map +1 -1
- package/lib/esm/extensions/keymaps/init-key-map.js +3 -9
- package/lib/esm/extensions/keymaps/init-key-map.js.map +1 -1
- package/lib/esm/extensions/listeners/get-change-event.js +3 -3
- package/lib/esm/extensions/listeners/get-change-event.js.map +1 -1
- package/lib/esm/extensions/listeners/get-focus-event.js +3 -3
- package/lib/esm/extensions/listeners/get-focus-event.js.map +1 -1
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js +1 -1
- package/lib/esm/extensions/markdown/blockquote/blockquote-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/bold/bold-decoration.js +1 -1
- package/lib/esm/extensions/markdown/code/code-decoration.js +3 -3
- package/lib/esm/extensions/markdown/code/code-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/header/header-decoration.js +1 -1
- package/lib/esm/extensions/markdown/image/image-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/image/image-widget.js +2 -1
- package/lib/esm/extensions/markdown/image/image-widget.js.map +1 -1
- package/lib/esm/extensions/markdown/italic/italic-decoration.js +2 -2
- package/lib/esm/extensions/markdown/italic/italic-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/link-decoration.js +1 -1
- package/lib/esm/extensions/markdown/link/link-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/link/link-widget.js +5 -2
- package/lib/esm/extensions/markdown/link/link-widget.js.map +1 -1
- package/lib/esm/extensions/markdown/list/list-decoration.js +1 -1
- package/lib/esm/extensions/markdown/list/list-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/markdown-decoration.js +2 -2
- package/lib/esm/extensions/markdown/markdown-decoration.js.map +1 -1
- package/lib/esm/extensions/markdown/mention/mention-decoration.js +1 -1
- package/lib/esm/extensions/markdown/mention/mention-parser.js.map +1 -1
- package/lib/esm/extensions/markdown/strike-through/strike-through-decoration.js +1 -1
- package/lib/esm/extensions/markdown/styles.module.scss.js +2 -2
- package/lib/esm/extensions/markdown/todo/todo-decoration.js +1 -1
- package/lib/esm/extensions/markdown/todo/todo-decoration.js.map +1 -1
- package/lib/esm/extensions/settings/init-settings.js +2 -2
- package/lib/esm/extensions/settings/init-settings.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-dark-theme.js +3 -2
- package/lib/esm/extensions/theme/themes/get-dark-theme.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-highlight-template.js +4 -1
- package/lib/esm/extensions/theme/themes/get-highlight-template.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-light-theme.js +3 -2
- package/lib/esm/extensions/theme/themes/get-light-theme.js.map +1 -1
- package/lib/esm/extensions/theme/themes/get-theme-template.js +1 -0
- package/lib/esm/extensions/theme/themes/get-theme-template.js.map +1 -1
- package/lib/esm/lib/utils/overlap-mark.js +5 -2
- package/lib/esm/lib/utils/overlap-mark.js.map +1 -1
- package/lib/esm/module/Editor/Editor.js +2 -6
- package/lib/esm/module/Editor/Editor.js.map +1 -1
- package/lib/esm/module/Editor/lib/init-editor-provider.js +2 -3
- package/lib/esm/module/Editor/lib/init-editor-provider.js.map +1 -1
- package/lib/esm/module/Editor/lib/init-editor.js +1 -1
- package/lib/esm/module/Editor/lib/init-editor.js.map +1 -1
- package/lib/esm/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/package.json +18 -29
- package/lib/cjs/index-Dj0jRUGF.js.map +0 -1
|
@@ -174,6 +174,7 @@ function overlapMark({ marks, shift, state, requireMatched }) {
|
|
|
174
174
|
originalText: text.substring(shiftBeforeOuter, text.length - shiftAfterOuter),
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
+
// eslint-disable-next-line max-params
|
|
177
178
|
function findMarkIndex(text, marks, requireMatched, direction = "right") {
|
|
178
179
|
if (text.length === 0)
|
|
179
180
|
return -1;
|
|
@@ -201,8 +202,10 @@ function findMarkIndex(text, marks, requireMatched, direction = "right") {
|
|
|
201
202
|
const posMin = pos - minRequired;
|
|
202
203
|
const posMax = pos - matched;
|
|
203
204
|
// console.log({ posMin, posMax, pos, minRequired, maxRequired, direction, matched });
|
|
205
|
+
// eslint-disable-next-line max-depth
|
|
204
206
|
if (direction === "right" && posMin > start)
|
|
205
207
|
start = posMin;
|
|
208
|
+
// eslint-disable-next-line max-depth
|
|
206
209
|
if (direction === "left" && (posMax < start || start === -1))
|
|
207
210
|
start = posMax;
|
|
208
211
|
}
|
|
@@ -262,7 +265,7 @@ function processShiftContent(state, shift, marks) {
|
|
|
262
265
|
if (initialText.length > 1)
|
|
263
266
|
while (pos < initialText.length) {
|
|
264
267
|
// eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations
|
|
265
|
-
if (marks.some((
|
|
268
|
+
if (marks.some((mark) => mark === initialText.codePointAt(pos)))
|
|
266
269
|
shiftBeforeInner++;
|
|
267
270
|
else
|
|
268
271
|
break;
|
|
@@ -274,7 +277,7 @@ function processShiftContent(state, shift, marks) {
|
|
|
274
277
|
if (initialText.length > 1 || shiftBeforeInner > 0)
|
|
275
278
|
while (pos > -1) {
|
|
276
279
|
// eslint-disable-next-line no-loop-func -- https://eslint.org/docs/latest/rules/no-loop-func#known-limitations
|
|
277
|
-
if (marks.some((
|
|
280
|
+
if (marks.some((mark) => mark === initialTextWithoutBeforeShift.codePointAt(pos)))
|
|
278
281
|
shiftAfterInner++;
|
|
279
282
|
else
|
|
280
283
|
break;
|
|
@@ -306,7 +309,10 @@ function getHighlightTemplate(config) {
|
|
|
306
309
|
color: config.string,
|
|
307
310
|
},
|
|
308
311
|
{ tag: [highlight.tags.function(highlight.tags.variableName), highlight.tags.labelName], color: config.function },
|
|
309
|
-
{
|
|
312
|
+
{
|
|
313
|
+
tag: [highlight.tags.color, highlight.tags.constant(highlight.tags.name), highlight.tags.standard(highlight.tags.name)],
|
|
314
|
+
color: config.constant,
|
|
315
|
+
},
|
|
310
316
|
{ tag: [highlight.tags.definition(highlight.tags.name), highlight.tags.separator], color: config.variable },
|
|
311
317
|
{ tag: [highlight.tags.className], color: config.class },
|
|
312
318
|
{
|
|
@@ -365,6 +371,7 @@ function getThemeTemplate(dark, config) {
|
|
|
365
371
|
[`.${CLASSES.code}`]: {
|
|
366
372
|
background: config.codeBackground,
|
|
367
373
|
color: config.codeColor,
|
|
374
|
+
fontFamily: `${config.codeFontFamily} !important`,
|
|
368
375
|
},
|
|
369
376
|
[`.${CLASSES.horizontal}`]: {
|
|
370
377
|
borderBottomColor: config.horizontalColor,
|
|
@@ -432,6 +439,7 @@ const THEME_CONFIG$1 = {
|
|
|
432
439
|
codeColor: "#DDDDDD",
|
|
433
440
|
color: "#DDDDDD",
|
|
434
441
|
fontFamily: "Montserrat",
|
|
442
|
+
codeFontFamily: "Consolas",
|
|
435
443
|
horizontalColor: "#DDDDDD",
|
|
436
444
|
linkColor: "#8A5CF5",
|
|
437
445
|
mentionColor: "#8A5CF5",
|
|
@@ -441,8 +449,8 @@ const THEME_CONFIG$1 = {
|
|
|
441
449
|
codeBlockBackground: "#24292e",
|
|
442
450
|
};
|
|
443
451
|
function getDarkTheme({ dark }) {
|
|
444
|
-
const highlightConfig = { ...HIGHLIGHT_CONFIG$1, ...(dark?.highlightConfig
|
|
445
|
-
const themeConfig = { ...THEME_CONFIG$1, ...(dark?.themeConfig
|
|
452
|
+
const highlightConfig = { ...HIGHLIGHT_CONFIG$1, ...(dark?.highlightConfig ?? {}) };
|
|
453
|
+
const themeConfig = { ...THEME_CONFIG$1, ...(dark?.themeConfig ?? {}) };
|
|
446
454
|
return [getThemeTemplate(true, themeConfig), getHighlightTemplate(highlightConfig)];
|
|
447
455
|
}
|
|
448
456
|
|
|
@@ -469,6 +477,7 @@ const THEME_CONFIG = {
|
|
|
469
477
|
codeColor: "#000000",
|
|
470
478
|
color: "#000000",
|
|
471
479
|
fontFamily: "Montserrat",
|
|
480
|
+
codeFontFamily: "Consolas",
|
|
472
481
|
horizontalColor: "#000000",
|
|
473
482
|
linkColor: "#8A5CF5",
|
|
474
483
|
mentionColor: "#8A5CF5",
|
|
@@ -478,8 +487,8 @@ const THEME_CONFIG = {
|
|
|
478
487
|
codeBlockBorderColor: "##CCCCCDFF",
|
|
479
488
|
};
|
|
480
489
|
function getLightTheme({ light }) {
|
|
481
|
-
const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig
|
|
482
|
-
const themeConfig = { ...THEME_CONFIG, ...(light?.themeConfig
|
|
490
|
+
const highlightConfig = { ...HIGHLIGHT_CONFIG, ...(light?.highlightConfig ?? {}) };
|
|
491
|
+
const themeConfig = { ...THEME_CONFIG, ...(light?.themeConfig ?? {}) };
|
|
483
492
|
return [getThemeTemplate(false, themeConfig), getHighlightTemplate(highlightConfig)];
|
|
484
493
|
}
|
|
485
494
|
|
|
@@ -662,15 +671,9 @@ const initKeyMaps = async ({ onEnter, onEscape, multiCursorMode, keyMaps, defaul
|
|
|
662
671
|
view.dispatch({
|
|
663
672
|
effects: ThemeCompartment.reconfigure(theme === "dark"
|
|
664
673
|
? getDarkTheme({
|
|
665
|
-
dark
|
|
666
|
-
light,
|
|
667
|
-
theme,
|
|
668
|
-
})
|
|
674
|
+
dark})
|
|
669
675
|
: getLightTheme({
|
|
670
|
-
|
|
671
|
-
light,
|
|
672
|
-
theme,
|
|
673
|
-
})),
|
|
676
|
+
light})),
|
|
674
677
|
});
|
|
675
678
|
});
|
|
676
679
|
return true;
|
|
@@ -702,9 +705,9 @@ const initKeyMaps = async ({ onEnter, onEscape, multiCursorMode, keyMaps, defaul
|
|
|
702
705
|
|
|
703
706
|
function getChangeEvent({ onChange }) {
|
|
704
707
|
return onChange
|
|
705
|
-
? view.EditorView.updateListener.of((
|
|
706
|
-
if (
|
|
707
|
-
onChange(
|
|
708
|
+
? view.EditorView.updateListener.of((event) => {
|
|
709
|
+
if (event.docChanged) {
|
|
710
|
+
onChange(event);
|
|
708
711
|
}
|
|
709
712
|
})
|
|
710
713
|
: [];
|
|
@@ -712,11 +715,11 @@ function getChangeEvent({ onChange }) {
|
|
|
712
715
|
|
|
713
716
|
function getFocusEvent({ onBlur, onFocus }) {
|
|
714
717
|
return onFocus || onBlur
|
|
715
|
-
? view.EditorView.focusChangeEffect.of((
|
|
718
|
+
? view.EditorView.focusChangeEffect.of((event, focus) => {
|
|
716
719
|
if (focus && onFocus)
|
|
717
|
-
onFocus(
|
|
720
|
+
onFocus(event);
|
|
718
721
|
else if (!focus && onBlur)
|
|
719
|
-
onBlur(
|
|
722
|
+
onBlur(event);
|
|
720
723
|
return null;
|
|
721
724
|
})
|
|
722
725
|
: [];
|
|
@@ -753,8 +756,8 @@ function styleInject(css, ref) {
|
|
|
753
756
|
}
|
|
754
757
|
}
|
|
755
758
|
|
|
756
|
-
var css_248z = "._header_XFwV5{font-weight:700}._header_XFwV5._level_1_-KPph{font-size:2em}._header_XFwV5._level_2_ecHlB{font-size:1.8em}._header_XFwV5._level_3_SYcVr{font-size:1.6em}._header_XFwV5._level_4_V3o5m{font-size:1.4em}._header_XFwV5._level_5_I7eVk{font-size:1.3em}._header_XFwV5._level_6_A3lbK{font-size:1.2em}._bold_I8DT-{font-weight:700}._italic_72qBe{font-style:italic}._blockquote_Xq6O4{border-left:3px solid;margin-left:5px}._blockquote__inner_mjT0h{margin-left:1px;padding-left:5px;position:relative}._blockquote__inner_mjT0h:before{border-left:3px solid;content:\"\";height:140%;left:0;position:absolute;top:-3px}._blockquote__inner-deep_s6tNj{margin-left:5px}._strike-through_U64jP{text-decoration:line-through}._list_MHIjT._common_0GdDi{position:relative;visibility:hidden}._list_MHIjT._common_0GdDi:after{border-radius:100%;content:\"\";height:5px;left:0;position:absolute;top:50%;transform:translateY(-50%);visibility:visible;width:5px}._link_7U9wl{text-decoration:none;text-decoration:underline}._link__label_dHGGf{font-size:12px;position:relative;top:-4px}._image_KmBM8{display:inline-flex}._code__line_m3IiO{padding:5px;position:relative}.
|
|
757
|
-
const styles = {"header":"_header_XFwV5","level_1":"_level_1_-KPph","level_2":"_level_2_ecHlB","level_3":"_level_3_SYcVr","level_4":"_level_4_V3o5m","level_5":"_level_5_I7eVk","level_6":"_level_6_A3lbK","bold":"_bold_I8DT-","italic":"_italic_72qBe","blockquote":"_blockquote_Xq6O4","blockquote__inner":"_blockquote__inner_mjT0h","blockquote__inner-deep":"_blockquote__inner-deep_s6tNj","strike-through":"_strike-through_U64jP","list":"_list_MHIjT","common":"_common_0GdDi","link":"_link_7U9wl","link__label":"_link__label_dHGGf","image":"_image_KmBM8","code__line":"_code__line_m3IiO","
|
|
759
|
+
var css_248z = "._header_XFwV5{font-weight:700}._header_XFwV5._level_1_-KPph{font-size:2em}._header_XFwV5._level_2_ecHlB{font-size:1.8em}._header_XFwV5._level_3_SYcVr{font-size:1.6em}._header_XFwV5._level_4_V3o5m{font-size:1.4em}._header_XFwV5._level_5_I7eVk{font-size:1.3em}._header_XFwV5._level_6_A3lbK{font-size:1.2em}._bold_I8DT-{font-weight:700}._italic_72qBe{font-style:italic}._blockquote_Xq6O4{border-left:3px solid;margin-left:5px}._blockquote__inner_mjT0h{margin-left:1px;padding-left:5px;position:relative}._blockquote__inner_mjT0h:before{border-left:3px solid;content:\"\";height:140%;left:0;position:absolute;top:-3px}._blockquote__inner-deep_s6tNj{margin-left:5px}._strike-through_U64jP{text-decoration:line-through}._list_MHIjT._common_0GdDi{position:relative;visibility:hidden}._list_MHIjT._common_0GdDi:after{border-radius:100%;content:\"\";height:5px;left:0;position:absolute;top:50%;transform:translateY(-50%);visibility:visible;width:5px}._link_7U9wl{text-decoration:none;text-decoration:underline}._link__label_dHGGf{font-size:12px;position:relative;top:-4px}._image_KmBM8{display:inline-flex}._code__line_m3IiO{padding:5px;position:relative}._code__button_WwYE-{background-color:transparent;border:none;border-radius:4px;box-shadow:none;cursor:pointer;min-width:30px;outline:none;padding:4px 10px;position:absolute;right:5px;top:5px;transition:all .3s ease;z-index:1}._code__button_WwYE-._pending_fgHgD:before{animation:_loading-btn--fade-in_8z5an .33s ease,_loading-btn--rotation_QaopN .66s linear 0s infinite;border:2px solid hsla(0,0%,100%,.33);border-radius:50%;border-top-color:#000;content:\"\";display:inline-block;height:10.5px;left:50%;position:absolute;top:50%;width:10.5px}._code__button_WwYE-._success_kUPnO:after{animation:_loading-btn--fade-in_8z5an .6s ease;border-color:currentcolor;border-style:solid;border-width:0 0 1px 1px;content:\"\";display:inline-block;height:7px;left:50%;position:absolute;top:50%;transform:translate(-50%,-75%) rotate(-45deg);width:11px}._code__button_WwYE-._fail_cOpap:after,._code__button_WwYE-._fail_cOpap:before{content:\" \";height:13px;left:50%;position:absolute;top:50%;width:1px}._code__button_WwYE-._fail_cOpap:before{transform:translate(-50%,-50%) rotate(45deg)}._code__button_WwYE-._fail_cOpap:after{transform:translate(-50%,-50%) rotate(-45deg)}@keyframes _loading-btn--fade-in_8z5an{0%{opacity:0}to{opacity:1}}@keyframes _loading-btn--rotation_QaopN{0%{transform:translate(-50%,-50%) rotate(0deg)}to{transform:translate(-50%,-50%) rotate(1turn)}}._code__span_iSCmj{opacity:1;transition:opacity .3s ease}._code__span_iSCmj._hide_uqpax{opacity:0}._code__block_JehA4{padding:1px 5px}._code__block_line_U7lcQ{border-left:1px solid;margin-left:5px}._horizontal_J1jU-{border-bottom:1px solid;margin:0 5px;position:relative;width:calc(100% - 10px)}._todo_m6MIP{align-items:flex-end;display:inline-flex;height:100%;padding-left:3px;padding-right:3px}._todo_m6MIP>input{margin:0}._todo__checked_kemjy{text-decoration:line-through}._mention_cpzik{font-weight:700}";
|
|
760
|
+
const styles = {"header":"_header_XFwV5","level_1":"_level_1_-KPph","level_2":"_level_2_ecHlB","level_3":"_level_3_SYcVr","level_4":"_level_4_V3o5m","level_5":"_level_5_I7eVk","level_6":"_level_6_A3lbK","bold":"_bold_I8DT-","italic":"_italic_72qBe","blockquote":"_blockquote_Xq6O4","blockquote__inner":"_blockquote__inner_mjT0h","blockquote__inner-deep":"_blockquote__inner-deep_s6tNj","strike-through":"_strike-through_U64jP","list":"_list_MHIjT","common":"_common_0GdDi","link":"_link_7U9wl","link__label":"_link__label_dHGGf","image":"_image_KmBM8","code__line":"_code__line_m3IiO","code__button":"_code__button_WwYE-","pending":"_pending_fgHgD","loading-btn--fade-in":"_loading-btn--fade-in_8z5an","loading-btn--rotation":"_loading-btn--rotation_QaopN","success":"_success_kUPnO","fail":"_fail_cOpap","code__span":"_code__span_iSCmj","hide":"_hide_uqpax","code__block":"_code__block_JehA4","code__block_line":"_code__block_line_U7lcQ","horizontal":"_horizontal_J1jU-","todo":"_todo_m6MIP","todo__checked":"_todo__checked_kemjy","mention":"_mention_cpzik"};
|
|
758
761
|
styleInject(css_248z);
|
|
759
762
|
|
|
760
763
|
const NAME_OF_BLOCKQUOTE_MARK = "QuoteMark";
|
|
@@ -1047,7 +1050,7 @@ function getCodeSelectionDecorations({ decorations, node, view, forceActive, })
|
|
|
1047
1050
|
}
|
|
1048
1051
|
else {
|
|
1049
1052
|
decorations.push(getMarkDecoration({
|
|
1050
|
-
style: clsx(
|
|
1053
|
+
style: clsx(CLASSES.code),
|
|
1051
1054
|
range: [node.from, node.to],
|
|
1052
1055
|
}));
|
|
1053
1056
|
}
|
|
@@ -1210,6 +1213,7 @@ const CODE_OF_END_IMAGE_TEXT = 93; // ]
|
|
|
1210
1213
|
const CODE_OF_START_IMAGE_URL = 40; // (
|
|
1211
1214
|
const CODE_OF_END_IMAGE_URL = 41; // )
|
|
1212
1215
|
|
|
1216
|
+
/* eslint-disable max-params */
|
|
1213
1217
|
const IMAGE_NODES = {};
|
|
1214
1218
|
const INTERVAL_DELAY = 10000;
|
|
1215
1219
|
const EXISTING_WIDGETS = new Set();
|
|
@@ -1362,7 +1366,7 @@ function isCorrectNode$1(text, link, node) {
|
|
|
1362
1366
|
textContent.includes(text));
|
|
1363
1367
|
}
|
|
1364
1368
|
function selectLink$1({ link, node, selection, start }) {
|
|
1365
|
-
const startPosition = start ??
|
|
1369
|
+
const startPosition = start ?? node.textContent?.indexOf?.(link) ?? 0;
|
|
1366
1370
|
const endPosition = startPosition + link.length;
|
|
1367
1371
|
if (startPosition === 0 && endPosition === 0) {
|
|
1368
1372
|
const content = node.textContent;
|
|
@@ -1523,7 +1527,7 @@ function getItalicSelectionDecorations({ decorations, node, view, forceActive, s
|
|
|
1523
1527
|
if (node.name !== NAME_OF_ITALIC) {
|
|
1524
1528
|
return;
|
|
1525
1529
|
}
|
|
1526
|
-
if (checkIsSeveralEmphasis({
|
|
1530
|
+
if (checkIsSeveralEmphasis({ node, view})) {
|
|
1527
1531
|
return void splitEmphasis({ decorations, node, view, forceActive, settings });
|
|
1528
1532
|
}
|
|
1529
1533
|
let step = 1;
|
|
@@ -1606,6 +1610,7 @@ function getLinkLabelSelectionDecoration({ decorations, node, view, forceActive,
|
|
|
1606
1610
|
}
|
|
1607
1611
|
}
|
|
1608
1612
|
|
|
1613
|
+
/* eslint-disable max-params */
|
|
1609
1614
|
const LINK_NODES = {};
|
|
1610
1615
|
class LinkWidget extends view.WidgetType {
|
|
1611
1616
|
text;
|
|
@@ -1662,7 +1667,9 @@ class LinkWidget extends view.WidgetType {
|
|
|
1662
1667
|
anchor.clearListeners?.();
|
|
1663
1668
|
const abortController = new AbortController();
|
|
1664
1669
|
anchor.addEventListener("mousedown", (event) => handleClick(this.view, this.text, this.link, this.key, event), { signal: abortController.signal });
|
|
1665
|
-
anchor.addEventListener("click", (
|
|
1670
|
+
anchor.addEventListener("click", (event) => event.preventDefault(), {
|
|
1671
|
+
signal: abortController.signal,
|
|
1672
|
+
});
|
|
1666
1673
|
anchor.clearListeners = () => {
|
|
1667
1674
|
abortController.abort();
|
|
1668
1675
|
};
|
|
@@ -1712,7 +1719,7 @@ function isCorrectNode(text, link, node) {
|
|
|
1712
1719
|
textContent.includes(text));
|
|
1713
1720
|
}
|
|
1714
1721
|
function selectLink({ link, node, selection, start }) {
|
|
1715
|
-
const startPosition = start ??
|
|
1722
|
+
const startPosition = start ?? node.textContent?.indexOf?.(link) ?? 0;
|
|
1716
1723
|
const endPosition = startPosition + link.length;
|
|
1717
1724
|
if (startPosition === 0 && endPosition === 0) {
|
|
1718
1725
|
const content = node.textContent;
|
|
@@ -1815,7 +1822,7 @@ function getLinkSelectionDecorations({ decorations, node, view, forceActive, set
|
|
|
1815
1822
|
urlCoordinates.to = pos;
|
|
1816
1823
|
}
|
|
1817
1824
|
if (urlCoordinates.from === -1 || urlCoordinates.to === -1)
|
|
1818
|
-
return void getLinkLabelSelectionDecoration({ decorations, forceActive, node, view
|
|
1825
|
+
return void getLinkLabelSelectionDecoration({ decorations, forceActive, node, view});
|
|
1819
1826
|
const text = content.substring(textCoordinates.from, textCoordinates.to);
|
|
1820
1827
|
const url = content.substring(urlCoordinates.from, urlCoordinates.to);
|
|
1821
1828
|
const openedLink = view.state.field(markdownState).openedLink;
|
|
@@ -1921,7 +1928,7 @@ function getListSelectionDecorations({ decorations, node, view, forceActive, })
|
|
|
1921
1928
|
return;
|
|
1922
1929
|
}
|
|
1923
1930
|
const content = view.state.doc.sliceString(node.from, node.to);
|
|
1924
|
-
const lastCodePoint = content.codePointAt(content.length - 1)
|
|
1931
|
+
const lastCodePoint = content.codePointAt(content.length - 1) ?? 0;
|
|
1925
1932
|
if (!LIST_OF_LIST_MARKS.has(lastCodePoint) && CODE_OF_ORDERED_LIST_MARK !== lastCodePoint) {
|
|
1926
1933
|
return;
|
|
1927
1934
|
}
|
|
@@ -2061,7 +2068,7 @@ function getTodoSelectionDecoration({ decorations, node, view, forceActive, }) {
|
|
|
2061
2068
|
const prevSibling = node.node.prevSibling;
|
|
2062
2069
|
if (!prevSibling || prevSibling.name !== NAME_OF_LIST_MARK)
|
|
2063
2070
|
return;
|
|
2064
|
-
const isChecked = LIST_OF_TODO_MARKS.has(view.state.doc.sliceString(node.from + 1, node.from + 2).codePointAt(0)
|
|
2071
|
+
const isChecked = LIST_OF_TODO_MARKS.has(view.state.doc.sliceString(node.from + 1, node.from + 2).codePointAt(0) ?? 0);
|
|
2065
2072
|
if (forceActive ||
|
|
2066
2073
|
!view.hasFocus ||
|
|
2067
2074
|
!isInRange(view.state.selection.ranges, [prevSibling.from, node.from + 3])) {
|
|
@@ -2143,10 +2150,10 @@ function createDecorationsGetter(settings) {
|
|
|
2143
2150
|
return;
|
|
2144
2151
|
/** Decoration by change content */
|
|
2145
2152
|
if (processDecorations)
|
|
2146
|
-
decorationFunctions.forEach((
|
|
2153
|
+
decorationFunctions.forEach((funk) => funk({ decorations, node, view: view$1, settings }));
|
|
2147
2154
|
/** Decoration by selection content */
|
|
2148
2155
|
if (processSelectionDecorations)
|
|
2149
|
-
selectionDecorationFunctions.forEach((
|
|
2156
|
+
selectionDecorationFunctions.forEach((funk) => funk({
|
|
2150
2157
|
decorations: selectionDecorations,
|
|
2151
2158
|
node,
|
|
2152
2159
|
view: view$1,
|
|
@@ -2207,7 +2214,7 @@ const markdownDecorationPlugin = (settings) => {
|
|
|
2207
2214
|
});
|
|
2208
2215
|
};
|
|
2209
2216
|
|
|
2210
|
-
async function
|
|
2217
|
+
async function initSettings({ readonly, vimMode, }) {
|
|
2211
2218
|
let vimExtension = [];
|
|
2212
2219
|
if (vimMode) {
|
|
2213
2220
|
const { vim } = await import('@replit/codemirror-vim');
|
|
@@ -2223,7 +2230,7 @@ async function InitSettings({ readonly, vimMode, }) {
|
|
|
2223
2230
|
const initExtensions = async ({ onBlur, onChange, onFocus, onEnter, onEscape, readonly = true, vimMode = false, multiCursorText, provider, theme = "light", dark, light, languages, keyMaps, defaultKeyMaps, imageSrcGetter, autoCompleteTagOptions, autoCompleteConfig, }) => {
|
|
2224
2231
|
const multiCursorMode = Boolean(multiCursorText && provider);
|
|
2225
2232
|
const asyncPlugins = await Promise.all([
|
|
2226
|
-
|
|
2233
|
+
initSettings({ readonly, vimMode }),
|
|
2227
2234
|
initKeyMaps({
|
|
2228
2235
|
onEnter,
|
|
2229
2236
|
onEscape,
|
|
@@ -2236,7 +2243,7 @@ const initExtensions = async ({ onBlur, onChange, onFocus, onEnter, onEscape, re
|
|
|
2236
2243
|
light,
|
|
2237
2244
|
}),
|
|
2238
2245
|
new Promise((resolve) => {
|
|
2239
|
-
void Promise.resolve().then(() => require('./index-
|
|
2246
|
+
void Promise.resolve().then(() => require('./index-Ne5xJkxS.js')).then(({ initMarkdown }) => {
|
|
2240
2247
|
resolve(initMarkdown({ languages, imageSrcGetter }));
|
|
2241
2248
|
});
|
|
2242
2249
|
}),
|
|
@@ -2261,8 +2268,7 @@ async function initEditorProvider({ roomId, url, userName = "Anonymous", userCol
|
|
|
2261
2268
|
const { WebsocketProvider } = await import('y-websocket');
|
|
2262
2269
|
const multiCursorDocument = new Doc();
|
|
2263
2270
|
const multiCursorText = multiCursorDocument.getText(roomId);
|
|
2264
|
-
if (!userColor
|
|
2265
|
-
// eslint-disable-next-line no-console
|
|
2271
|
+
if (!userColor?.startsWith?.("#")) {
|
|
2266
2272
|
console.warn("user color must be hex!");
|
|
2267
2273
|
userColor = "#30bced";
|
|
2268
2274
|
}
|
|
@@ -2277,7 +2283,7 @@ async function initEditorProvider({ roomId, url, userName = "Anonymous", userCol
|
|
|
2277
2283
|
provider.on("status", (event) => {
|
|
2278
2284
|
onStartProvider(event?.status);
|
|
2279
2285
|
});
|
|
2280
|
-
if (provider
|
|
2286
|
+
if (provider)
|
|
2281
2287
|
provider.on("sync", (isSynced) => {
|
|
2282
2288
|
if (isSynced && !multiCursorText.length && initialText) {
|
|
2283
2289
|
multiCursorText.insert(0, initialText);
|
|
@@ -2305,7 +2311,7 @@ async function initEditor({ multiCursor, root, initialText, ...rest }) {
|
|
|
2305
2311
|
}
|
|
2306
2312
|
const state = await initEditorState({
|
|
2307
2313
|
...rest,
|
|
2308
|
-
text: initialText
|
|
2314
|
+
text: initialText ?? "",
|
|
2309
2315
|
provider,
|
|
2310
2316
|
multiCursorText,
|
|
2311
2317
|
});
|
|
@@ -2391,14 +2397,10 @@ class Editor {
|
|
|
2391
2397
|
effects: ThemeCompartment.reconfigure(theme === "dark"
|
|
2392
2398
|
? getDarkTheme({
|
|
2393
2399
|
dark: this.arguments.dark,
|
|
2394
|
-
light: this.arguments.light
|
|
2395
|
-
theme,
|
|
2396
|
-
})
|
|
2400
|
+
light: this.arguments.light})
|
|
2397
2401
|
: getLightTheme({
|
|
2398
2402
|
dark: this.arguments.dark,
|
|
2399
|
-
light: this.arguments.light,
|
|
2400
|
-
theme,
|
|
2401
|
-
})),
|
|
2403
|
+
light: this.arguments.light})),
|
|
2402
2404
|
});
|
|
2403
2405
|
});
|
|
2404
2406
|
};
|
|
@@ -2439,4 +2441,4 @@ exports.Editor = Editor;
|
|
|
2439
2441
|
exports.NAME_OF_MENTION = NAME_OF_MENTION;
|
|
2440
2442
|
exports.markdownDecorationPlugin = markdownDecorationPlugin;
|
|
2441
2443
|
exports.markdownState = markdownState;
|
|
2442
|
-
//# sourceMappingURL=index-
|
|
2444
|
+
//# sourceMappingURL=index-Df0WnJ4c.js.map
|