react-native-simple-rich-text-editor 0.1.0-beta.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.
- package/LICENSE +20 -0
- package/README.md +69 -0
- package/lib/commonjs/index.js +166 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/rendering/components/Bold.js +23 -0
- package/lib/commonjs/internal/rendering/components/Bold.js.map +1 -0
- package/lib/commonjs/internal/rendering/components/BulletPoint.js +30 -0
- package/lib/commonjs/internal/rendering/components/BulletPoint.js.map +1 -0
- package/lib/commonjs/internal/rendering/components/Headline.js +37 -0
- package/lib/commonjs/internal/rendering/components/Headline.js.map +1 -0
- package/lib/commonjs/internal/rendering/components/Italic.js +23 -0
- package/lib/commonjs/internal/rendering/components/Italic.js.map +1 -0
- package/lib/commonjs/internal/rendering/components/Render.js +99 -0
- package/lib/commonjs/internal/rendering/components/Render.js.map +1 -0
- package/lib/commonjs/internal/rendering/utils.js +19 -0
- package/lib/commonjs/internal/rendering/utils.js.map +1 -0
- package/lib/commonjs/internal/text-formats/conversions.js +47 -0
- package/lib/commonjs/internal/text-formats/conversions.js.map +1 -0
- package/lib/commonjs/internal/text-formats/markdown-format.js +2 -0
- package/lib/commonjs/internal/text-formats/markdown-format.js.map +1 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/constants.js +48 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/constants.js.map +1 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/encode-decode.js +65 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/encode-decode.js.map +1 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/markers.js +19 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/markers.js.map +1 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/text-manipulation.js +124 -0
- package/lib/commonjs/internal/text-formats/unicode-markers-format/text-manipulation.js.map +1 -0
- package/lib/module/index.js +162 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/rendering/components/Bold.js +18 -0
- package/lib/module/internal/rendering/components/Bold.js.map +1 -0
- package/lib/module/internal/rendering/components/BulletPoint.js +25 -0
- package/lib/module/internal/rendering/components/BulletPoint.js.map +1 -0
- package/lib/module/internal/rendering/components/Headline.js +32 -0
- package/lib/module/internal/rendering/components/Headline.js.map +1 -0
- package/lib/module/internal/rendering/components/Italic.js +18 -0
- package/lib/module/internal/rendering/components/Italic.js.map +1 -0
- package/lib/module/internal/rendering/components/Render.js +94 -0
- package/lib/module/internal/rendering/components/Render.js.map +1 -0
- package/lib/module/internal/rendering/utils.js +16 -0
- package/lib/module/internal/rendering/utils.js.map +1 -0
- package/lib/module/internal/text-formats/conversions.js +43 -0
- package/lib/module/internal/text-formats/conversions.js.map +1 -0
- package/lib/module/internal/text-formats/markdown-format.js +2 -0
- package/lib/module/internal/text-formats/markdown-format.js.map +1 -0
- package/lib/module/internal/text-formats/unicode-markers-format/constants.js +45 -0
- package/lib/module/internal/text-formats/unicode-markers-format/constants.js.map +1 -0
- package/lib/module/internal/text-formats/unicode-markers-format/encode-decode.js +61 -0
- package/lib/module/internal/text-formats/unicode-markers-format/encode-decode.js.map +1 -0
- package/lib/module/internal/text-formats/unicode-markers-format/markers.js +15 -0
- package/lib/module/internal/text-formats/unicode-markers-format/markers.js.map +1 -0
- package/lib/module/internal/text-formats/unicode-markers-format/text-manipulation.js +117 -0
- package/lib/module/internal/text-formats/unicode-markers-format/text-manipulation.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +38 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Bold.d.ts +3 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Bold.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/BulletPoint.d.ts +3 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/BulletPoint.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Headline.d.ts +24 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Headline.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Italic.d.ts +3 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Italic.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Render.d.ts +4 -0
- package/lib/typescript/commonjs/src/internal/rendering/components/Render.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/rendering/utils.d.ts +3 -0
- package/lib/typescript/commonjs/src/internal/rendering/utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/text-formats/conversions.d.ts +9 -0
- package/lib/typescript/commonjs/src/internal/text-formats/conversions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/text-formats/markdown-format.d.ts +1 -0
- package/lib/typescript/commonjs/src/internal/text-formats/markdown-format.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/constants.d.ts +26 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts +15 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/markers.d.ts +11 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/markers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts +52 -0
- package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/index.d.ts +38 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/rendering/components/Bold.d.ts +3 -0
- package/lib/typescript/module/src/internal/rendering/components/Bold.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/rendering/components/BulletPoint.d.ts +3 -0
- package/lib/typescript/module/src/internal/rendering/components/BulletPoint.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/rendering/components/Headline.d.ts +24 -0
- package/lib/typescript/module/src/internal/rendering/components/Headline.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/rendering/components/Italic.d.ts +3 -0
- package/lib/typescript/module/src/internal/rendering/components/Italic.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/rendering/components/Render.d.ts +4 -0
- package/lib/typescript/module/src/internal/rendering/components/Render.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/rendering/utils.d.ts +3 -0
- package/lib/typescript/module/src/internal/rendering/utils.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/text-formats/conversions.d.ts +9 -0
- package/lib/typescript/module/src/internal/text-formats/conversions.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/text-formats/markdown-format.d.ts +1 -0
- package/lib/typescript/module/src/internal/text-formats/markdown-format.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/constants.d.ts +26 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/constants.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts +15 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/markers.d.ts +11 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/markers.d.ts.map +1 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts +52 -0
- package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts.map +1 -0
- package/package.json +194 -0
- package/src/index.tsx +178 -0
- package/src/internal/rendering/components/Bold.tsx +12 -0
- package/src/internal/rendering/components/BulletPoint.tsx +19 -0
- package/src/internal/rendering/components/Headline.tsx +32 -0
- package/src/internal/rendering/components/Italic.tsx +12 -0
- package/src/internal/rendering/components/Render.tsx +105 -0
- package/src/internal/rendering/utils.ts +15 -0
- package/src/internal/text-formats/conversions.ts +62 -0
- package/src/internal/text-formats/markdown-format.ts +0 -0
- package/src/internal/text-formats/unicode-markers-format/constants.ts +64 -0
- package/src/internal/text-formats/unicode-markers-format/encode-decode.ts +60 -0
- package/src/internal/text-formats/unicode-markers-format/markers.ts +19 -0
- package/src/internal/text-formats/unicode-markers-format/text-manipulation.ts +135 -0
package/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Christian Kozalla
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# react-native-simple-rich-text-editor
|
2
|
+
|
3
|
+
A lean Rich Text Editor for React Native built upon TextInput outputting Markdown
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```sh
|
8
|
+
npm install react-native-simple-rich-text-editor
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
The Rich Text Editor is a controlled component that takes a `text` prop and an `onEmitText` prop.
|
14
|
+
|
15
|
+
```js
|
16
|
+
// React-Native Simple Rich Text Editor example
|
17
|
+
// From ./example/src/App.tsx
|
18
|
+
// Run this code via `yarn example`
|
19
|
+
import RichTextEditor from 'react-native-simple-rich-text-editor';
|
20
|
+
import { View, StyleSheet } from 'react-native';
|
21
|
+
import { useState } from 'react';
|
22
|
+
|
23
|
+
export default function App() {
|
24
|
+
const [markdownText, setMarkdownText] = useState(
|
25
|
+
'# Hello World\nA paragraph.'
|
26
|
+
);
|
27
|
+
|
28
|
+
return (
|
29
|
+
<View style={styles.container}>
|
30
|
+
<RichTextEditor text={markdownText} onEmitText={setMarkdownText} />
|
31
|
+
</View>
|
32
|
+
);
|
33
|
+
}
|
34
|
+
|
35
|
+
const styles = StyleSheet.create({
|
36
|
+
container: {
|
37
|
+
flex: 1,
|
38
|
+
alignItems: 'center',
|
39
|
+
justifyContent: 'center',
|
40
|
+
},
|
41
|
+
});
|
42
|
+
```
|
43
|
+
|
44
|
+
## Roadmap
|
45
|
+
|
46
|
+
Currently, in the beta version, the editor component emits text that contains the formatting markers used internally. In the first release, markdown formatted text may be passed initially and the editor will also emit proper markdown - but only supporting a limited set of markdown features, such as headings, bold and italic font styles and unordered lists, maybe links.
|
47
|
+
|
48
|
+
### Features planned
|
49
|
+
|
50
|
+
- Load markdown text on startup and render everything that is supported in the editor. Everything that is not supported stays unchanged.
|
51
|
+
- Emit markdown through onEmitText callback.
|
52
|
+
- (Enable user, i.e. the developer who uses the editor in their app, to fetch the markdown text. Effectively eliminating the need to compile to markdown on every keystroke.)
|
53
|
+
- Headings H1, H2, H3 ✅
|
54
|
+
- Bold and italic font styles ✅
|
55
|
+
- Unordered List ✅
|
56
|
+
- (Customizeable Toolbar)
|
57
|
+
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
62
|
+
|
63
|
+
## License
|
64
|
+
|
65
|
+
MIT
|
66
|
+
|
67
|
+
---
|
68
|
+
|
69
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
@@ -0,0 +1,166 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = exports.RichTextEditor = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
var _reactNative = require("react-native");
|
9
|
+
var _Render = require("./internal/rendering/components/Render.js");
|
10
|
+
var _textManipulation = require("./internal/text-formats/unicode-markers-format/text-manipulation.js");
|
11
|
+
var _markers = require("./internal/text-formats/unicode-markers-format/markers.js");
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
+
/**
|
14
|
+
* React Native Simple Rich Text Editor
|
15
|
+
*
|
16
|
+
* Documentation of the public API:
|
17
|
+
* - SimpleRichTextEditor Component
|
18
|
+
* -> let user specifiy when to emit (e.g. on keyboard dismiss)
|
19
|
+
* -> let user pass custom H1, H2, Bold, Italic, List buttons
|
20
|
+
*
|
21
|
+
* Internals:
|
22
|
+
* - RichTextEditor is a controlled component. The user provides `state` and `setState` to receive markdown output.
|
23
|
+
* - Only a subset of markdown will be supported. Unsupported markdown like images will be rendered as plain markdown text.
|
24
|
+
* - Receive text prop -> convert markdown to internal representation -> render
|
25
|
+
* - onEmitText: convert internal representation to markdown -> setState(markdown)
|
26
|
+
*
|
27
|
+
* Usage Example:
|
28
|
+
*
|
29
|
+
* ```typescript
|
30
|
+
* import RichTextEditor from "react-native-simple-rich-text-editor";
|
31
|
+
* import { useState } from "react";
|
32
|
+
*
|
33
|
+
*
|
34
|
+
* const Screen = () => {
|
35
|
+
* const [markdownText, setMarkdownText] = useState("# Hello World\nA paragraph."); // or with backticks ``
|
36
|
+
*
|
37
|
+
* return (
|
38
|
+
* <RichTextEditor text={markdownText} onEmitText={setMarkdownText} style={styles.editor} />
|
39
|
+
* );
|
40
|
+
* };
|
41
|
+
* ```
|
42
|
+
*/
|
43
|
+
|
44
|
+
const RichTextEditor = ({
|
45
|
+
text,
|
46
|
+
onEmitText
|
47
|
+
}) => {
|
48
|
+
// Track the current selection (cursor position) in the TextInput.
|
49
|
+
const [selection, setSelection] = (0, _react.useState)({
|
50
|
+
start: 0,
|
51
|
+
end: 0
|
52
|
+
});
|
53
|
+
const [needsBoldEndMarker, setNeedsBoldEndMarker] = (0, _react.useState)(false); // we must count the BOLD_START and BOLD_END markers in text prop => inital state
|
54
|
+
const [needsItalicEndMarker, setNeedsItalicEndMarker] = (0, _react.useState)(false);
|
55
|
+
const handleFontStyleMarkerInsertion = style => () => {
|
56
|
+
const isBold = style === 'bold';
|
57
|
+
if (isBold ? needsBoldEndMarker : needsItalicEndMarker) {
|
58
|
+
const {
|
59
|
+
text: newText
|
60
|
+
} = (0, _textManipulation.addFontStyleEndMarker)(text, selection, style);
|
61
|
+
isBold ? setNeedsBoldEndMarker(false) : setNeedsItalicEndMarker(false);
|
62
|
+
onEmitText(newText);
|
63
|
+
} else {
|
64
|
+
const {
|
65
|
+
text: newText
|
66
|
+
} = (0, _textManipulation.addFontStyleMarkers)(text, selection, style);
|
67
|
+
// this is a reaction to an implementation detail of addBoldMarkers - TODO: solve it cleanly
|
68
|
+
if (selection.start - selection.end === 0) isBold ? setNeedsBoldEndMarker(true) : setNeedsItalicEndMarker(true);
|
69
|
+
onEmitText(newText);
|
70
|
+
}
|
71
|
+
};
|
72
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
73
|
+
style: styles.container,
|
74
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
75
|
+
style: styles.row,
|
76
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
77
|
+
style: styles.button,
|
78
|
+
onPress: () => onEmitText((0, _textManipulation.addHeadlineMarker)(_markers.Markers.H1, text, selection)),
|
79
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
80
|
+
style: styles.buttonText,
|
81
|
+
children: "H1"
|
82
|
+
})
|
83
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
84
|
+
style: styles.button,
|
85
|
+
onPress: () => onEmitText((0, _textManipulation.addHeadlineMarker)(_markers.Markers.H2, text, selection)),
|
86
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
87
|
+
style: styles.buttonText,
|
88
|
+
children: "H2"
|
89
|
+
})
|
90
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
91
|
+
style: styles.button,
|
92
|
+
onPress: () => onEmitText((0, _textManipulation.addHeadlineMarker)(_markers.Markers.H3, text, selection)),
|
93
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
94
|
+
style: styles.buttonText,
|
95
|
+
children: "H3"
|
96
|
+
})
|
97
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
98
|
+
style: styles.button,
|
99
|
+
onPress: () => onEmitText((0, _textManipulation.addBulletPointMarker)(text, selection)),
|
100
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
101
|
+
style: styles.buttonText,
|
102
|
+
children: "List"
|
103
|
+
})
|
104
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
105
|
+
style: [styles.button, styles.fixedWidth],
|
106
|
+
onPress: handleFontStyleMarkerInsertion('bold'),
|
107
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
108
|
+
style: styles.buttonText,
|
109
|
+
children: needsBoldEndMarker ? 'Bold ✖' : 'Bold'
|
110
|
+
})
|
111
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
112
|
+
style: [styles.button, styles.fixedWidth],
|
113
|
+
onPress: handleFontStyleMarkerInsertion('italic'),
|
114
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
115
|
+
style: styles.buttonText,
|
116
|
+
children: needsItalicEndMarker ? 'Italic ✖' : 'Italic'
|
117
|
+
})
|
118
|
+
})]
|
119
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
|
120
|
+
multiline: true,
|
121
|
+
autoFocus: true,
|
122
|
+
autoCorrect: false,
|
123
|
+
style: styles.input,
|
124
|
+
onSelectionChange: e => setSelection(e.nativeEvent.selection),
|
125
|
+
onChangeText: onEmitText,
|
126
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Render.Render, {
|
127
|
+
encodedText: text
|
128
|
+
})
|
129
|
+
})]
|
130
|
+
});
|
131
|
+
};
|
132
|
+
exports.RichTextEditor = RichTextEditor;
|
133
|
+
const electricBlueHex = '#009DDC';
|
134
|
+
const styles = _reactNative.StyleSheet.create({
|
135
|
+
container: {
|
136
|
+
flex: 1
|
137
|
+
},
|
138
|
+
row: {
|
139
|
+
margin: 8,
|
140
|
+
flexDirection: 'row',
|
141
|
+
justifyContent: 'space-between',
|
142
|
+
flexWrap: 'nowrap'
|
143
|
+
},
|
144
|
+
input: {
|
145
|
+
flex: 1,
|
146
|
+
textAlignVertical: 'top'
|
147
|
+
},
|
148
|
+
button: {
|
149
|
+
paddingVertical: 6,
|
150
|
+
paddingHorizontal: 8,
|
151
|
+
borderRadius: 4,
|
152
|
+
borderWidth: 1,
|
153
|
+
borderColor: electricBlueHex,
|
154
|
+
backgroundColor: 'white',
|
155
|
+
flexShrink: 1
|
156
|
+
},
|
157
|
+
buttonText: {
|
158
|
+
textAlign: 'center',
|
159
|
+
color: electricBlueHex
|
160
|
+
},
|
161
|
+
fixedWidth: {
|
162
|
+
width: 70
|
163
|
+
}
|
164
|
+
});
|
165
|
+
var _default = exports.default = RichTextEditor;
|
166
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_Render","_textManipulation","_markers","_jsxRuntime","RichTextEditor","text","onEmitText","selection","setSelection","useState","start","end","needsBoldEndMarker","setNeedsBoldEndMarker","needsItalicEndMarker","setNeedsItalicEndMarker","handleFontStyleMarkerInsertion","style","isBold","newText","addFontStyleEndMarker","addFontStyleMarkers","jsxs","View","styles","container","children","row","jsx","TouchableOpacity","button","onPress","addHeadlineMarker","Markers","H1","Text","buttonText","H2","H3","addBulletPointMarker","fixedWidth","TextInput","multiline","autoFocus","autoCorrect","input","onSelectionChange","e","nativeEvent","onChangeText","Render","encodedText","exports","electricBlueHex","StyleSheet","create","flex","margin","flexDirection","justifyContent","flexWrap","textAlignVertical","paddingVertical","paddingHorizontal","borderRadius","borderWidth","borderColor","backgroundColor","flexShrink","textAlign","color","width","_default","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AA+BA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAMA,IAAAI,QAAA,GAAAJ,OAAA;AAAoF,IAAAK,WAAA,GAAAL,OAAA;AAhDpF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA,MAAMM,cAAc,GAAGA,CAAC;EACtBC,IAAI;EACJC;AAIF,CAAC,KAAK;EACJ;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
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Bold = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
9
|
+
const Bold = ({
|
10
|
+
children
|
11
|
+
}) => {
|
12
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
13
|
+
style: styles.bold,
|
14
|
+
children: children
|
15
|
+
});
|
16
|
+
};
|
17
|
+
exports.Bold = Bold;
|
18
|
+
const styles = _reactNative.StyleSheet.create({
|
19
|
+
bold: {
|
20
|
+
fontWeight: 700
|
21
|
+
}
|
22
|
+
});
|
23
|
+
//# sourceMappingURL=Bold.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_jsxRuntime","Bold","children","jsx","Text","style","styles","bold","exports","StyleSheet","create","fontWeight"],"sourceRoot":"../../../../../src","sources":["internal/rendering/components/Bold.tsx"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAgD,IAAAC,WAAA,GAAAD,OAAA;AAEzC,MAAME,IAAI,GAAGA,CAAC;EAAEC;AAA4B,CAAC,KAAK;EACvD,oBAAO,IAAAF,WAAA,CAAAG,GAAA,EAACL,YAAA,CAAAM,IAAI;IAACC,KAAK,EAAEC,MAAM,CAACC,IAAK;IAAAL,QAAA,EAAEA;EAAQ,CAAO,CAAC;AACpD,CAAC;AAACM,OAAA,CAAAP,IAAA,GAAAA,IAAA;AAEF,MAAMK,MAAM,GAAGG,uBAAU,CAACC,MAAM,CAAC;EAC/BH,IAAI,EAAE;IACJI,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.BulletPoint = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
var _reactNative = require("react-native");
|
9
|
+
var _constants = require("../../text-formats/unicode-markers-format/constants.js");
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
11
|
+
const BulletPoint = ({
|
12
|
+
children
|
13
|
+
}) => {
|
14
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
15
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
16
|
+
style: styles.bullet,
|
17
|
+
children: _constants.BULLET_POINT_STRING_REPRESENTATION
|
18
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
19
|
+
children: children
|
20
|
+
})]
|
21
|
+
});
|
22
|
+
};
|
23
|
+
exports.BulletPoint = BulletPoint;
|
24
|
+
const styles = _reactNative.StyleSheet.create({
|
25
|
+
bullet: {
|
26
|
+
marginRight: 8,
|
27
|
+
fontSize: 16
|
28
|
+
}
|
29
|
+
});
|
30
|
+
//# sourceMappingURL=BulletPoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_constants","_jsxRuntime","BulletPoint","children","jsxs","Fragment","jsx","Text","style","styles","bullet","BULLET_POINT_STRING_REPRESENTATION","exports","StyleSheet","create","marginRight","fontSize"],"sourceRoot":"../../../../../src","sources":["internal/rendering/components/BulletPoint.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAAyG,IAAAG,WAAA,GAAAH,OAAA;AAElG,MAAMI,WAAW,GAAGA,CAAC;EAAEC;AAA4B,CAAC,KAAK;EAC9D,oBACE,IAAAF,WAAA,CAAAG,IAAA,EAACP,MAAA,CAAAQ,QAAQ;IAAAF,QAAA,gBACP,IAAAF,WAAA,CAAAK,GAAA,EAACP,YAAA,CAAAQ,IAAI;MAACC,KAAK,EAAEC,MAAM,CAACC,MAAO;MAAAP,QAAA,EAAEQ;IAAkC,CAAO,CAAC,eACvE,IAAAV,WAAA,CAAAK,GAAA,EAACP,YAAA,CAAAQ,IAAI;MAAAJ,QAAA,EAAEA;IAAQ,CAAO,CAAC;EAAA,CACf,CAAC;AAEf,CAAC;AAACS,OAAA,CAAAV,WAAA,GAAAA,WAAA;AAEF,MAAMO,MAAM,GAAGI,uBAAU,CAACC,MAAM,CAAC;EAC/BJ,MAAM,EAAE;IACNK,WAAW,EAAE,CAAC;IACdC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Headline = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
var _markers = require("../../text-formats/unicode-markers-format/markers.js");
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
10
|
+
const Headline = ({
|
11
|
+
level,
|
12
|
+
children
|
13
|
+
}) => {
|
14
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
15
|
+
style: styles[level] ?? styles[3],
|
16
|
+
children: children
|
17
|
+
});
|
18
|
+
};
|
19
|
+
exports.Headline = Headline;
|
20
|
+
const styles = _reactNative.StyleSheet.create({
|
21
|
+
[_markers.Markers.H1]: {
|
22
|
+
fontSize: 32,
|
23
|
+
fontWeight: 'bold',
|
24
|
+
marginVertical: 4
|
25
|
+
},
|
26
|
+
[_markers.Markers.H2]: {
|
27
|
+
fontSize: 24,
|
28
|
+
fontWeight: 'bold',
|
29
|
+
marginVertical: 4
|
30
|
+
},
|
31
|
+
[_markers.Markers.H3]: {
|
32
|
+
fontSize: 18,
|
33
|
+
fontWeight: 'bold',
|
34
|
+
marginVertical: 4
|
35
|
+
}
|
36
|
+
});
|
37
|
+
//# sourceMappingURL=Headline.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_markers","_jsxRuntime","Headline","level","children","jsx","Text","style","styles","exports","StyleSheet","create","Markers","H1","fontSize","fontWeight","marginVertical","H2","H3"],"sourceRoot":"../../../../../src","sources":["internal/rendering/components/Headline.tsx"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAA+E,IAAAE,WAAA,GAAAF,OAAA;AAExE,MAAMG,QAAQ,GAAGA,CAAC;EACvBC,KAAK;EACLC;AAGD,CAAC,KAAK;EACL,oBACE,IAAAH,WAAA,CAAAI,GAAA,EAACP,YAAA,CAAAQ,IAAI;IAACC,KAAK,EAAGC,MAAM,CAACL,KAAK,CAAC,IAAkBK,MAAM,CAAC,CAAC,CAAE;IAAAJ,QAAA,EAAEA;EAAQ,CAAO,CAAC;AAE7E,CAAC;AAACK,OAAA,CAAAP,QAAA,GAAAA,QAAA;AAEF,MAAMM,MAAM,GAAGE,uBAAU,CAACC,MAAM,CAAC;EAC/B,CAACC,gBAAO,CAACC,EAAE,GAAG;IACZC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,cAAc,EAAE;EAClB,CAAC;EACD,CAACJ,gBAAO,CAACK,EAAE,GAAG;IACZH,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,cAAc,EAAE;EAClB,CAAC;EACD,CAACJ,gBAAO,CAACM,EAAE,GAAG;IACZJ,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Italic = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
9
|
+
const Italic = ({
|
10
|
+
children
|
11
|
+
}) => {
|
12
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
13
|
+
style: styles.italic,
|
14
|
+
children: children
|
15
|
+
});
|
16
|
+
};
|
17
|
+
exports.Italic = Italic;
|
18
|
+
const styles = _reactNative.StyleSheet.create({
|
19
|
+
italic: {
|
20
|
+
fontStyle: 'italic'
|
21
|
+
}
|
22
|
+
});
|
23
|
+
//# sourceMappingURL=Italic.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_jsxRuntime","Italic","children","jsx","Text","style","styles","italic","exports","StyleSheet","create","fontStyle"],"sourceRoot":"../../../../../src","sources":["internal/rendering/components/Italic.tsx"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAgD,IAAAC,WAAA,GAAAD,OAAA;AAEzC,MAAME,MAAM,GAAGA,CAAC;EAAEC;AAA4B,CAAC,KAAK;EACzD,oBAAO,IAAAF,WAAA,CAAAG,GAAA,EAACL,YAAA,CAAAM,IAAI;IAACC,KAAK,EAAEC,MAAM,CAACC,MAAO;IAAAL,QAAA,EAAEA;EAAQ,CAAO,CAAC;AACtD,CAAC;AAACM,OAAA,CAAAP,MAAA,GAAAA,MAAA;AAEF,MAAMK,MAAM,GAAGG,uBAAU,CAACC,MAAM,CAAC;EAC/BH,MAAM,EAAE;IACNI,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Render = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
var _constants = require("../../text-formats/unicode-markers-format/constants.js");
|
9
|
+
var _Headline = require("./Headline.js");
|
10
|
+
var _Bold = require("./Bold.js");
|
11
|
+
var _markers = require("../../text-formats/unicode-markers-format/markers.js");
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
+
var _Italic = require("./Italic.js");
|
14
|
+
var _BulletPoint = require("./BulletPoint.js");
|
15
|
+
var _utils = require("../utils.js");
|
16
|
+
const Render = ({
|
17
|
+
encodedText
|
18
|
+
}) => {
|
19
|
+
const lines = splitPreservingSeparator(encodedText.replaceAll(_constants.BULLET_POINT_STRING_REPRESENTATION, ''), _constants.ZWS); // each BulletPoint.tsx instance adds a BULLET_POINT_STRING_REPRESENTATION, we need to remove them to avoid adding extra chars on each render
|
20
|
+
|
21
|
+
return lines.map((line, i) => {
|
22
|
+
const marker = line.substring(0, _constants.MARKER_STRING_LENGTH);
|
23
|
+
switch (marker) {
|
24
|
+
case _markers.Markers.H1:
|
25
|
+
case _markers.Markers.H2:
|
26
|
+
case _markers.Markers.H3:
|
27
|
+
const [headline, ...restOfLineWithoutMarkers] = splitPreservingSeparator(line, '\n');
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
29
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Headline.Headline, {
|
30
|
+
level: marker,
|
31
|
+
children: headline
|
32
|
+
}), restOfLineWithoutMarkers.join('')]
|
33
|
+
}, i + line);
|
34
|
+
case _markers.Markers.UL:
|
35
|
+
// NOTE: no other markers are allowed in a bullet point list for now..
|
36
|
+
// if there are other markers they will lead to a break out of the the list -> will make the list terminate early
|
37
|
+
const [bulletPoints, ...paragraphs] = splitPreservingSeparator(line, '\n\n');
|
38
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
39
|
+
children: [(0, _utils.intersperse)(
|
40
|
+
// adds newlines after split() operation
|
41
|
+
(bulletPoints ?? '').split('\n') // erases newlines
|
42
|
+
.map((bulletPointLine, j) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_BulletPoint.BulletPoint, {
|
43
|
+
children: bulletPointLine
|
44
|
+
}, j + bulletPointLine)), '\n'), paragraphs.map(p => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
45
|
+
children: p
|
46
|
+
}, p))]
|
47
|
+
}, i + line);
|
48
|
+
case _markers.Markers.BOLD_START:
|
49
|
+
// NOTE: We could check if lines[i+1] starts with a BOLD_END marker
|
50
|
+
// but for now I opt for this simpler solution.
|
51
|
+
// Because of the above: There must not be any other markers between Markers.BOLD_START and Markers.BOLD_END!
|
52
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Bold.Bold, {
|
53
|
+
children: line
|
54
|
+
}, i + line);
|
55
|
+
case _markers.Markers.BOLD_END:
|
56
|
+
break;
|
57
|
+
case _markers.Markers.ITALIC_START:
|
58
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Italic.Italic, {
|
59
|
+
children: line
|
60
|
+
}, i + line);
|
61
|
+
case _markers.Markers.ITALIC_END:
|
62
|
+
break;
|
63
|
+
default:
|
64
|
+
// remove any broken markers
|
65
|
+
// markers can be broken by erasing text via backspace key in the editor
|
66
|
+
// first line always has no marker at the start
|
67
|
+
if (i !== 0) {
|
68
|
+
// detect broken marker
|
69
|
+
if (line.length < _constants.MARKER_STRING_LENGTH) {
|
70
|
+
return '';
|
71
|
+
}
|
72
|
+
}
|
73
|
+
break;
|
74
|
+
}
|
75
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
76
|
+
children: line
|
77
|
+
}, i + line);
|
78
|
+
});
|
79
|
+
};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Splits a string by the specified separator but preserves the separator
|
83
|
+
* in the resulting array.
|
84
|
+
*
|
85
|
+
* @param str - The string to split
|
86
|
+
* @param separator - The separator to split by (string or RegExp)
|
87
|
+
* @returns An array of strings split by the separator with special handling
|
88
|
+
*/
|
89
|
+
exports.Render = Render;
|
90
|
+
function splitPreservingSeparator(str, separator) {
|
91
|
+
return str.split(separator).map((s, i) => {
|
92
|
+
if (i === 0) {
|
93
|
+
return s;
|
94
|
+
} else {
|
95
|
+
return separator + s;
|
96
|
+
}
|
97
|
+
});
|
98
|
+
}
|
99
|
+
//# sourceMappingURL=Render.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_constants","_Headline","_Bold","_markers","_jsxRuntime","_Italic","_BulletPoint","_utils","Render","encodedText","lines","splitPreservingSeparator","replaceAll","BULLET_POINT_STRING_REPRESENTATION","ZWS","map","line","i","marker","substring","MARKER_STRING_LENGTH","Markers","H1","H2","H3","headline","restOfLineWithoutMarkers","jsxs","Fragment","children","jsx","Headline","level","join","UL","bulletPoints","paragraphs","intersperse","split","bulletPointLine","j","BulletPoint","p","Text","BOLD_START","Bold","BOLD_END","ITALIC_START","Italic","ITALIC_END","length","exports","str","separator","s"],"sourceRoot":"../../../../../src","sources":["internal/rendering/components/Render.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAEO,MAAMS,MAAM,GAAGA,CAAC;EAAEC;AAAqC,CAAC,KAAK;EAClE,MAAMC,KAAK,GAAGC,wBAAwB,CACpCF,WAAW,CAACG,UAAU,CAACC,6CAAkC,EAAE,EAAE,CAAC,EAC9DC,cACF,CAAC,CAAC,CAAC;;EAEH,OAAOJ,KAAK,CAACK,GAAG,CAAC,CAACC,IAAI,EAAEC,CAAC,KAAK;IAC5B,MAAMC,MAAM,GAAGF,IAAI,CAACG,SAAS,CAAC,CAAC,EAAEC,+BAAoB,CAAC;IACtD,QAAQF,MAAM;MACZ,KAAKG,gBAAO,CAACC,EAAE;MACf,KAAKD,gBAAO,CAACE,EAAE;MACf,KAAKF,gBAAO,CAACG,EAAE;QACb,MAAM,CAACC,QAAQ,EAA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,GAAGD,IAAkB,CAAC;MAC3C,KAAKK,gBAAO,CAACyB,QAAQ;QACnB;MACF,KAAKzB,gBAAO,CAAC0B,YAAY;QACvB,oBAAO,IAAA3C,WAAA,CAAA0B,GAAA,EAACzB,OAAA,CAAA2C,MAAM;UAAAnB,QAAA,EAAiBb;QAAI,GAAfC,CAAC,GAAGD,IAAoB,CAAC;MAC/C,KAAKK,gBAAO,CAAC4B,UAAU;QACrB;MACF;QACE;QACA;QACA;QACA,IAAIhC,CAAC,KAAK,CAAC,EAAE;UACX;UACA,IAAID,IAAI,CAACkC,MAAM,GAAG9B,+BAAoB,EAAE;YACtC,OAAO,EAAE;UACX;QACF;QACA;IACJ;IAEA,oBAAO,IAAAhB,WAAA,CAAA0B,GAAA,EAAChC,YAAA,CAAA6C,IAAI;MAAAd,QAAA,EAAiBb;IAAI,GAAfC,CAAC,GAAGD,IAAkB,CAAC;EAC3C,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAmC,OAAA,CAAA3C,MAAA,GAAAA,MAAA;AAQA,SAASG,wBAAwBA,CAACyC,GAAW,EAAEC,SAAiB,EAAY;EAC1E,OAAOD,GAAG,CAACd,KAAK,CAACe,SAAS,CAAC,CAACtC,GAAG,CAAC,CAACuC,CAAC,EAAErC,CAAC,KAAK;IACxC,IAAIA,CAAC,KAAK,CAAC,EAAE;MACX,OAAOqC,CAAC;IACV,CAAC,MAAM;MACL,OAAOD,SAAS,GAAGC,CAAC;IACtB;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.intersperse = intersperse;
|
7
|
+
// add the separator after each element of arr, except for the last element
|
8
|
+
function intersperse(arr, separator) {
|
9
|
+
if (arr.length === 0) return [];
|
10
|
+
const output = new Array(arr.length * 2 - 1);
|
11
|
+
for (let i = 0, j = 0; i < arr.length; i++, j += 2) {
|
12
|
+
output[j] = arr[i];
|
13
|
+
if (j + 1 < output.length) {
|
14
|
+
output[j + 1] = separator;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
return output;
|
18
|
+
}
|
19
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["intersperse","arr","separator","length","output","Array","i","j"],"sourceRoot":"../../../../src","sources":["internal/rendering/utils.ts"],"mappings":";;;;;;AAAA;AACA,SAASA,WAAWA,CAAIC,GAAQ,EAAEC,SAAqB,EAAkB;EACvE,IAAID,GAAG,CAACE,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE;EAE/B,MAAMC,MAAM,GAAG,IAAIC,KAAK,CAACJ,GAAG,CAACE,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;EAC5C,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAED,CAAC,GAAGL,GAAG,CAACE,MAAM,EAAEG,CAAC,EAAE,EAAEC,CAAC,IAAI,CAAC,EAAE;IAClDH,MAAM,CAACG,CAAC,CAAC,GAAGN,GAAG,CAACK,CAAC,CAAC;IAClB,IAAIC,CAAC,GAAG,CAAC,GAAGH,MAAM,CAACD,MAAM,EAAE;MACzBC,MAAM,CAACG,CAAC,GAAG,CAAC,CAAC,GAAGL,SAAS;IAC3B;EACF;EACA,OAAOE,MAAM;AACf","ignoreList":[]}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.convertInternalFormatToMarkdown = void 0;
|
7
|
+
var _constants = require("./unicode-markers-format/constants.js");
|
8
|
+
var _encodeDecode = require("./unicode-markers-format/encode-decode.js");
|
9
|
+
const Markdown = {
|
10
|
+
H1: '# ',
|
11
|
+
H2: '## ',
|
12
|
+
H3: '### '
|
13
|
+
};
|
14
|
+
/**
|
15
|
+
* convertInternalFormatToMarkdown converts text from the internal format to Markdown
|
16
|
+
* @param internalText rich text in the internal format
|
17
|
+
* @returns markdown formatted text
|
18
|
+
*/
|
19
|
+
const convertInternalFormatToMarkdown = internalText => {
|
20
|
+
// // 1. find all markers
|
21
|
+
// // 2. translate the markers into corresponding Markdown markers
|
22
|
+
// // 3. Replace internal markers with Markdown markers
|
23
|
+
let markdownText = '';
|
24
|
+
let i = 0;
|
25
|
+
while (i < internalText.length) {
|
26
|
+
const char = internalText[i];
|
27
|
+
if (char === _constants.ZWS) {
|
28
|
+
markdownText += decodedTokenToMarkdownToken((0, _encodeDecode.decode)(internalText.substring(i, i + _constants.MARKER_BYTE_LENGTH)));
|
29
|
+
i += _constants.MARKER_BYTE_LENGTH;
|
30
|
+
} else {
|
31
|
+
markdownText += char;
|
32
|
+
i++;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return markdownText;
|
36
|
+
};
|
37
|
+
exports.convertInternalFormatToMarkdown = convertInternalFormatToMarkdown;
|
38
|
+
const decodedTokenToMarkdownToken = internalToken => {
|
39
|
+
// the first byte declares the token type
|
40
|
+
switch (internalToken[0]) {
|
41
|
+
case _constants.HEADLINE_MARKER_TYPE:
|
42
|
+
return Markdown[`H${internalToken[1]}`];
|
43
|
+
default:
|
44
|
+
return '';
|
45
|
+
}
|
46
|
+
};
|
47
|
+
//# sourceMappingURL=conversions.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_constants","require","_encodeDecode","Markdown","H1","H2","H3","convertInternalFormatToMarkdown","internalText","markdownText","i","length","char","ZWS","decodedTokenToMarkdownToken","decode","substring","MARKER_BYTE_LENGTH","exports","internalToken","HEADLINE_MARKER_TYPE"],"sourceRoot":"../../../../src","sources":["internal/text-formats/conversions.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAMA,IAAAC,aAAA,GAAAD,OAAA;AAEA,MAAME,QAAQ,GAAG;EACfC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,KAAK;EACTC,EAAE,EAAE;AACN,CAAU;AAIV;AACA;AACA;AACA;AACA;AACA,MAAMC,+BAA+B,GACnCC,YAAoB,IACD;EACnB;EACA;EACA;EACA,IAAIC,YAAY,GAAG,EAAE;EAErB,IAAIC,CAAC,GAAG,CAAC;EACT,OAAOA,CAAC,GAAGF,YAAY,CAACG,MAAM,EAAE;IAC9B,MAAMC,IAAI,GAAGJ,YAAY,CAACE,CAAC,CAAC;IAE5B,IAAIE,IAAI,KAAKC,cAAG,EAAE;MAChBJ,YAAY,IAAIK,2BAA2B,CACzC,IAAAC,oBAAM,EAACP,YAAY,CAACQ,SAAS,CAACN,CAAC,EAAEA,CAAC,GAAGO,6BAAkB,CAAC,CAC1D,CAAC;MACDP,CAAC,IAAIO,6BAAkB;IACzB,CAAC,MAAM;MACLR,YAAY,IAAIG,IAAI;MACpBF,CAAC,EAAE;IACL;EACF;EAEA,OAAOD,YAAY;AACrB,CAAC;AAACS,OAAA,CAAAX,+BAAA,GAAAA,+BAAA;AAEF,MAAMO,2BAA2B,GAC/BK,aAAuB,IACJ;EACnB;EACA,QAAQA,aAAa,CAAC,CAAC,CAAC;IACtB,KAAKC,+BAAoB;MACvB,OAAOjB,QAAQ,CACb,IAAIgB,aAAa,CAAC,CAAC,CAAC,EAA4D,CACjF;IACH;MACE,OAAO,EAAE;EACb;AACF,CAAC","ignoreList":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["internal/text-formats/markdown-format.ts"],"mappings":"","ignoreList":[]}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ZWS = exports.MARKER_STRING_LENGTH = exports.MARKER_BYTE_LENGTH = exports.ITALIC_MARKERS = exports.HEADLINE_MARKER_TYPE = exports.HEADLINE_MARKERS = exports.HEADLINE_LEVELS = exports.BULLET_POINT_UL_MARKER = exports.BULLET_POINT_STRING_REPRESENTATION = exports.BOLD_MARKER_TYPE = exports.BOLD_MARKERS = void 0;
|
7
|
+
/**
|
8
|
+
* Constants for rich text markers.
|
9
|
+
*/
|
10
|
+
const ZWS = exports.ZWS = '\u200B'; // Zero-width space used as the marker (both as prefix and base).
|
11
|
+
const MARKER_BYTE_LENGTH = exports.MARKER_BYTE_LENGTH = 6; // Define a fixed marker length enables easy decoding when iterating over a string of the internal text format
|
12
|
+
const MARKER_STRING_LENGTH = exports.MARKER_STRING_LENGTH = MARKER_BYTE_LENGTH + 2; // like Markers.H1.length or Markers.BOLD.length
|
13
|
+
const HEADLINE_MARKER_TYPE = exports.HEADLINE_MARKER_TYPE = 0x10; // Marker type for headline start.
|
14
|
+
// PROBLEM: HEADLINE_LEVELS is used in two semantic ways. 1) for specifying the headline level in the encoded marker (see below) 2) and at the level interface (e.g. of Headline component) --> here we should use "H1" | "H2" | "H3" in an Enum or readonly object
|
15
|
+
const HEADLINE_LEVELS = exports.HEADLINE_LEVELS = {
|
16
|
+
H1: 1,
|
17
|
+
H2: 2,
|
18
|
+
H3: 3
|
19
|
+
};
|
20
|
+
const HEADLINE_MARKERS = exports.HEADLINE_MARKERS = {
|
21
|
+
H1: createMarker([HEADLINE_MARKER_TYPE, HEADLINE_LEVELS.H1]),
|
22
|
+
H2: createMarker([HEADLINE_MARKER_TYPE, HEADLINE_LEVELS.H2]),
|
23
|
+
H3: createMarker([HEADLINE_MARKER_TYPE, HEADLINE_LEVELS.H3])
|
24
|
+
};
|
25
|
+
const BOLD_MARKER_TYPE = exports.BOLD_MARKER_TYPE = 0x20;
|
26
|
+
const BOLD_MARKER_START = 1;
|
27
|
+
const BOLD_MARKER_END = 2;
|
28
|
+
const BOLD_MARKERS = exports.BOLD_MARKERS = {
|
29
|
+
START: createMarker([BOLD_MARKER_TYPE, BOLD_MARKER_START]),
|
30
|
+
END: createMarker([BOLD_MARKER_TYPE, BOLD_MARKER_END])
|
31
|
+
};
|
32
|
+
const ITALIC_MARKER_TYPE = 0x30;
|
33
|
+
const ITALIC_MARKER_START = 3;
|
34
|
+
const ITALIC_MARKER_END = 4;
|
35
|
+
const ITALIC_MARKERS = exports.ITALIC_MARKERS = {
|
36
|
+
START: createMarker([ITALIC_MARKER_TYPE, ITALIC_MARKER_START]),
|
37
|
+
END: createMarker([ITALIC_MARKER_TYPE, ITALIC_MARKER_END])
|
38
|
+
};
|
39
|
+
const BULLET_POINT_MARKER_TYPE = 0x40;
|
40
|
+
const BULLET_POINT_UNORDERED = 1;
|
41
|
+
const BULLET_POINT_UL_MARKER = exports.BULLET_POINT_UL_MARKER = createMarker([BULLET_POINT_MARKER_TYPE, BULLET_POINT_UNORDERED]);
|
42
|
+
const BULLET_POINT_STRING_REPRESENTATION = exports.BULLET_POINT_STRING_REPRESENTATION = '• ';
|
43
|
+
function createMarker(data, length = MARKER_BYTE_LENGTH) {
|
44
|
+
const array = new Uint8Array(length);
|
45
|
+
array.set(data);
|
46
|
+
return array;
|
47
|
+
}
|
48
|
+
//# sourceMappingURL=constants.js.map
|