@uipath/apollo-react 3.66.1 → 3.67.0

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.
Files changed (19) hide show
  1. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts +6 -0
  2. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts.map +1 -1
  3. package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.cjs +69 -0
  4. package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.d.ts +11 -0
  5. package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.d.ts.map +1 -0
  6. package/dist/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.js +32 -0
  7. package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.cjs +68 -0
  8. package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.d.ts +4 -0
  9. package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.d.ts.map +1 -0
  10. package/dist/canvas/components/StickyNoteNode/markdown-formatting/index.js +4 -0
  11. package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.cjs +173 -0
  12. package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.d.ts +5 -0
  13. package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.d.ts.map +1 -0
  14. package/dist/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.js +133 -0
  15. package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.cjs +175 -0
  16. package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.d.ts +8 -0
  17. package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.d.ts.map +1 -0
  18. package/dist/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.js +126 -0
  19. package/package.json +1 -1
@@ -12,4 +12,10 @@ export interface StickyNoteData extends Record<string, unknown> {
12
12
  autoFocus?: boolean;
13
13
  }
14
14
  export declare function withAlpha(hex: string, alpha?: number): string;
15
+ export type TextSelection = {
16
+ value: string;
17
+ selectionStart: number;
18
+ selectionEnd: number;
19
+ };
20
+ export type FormattingAction = 'bold' | 'italic' | 'strikethrough' | 'bulletList' | 'numberedList';
15
21
  //# sourceMappingURL=StickyNoteNode.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StickyNoteNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.types.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE9D,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAWD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAA6B,GAAG,MAAM,CAyBnF"}
1
+ {"version":3,"file":"StickyNoteNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.types.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE9D,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAWD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAA6B,GAAG,MAAM,CAyBnF;AAGD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,CAAC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ detectActiveFormats: ()=>detectActiveFormats,
28
+ activeFormatsEqual: ()=>activeFormatsEqual
29
+ });
30
+ const external_listFormatting_cjs_namespaceObject = require("./listFormatting.cjs");
31
+ function activeFormatsEqual(a, b) {
32
+ return a.bold === b.bold && a.italic === b.italic && a.strikethrough === b.strikethrough && a.bulletList === b.bulletList && a.numberedList === b.numberedList;
33
+ }
34
+ function detectActiveFormats(input) {
35
+ const { value, selectionStart } = input;
36
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
37
+ let lineEnd = value.indexOf('\n', selectionStart);
38
+ if (-1 === lineEnd) lineEnd = value.length;
39
+ const currentLine = value.slice(lineStart, lineEnd);
40
+ const cursorInLine = selectionStart - lineStart;
41
+ const textBefore = currentLine.slice(0, cursorInLine);
42
+ const textAfter = currentLine.slice(cursorInLine);
43
+ const bold = /\*\*(?:[^*\n]|\*(?!\*))*$/.test(textBefore) && /^(?:[^*\n]|\*(?!\*))*\*\*/.test(textAfter);
44
+ const strikethrough = /~~[^~\n]*$/.test(textBefore) && /^[^~\n]*~~/.test(textAfter);
45
+ const italicBefore = /(?<!\*)\*(?!\*)(?:[^*\n]|\*\*)*$/.test(textBefore);
46
+ const italicAfter = /^(?:[^*\n]|\*\*)*(?<!\*)\*(?!\*)/.test(textAfter);
47
+ let italic = italicBefore && italicAfter;
48
+ if (!italic && bold) {
49
+ const beforeStars = /(\*{3,})[^*\n]*$/.exec(textBefore);
50
+ const afterStars = /^[^*\n]*(\*{3,})/.exec(textAfter);
51
+ if (beforeStars && afterStars && beforeStars[1].length % 2 === 1 && afterStars[1].length % 2 === 1) italic = true;
52
+ }
53
+ return {
54
+ bold,
55
+ italic,
56
+ strikethrough,
57
+ bulletList: external_listFormatting_cjs_namespaceObject.BULLET_PREFIX.test(currentLine),
58
+ numberedList: external_listFormatting_cjs_namespaceObject.NUMBERED_PREFIX.test(currentLine)
59
+ };
60
+ }
61
+ exports.activeFormatsEqual = __webpack_exports__.activeFormatsEqual;
62
+ exports.detectActiveFormats = __webpack_exports__.detectActiveFormats;
63
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
64
+ "activeFormatsEqual",
65
+ "detectActiveFormats"
66
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
67
+ Object.defineProperty(exports, '__esModule', {
68
+ value: true
69
+ });
@@ -0,0 +1,11 @@
1
+ import type { TextSelection } from '../StickyNoteNode.types';
2
+ export type ActiveFormats = {
3
+ bold: boolean;
4
+ italic: boolean;
5
+ strikethrough: boolean;
6
+ bulletList: boolean;
7
+ numberedList: boolean;
8
+ };
9
+ export declare function activeFormatsEqual(a: ActiveFormats, b: ActiveFormats): boolean;
10
+ export declare function detectActiveFormats(input: TextSelection): ActiveFormats;
11
+ //# sourceMappingURL=detectActiveFormats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectActiveFormats.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/StickyNoteNode/markdown-formatting/detectActiveFormats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAQ9E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CA4CvE"}
@@ -0,0 +1,32 @@
1
+ import { BULLET_PREFIX, NUMBERED_PREFIX } from "./listFormatting.js";
2
+ function activeFormatsEqual(a, b) {
3
+ return a.bold === b.bold && a.italic === b.italic && a.strikethrough === b.strikethrough && a.bulletList === b.bulletList && a.numberedList === b.numberedList;
4
+ }
5
+ function detectActiveFormats(input) {
6
+ const { value, selectionStart } = input;
7
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
8
+ let lineEnd = value.indexOf('\n', selectionStart);
9
+ if (-1 === lineEnd) lineEnd = value.length;
10
+ const currentLine = value.slice(lineStart, lineEnd);
11
+ const cursorInLine = selectionStart - lineStart;
12
+ const textBefore = currentLine.slice(0, cursorInLine);
13
+ const textAfter = currentLine.slice(cursorInLine);
14
+ const bold = /\*\*(?:[^*\n]|\*(?!\*))*$/.test(textBefore) && /^(?:[^*\n]|\*(?!\*))*\*\*/.test(textAfter);
15
+ const strikethrough = /~~[^~\n]*$/.test(textBefore) && /^[^~\n]*~~/.test(textAfter);
16
+ const italicBefore = /(?<!\*)\*(?!\*)(?:[^*\n]|\*\*)*$/.test(textBefore);
17
+ const italicAfter = /^(?:[^*\n]|\*\*)*(?<!\*)\*(?!\*)/.test(textAfter);
18
+ let italic = italicBefore && italicAfter;
19
+ if (!italic && bold) {
20
+ const beforeStars = /(\*{3,})[^*\n]*$/.exec(textBefore);
21
+ const afterStars = /^[^*\n]*(\*{3,})/.exec(textAfter);
22
+ if (beforeStars && afterStars && beforeStars[1].length % 2 === 1 && afterStars[1].length % 2 === 1) italic = true;
23
+ }
24
+ return {
25
+ bold,
26
+ italic,
27
+ strikethrough,
28
+ bulletList: BULLET_PREFIX.test(currentLine),
29
+ numberedList: NUMBERED_PREFIX.test(currentLine)
30
+ };
31
+ }
32
+ export { activeFormatsEqual, detectActiveFormats };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ detectActiveFormats: ()=>external_detectActiveFormats_cjs_namespaceObject.detectActiveFormats,
28
+ toggleItalic: ()=>external_inlineFormatting_cjs_namespaceObject.toggleItalic,
29
+ toggleStrikethrough: ()=>external_inlineFormatting_cjs_namespaceObject.toggleStrikethrough,
30
+ toggleBulletList: ()=>external_listFormatting_cjs_namespaceObject.toggleBulletList,
31
+ toggleNumberedList: ()=>external_listFormatting_cjs_namespaceObject.toggleNumberedList,
32
+ BULLET_PREFIX: ()=>external_listFormatting_cjs_namespaceObject.BULLET_PREFIX,
33
+ activeFormatsEqual: ()=>external_detectActiveFormats_cjs_namespaceObject.activeFormatsEqual,
34
+ NUMBERED_PREFIX: ()=>external_listFormatting_cjs_namespaceObject.NUMBERED_PREFIX,
35
+ continueListOnEnter: ()=>external_listFormatting_cjs_namespaceObject.continueListOnEnter,
36
+ toggleBold: ()=>external_inlineFormatting_cjs_namespaceObject.toggleBold,
37
+ NUMBERED_PREFIX_FULL: ()=>external_listFormatting_cjs_namespaceObject.NUMBERED_PREFIX_FULL
38
+ });
39
+ const external_detectActiveFormats_cjs_namespaceObject = require("./detectActiveFormats.cjs");
40
+ const external_inlineFormatting_cjs_namespaceObject = require("./inlineFormatting.cjs");
41
+ const external_listFormatting_cjs_namespaceObject = require("./listFormatting.cjs");
42
+ exports.BULLET_PREFIX = __webpack_exports__.BULLET_PREFIX;
43
+ exports.NUMBERED_PREFIX = __webpack_exports__.NUMBERED_PREFIX;
44
+ exports.NUMBERED_PREFIX_FULL = __webpack_exports__.NUMBERED_PREFIX_FULL;
45
+ exports.activeFormatsEqual = __webpack_exports__.activeFormatsEqual;
46
+ exports.continueListOnEnter = __webpack_exports__.continueListOnEnter;
47
+ exports.detectActiveFormats = __webpack_exports__.detectActiveFormats;
48
+ exports.toggleBold = __webpack_exports__.toggleBold;
49
+ exports.toggleBulletList = __webpack_exports__.toggleBulletList;
50
+ exports.toggleItalic = __webpack_exports__.toggleItalic;
51
+ exports.toggleNumberedList = __webpack_exports__.toggleNumberedList;
52
+ exports.toggleStrikethrough = __webpack_exports__.toggleStrikethrough;
53
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
54
+ "BULLET_PREFIX",
55
+ "NUMBERED_PREFIX",
56
+ "NUMBERED_PREFIX_FULL",
57
+ "activeFormatsEqual",
58
+ "continueListOnEnter",
59
+ "detectActiveFormats",
60
+ "toggleBold",
61
+ "toggleBulletList",
62
+ "toggleItalic",
63
+ "toggleNumberedList",
64
+ "toggleStrikethrough"
65
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
66
+ Object.defineProperty(exports, '__esModule', {
67
+ value: true
68
+ });
@@ -0,0 +1,4 @@
1
+ export { type ActiveFormats, activeFormatsEqual, detectActiveFormats } from './detectActiveFormats';
2
+ export { toggleBold, toggleItalic, toggleStrikethrough } from './inlineFormatting';
3
+ export { BULLET_PREFIX, continueListOnEnter, NUMBERED_PREFIX, NUMBERED_PREFIX_FULL, toggleBulletList, toggleNumberedList, } from './listFormatting';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/StickyNoteNode/markdown-formatting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { activeFormatsEqual, detectActiveFormats } from "./detectActiveFormats.js";
2
+ import { toggleBold, toggleItalic, toggleStrikethrough } from "./inlineFormatting.js";
3
+ import { BULLET_PREFIX, NUMBERED_PREFIX, NUMBERED_PREFIX_FULL, continueListOnEnter, toggleBulletList, toggleNumberedList } from "./listFormatting.js";
4
+ export { BULLET_PREFIX, NUMBERED_PREFIX, NUMBERED_PREFIX_FULL, activeFormatsEqual, continueListOnEnter, detectActiveFormats, toggleBold, toggleBulletList, toggleItalic, toggleNumberedList, toggleStrikethrough };
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ toggleItalic: ()=>toggleItalic,
28
+ toggleBold: ()=>toggleBold,
29
+ toggleStrikethrough: ()=>toggleStrikethrough
30
+ });
31
+ const external_listFormatting_cjs_namespaceObject = require("./listFormatting.cjs");
32
+ function toggleInlineWrap(input, marker) {
33
+ const { value, selectionStart, selectionEnd } = input;
34
+ const markerLen = marker.length;
35
+ const selectedText = value.slice(selectionStart, selectionEnd);
36
+ const hasSelection = selectionStart !== selectionEnd;
37
+ if (!hasSelection) {
38
+ const textBefore = value.slice(0, selectionStart);
39
+ const textAfter = value.slice(selectionStart);
40
+ const markerChar = marker[0];
41
+ const esc = (s)=>s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
42
+ const me = esc(marker);
43
+ const ce = esc(markerChar);
44
+ const beforeRe = 1 === markerLen ? new RegExp(`(?<!${ce})${me}(?!${ce})([^${ce}]*)$`) : new RegExp(`${me}([^${ce}]*)$`);
45
+ const afterRe = 1 === markerLen ? new RegExp(`^([^${ce}]*)(?<!${ce})${me}(?!${ce})`) : new RegExp(`^([^${ce}]*)${me}`);
46
+ const bm = beforeRe.exec(textBefore);
47
+ const am = afterRe.exec(textAfter);
48
+ if (bm && am) {
49
+ const openStart = selectionStart - bm[0].length;
50
+ const closeEnd = selectionStart + am[0].length;
51
+ const boundaryClean = 1 === markerLen || value[openStart - 1] !== markerChar && value[closeEnd] !== markerChar;
52
+ if (boundaryClean) {
53
+ const newValue = value.slice(0, openStart) + bm[1] + am[1] + value.slice(closeEnd);
54
+ const newCursor = selectionStart - markerLen;
55
+ return {
56
+ value: newValue,
57
+ selectionStart: newCursor,
58
+ selectionEnd: newCursor
59
+ };
60
+ }
61
+ }
62
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
63
+ let lineEnd = value.indexOf('\n', selectionStart);
64
+ if (-1 === lineEnd) lineEnd = value.length;
65
+ const currentLine = value.slice(lineStart, lineEnd);
66
+ const bulletMatch = external_listFormatting_cjs_namespaceObject.BULLET_PREFIX.exec(currentLine);
67
+ const numberedMatch = external_listFormatting_cjs_namespaceObject.NUMBERED_PREFIX_FULL.exec(currentLine);
68
+ const prefixLen = bulletMatch?.[0].length ?? numberedMatch?.[0].length ?? 0;
69
+ if (prefixLen > 0) {
70
+ const content = currentLine.slice(prefixLen);
71
+ if (content.length > 0) {
72
+ const prefix = currentLine.slice(0, prefixLen);
73
+ const newLine = `${prefix}${marker}${content}${marker}`;
74
+ const newValue = value.slice(0, lineStart) + newLine + value.slice(lineEnd);
75
+ const newCursor = selectionStart + markerLen;
76
+ return {
77
+ value: newValue,
78
+ selectionStart: newCursor,
79
+ selectionEnd: newCursor
80
+ };
81
+ }
82
+ }
83
+ const newValue = value.slice(0, selectionStart) + marker + marker + value.slice(selectionEnd);
84
+ const cursorPos = selectionStart + markerLen;
85
+ return {
86
+ value: newValue,
87
+ selectionStart: cursorPos,
88
+ selectionEnd: cursorPos
89
+ };
90
+ }
91
+ {
92
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
93
+ let lineEnd = value.indexOf('\n', selectionEnd);
94
+ if (-1 === lineEnd) lineEnd = value.length;
95
+ if (selectionEnd > lineStart && '\n' === value[selectionEnd - 1]) lineEnd = selectionEnd - 1;
96
+ const lines = value.slice(lineStart, lineEnd).split('\n');
97
+ if (lines.length >= 2 && lines.some((line)=>external_listFormatting_cjs_namespaceObject.BULLET_PREFIX.test(line) || external_listFormatting_cjs_namespaceObject.NUMBERED_PREFIX.test(line))) {
98
+ const parsed = lines.map((line)=>{
99
+ const bulletMatch = external_listFormatting_cjs_namespaceObject.BULLET_PREFIX.exec(line);
100
+ const numberedMatch = external_listFormatting_cjs_namespaceObject.NUMBERED_PREFIX.exec(line);
101
+ const prefix = bulletMatch?.[0] ?? numberedMatch?.[0] ?? '';
102
+ const content = line.slice(prefix.length);
103
+ return {
104
+ prefix,
105
+ content
106
+ };
107
+ });
108
+ const isWrapped = (content)=>{
109
+ if (content.length < 2 * markerLen) return false;
110
+ if (!content.startsWith(marker) || !content.endsWith(marker)) return false;
111
+ const mc = marker[0];
112
+ if (1 === markerLen) {
113
+ let leadingStars = 0;
114
+ while(content[leadingStars] === mc)leadingStars++;
115
+ let trailingStars = 0;
116
+ while(content[content.length - 1 - trailingStars] === mc)trailingStars++;
117
+ return leadingStars % 2 === 1 && trailingStars % 2 === 1;
118
+ }
119
+ return content[markerLen] !== mc && content[content.length - markerLen - 1] !== mc;
120
+ };
121
+ const allWrapped = parsed.every(({ content })=>isWrapped(content));
122
+ const newLines = allWrapped ? parsed.map(({ prefix, content })=>`${prefix}${content.slice(markerLen, content.length - markerLen)}`) : parsed.map(({ prefix, content })=>content.length > 0 ? `${prefix}${marker}${content}${marker}` : `${prefix}${content}`);
123
+ const newLinesText = newLines.join('\n');
124
+ const newValue = value.slice(0, lineStart) + newLinesText + value.slice(lineEnd);
125
+ const newSelectionEnd = lineStart + newLinesText.length;
126
+ return {
127
+ value: newValue,
128
+ selectionStart: lineStart,
129
+ selectionEnd: newSelectionEnd
130
+ };
131
+ }
132
+ }
133
+ const before = value.slice(selectionStart - markerLen, selectionStart);
134
+ const after = value.slice(selectionEnd, selectionEnd + markerLen);
135
+ const markerChar = marker[0];
136
+ const outerBefore = value[selectionStart - markerLen - 1];
137
+ const outerAfter = value[selectionEnd + markerLen];
138
+ const isBoundaryClean = outerBefore !== markerChar && outerAfter !== markerChar;
139
+ if (before === marker && after === marker && isBoundaryClean) {
140
+ const newValue = value.slice(0, selectionStart - markerLen) + selectedText + value.slice(selectionEnd + markerLen);
141
+ return {
142
+ value: newValue,
143
+ selectionStart: selectionStart - markerLen,
144
+ selectionEnd: selectionEnd - markerLen
145
+ };
146
+ }
147
+ const newValue = value.slice(0, selectionStart) + marker + selectedText + marker + value.slice(selectionEnd);
148
+ return {
149
+ value: newValue,
150
+ selectionStart: selectionStart + markerLen,
151
+ selectionEnd: selectionEnd + markerLen
152
+ };
153
+ }
154
+ function toggleBold(input) {
155
+ return toggleInlineWrap(input, '**');
156
+ }
157
+ function toggleItalic(input) {
158
+ return toggleInlineWrap(input, '*');
159
+ }
160
+ function toggleStrikethrough(input) {
161
+ return toggleInlineWrap(input, '~~');
162
+ }
163
+ exports.toggleBold = __webpack_exports__.toggleBold;
164
+ exports.toggleItalic = __webpack_exports__.toggleItalic;
165
+ exports.toggleStrikethrough = __webpack_exports__.toggleStrikethrough;
166
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
167
+ "toggleBold",
168
+ "toggleItalic",
169
+ "toggleStrikethrough"
170
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
171
+ Object.defineProperty(exports, '__esModule', {
172
+ value: true
173
+ });
@@ -0,0 +1,5 @@
1
+ import type { TextSelection } from '../StickyNoteNode.types';
2
+ export declare function toggleBold(input: TextSelection): TextSelection;
3
+ export declare function toggleItalic(input: TextSelection): TextSelection;
4
+ export declare function toggleStrikethrough(input: TextSelection): TextSelection;
5
+ //# sourceMappingURL=inlineFormatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineFormatting.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/StickyNoteNode/markdown-formatting/inlineFormatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA0K7D,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAE9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAEhE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAEvE"}
@@ -0,0 +1,133 @@
1
+ import { BULLET_PREFIX, NUMBERED_PREFIX, NUMBERED_PREFIX_FULL } from "./listFormatting.js";
2
+ function toggleInlineWrap(input, marker) {
3
+ const { value, selectionStart, selectionEnd } = input;
4
+ const markerLen = marker.length;
5
+ const selectedText = value.slice(selectionStart, selectionEnd);
6
+ const hasSelection = selectionStart !== selectionEnd;
7
+ if (!hasSelection) {
8
+ const textBefore = value.slice(0, selectionStart);
9
+ const textAfter = value.slice(selectionStart);
10
+ const markerChar = marker[0];
11
+ const esc = (s)=>s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
12
+ const me = esc(marker);
13
+ const ce = esc(markerChar);
14
+ const beforeRe = 1 === markerLen ? new RegExp(`(?<!${ce})${me}(?!${ce})([^${ce}]*)$`) : new RegExp(`${me}([^${ce}]*)$`);
15
+ const afterRe = 1 === markerLen ? new RegExp(`^([^${ce}]*)(?<!${ce})${me}(?!${ce})`) : new RegExp(`^([^${ce}]*)${me}`);
16
+ const bm = beforeRe.exec(textBefore);
17
+ const am = afterRe.exec(textAfter);
18
+ if (bm && am) {
19
+ const openStart = selectionStart - bm[0].length;
20
+ const closeEnd = selectionStart + am[0].length;
21
+ const boundaryClean = 1 === markerLen || value[openStart - 1] !== markerChar && value[closeEnd] !== markerChar;
22
+ if (boundaryClean) {
23
+ const newValue = value.slice(0, openStart) + bm[1] + am[1] + value.slice(closeEnd);
24
+ const newCursor = selectionStart - markerLen;
25
+ return {
26
+ value: newValue,
27
+ selectionStart: newCursor,
28
+ selectionEnd: newCursor
29
+ };
30
+ }
31
+ }
32
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
33
+ let lineEnd = value.indexOf('\n', selectionStart);
34
+ if (-1 === lineEnd) lineEnd = value.length;
35
+ const currentLine = value.slice(lineStart, lineEnd);
36
+ const bulletMatch = BULLET_PREFIX.exec(currentLine);
37
+ const numberedMatch = NUMBERED_PREFIX_FULL.exec(currentLine);
38
+ const prefixLen = bulletMatch?.[0].length ?? numberedMatch?.[0].length ?? 0;
39
+ if (prefixLen > 0) {
40
+ const content = currentLine.slice(prefixLen);
41
+ if (content.length > 0) {
42
+ const prefix = currentLine.slice(0, prefixLen);
43
+ const newLine = `${prefix}${marker}${content}${marker}`;
44
+ const newValue = value.slice(0, lineStart) + newLine + value.slice(lineEnd);
45
+ const newCursor = selectionStart + markerLen;
46
+ return {
47
+ value: newValue,
48
+ selectionStart: newCursor,
49
+ selectionEnd: newCursor
50
+ };
51
+ }
52
+ }
53
+ const newValue = value.slice(0, selectionStart) + marker + marker + value.slice(selectionEnd);
54
+ const cursorPos = selectionStart + markerLen;
55
+ return {
56
+ value: newValue,
57
+ selectionStart: cursorPos,
58
+ selectionEnd: cursorPos
59
+ };
60
+ }
61
+ {
62
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
63
+ let lineEnd = value.indexOf('\n', selectionEnd);
64
+ if (-1 === lineEnd) lineEnd = value.length;
65
+ if (selectionEnd > lineStart && '\n' === value[selectionEnd - 1]) lineEnd = selectionEnd - 1;
66
+ const lines = value.slice(lineStart, lineEnd).split('\n');
67
+ if (lines.length >= 2 && lines.some((line)=>BULLET_PREFIX.test(line) || NUMBERED_PREFIX.test(line))) {
68
+ const parsed = lines.map((line)=>{
69
+ const bulletMatch = BULLET_PREFIX.exec(line);
70
+ const numberedMatch = NUMBERED_PREFIX.exec(line);
71
+ const prefix = bulletMatch?.[0] ?? numberedMatch?.[0] ?? '';
72
+ const content = line.slice(prefix.length);
73
+ return {
74
+ prefix,
75
+ content
76
+ };
77
+ });
78
+ const isWrapped = (content)=>{
79
+ if (content.length < 2 * markerLen) return false;
80
+ if (!content.startsWith(marker) || !content.endsWith(marker)) return false;
81
+ const mc = marker[0];
82
+ if (1 === markerLen) {
83
+ let leadingStars = 0;
84
+ while(content[leadingStars] === mc)leadingStars++;
85
+ let trailingStars = 0;
86
+ while(content[content.length - 1 - trailingStars] === mc)trailingStars++;
87
+ return leadingStars % 2 === 1 && trailingStars % 2 === 1;
88
+ }
89
+ return content[markerLen] !== mc && content[content.length - markerLen - 1] !== mc;
90
+ };
91
+ const allWrapped = parsed.every(({ content })=>isWrapped(content));
92
+ const newLines = allWrapped ? parsed.map(({ prefix, content })=>`${prefix}${content.slice(markerLen, content.length - markerLen)}`) : parsed.map(({ prefix, content })=>content.length > 0 ? `${prefix}${marker}${content}${marker}` : `${prefix}${content}`);
93
+ const newLinesText = newLines.join('\n');
94
+ const newValue = value.slice(0, lineStart) + newLinesText + value.slice(lineEnd);
95
+ const newSelectionEnd = lineStart + newLinesText.length;
96
+ return {
97
+ value: newValue,
98
+ selectionStart: lineStart,
99
+ selectionEnd: newSelectionEnd
100
+ };
101
+ }
102
+ }
103
+ const before = value.slice(selectionStart - markerLen, selectionStart);
104
+ const after = value.slice(selectionEnd, selectionEnd + markerLen);
105
+ const markerChar = marker[0];
106
+ const outerBefore = value[selectionStart - markerLen - 1];
107
+ const outerAfter = value[selectionEnd + markerLen];
108
+ const isBoundaryClean = outerBefore !== markerChar && outerAfter !== markerChar;
109
+ if (before === marker && after === marker && isBoundaryClean) {
110
+ const newValue = value.slice(0, selectionStart - markerLen) + selectedText + value.slice(selectionEnd + markerLen);
111
+ return {
112
+ value: newValue,
113
+ selectionStart: selectionStart - markerLen,
114
+ selectionEnd: selectionEnd - markerLen
115
+ };
116
+ }
117
+ const newValue = value.slice(0, selectionStart) + marker + selectedText + marker + value.slice(selectionEnd);
118
+ return {
119
+ value: newValue,
120
+ selectionStart: selectionStart + markerLen,
121
+ selectionEnd: selectionEnd + markerLen
122
+ };
123
+ }
124
+ function toggleBold(input) {
125
+ return toggleInlineWrap(input, '**');
126
+ }
127
+ function toggleItalic(input) {
128
+ return toggleInlineWrap(input, '*');
129
+ }
130
+ function toggleStrikethrough(input) {
131
+ return toggleInlineWrap(input, '~~');
132
+ }
133
+ export { toggleBold, toggleItalic, toggleStrikethrough };
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ BULLET_PREFIX: ()=>BULLET_PREFIX,
28
+ NUMBERED_PREFIX: ()=>NUMBERED_PREFIX,
29
+ NUMBERED_PREFIX_FULL: ()=>NUMBERED_PREFIX_FULL,
30
+ continueListOnEnter: ()=>continueListOnEnter,
31
+ toggleBulletList: ()=>toggleBulletList,
32
+ toggleNumberedList: ()=>toggleNumberedList
33
+ });
34
+ const BULLET_PREFIX = /^(\s*)-\s/;
35
+ const NUMBERED_PREFIX = /^(\s*)\d+\.\s/;
36
+ const NUMBERED_PREFIX_FULL = /^(\s*)(\d+)\.\s/;
37
+ function getAffectedLines(value, selectionStart, selectionEnd) {
38
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
39
+ let lineEnd = value.indexOf('\n', selectionEnd);
40
+ if (-1 === lineEnd) lineEnd = value.length;
41
+ const linesText = value.slice(lineStart, lineEnd);
42
+ const lines = linesText.split('\n');
43
+ return {
44
+ lineStart,
45
+ lineEnd,
46
+ lines
47
+ };
48
+ }
49
+ function toggleBulletList(input) {
50
+ const { value, selectionStart, selectionEnd } = input;
51
+ const { lineStart, lineEnd, lines } = getAffectedLines(value, selectionStart, selectionEnd);
52
+ const allHaveBullet = lines.every((line)=>BULLET_PREFIX.test(line));
53
+ let newLines;
54
+ let prefixDelta;
55
+ if (allHaveBullet) {
56
+ newLines = lines.map((line)=>line.replace(BULLET_PREFIX, '$1'));
57
+ prefixDelta = lines[0].length - newLines[0].length;
58
+ } else {
59
+ newLines = lines.map((line)=>{
60
+ if (BULLET_PREFIX.test(line)) return line;
61
+ if (NUMBERED_PREFIX.test(line)) return line.replace(NUMBERED_PREFIX, '$1- ');
62
+ return `- ${line}`;
63
+ });
64
+ prefixDelta = newLines[0].length - lines[0].length;
65
+ }
66
+ const newLinesText = newLines.join('\n');
67
+ const newValue = value.slice(0, lineStart) + newLinesText + value.slice(lineEnd);
68
+ const totalLengthDelta = newLinesText.length - (lineEnd - lineStart);
69
+ const isMultiLine = lines.length > 1;
70
+ const newStart = allHaveBullet ? Math.max(lineStart, selectionStart - prefixDelta) : isMultiLine ? selectionStart : selectionStart + prefixDelta;
71
+ const newEnd = selectionEnd + totalLengthDelta;
72
+ return {
73
+ value: newValue,
74
+ selectionStart: newStart,
75
+ selectionEnd: Math.max(newStart, newEnd)
76
+ };
77
+ }
78
+ function toggleNumberedList(input) {
79
+ const { value, selectionStart, selectionEnd } = input;
80
+ const { lineStart, lineEnd, lines } = getAffectedLines(value, selectionStart, selectionEnd);
81
+ const allHaveNumbered = lines.every((line)=>NUMBERED_PREFIX.test(line));
82
+ let newLines;
83
+ let prefixDelta;
84
+ if (allHaveNumbered) {
85
+ newLines = lines.map((line)=>line.replace(NUMBERED_PREFIX, '$1'));
86
+ prefixDelta = lines[0].length - newLines[0].length;
87
+ } else {
88
+ newLines = lines.map((line, i)=>{
89
+ const num = `${i + 1}. `;
90
+ if (NUMBERED_PREFIX.test(line)) return line.replace(NUMBERED_PREFIX, `$1${num}`);
91
+ if (BULLET_PREFIX.test(line)) return line.replace(BULLET_PREFIX, `$1${num}`);
92
+ return `${num}${line}`;
93
+ });
94
+ prefixDelta = newLines[0].length - lines[0].length;
95
+ }
96
+ const newLinesText = newLines.join('\n');
97
+ const newValue = value.slice(0, lineStart) + newLinesText + value.slice(lineEnd);
98
+ const totalLengthDelta = newLinesText.length - (lineEnd - lineStart);
99
+ const newStart = allHaveNumbered ? Math.max(lineStart, selectionStart - prefixDelta) : selectionStart + prefixDelta;
100
+ const newEnd = selectionEnd + totalLengthDelta;
101
+ return {
102
+ value: newValue,
103
+ selectionStart: newStart,
104
+ selectionEnd: Math.max(newStart, newEnd)
105
+ };
106
+ }
107
+ function continueListOnEnter(input) {
108
+ const { value, selectionStart, selectionEnd } = input;
109
+ if (selectionStart !== selectionEnd) return null;
110
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
111
+ let lineEnd = value.indexOf('\n', selectionStart);
112
+ if (-1 === lineEnd) lineEnd = value.length;
113
+ const currentLine = value.slice(lineStart, lineEnd);
114
+ const bulletMatch = BULLET_PREFIX.exec(currentLine);
115
+ if (bulletMatch) {
116
+ const indent = bulletMatch[1];
117
+ const prefix = `${indent}- `;
118
+ const contentAfterPrefix = currentLine.slice(bulletMatch[0].length);
119
+ if ('' === contentAfterPrefix.trim() && selectionStart === lineStart + currentLine.length) {
120
+ const newValue = value.slice(0, lineStart) + value.slice(lineEnd);
121
+ return {
122
+ value: newValue,
123
+ selectionStart: lineStart,
124
+ selectionEnd: lineStart
125
+ };
126
+ }
127
+ const newValue = `${value.slice(0, selectionStart)}\n${prefix}${value.slice(selectionStart)}`;
128
+ const newCursor = selectionStart + 1 + prefix.length;
129
+ return {
130
+ value: newValue,
131
+ selectionStart: newCursor,
132
+ selectionEnd: newCursor
133
+ };
134
+ }
135
+ const numberedMatch = NUMBERED_PREFIX_FULL.exec(currentLine);
136
+ if (numberedMatch) {
137
+ const indent = numberedMatch[1];
138
+ const currentNum = parseInt(numberedMatch[2], 10);
139
+ const contentAfterPrefix = currentLine.slice(numberedMatch[0].length);
140
+ if ('' === contentAfterPrefix.trim() && selectionStart === lineStart + currentLine.length) {
141
+ const newValue = value.slice(0, lineStart) + value.slice(lineEnd);
142
+ return {
143
+ value: newValue,
144
+ selectionStart: lineStart,
145
+ selectionEnd: lineStart
146
+ };
147
+ }
148
+ const prefix = `${indent}${currentNum + 1}. `;
149
+ const newValue = `${value.slice(0, selectionStart)}\n${prefix}${value.slice(selectionStart)}`;
150
+ const newCursor = selectionStart + 1 + prefix.length;
151
+ return {
152
+ value: newValue,
153
+ selectionStart: newCursor,
154
+ selectionEnd: newCursor
155
+ };
156
+ }
157
+ return null;
158
+ }
159
+ exports.BULLET_PREFIX = __webpack_exports__.BULLET_PREFIX;
160
+ exports.NUMBERED_PREFIX = __webpack_exports__.NUMBERED_PREFIX;
161
+ exports.NUMBERED_PREFIX_FULL = __webpack_exports__.NUMBERED_PREFIX_FULL;
162
+ exports.continueListOnEnter = __webpack_exports__.continueListOnEnter;
163
+ exports.toggleBulletList = __webpack_exports__.toggleBulletList;
164
+ exports.toggleNumberedList = __webpack_exports__.toggleNumberedList;
165
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
166
+ "BULLET_PREFIX",
167
+ "NUMBERED_PREFIX",
168
+ "NUMBERED_PREFIX_FULL",
169
+ "continueListOnEnter",
170
+ "toggleBulletList",
171
+ "toggleNumberedList"
172
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
173
+ Object.defineProperty(exports, '__esModule', {
174
+ value: true
175
+ });
@@ -0,0 +1,8 @@
1
+ import type { TextSelection } from '../StickyNoteNode.types';
2
+ export declare const BULLET_PREFIX: RegExp;
3
+ export declare const NUMBERED_PREFIX: RegExp;
4
+ export declare const NUMBERED_PREFIX_FULL: RegExp;
5
+ export declare function toggleBulletList(input: TextSelection): TextSelection;
6
+ export declare function toggleNumberedList(input: TextSelection): TextSelection;
7
+ export declare function continueListOnEnter(input: TextSelection): TextSelection | null;
8
+ //# sourceMappingURL=listFormatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listFormatting.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/StickyNoteNode/markdown-formatting/listFormatting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,eAAO,MAAM,aAAa,QAAc,CAAC;AACzC,eAAO,MAAM,eAAe,QAAkB,CAAC;AAC/C,eAAO,MAAM,oBAAoB,QAAoB,CAAC;AAetD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAsCpE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAoCtE;AAOD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,GAAG,IAAI,CA4C9E"}
@@ -0,0 +1,126 @@
1
+ const BULLET_PREFIX = /^(\s*)-\s/;
2
+ const NUMBERED_PREFIX = /^(\s*)\d+\.\s/;
3
+ const NUMBERED_PREFIX_FULL = /^(\s*)(\d+)\.\s/;
4
+ function getAffectedLines(value, selectionStart, selectionEnd) {
5
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
6
+ let lineEnd = value.indexOf('\n', selectionEnd);
7
+ if (-1 === lineEnd) lineEnd = value.length;
8
+ const linesText = value.slice(lineStart, lineEnd);
9
+ const lines = linesText.split('\n');
10
+ return {
11
+ lineStart,
12
+ lineEnd,
13
+ lines
14
+ };
15
+ }
16
+ function toggleBulletList(input) {
17
+ const { value, selectionStart, selectionEnd } = input;
18
+ const { lineStart, lineEnd, lines } = getAffectedLines(value, selectionStart, selectionEnd);
19
+ const allHaveBullet = lines.every((line)=>BULLET_PREFIX.test(line));
20
+ let newLines;
21
+ let prefixDelta;
22
+ if (allHaveBullet) {
23
+ newLines = lines.map((line)=>line.replace(BULLET_PREFIX, '$1'));
24
+ prefixDelta = lines[0].length - newLines[0].length;
25
+ } else {
26
+ newLines = lines.map((line)=>{
27
+ if (BULLET_PREFIX.test(line)) return line;
28
+ if (NUMBERED_PREFIX.test(line)) return line.replace(NUMBERED_PREFIX, '$1- ');
29
+ return `- ${line}`;
30
+ });
31
+ prefixDelta = newLines[0].length - lines[0].length;
32
+ }
33
+ const newLinesText = newLines.join('\n');
34
+ const newValue = value.slice(0, lineStart) + newLinesText + value.slice(lineEnd);
35
+ const totalLengthDelta = newLinesText.length - (lineEnd - lineStart);
36
+ const isMultiLine = lines.length > 1;
37
+ const newStart = allHaveBullet ? Math.max(lineStart, selectionStart - prefixDelta) : isMultiLine ? selectionStart : selectionStart + prefixDelta;
38
+ const newEnd = selectionEnd + totalLengthDelta;
39
+ return {
40
+ value: newValue,
41
+ selectionStart: newStart,
42
+ selectionEnd: Math.max(newStart, newEnd)
43
+ };
44
+ }
45
+ function toggleNumberedList(input) {
46
+ const { value, selectionStart, selectionEnd } = input;
47
+ const { lineStart, lineEnd, lines } = getAffectedLines(value, selectionStart, selectionEnd);
48
+ const allHaveNumbered = lines.every((line)=>NUMBERED_PREFIX.test(line));
49
+ let newLines;
50
+ let prefixDelta;
51
+ if (allHaveNumbered) {
52
+ newLines = lines.map((line)=>line.replace(NUMBERED_PREFIX, '$1'));
53
+ prefixDelta = lines[0].length - newLines[0].length;
54
+ } else {
55
+ newLines = lines.map((line, i)=>{
56
+ const num = `${i + 1}. `;
57
+ if (NUMBERED_PREFIX.test(line)) return line.replace(NUMBERED_PREFIX, `$1${num}`);
58
+ if (BULLET_PREFIX.test(line)) return line.replace(BULLET_PREFIX, `$1${num}`);
59
+ return `${num}${line}`;
60
+ });
61
+ prefixDelta = newLines[0].length - lines[0].length;
62
+ }
63
+ const newLinesText = newLines.join('\n');
64
+ const newValue = value.slice(0, lineStart) + newLinesText + value.slice(lineEnd);
65
+ const totalLengthDelta = newLinesText.length - (lineEnd - lineStart);
66
+ const newStart = allHaveNumbered ? Math.max(lineStart, selectionStart - prefixDelta) : selectionStart + prefixDelta;
67
+ const newEnd = selectionEnd + totalLengthDelta;
68
+ return {
69
+ value: newValue,
70
+ selectionStart: newStart,
71
+ selectionEnd: Math.max(newStart, newEnd)
72
+ };
73
+ }
74
+ function continueListOnEnter(input) {
75
+ const { value, selectionStart, selectionEnd } = input;
76
+ if (selectionStart !== selectionEnd) return null;
77
+ const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
78
+ let lineEnd = value.indexOf('\n', selectionStart);
79
+ if (-1 === lineEnd) lineEnd = value.length;
80
+ const currentLine = value.slice(lineStart, lineEnd);
81
+ const bulletMatch = BULLET_PREFIX.exec(currentLine);
82
+ if (bulletMatch) {
83
+ const indent = bulletMatch[1];
84
+ const prefix = `${indent}- `;
85
+ const contentAfterPrefix = currentLine.slice(bulletMatch[0].length);
86
+ if ('' === contentAfterPrefix.trim() && selectionStart === lineStart + currentLine.length) {
87
+ const newValue = value.slice(0, lineStart) + value.slice(lineEnd);
88
+ return {
89
+ value: newValue,
90
+ selectionStart: lineStart,
91
+ selectionEnd: lineStart
92
+ };
93
+ }
94
+ const newValue = `${value.slice(0, selectionStart)}\n${prefix}${value.slice(selectionStart)}`;
95
+ const newCursor = selectionStart + 1 + prefix.length;
96
+ return {
97
+ value: newValue,
98
+ selectionStart: newCursor,
99
+ selectionEnd: newCursor
100
+ };
101
+ }
102
+ const numberedMatch = NUMBERED_PREFIX_FULL.exec(currentLine);
103
+ if (numberedMatch) {
104
+ const indent = numberedMatch[1];
105
+ const currentNum = parseInt(numberedMatch[2], 10);
106
+ const contentAfterPrefix = currentLine.slice(numberedMatch[0].length);
107
+ if ('' === contentAfterPrefix.trim() && selectionStart === lineStart + currentLine.length) {
108
+ const newValue = value.slice(0, lineStart) + value.slice(lineEnd);
109
+ return {
110
+ value: newValue,
111
+ selectionStart: lineStart,
112
+ selectionEnd: lineStart
113
+ };
114
+ }
115
+ const prefix = `${indent}${currentNum + 1}. `;
116
+ const newValue = `${value.slice(0, selectionStart)}\n${prefix}${value.slice(selectionStart)}`;
117
+ const newCursor = selectionStart + 1 + prefix.length;
118
+ return {
119
+ value: newValue,
120
+ selectionStart: newCursor,
121
+ selectionEnd: newCursor
122
+ };
123
+ }
124
+ return null;
125
+ }
126
+ export { BULLET_PREFIX, NUMBERED_PREFIX, NUMBERED_PREFIX_FULL, continueListOnEnter, toggleBulletList, toggleNumberedList };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/apollo-react",
3
- "version": "3.66.1",
3
+ "version": "3.67.0",
4
4
  "description": "Apollo Design System - React component library with Material UI theming",
5
5
  "repository": {
6
6
  "type": "git",