@expensify/react-native-live-markdown 0.1.116 → 0.1.118

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 (90) hide show
  1. package/lib/commonjs/MarkdownTextInput.js +2 -4
  2. package/lib/commonjs/MarkdownTextInput.js.map +1 -1
  3. package/lib/commonjs/MarkdownTextInput.web.js +105 -149
  4. package/lib/commonjs/MarkdownTextInput.web.js.map +1 -1
  5. package/lib/commonjs/styleUtils.js.map +1 -1
  6. package/lib/commonjs/web/utils/blockUtils.js +77 -0
  7. package/lib/commonjs/web/utils/blockUtils.js.map +1 -0
  8. package/lib/commonjs/web/utils/browserUtils.js +18 -0
  9. package/lib/commonjs/web/utils/browserUtils.js.map +1 -0
  10. package/lib/commonjs/web/utils/cursorUtils.js +111 -0
  11. package/lib/commonjs/web/utils/cursorUtils.js.map +1 -0
  12. package/lib/commonjs/web/utils/inputUtils.js +108 -0
  13. package/lib/commonjs/web/utils/inputUtils.js.map +1 -0
  14. package/lib/commonjs/web/utils/parserUtils.js +266 -0
  15. package/lib/commonjs/web/utils/parserUtils.js.map +1 -0
  16. package/lib/commonjs/web/utils/treeUtils.js +85 -0
  17. package/lib/commonjs/web/utils/treeUtils.js.map +1 -0
  18. package/lib/commonjs/web/utils/webStyleUtils.js +51 -0
  19. package/lib/commonjs/web/utils/webStyleUtils.js.map +1 -0
  20. package/lib/module/MarkdownTextInput.js +2 -2
  21. package/lib/module/MarkdownTextInput.js.map +1 -1
  22. package/lib/module/MarkdownTextInput.web.js +101 -145
  23. package/lib/module/MarkdownTextInput.web.js.map +1 -1
  24. package/lib/module/styleUtils.js.map +1 -1
  25. package/lib/module/web/utils/blockUtils.js +72 -0
  26. package/lib/module/web/utils/blockUtils.js.map +1 -0
  27. package/lib/module/web/utils/browserUtils.js +12 -0
  28. package/lib/module/web/utils/browserUtils.js.map +1 -0
  29. package/lib/module/web/utils/cursorUtils.js +102 -0
  30. package/lib/module/web/utils/cursorUtils.js.map +1 -0
  31. package/lib/module/web/utils/inputUtils.js +99 -0
  32. package/lib/module/web/utils/inputUtils.js.map +1 -0
  33. package/lib/module/web/utils/parserUtils.js +260 -0
  34. package/lib/module/web/utils/parserUtils.js.map +1 -0
  35. package/lib/module/web/utils/treeUtils.js +78 -0
  36. package/lib/module/web/utils/treeUtils.js.map +1 -0
  37. package/lib/module/web/utils/webStyleUtils.js +45 -0
  38. package/lib/module/web/utils/webStyleUtils.js.map +1 -0
  39. package/lib/typescript/src/MarkdownTextInput.d.ts +1 -2
  40. package/lib/typescript/src/MarkdownTextInput.d.ts.map +1 -1
  41. package/lib/typescript/src/MarkdownTextInput.web.d.ts +9 -3
  42. package/lib/typescript/src/MarkdownTextInput.web.d.ts.map +1 -1
  43. package/lib/typescript/src/styleUtils.d.ts +1 -2
  44. package/lib/typescript/src/styleUtils.d.ts.map +1 -1
  45. package/lib/typescript/src/web/utils/blockUtils.d.ts +5 -0
  46. package/lib/typescript/src/web/utils/blockUtils.d.ts.map +1 -0
  47. package/lib/typescript/src/web/utils/browserUtils.d.ts +12 -0
  48. package/lib/typescript/src/web/utils/browserUtils.d.ts.map +1 -0
  49. package/lib/typescript/src/web/utils/cursorUtils.d.ts +12 -0
  50. package/lib/typescript/src/web/utils/cursorUtils.d.ts.map +1 -0
  51. package/lib/typescript/src/web/utils/inputUtils.d.ts +9 -0
  52. package/lib/typescript/src/web/utils/inputUtils.d.ts.map +1 -0
  53. package/lib/typescript/src/web/utils/parserUtils.d.ts +22 -0
  54. package/lib/typescript/src/web/utils/parserUtils.d.ts.map +1 -0
  55. package/lib/typescript/src/web/utils/treeUtils.d.ts +17 -0
  56. package/lib/typescript/src/web/utils/treeUtils.d.ts.map +1 -0
  57. package/lib/typescript/src/web/utils/webStyleUtils.d.ts +6 -0
  58. package/lib/typescript/src/web/utils/webStyleUtils.d.ts.map +1 -0
  59. package/package.json +5 -2
  60. package/src/MarkdownTextInput.tsx +4 -7
  61. package/src/MarkdownTextInput.web.tsx +142 -171
  62. package/src/styleUtils.ts +1 -3
  63. package/src/web/utils/blockUtils.ts +72 -0
  64. package/src/web/utils/browserUtils.ts +13 -0
  65. package/src/web/utils/cursorUtils.ts +116 -0
  66. package/src/web/utils/inputUtils.ts +106 -0
  67. package/src/web/utils/parserUtils.ts +302 -0
  68. package/src/web/utils/treeUtils.ts +103 -0
  69. package/src/web/utils/webStyleUtils.ts +54 -0
  70. package/lib/commonjs/web/browserUtils.js +0 -16
  71. package/lib/commonjs/web/browserUtils.js.map +0 -1
  72. package/lib/commonjs/web/cursorUtils.js +0 -167
  73. package/lib/commonjs/web/cursorUtils.js.map +0 -1
  74. package/lib/commonjs/web/parserUtils.js +0 -214
  75. package/lib/commonjs/web/parserUtils.js.map +0 -1
  76. package/lib/module/web/browserUtils.js +0 -11
  77. package/lib/module/web/browserUtils.js.map +0 -1
  78. package/lib/module/web/cursorUtils.js +0 -154
  79. package/lib/module/web/cursorUtils.js.map +0 -1
  80. package/lib/module/web/parserUtils.js +0 -206
  81. package/lib/module/web/parserUtils.js.map +0 -1
  82. package/lib/typescript/src/web/browserUtils.d.ts +0 -10
  83. package/lib/typescript/src/web/browserUtils.d.ts.map +0 -1
  84. package/lib/typescript/src/web/cursorUtils.d.ts +0 -12
  85. package/lib/typescript/src/web/cursorUtils.d.ts.map +0 -1
  86. package/lib/typescript/src/web/parserUtils.d.ts +0 -17
  87. package/lib/typescript/src/web/parserUtils.d.ts.map +0 -1
  88. package/src/web/browserUtils.ts +0 -11
  89. package/src/web/cursorUtils.ts +0 -177
  90. package/src/web/parserUtils.ts +0 -228
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isMobile = exports.isFirefox = exports.isChromium = void 0;
7
- const isFirefox = exports.isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
8
- const isChromium = exports.isChromium = 'chrome' in window;
9
-
10
- /**
11
- * Whether the platform is a mobile browser.
12
- * Copied from Expensify App https://github.com/Expensify/App/blob/90dee7accae79c49debf30354c160cab6c52c423/src/libs/Browser/index.website.ts#L41
13
- *
14
- */
15
- const isMobile = exports.isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent);
16
- //# sourceMappingURL=browserUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isFirefox","exports","navigator","userAgent","toLowerCase","includes","isChromium","window","isMobile","test"],"sourceRoot":"../../../src","sources":["web/browserUtils.ts"],"mappings":";;;;;;AAAA,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAGE,SAAS,CAACC,SAAS,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,SAAS,CAAC;AACvE,MAAMC,UAAU,GAAAL,OAAA,CAAAK,UAAA,GAAG,QAAQ,IAAIC,MAAM;;AAErC;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAAP,OAAA,CAAAO,QAAA,GAAG,+FAA+F,CAACC,IAAI,CAACP,SAAS,CAACC,SAAS,CAAC"}
@@ -1,167 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getCurrentCursorPosition = getCurrentCursorPosition;
7
- exports.getPrevTextLength = getPrevTextLength;
8
- exports.moveCursorToEnd = moveCursorToEnd;
9
- exports.removeSelection = removeSelection;
10
- exports.scrollCursorIntoView = scrollCursorIntoView;
11
- exports.setCursorPosition = setCursorPosition;
12
- exports.setPrevText = setPrevText;
13
- var BrowserUtils = _interopRequireWildcard(require("./browserUtils"));
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- let prevTextLength;
17
- function getPrevTextLength() {
18
- return prevTextLength;
19
- }
20
- function findTextNodes(textNodes, node) {
21
- if (node.nodeType === Node.TEXT_NODE) {
22
- textNodes.push(node);
23
- } else {
24
- for (let i = 0, length = node.childNodes.length; i < length; ++i) {
25
- const childNode = node.childNodes[i];
26
- if (childNode) {
27
- findTextNodes(textNodes, childNode);
28
- }
29
- }
30
- }
31
- }
32
- function setPrevText(target) {
33
- var _textNodes$map;
34
- let text = [];
35
- const textNodes = [];
36
- findTextNodes(textNodes, target);
37
- text = (_textNodes$map = textNodes.map(e => e.nodeValue ?? '')) === null || _textNodes$map === void 0 || (_textNodes$map = _textNodes$map.join('')) === null || _textNodes$map === void 0 ? void 0 : _textNodes$map.split('');
38
- prevTextLength = text.length;
39
- }
40
- function setCursorPosition(target, start, end = null) {
41
- var _textNodes$map2;
42
- // We don't want to move the cursor if the target is not focused
43
- if (target !== document.activeElement) {
44
- return;
45
- }
46
- const range = document.createRange();
47
- range.selectNodeContents(target);
48
- const textNodes = [];
49
- findTextNodes(textNodes, target);
50
-
51
- // These are utilities for handling the boundary cases (especially onEnter)
52
- // prevChar & nextChar are characters before & after the target cursor position
53
- const textCharacters = (_textNodes$map2 = textNodes.map(e => e.nodeValue ?? '')) === null || _textNodes$map2 === void 0 || (_textNodes$map2 = _textNodes$map2.join('')) === null || _textNodes$map2 === void 0 ? void 0 : _textNodes$map2.split('');
54
- const prevChar = (textCharacters === null || textCharacters === void 0 ? void 0 : textCharacters[start - 1]) ?? '';
55
- const nextChar = (textCharacters === null || textCharacters === void 0 ? void 0 : textCharacters[start]) ?? '';
56
- let charCount = 0;
57
- let startNode = null;
58
- let endNode = null;
59
- const n = textNodes.length;
60
- for (let i = 0; i < n; ++i) {
61
- const textNode = textNodes[i];
62
- if (textNode) {
63
- const nextCharCount = charCount + textNode.length;
64
- if (!startNode && start >= charCount && (start <= nextCharCount || start === nextCharCount && i < n - 1)) {
65
- startNode = textNode;
66
-
67
- // There are 4 cases to consider here:
68
- // 1. Caret in front of a character, when pressing enter
69
- // 2. Caret at the end of a line (not last one)
70
- // 3. Caret at the end of whole input, when pressing enter
71
- // 4. All other placements
72
- if (prevChar === '\n' && prevTextLength !== undefined && prevTextLength < textCharacters.length) {
73
- if (nextChar && nextChar !== '\n' && i !== n - 1) {
74
- range.setStart(textNodes[i + 1], 0);
75
- } else if (i !== textNodes.length - 1) {
76
- range.setStart(textNodes[i], 1);
77
- } else {
78
- range.setStart(textNode, start - charCount);
79
- }
80
- } else {
81
- range.setStart(textNode, start - charCount);
82
- }
83
- if (!end) {
84
- break;
85
- }
86
- }
87
- if (end && !endNode && end >= charCount && (end <= nextCharCount || end === nextCharCount && i < n - 1)) {
88
- endNode = textNode;
89
- range.setEnd(textNode, end - charCount);
90
- }
91
- charCount = nextCharCount;
92
- }
93
- }
94
- if (!end) {
95
- range.collapse(true);
96
- }
97
- const selection = window.getSelection();
98
- if (selection) {
99
- selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
100
- }
101
- scrollCursorIntoView(target);
102
- }
103
- function moveCursorToEnd(target) {
104
- const range = document.createRange();
105
- const selection = window.getSelection();
106
- if (selection) {
107
- range.setStart(target, target.childNodes.length);
108
- range.collapse(true);
109
- selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
110
- }
111
- }
112
- function getCurrentCursorPosition(target) {
113
- const selection = window.getSelection();
114
- if (!selection || selection && selection.rangeCount === 0) {
115
- return null;
116
- }
117
- const range = selection.getRangeAt(0);
118
- const preSelectionRange = range.cloneRange();
119
- preSelectionRange.selectNodeContents(target);
120
- preSelectionRange.setEnd(range.startContainer, range.startOffset);
121
- const start = preSelectionRange.toString().length;
122
- const end = start + range.toString().length;
123
- return {
124
- start,
125
- end
126
- };
127
- }
128
- function removeSelection() {
129
- const selection = window.getSelection();
130
- if (selection) {
131
- selection.removeAllRanges();
132
- }
133
- }
134
- function scrollCursorIntoView(target) {
135
- if (target.selectionStart === null || !target.value || BrowserUtils.isFirefox) {
136
- return;
137
- }
138
- const selection = window.getSelection();
139
- if (!selection || selection && selection.rangeCount === 0) {
140
- return;
141
- }
142
- const caretRects = selection.getRangeAt(0).getClientRects();
143
-
144
- // we'll find the caretRect from the DOMRectList above with the largest bottom value
145
- let currentCaretRect = caretRects[0];
146
- if (currentCaretRect) {
147
- for (let i = 1; i < caretRects.length; i++) {
148
- const caretRect = caretRects[i];
149
- if (caretRect && caretRect.bottom > currentCaretRect.bottom) {
150
- currentCaretRect = caretRect;
151
- }
152
- }
153
- }
154
- const editableRect = target.getBoundingClientRect();
155
-
156
- // Adjust for padding and border
157
- const paddingTop = parseFloat(window.getComputedStyle(target).paddingTop);
158
- const borderTop = parseFloat(window.getComputedStyle(target).borderTopWidth);
159
- if (currentCaretRect && !(currentCaretRect.top >= editableRect.top + paddingTop + borderTop && currentCaretRect.bottom <= editableRect.bottom - 2 * (paddingTop - borderTop))) {
160
- const topToCaret = currentCaretRect.top - editableRect.top;
161
- const inputHeight = editableRect.height;
162
- // Chrome Rects don't include padding & border, so we're adding them manually
163
- const inputOffset = currentCaretRect.height - inputHeight + paddingTop + borderTop + (BrowserUtils.isChromium ? 0 : 4 * (paddingTop + borderTop));
164
- target.scrollTo(0, topToCaret + target.scrollTop + inputOffset);
165
- }
166
- }
167
- //# sourceMappingURL=cursorUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["BrowserUtils","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","prevTextLength","getPrevTextLength","findTextNodes","textNodes","node","nodeType","Node","TEXT_NODE","push","length","childNodes","childNode","setPrevText","target","_textNodes$map","text","map","nodeValue","join","split","setCursorPosition","start","end","_textNodes$map2","document","activeElement","range","createRange","selectNodeContents","textCharacters","prevChar","nextChar","charCount","startNode","endNode","textNode","nextCharCount","undefined","setStart","setEnd","collapse","selection","window","getSelection","setBaseAndExtent","startContainer","startOffset","endContainer","endOffset","scrollCursorIntoView","moveCursorToEnd","getCurrentCursorPosition","rangeCount","getRangeAt","preSelectionRange","cloneRange","toString","removeSelection","removeAllRanges","selectionStart","value","isFirefox","caretRects","getClientRects","currentCaretRect","caretRect","bottom","editableRect","getBoundingClientRect","paddingTop","parseFloat","getComputedStyle","borderTop","borderTopWidth","top","topToCaret","inputHeight","height","inputOffset","isChromium","scrollTo","scrollTop"],"sourceRoot":"../../../src","sources":["web/cursorUtils.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+C,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAA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es;
7
- exports.parseText = parseText;
8
- var CursorUtils = _interopRequireWildcard(require("./cursorUtils"));
9
- var BrowserUtils = _interopRequireWildcard(require("./browserUtils"));
10
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
- function addStyling(targetElement, type, markdownStyle) {
13
- const node = targetElement;
14
- switch (type) {
15
- case 'syntax':
16
- Object.assign(node.style, markdownStyle.syntax);
17
- break;
18
- case 'bold':
19
- node.style.fontWeight = 'bold';
20
- break;
21
- case 'italic':
22
- node.style.fontStyle = 'italic';
23
- break;
24
- case 'strikethrough':
25
- node.style.textDecoration = 'line-through';
26
- break;
27
- case 'emoji':
28
- Object.assign(node.style, {
29
- ...markdownStyle.emoji,
30
- verticalAlign: 'middle'
31
- });
32
- break;
33
- case 'mention-here':
34
- Object.assign(node.style, markdownStyle.mentionHere);
35
- break;
36
- case 'mention-user':
37
- Object.assign(node.style, markdownStyle.mentionUser);
38
- break;
39
- case 'mention-report':
40
- Object.assign(node.style, markdownStyle.mentionReport);
41
- break;
42
- case 'link':
43
- Object.assign(node.style, {
44
- ...markdownStyle.link,
45
- textDecoration: 'underline'
46
- });
47
- break;
48
- case 'code':
49
- Object.assign(node.style, markdownStyle.code);
50
- break;
51
- case 'pre':
52
- Object.assign(node.style, markdownStyle.pre);
53
- break;
54
- case 'blockquote':
55
- Object.assign(node.style, {
56
- ...markdownStyle.blockquote,
57
- borderLeftStyle: 'solid',
58
- display: 'inline-block',
59
- maxWidth: '100%',
60
- boxSizing: 'border-box'
61
- });
62
- break;
63
- case 'h1':
64
- Object.assign(node.style, {
65
- ...markdownStyle.h1,
66
- fontWeight: 'bold'
67
- });
68
- break;
69
- default:
70
- break;
71
- }
72
- }
73
- function addSubstringAsTextNode(root, text, startIndex, endIndex) {
74
- const substring = text.substring(startIndex, endIndex);
75
- if (substring.length > 0) {
76
- root.appendChild(document.createTextNode(substring));
77
- }
78
- }
79
- function ungroupRanges(ranges) {
80
- const ungroupedRanges = [];
81
- ranges.forEach(range => {
82
- if (!range.depth) {
83
- ungroupedRanges.push(range);
84
- }
85
- const {
86
- depth,
87
- ...rangeWithoutDepth
88
- } = range;
89
- Array.from({
90
- length: depth
91
- }).forEach(() => {
92
- ungroupedRanges.push(rangeWithoutDepth);
93
- });
94
- });
95
- return ungroupedRanges;
96
- }
97
- function parseRangesToHTMLNodes(text, ranges, markdownStyle = {}, disableInlineStyles = false) {
98
- const root = document.createElement('span');
99
- root.className = 'root';
100
- const textLength = text.length;
101
- if (ranges.length === 0) {
102
- addSubstringAsTextNode(root, text, 0, textLength);
103
- return root;
104
- }
105
- const stack = ungroupRanges(ranges);
106
- const nestedStack = [{
107
- node: root,
108
- endIndex: textLength
109
- }];
110
- let lastRangeEndIndex = 0;
111
- while (stack.length > 0) {
112
- const range = stack.shift();
113
- if (!range) {
114
- break;
115
- }
116
- let currentRoot = nestedStack[nestedStack.length - 1];
117
- if (!currentRoot) {
118
- break;
119
- }
120
- const endOfCurrentRange = range.start + range.length;
121
- const nextRangeStartIndex = stack.length > 0 && !!stack[0] ? stack[0].start || 0 : textLength;
122
- addSubstringAsTextNode(currentRoot.node, text, lastRangeEndIndex, range.start); // add text with newlines before current range
123
-
124
- const span = document.createElement('span');
125
- if (disableInlineStyles) {
126
- span.className = range.type;
127
- } else {
128
- addStyling(span, range.type, markdownStyle);
129
- }
130
- if (stack.length > 0 && nextRangeStartIndex < endOfCurrentRange && range.type !== 'syntax') {
131
- // tag nesting
132
- currentRoot.node.appendChild(span);
133
- nestedStack.push({
134
- node: span,
135
- endIndex: endOfCurrentRange
136
- });
137
- lastRangeEndIndex = range.start;
138
- } else {
139
- addSubstringAsTextNode(span, text, range.start, endOfCurrentRange);
140
- currentRoot.node.appendChild(span);
141
- lastRangeEndIndex = endOfCurrentRange;
142
-
143
- // end of tag nesting
144
- while (nestedStack.length - 1 > 0 && nextRangeStartIndex >= currentRoot.endIndex) {
145
- addSubstringAsTextNode(currentRoot.node, text, lastRangeEndIndex, currentRoot.endIndex);
146
- const prevRoot = nestedStack.pop();
147
- if (!prevRoot) {
148
- break;
149
- }
150
- lastRangeEndIndex = prevRoot.endIndex;
151
- currentRoot = nestedStack[nestedStack.length - 1] || currentRoot;
152
- }
153
- }
154
- }
155
- if (nestedStack.length > 1) {
156
- const lastNestedNode = nestedStack[nestedStack.length - 1];
157
- if (lastNestedNode) {
158
- root.appendChild(lastNestedNode.node);
159
- }
160
- }
161
- addSubstringAsTextNode(root, text, lastRangeEndIndex, textLength);
162
- return root;
163
- }
164
- function moveCursor(isFocused, alwaysMoveCursorToTheEnd, cursorPosition, target) {
165
- if (!isFocused) {
166
- return;
167
- }
168
- if (alwaysMoveCursorToTheEnd || cursorPosition === null) {
169
- CursorUtils.moveCursorToEnd(target);
170
- } else if (cursorPosition !== null) {
171
- CursorUtils.setCursorPosition(target, cursorPosition);
172
- }
173
- }
174
- function parseText(target, text, cursorPositionIndex, markdownStyle = {}, alwaysMoveCursorToTheEnd = false) {
175
- const targetElement = target;
176
-
177
- // in case the cursorPositionIndex is larger than text length, cursorPosition will be null, i.e: move the caret to the end
178
- let cursorPosition = cursorPositionIndex && cursorPositionIndex <= text.length ? cursorPositionIndex : null;
179
- const isFocused = document.activeElement === target;
180
- if (isFocused && cursorPositionIndex === null) {
181
- const selection = CursorUtils.getCurrentCursorPosition(target);
182
- cursorPosition = selection ? selection.end : null;
183
- }
184
- const ranges = global.parseExpensiMarkToRanges(text);
185
- const markdownRanges = ranges;
186
- const rootSpan = targetElement.firstChild;
187
- if (!text || targetElement.innerHTML === '<br>' || rootSpan && rootSpan.innerHTML === '\n') {
188
- targetElement.innerHTML = '';
189
- targetElement.innerText = '';
190
- }
191
-
192
- // We don't want to parse text with single '\n', because contentEditable represents it as invisible <br />
193
- if (text) {
194
- var _rootSpan$classList;
195
- const dom = parseRangesToHTMLNodes(text, markdownRanges, markdownStyle);
196
- if (!rootSpan || !(rootSpan !== null && rootSpan !== void 0 && (_rootSpan$classList = rootSpan.classList) !== null && _rootSpan$classList !== void 0 && _rootSpan$classList.contains('root')) || rootSpan.innerHTML !== dom.innerHTML) {
197
- targetElement.innerHTML = '';
198
- targetElement.innerText = '';
199
- target.appendChild(dom);
200
- if (BrowserUtils.isChromium) {
201
- moveCursor(isFocused, alwaysMoveCursorToTheEnd, cursorPosition, target);
202
- }
203
- }
204
- if (!BrowserUtils.isChromium) {
205
- moveCursor(isFocused, alwaysMoveCursorToTheEnd, cursorPosition, target);
206
- }
207
- }
208
- CursorUtils.setPrevText(target);
209
- return {
210
- text: target.innerText,
211
- cursorPosition: cursorPosition || 0
212
- };
213
- }
214
- //# sourceMappingURL=parserUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CursorUtils","_interopRequireWildcard","require","BrowserUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","addStyling","targetElement","type","markdownStyle","node","assign","style","syntax","fontWeight","fontStyle","textDecoration","emoji","verticalAlign","mentionHere","mentionUser","mentionReport","link","code","pre","blockquote","borderLeftStyle","display","maxWidth","boxSizing","h1","addSubstringAsTextNode","root","text","startIndex","endIndex","substring","length","appendChild","document","createTextNode","ungroupRanges","ranges","ungroupedRanges","forEach","range","depth","push","rangeWithoutDepth","Array","from","parseRangesToHTMLNodes","disableInlineStyles","createElement","className","textLength","stack","nestedStack","lastRangeEndIndex","shift","currentRoot","endOfCurrentRange","start","nextRangeStartIndex","span","prevRoot","pop","lastNestedNode","moveCursor","isFocused","alwaysMoveCursorToTheEnd","cursorPosition","target","moveCursorToEnd","setCursorPosition","parseText","cursorPositionIndex","activeElement","selection","getCurrentCursorPosition","end","global","parseExpensiMarkToRanges","markdownRanges","rootSpan","firstChild","innerHTML","innerText","_rootSpan$classList","dom","classList","contains","isChromium","setPrevText"],"sourceRoot":"../../../src","sources":["web/parserUtils.ts"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,uBAAA,CAAAC,OAAA;AAA+C,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CA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AEC,wBAAwB,EAAEC,cAAc,EAAEC,MAAM,CAAC;MACzE;IACF;IAEA,IAAI,CAACxF,YAAY,CAAC4G,UAAU,EAAE;MAC5BxB,UAAU,CAACC,SAAS,EAAEC,wBAAwB,EAAEC,cAAc,EAAEC,MAAM,CAAC;IACzE;EACF;EAEA3F,WAAW,CAACgH,WAAW,CAACrB,MAAM,CAAC;EAE/B,OAAO;IAACvC,IAAI,EAAEuC,MAAM,CAACe,SAAS;IAAEhB,cAAc,EAAEA,cAAc,IAAI;EAAC,CAAC;AACtE"}
@@ -1,11 +0,0 @@
1
- const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
2
- const isChromium = ('chrome' in window);
3
-
4
- /**
5
- * Whether the platform is a mobile browser.
6
- * Copied from Expensify App https://github.com/Expensify/App/blob/90dee7accae79c49debf30354c160cab6c52c423/src/libs/Browser/index.website.ts#L41
7
- *
8
- */
9
- const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent);
10
- export { isFirefox, isChromium, isMobile };
11
- //# sourceMappingURL=browserUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isFirefox","navigator","userAgent","toLowerCase","includes","isChromium","window","isMobile","test"],"sourceRoot":"../../../src","sources":["web/browserUtils.ts"],"mappings":"AAAA,MAAMA,SAAS,GAAGC,SAAS,CAACC,SAAS,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,SAAS,CAAC;AACvE,MAAMC,UAAU,IAAG,QAAQ,IAAIC,MAAM;;AAErC;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAG,+FAA+F,CAACC,IAAI,CAACP,SAAS,CAACC,SAAS,CAAC;AAE1I,SAAQF,SAAS,EAAEK,UAAU,EAAEE,QAAQ"}
@@ -1,154 +0,0 @@
1
- import * as BrowserUtils from './browserUtils';
2
- let prevTextLength;
3
- function getPrevTextLength() {
4
- return prevTextLength;
5
- }
6
- function findTextNodes(textNodes, node) {
7
- if (node.nodeType === Node.TEXT_NODE) {
8
- textNodes.push(node);
9
- } else {
10
- for (let i = 0, length = node.childNodes.length; i < length; ++i) {
11
- const childNode = node.childNodes[i];
12
- if (childNode) {
13
- findTextNodes(textNodes, childNode);
14
- }
15
- }
16
- }
17
- }
18
- function setPrevText(target) {
19
- var _textNodes$map;
20
- let text = [];
21
- const textNodes = [];
22
- findTextNodes(textNodes, target);
23
- text = (_textNodes$map = textNodes.map(e => e.nodeValue ?? '')) === null || _textNodes$map === void 0 || (_textNodes$map = _textNodes$map.join('')) === null || _textNodes$map === void 0 ? void 0 : _textNodes$map.split('');
24
- prevTextLength = text.length;
25
- }
26
- function setCursorPosition(target, start, end = null) {
27
- var _textNodes$map2;
28
- // We don't want to move the cursor if the target is not focused
29
- if (target !== document.activeElement) {
30
- return;
31
- }
32
- const range = document.createRange();
33
- range.selectNodeContents(target);
34
- const textNodes = [];
35
- findTextNodes(textNodes, target);
36
-
37
- // These are utilities for handling the boundary cases (especially onEnter)
38
- // prevChar & nextChar are characters before & after the target cursor position
39
- const textCharacters = (_textNodes$map2 = textNodes.map(e => e.nodeValue ?? '')) === null || _textNodes$map2 === void 0 || (_textNodes$map2 = _textNodes$map2.join('')) === null || _textNodes$map2 === void 0 ? void 0 : _textNodes$map2.split('');
40
- const prevChar = (textCharacters === null || textCharacters === void 0 ? void 0 : textCharacters[start - 1]) ?? '';
41
- const nextChar = (textCharacters === null || textCharacters === void 0 ? void 0 : textCharacters[start]) ?? '';
42
- let charCount = 0;
43
- let startNode = null;
44
- let endNode = null;
45
- const n = textNodes.length;
46
- for (let i = 0; i < n; ++i) {
47
- const textNode = textNodes[i];
48
- if (textNode) {
49
- const nextCharCount = charCount + textNode.length;
50
- if (!startNode && start >= charCount && (start <= nextCharCount || start === nextCharCount && i < n - 1)) {
51
- startNode = textNode;
52
-
53
- // There are 4 cases to consider here:
54
- // 1. Caret in front of a character, when pressing enter
55
- // 2. Caret at the end of a line (not last one)
56
- // 3. Caret at the end of whole input, when pressing enter
57
- // 4. All other placements
58
- if (prevChar === '\n' && prevTextLength !== undefined && prevTextLength < textCharacters.length) {
59
- if (nextChar && nextChar !== '\n' && i !== n - 1) {
60
- range.setStart(textNodes[i + 1], 0);
61
- } else if (i !== textNodes.length - 1) {
62
- range.setStart(textNodes[i], 1);
63
- } else {
64
- range.setStart(textNode, start - charCount);
65
- }
66
- } else {
67
- range.setStart(textNode, start - charCount);
68
- }
69
- if (!end) {
70
- break;
71
- }
72
- }
73
- if (end && !endNode && end >= charCount && (end <= nextCharCount || end === nextCharCount && i < n - 1)) {
74
- endNode = textNode;
75
- range.setEnd(textNode, end - charCount);
76
- }
77
- charCount = nextCharCount;
78
- }
79
- }
80
- if (!end) {
81
- range.collapse(true);
82
- }
83
- const selection = window.getSelection();
84
- if (selection) {
85
- selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
86
- }
87
- scrollCursorIntoView(target);
88
- }
89
- function moveCursorToEnd(target) {
90
- const range = document.createRange();
91
- const selection = window.getSelection();
92
- if (selection) {
93
- range.setStart(target, target.childNodes.length);
94
- range.collapse(true);
95
- selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
96
- }
97
- }
98
- function getCurrentCursorPosition(target) {
99
- const selection = window.getSelection();
100
- if (!selection || selection && selection.rangeCount === 0) {
101
- return null;
102
- }
103
- const range = selection.getRangeAt(0);
104
- const preSelectionRange = range.cloneRange();
105
- preSelectionRange.selectNodeContents(target);
106
- preSelectionRange.setEnd(range.startContainer, range.startOffset);
107
- const start = preSelectionRange.toString().length;
108
- const end = start + range.toString().length;
109
- return {
110
- start,
111
- end
112
- };
113
- }
114
- function removeSelection() {
115
- const selection = window.getSelection();
116
- if (selection) {
117
- selection.removeAllRanges();
118
- }
119
- }
120
- function scrollCursorIntoView(target) {
121
- if (target.selectionStart === null || !target.value || BrowserUtils.isFirefox) {
122
- return;
123
- }
124
- const selection = window.getSelection();
125
- if (!selection || selection && selection.rangeCount === 0) {
126
- return;
127
- }
128
- const caretRects = selection.getRangeAt(0).getClientRects();
129
-
130
- // we'll find the caretRect from the DOMRectList above with the largest bottom value
131
- let currentCaretRect = caretRects[0];
132
- if (currentCaretRect) {
133
- for (let i = 1; i < caretRects.length; i++) {
134
- const caretRect = caretRects[i];
135
- if (caretRect && caretRect.bottom > currentCaretRect.bottom) {
136
- currentCaretRect = caretRect;
137
- }
138
- }
139
- }
140
- const editableRect = target.getBoundingClientRect();
141
-
142
- // Adjust for padding and border
143
- const paddingTop = parseFloat(window.getComputedStyle(target).paddingTop);
144
- const borderTop = parseFloat(window.getComputedStyle(target).borderTopWidth);
145
- if (currentCaretRect && !(currentCaretRect.top >= editableRect.top + paddingTop + borderTop && currentCaretRect.bottom <= editableRect.bottom - 2 * (paddingTop - borderTop))) {
146
- const topToCaret = currentCaretRect.top - editableRect.top;
147
- const inputHeight = editableRect.height;
148
- // Chrome Rects don't include padding & border, so we're adding them manually
149
- const inputOffset = currentCaretRect.height - inputHeight + paddingTop + borderTop + (BrowserUtils.isChromium ? 0 : 4 * (paddingTop + borderTop));
150
- target.scrollTo(0, topToCaret + target.scrollTop + inputOffset);
151
- }
152
- }
153
- export { getCurrentCursorPosition, moveCursorToEnd, setCursorPosition, setPrevText, removeSelection, scrollCursorIntoView, getPrevTextLength };
154
- //# sourceMappingURL=cursorUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["BrowserUtils","prevTextLength","getPrevTextLength","findTextNodes","textNodes","node","nodeType","Node","TEXT_NODE","push","i","length","childNodes","childNode","setPrevText","target","_textNodes$map","text","map","e","nodeValue","join","split","setCursorPosition","start","end","_textNodes$map2","document","activeElement","range","createRange","selectNodeContents","textCharacters","prevChar","nextChar","charCount","startNode","endNode","n","textNode","nextCharCount","undefined","setStart","setEnd","collapse","selection","window","getSelection","setBaseAndExtent","startContainer","startOffset","endContainer","endOffset","scrollCursorIntoView","moveCursorToEnd","getCurrentCursorPosition","rangeCount","getRangeAt","preSelectionRange","cloneRange","toString","removeSelection","removeAllRanges","selectionStart","value","isFirefox","caretRects","getClientRects","currentCaretRect","caretRect","bottom","editableRect","getBoundingClientRect","paddingTop","parseFloat","getComputedStyle","borderTop","borderTopWidth","top","topToCaret","inputHeight","height","inputOffset","isChromium","scrollTo","scrollTop"],"sourceRoot":"../../../src","sources":["web/cursorUtils.ts"],"mappings":"AAAA,OAAO,KAAKA,YAAY,MAAM,gBAAgB;AAE9C,IAAIC,cAAkC;AAEtC,SAASC,iBAAiBA,CAAA,EAAG;EAC3B,OAAOD,cAAc;AACvB;AAEA,SAASE,aAAaA,CAACC,SAAiB,EAAEC,IAAe,EAAE;EACzD,IAAIA,IAAI,CAACC,QAAQ,KAAKC,IAAI,CAACC,SAAS,EAAE;IACpCJ,SAAS,CAACK,IAAI,CAACJ,IAAY,CAAC;EAC9B,CAAC,MAAM;IACL,KAAK,IAAIK,CAAC,GAAG,CAAC,EAAEC,MAAM,GAAGN,IAAI,CAACO,UAAU,CAACD,MAAM,EAAED,CAAC,GAAGC,MAAM,EAAE,EAAED,CAAC,EAAE;MAChE,MAAMG,SAAS,GAAGR,IAAI,CAACO,UAAU,CAACF,CAAC,CAAC;MACpC,IAAIG,SAAS,EAAE;QACbV,aAAa,CAACC,SAAS,EAAES,SAAS,CAAC;MACrC;IACF;EACF;AACF;AAEA,SAASC,WAAWA,CAACC,MAAmB,EAAE;EAAA,IAAAC,cAAA;EACxC,IAAIC,IAAI,GAAG,EAAE;EACb,MAAMb,SAAiB,GAAG,EAAE;EAC5BD,aAAa,CAACC,SAAS,EAAEW,MAAM,CAAC;EAChCE,IAAI,IAAAD,cAAA,GAAGZ,SAAS,CACbc,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACC,SAAS,IAAI,EAAE,CAAC,cAAAJ,cAAA,gBAAAA,cAAA,GADzBA,cAAA,CAEHK,IAAI,CAAC,EAAE,CAAC,cAAAL,cAAA,uBAFLA,cAAA,CAGHM,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