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.
Files changed (122) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +69 -0
  3. package/lib/commonjs/index.js +166 -0
  4. package/lib/commonjs/index.js.map +1 -0
  5. package/lib/commonjs/internal/rendering/components/Bold.js +23 -0
  6. package/lib/commonjs/internal/rendering/components/Bold.js.map +1 -0
  7. package/lib/commonjs/internal/rendering/components/BulletPoint.js +30 -0
  8. package/lib/commonjs/internal/rendering/components/BulletPoint.js.map +1 -0
  9. package/lib/commonjs/internal/rendering/components/Headline.js +37 -0
  10. package/lib/commonjs/internal/rendering/components/Headline.js.map +1 -0
  11. package/lib/commonjs/internal/rendering/components/Italic.js +23 -0
  12. package/lib/commonjs/internal/rendering/components/Italic.js.map +1 -0
  13. package/lib/commonjs/internal/rendering/components/Render.js +99 -0
  14. package/lib/commonjs/internal/rendering/components/Render.js.map +1 -0
  15. package/lib/commonjs/internal/rendering/utils.js +19 -0
  16. package/lib/commonjs/internal/rendering/utils.js.map +1 -0
  17. package/lib/commonjs/internal/text-formats/conversions.js +47 -0
  18. package/lib/commonjs/internal/text-formats/conversions.js.map +1 -0
  19. package/lib/commonjs/internal/text-formats/markdown-format.js +2 -0
  20. package/lib/commonjs/internal/text-formats/markdown-format.js.map +1 -0
  21. package/lib/commonjs/internal/text-formats/unicode-markers-format/constants.js +48 -0
  22. package/lib/commonjs/internal/text-formats/unicode-markers-format/constants.js.map +1 -0
  23. package/lib/commonjs/internal/text-formats/unicode-markers-format/encode-decode.js +65 -0
  24. package/lib/commonjs/internal/text-formats/unicode-markers-format/encode-decode.js.map +1 -0
  25. package/lib/commonjs/internal/text-formats/unicode-markers-format/markers.js +19 -0
  26. package/lib/commonjs/internal/text-formats/unicode-markers-format/markers.js.map +1 -0
  27. package/lib/commonjs/internal/text-formats/unicode-markers-format/text-manipulation.js +124 -0
  28. package/lib/commonjs/internal/text-formats/unicode-markers-format/text-manipulation.js.map +1 -0
  29. package/lib/module/index.js +162 -0
  30. package/lib/module/index.js.map +1 -0
  31. package/lib/module/internal/rendering/components/Bold.js +18 -0
  32. package/lib/module/internal/rendering/components/Bold.js.map +1 -0
  33. package/lib/module/internal/rendering/components/BulletPoint.js +25 -0
  34. package/lib/module/internal/rendering/components/BulletPoint.js.map +1 -0
  35. package/lib/module/internal/rendering/components/Headline.js +32 -0
  36. package/lib/module/internal/rendering/components/Headline.js.map +1 -0
  37. package/lib/module/internal/rendering/components/Italic.js +18 -0
  38. package/lib/module/internal/rendering/components/Italic.js.map +1 -0
  39. package/lib/module/internal/rendering/components/Render.js +94 -0
  40. package/lib/module/internal/rendering/components/Render.js.map +1 -0
  41. package/lib/module/internal/rendering/utils.js +16 -0
  42. package/lib/module/internal/rendering/utils.js.map +1 -0
  43. package/lib/module/internal/text-formats/conversions.js +43 -0
  44. package/lib/module/internal/text-formats/conversions.js.map +1 -0
  45. package/lib/module/internal/text-formats/markdown-format.js +2 -0
  46. package/lib/module/internal/text-formats/markdown-format.js.map +1 -0
  47. package/lib/module/internal/text-formats/unicode-markers-format/constants.js +45 -0
  48. package/lib/module/internal/text-formats/unicode-markers-format/constants.js.map +1 -0
  49. package/lib/module/internal/text-formats/unicode-markers-format/encode-decode.js +61 -0
  50. package/lib/module/internal/text-formats/unicode-markers-format/encode-decode.js.map +1 -0
  51. package/lib/module/internal/text-formats/unicode-markers-format/markers.js +15 -0
  52. package/lib/module/internal/text-formats/unicode-markers-format/markers.js.map +1 -0
  53. package/lib/module/internal/text-formats/unicode-markers-format/text-manipulation.js +117 -0
  54. package/lib/module/internal/text-formats/unicode-markers-format/text-manipulation.js.map +1 -0
  55. package/lib/typescript/commonjs/package.json +1 -0
  56. package/lib/typescript/commonjs/src/index.d.ts +38 -0
  57. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  58. package/lib/typescript/commonjs/src/internal/rendering/components/Bold.d.ts +3 -0
  59. package/lib/typescript/commonjs/src/internal/rendering/components/Bold.d.ts.map +1 -0
  60. package/lib/typescript/commonjs/src/internal/rendering/components/BulletPoint.d.ts +3 -0
  61. package/lib/typescript/commonjs/src/internal/rendering/components/BulletPoint.d.ts.map +1 -0
  62. package/lib/typescript/commonjs/src/internal/rendering/components/Headline.d.ts +24 -0
  63. package/lib/typescript/commonjs/src/internal/rendering/components/Headline.d.ts.map +1 -0
  64. package/lib/typescript/commonjs/src/internal/rendering/components/Italic.d.ts +3 -0
  65. package/lib/typescript/commonjs/src/internal/rendering/components/Italic.d.ts.map +1 -0
  66. package/lib/typescript/commonjs/src/internal/rendering/components/Render.d.ts +4 -0
  67. package/lib/typescript/commonjs/src/internal/rendering/components/Render.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/src/internal/rendering/utils.d.ts +3 -0
  69. package/lib/typescript/commonjs/src/internal/rendering/utils.d.ts.map +1 -0
  70. package/lib/typescript/commonjs/src/internal/text-formats/conversions.d.ts +9 -0
  71. package/lib/typescript/commonjs/src/internal/text-formats/conversions.d.ts.map +1 -0
  72. package/lib/typescript/commonjs/src/internal/text-formats/markdown-format.d.ts +1 -0
  73. package/lib/typescript/commonjs/src/internal/text-formats/markdown-format.d.ts.map +1 -0
  74. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/constants.d.ts +26 -0
  75. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/constants.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts +15 -0
  77. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/markers.d.ts +11 -0
  79. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/markers.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts +52 -0
  81. package/lib/typescript/commonjs/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts.map +1 -0
  82. package/lib/typescript/module/package.json +1 -0
  83. package/lib/typescript/module/src/index.d.ts +38 -0
  84. package/lib/typescript/module/src/index.d.ts.map +1 -0
  85. package/lib/typescript/module/src/internal/rendering/components/Bold.d.ts +3 -0
  86. package/lib/typescript/module/src/internal/rendering/components/Bold.d.ts.map +1 -0
  87. package/lib/typescript/module/src/internal/rendering/components/BulletPoint.d.ts +3 -0
  88. package/lib/typescript/module/src/internal/rendering/components/BulletPoint.d.ts.map +1 -0
  89. package/lib/typescript/module/src/internal/rendering/components/Headline.d.ts +24 -0
  90. package/lib/typescript/module/src/internal/rendering/components/Headline.d.ts.map +1 -0
  91. package/lib/typescript/module/src/internal/rendering/components/Italic.d.ts +3 -0
  92. package/lib/typescript/module/src/internal/rendering/components/Italic.d.ts.map +1 -0
  93. package/lib/typescript/module/src/internal/rendering/components/Render.d.ts +4 -0
  94. package/lib/typescript/module/src/internal/rendering/components/Render.d.ts.map +1 -0
  95. package/lib/typescript/module/src/internal/rendering/utils.d.ts +3 -0
  96. package/lib/typescript/module/src/internal/rendering/utils.d.ts.map +1 -0
  97. package/lib/typescript/module/src/internal/text-formats/conversions.d.ts +9 -0
  98. package/lib/typescript/module/src/internal/text-formats/conversions.d.ts.map +1 -0
  99. package/lib/typescript/module/src/internal/text-formats/markdown-format.d.ts +1 -0
  100. package/lib/typescript/module/src/internal/text-formats/markdown-format.d.ts.map +1 -0
  101. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/constants.d.ts +26 -0
  102. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/constants.d.ts.map +1 -0
  103. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts +15 -0
  104. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/encode-decode.d.ts.map +1 -0
  105. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/markers.d.ts +11 -0
  106. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/markers.d.ts.map +1 -0
  107. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts +52 -0
  108. package/lib/typescript/module/src/internal/text-formats/unicode-markers-format/text-manipulation.d.ts.map +1 -0
  109. package/package.json +194 -0
  110. package/src/index.tsx +178 -0
  111. package/src/internal/rendering/components/Bold.tsx +12 -0
  112. package/src/internal/rendering/components/BulletPoint.tsx +19 -0
  113. package/src/internal/rendering/components/Headline.tsx +32 -0
  114. package/src/internal/rendering/components/Italic.tsx +12 -0
  115. package/src/internal/rendering/components/Render.tsx +105 -0
  116. package/src/internal/rendering/utils.ts +15 -0
  117. package/src/internal/text-formats/conversions.ts +62 -0
  118. package/src/internal/text-formats/markdown-format.ts +0 -0
  119. package/src/internal/text-formats/unicode-markers-format/constants.ts +64 -0
  120. package/src/internal/text-formats/unicode-markers-format/encode-decode.ts +60 -0
  121. package/src/internal/text-formats/unicode-markers-format/markers.ts +19 -0
  122. package/src/internal/text-formats/unicode-markers-format/text-manipulation.ts +135 -0
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ import { HEADLINE_MARKER_TYPE, ZWS, MARKER_BYTE_LENGTH } from "./unicode-markers-format/constants.js";
4
+ import { decode } from "./unicode-markers-format/encode-decode.js";
5
+ const Markdown = {
6
+ H1: '# ',
7
+ H2: '## ',
8
+ H3: '### '
9
+ };
10
+ /**
11
+ * convertInternalFormatToMarkdown converts text from the internal format to Markdown
12
+ * @param internalText rich text in the internal format
13
+ * @returns markdown formatted text
14
+ */
15
+ const convertInternalFormatToMarkdown = internalText => {
16
+ // // 1. find all markers
17
+ // // 2. translate the markers into corresponding Markdown markers
18
+ // // 3. Replace internal markers with Markdown markers
19
+ let markdownText = '';
20
+ let i = 0;
21
+ while (i < internalText.length) {
22
+ const char = internalText[i];
23
+ if (char === ZWS) {
24
+ markdownText += decodedTokenToMarkdownToken(decode(internalText.substring(i, i + MARKER_BYTE_LENGTH)));
25
+ i += MARKER_BYTE_LENGTH;
26
+ } else {
27
+ markdownText += char;
28
+ i++;
29
+ }
30
+ }
31
+ return markdownText;
32
+ };
33
+ const decodedTokenToMarkdownToken = internalToken => {
34
+ // the first byte declares the token type
35
+ switch (internalToken[0]) {
36
+ case HEADLINE_MARKER_TYPE:
37
+ return Markdown[`H${internalToken[1]}`];
38
+ default:
39
+ return '';
40
+ }
41
+ };
42
+ export { convertInternalFormatToMarkdown };
43
+ //# sourceMappingURL=conversions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HEADLINE_MARKER_TYPE","ZWS","MARKER_BYTE_LENGTH","decode","Markdown","H1","H2","H3","convertInternalFormatToMarkdown","internalText","markdownText","i","length","char","decodedTokenToMarkdownToken","substring","internalToken"],"sourceRoot":"../../../../src","sources":["internal/text-formats/conversions.ts"],"mappings":";;AAAA,SAEEA,oBAAoB,EACpBC,GAAG,EACHC,kBAAkB,QACb,uCAAuC;AAC9C,SAASC,MAAM,QAAQ,2CAA2C;AAElE,MAAMC,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,KAAKZ,GAAG,EAAE;MAChBS,YAAY,IAAII,2BAA2B,CACzCX,MAAM,CAACM,YAAY,CAACM,SAAS,CAACJ,CAAC,EAAEA,CAAC,GAAGT,kBAAkB,CAAC,CAC1D,CAAC;MACDS,CAAC,IAAIT,kBAAkB;IACzB,CAAC,MAAM;MACLQ,YAAY,IAAIG,IAAI;MACpBF,CAAC,EAAE;IACL;EACF;EAEA,OAAOD,YAAY;AACrB,CAAC;AAED,MAAMI,2BAA2B,GAC/BE,aAAuB,IACJ;EACnB;EACA,QAAQA,aAAa,CAAC,CAAC,CAAC;IACtB,KAAKhB,oBAAoB;MACvB,OAAOI,QAAQ,CACb,IAAIY,aAAa,CAAC,CAAC,CAAC,EAA4D,CACjF;IACH;MACE,OAAO,EAAE;EACb;AACF,CAAC;AAED,SAASR,+BAA+B","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=markdown-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["internal/text-formats/markdown-format.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Constants for rich text markers.
5
+ */
6
+ const ZWS = '\u200B'; // Zero-width space used as the marker (both as prefix and base).
7
+ const MARKER_BYTE_LENGTH = 6; // Define a fixed marker length enables easy decoding when iterating over a string of the internal text format
8
+ const MARKER_STRING_LENGTH = MARKER_BYTE_LENGTH + 2; // like Markers.H1.length or Markers.BOLD.length
9
+ const HEADLINE_MARKER_TYPE = 0x10; // Marker type for headline start.
10
+ // 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
11
+ const HEADLINE_LEVELS = {
12
+ H1: 1,
13
+ H2: 2,
14
+ H3: 3
15
+ };
16
+ const HEADLINE_MARKERS = {
17
+ H1: createMarker([HEADLINE_MARKER_TYPE, HEADLINE_LEVELS.H1]),
18
+ H2: createMarker([HEADLINE_MARKER_TYPE, HEADLINE_LEVELS.H2]),
19
+ H3: createMarker([HEADLINE_MARKER_TYPE, HEADLINE_LEVELS.H3])
20
+ };
21
+ const BOLD_MARKER_TYPE = 0x20;
22
+ const BOLD_MARKER_START = 1;
23
+ const BOLD_MARKER_END = 2;
24
+ const BOLD_MARKERS = {
25
+ START: createMarker([BOLD_MARKER_TYPE, BOLD_MARKER_START]),
26
+ END: createMarker([BOLD_MARKER_TYPE, BOLD_MARKER_END])
27
+ };
28
+ const ITALIC_MARKER_TYPE = 0x30;
29
+ const ITALIC_MARKER_START = 3;
30
+ const ITALIC_MARKER_END = 4;
31
+ const ITALIC_MARKERS = {
32
+ START: createMarker([ITALIC_MARKER_TYPE, ITALIC_MARKER_START]),
33
+ END: createMarker([ITALIC_MARKER_TYPE, ITALIC_MARKER_END])
34
+ };
35
+ const BULLET_POINT_MARKER_TYPE = 0x40;
36
+ const BULLET_POINT_UNORDERED = 1;
37
+ const BULLET_POINT_UL_MARKER = createMarker([BULLET_POINT_MARKER_TYPE, BULLET_POINT_UNORDERED]);
38
+ const BULLET_POINT_STRING_REPRESENTATION = '• ';
39
+ function createMarker(data, length = MARKER_BYTE_LENGTH) {
40
+ const array = new Uint8Array(length);
41
+ array.set(data);
42
+ return array;
43
+ }
44
+ export { ZWS, MARKER_STRING_LENGTH, MARKER_BYTE_LENGTH, HEADLINE_MARKER_TYPE, HEADLINE_LEVELS, HEADLINE_MARKERS, BOLD_MARKER_TYPE, BOLD_MARKERS, ITALIC_MARKERS, BULLET_POINT_UL_MARKER, BULLET_POINT_STRING_REPRESENTATION };
45
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ZWS","MARKER_BYTE_LENGTH","MARKER_STRING_LENGTH","HEADLINE_MARKER_TYPE","HEADLINE_LEVELS","H1","H2","H3","HEADLINE_MARKERS","createMarker","BOLD_MARKER_TYPE","BOLD_MARKER_START","BOLD_MARKER_END","BOLD_MARKERS","START","END","ITALIC_MARKER_TYPE","ITALIC_MARKER_START","ITALIC_MARKER_END","ITALIC_MARKERS","BULLET_POINT_MARKER_TYPE","BULLET_POINT_UNORDERED","BULLET_POINT_UL_MARKER","BULLET_POINT_STRING_REPRESENTATION","data","length","array","Uint8Array","set"],"sourceRoot":"../../../../../src","sources":["internal/text-formats/unicode-markers-format/constants.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AMC,sBAAsB,GAAG,CAAC;AAChC,MAAMC,sBAAsB,GAAGb,YAAY,CAAC,CAC1CW,wBAAwB,EACxBC,sBAAsB,CACvB,CAAC;AACF,MAAME,kCAAkC,GAAG,IAAI;AAE/C,SAASd,YAAYA,CAACe,IAAc,EAAEC,MAAM,GAAGxB,kBAAkB,EAAE;EACjE,MAAMyB,KAAK,GAAG,IAAIC,UAAU,CAACF,MAAM,CAAC;EACpCC,KAAK,CAACE,GAAG,CAACJ,IAAI,CAAC;EACf,OAAOE,KAAK;AACd;AAEA,SACE1B,GAAG,EACHE,oBAAoB,EACpBD,kBAAkB,EAClBE,oBAAoB,EACpBC,eAAe,EACfI,gBAAgB,EAChBE,gBAAgB,EAChBG,YAAY,EACZM,cAAc,EACdG,sBAAsB,EACtBC,kCAAkC","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The encode function leverages a concept from the Unicode spec - Variant Selectors - which enables arbitrary bytes to be appended invisibly to a unicode char.
5
+ * @param base string, usually a single char, to which bytes are appended. These bytes remain invisible when base is rendered
6
+ * @param bytes to added to the base string/char.
7
+ * @returns string
8
+ */
9
+ function encode(base, bytes) {
10
+ let result = base;
11
+ for (const byte of bytes) {
12
+ result += byteToVariationSelector(byte);
13
+ }
14
+ return result;
15
+ }
16
+
17
+ /**
18
+ * The decode function extracts data hidden inside a string masquerading as variation selectors.
19
+ * @param variationSelectors string that may contain bytes hidden as variation selectors
20
+ * @returns a list of numbers/bytes
21
+ */
22
+ function decode(variationSelectors) {
23
+ const result = [];
24
+ let started = false;
25
+ for (const char of variationSelectors) {
26
+ const byte = variationSelectorToByte(char);
27
+ if (byte !== null) {
28
+ result.push(byte);
29
+ started = true;
30
+ } else if (started) {
31
+ break;
32
+ }
33
+ }
34
+ return result;
35
+ }
36
+
37
+ // Utility function to transform a byte into a variation selector, for appending it to a unicode char.
38
+ function byteToVariationSelector(byte) {
39
+ if (byte < 16) {
40
+ return String.fromCodePoint(0xfe00 + byte);
41
+ } else {
42
+ return String.fromCodePoint(0xe0100 + (byte - 16));
43
+ }
44
+ }
45
+
46
+ // Utility function to extract hidden data from a unicode char's variation selectors.
47
+ function variationSelectorToByte(variationSelector) {
48
+ const codePoint = variationSelector.codePointAt(0);
49
+ if (codePoint === undefined) return null;
50
+ if (codePoint >= 0xfe00 && codePoint <= 0xfe0f) {
51
+ return codePoint - 0xfe00;
52
+ } else if (codePoint >= 0xe0100 && codePoint <= 0xe01ef) {
53
+ return codePoint - 0xe0100 + 16;
54
+ } else {
55
+ return null;
56
+ }
57
+ }
58
+
59
+ // Source of encode, decode and variation selector utilities is https://paulbutler.org/2025/smuggling-arbitrary-data-through-an-emoji/ originally written in Rust
60
+ export { encode, decode };
61
+ //# sourceMappingURL=encode-decode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["encode","base","bytes","result","byte","byteToVariationSelector","decode","variationSelectors","started","char","variationSelectorToByte","push","String","fromCodePoint","variationSelector","codePoint","codePointAt","undefined"],"sourceRoot":"../../../../../src","sources":["internal/text-formats/unicode-markers-format/encode-decode.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAMA,CAACC,IAAY,EAAEC,KAAiB,EAAU;EACvD,IAAIC,MAAM,GAAGF,IAAI;EACjB,KAAK,MAAMG,IAAI,IAAIF,KAAK,EAAE;IACxBC,MAAM,IAAIE,uBAAuB,CAACD,IAAI,CAAC;EACzC;EACA,OAAOD,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASG,MAAMA,CAACC,kBAA0B,EAAY;EACpD,MAAMJ,MAAgB,GAAG,EAAE;EAC3B,IAAIK,OAAO,GAAG,KAAK;EAEnB,KAAK,MAAMC,IAAI,IAAIF,kBAAkB,EAAE;IACrC,MAAMH,IAAI,GAAGM,uBAAuB,CAACD,IAAI,CAAC;IAC1C,IAAIL,IAAI,KAAK,IAAI,EAAE;MACjBD,MAAM,CAACQ,IAAI,CAACP,IAAI,CAAC;MACjBI,OAAO,GAAG,IAAI;IAChB,CAAC,MAAM,IAAIA,OAAO,EAAE;MAClB;IACF;EACF;EAEA,OAAOL,MAAM;AACf;;AAEA;AACA,SAASE,uBAAuBA,CAACD,IAAY,EAAU;EACrD,IAAIA,IAAI,GAAG,EAAE,EAAE;IACb,OAAOQ,MAAM,CAACC,aAAa,CAAC,MAAM,GAAGT,IAAI,CAAC;EAC5C,CAAC,MAAM;IACL,OAAOQ,MAAM,CAACC,aAAa,CAAC,OAAO,IAAIT,IAAI,GAAG,EAAE,CAAC,CAAC;EACpD;AACF;;AAEA;AACA,SAASM,uBAAuBA,CAACI,iBAAyB,EAAiB;EACzE,MAAMC,SAAS,GAAGD,iBAAiB,CAACE,WAAW,CAAC,CAAC,CAAC;EAClD,IAAID,SAAS,KAAKE,SAAS,EAAE,OAAO,IAAI;EACxC,IAAIF,SAAS,IAAI,MAAM,IAAIA,SAAS,IAAI,MAAM,EAAE;IAC9C,OAAOA,SAAS,GAAG,MAAM;EAC3B,CAAC,MAAM,IAAIA,SAAS,IAAI,OAAO,IAAIA,SAAS,IAAI,OAAO,EAAE;IACvD,OAAOA,SAAS,GAAG,OAAO,GAAG,EAAE;EACjC,CAAC,MAAM;IACL,OAAO,IAAI;EACb;AACF;;AAEA;AACA,SAASf,MAAM,EAAEM,MAAM","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ import { encode } from "./encode-decode.js";
4
+ import { ZWS, HEADLINE_MARKERS, BOLD_MARKERS, ITALIC_MARKERS, BULLET_POINT_UL_MARKER } from "./constants.js";
5
+ export const Markers = {
6
+ H1: encode(ZWS, HEADLINE_MARKERS.H1),
7
+ H2: encode(ZWS, HEADLINE_MARKERS.H2),
8
+ H3: encode(ZWS, HEADLINE_MARKERS.H3),
9
+ BOLD_START: encode(ZWS, BOLD_MARKERS.START),
10
+ BOLD_END: encode(ZWS, BOLD_MARKERS.END),
11
+ ITALIC_START: encode(ZWS, ITALIC_MARKERS.START),
12
+ ITALIC_END: encode(ZWS, ITALIC_MARKERS.END),
13
+ UL: encode(ZWS, BULLET_POINT_UL_MARKER)
14
+ };
15
+ //# sourceMappingURL=markers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["encode","ZWS","HEADLINE_MARKERS","BOLD_MARKERS","ITALIC_MARKERS","BULLET_POINT_UL_MARKER","Markers","H1","H2","H3","BOLD_START","START","BOLD_END","END","ITALIC_START","ITALIC_END","UL"],"sourceRoot":"../../../../../src","sources":["internal/text-formats/unicode-markers-format/markers.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SACEC,GAAG,EACHC,gBAAgB,EAChBC,YAAY,EACZC,cAAc,EACdC,sBAAsB,QACjB,gBAAgB;AAEvB,OAAO,MAAMC,OAAO,GAAG;EACrBC,EAAE,EAAEP,MAAM,CAACC,GAAG,EAAEC,gBAAgB,CAACK,EAAE,CAAC;EACpCC,EAAE,EAAER,MAAM,CAACC,GAAG,EAAEC,gBAAgB,CAACM,EAAE,CAAC;EACpCC,EAAE,EAAET,MAAM,CAACC,GAAG,EAAEC,gBAAgB,CAACO,EAAE,CAAC;EACpCC,UAAU,EAAEV,MAAM,CAACC,GAAG,EAAEE,YAAY,CAACQ,KAAK,CAAC;EAC3CC,QAAQ,EAAEZ,MAAM,CAACC,GAAG,EAAEE,YAAY,CAACU,GAAG,CAAC;EACvCC,YAAY,EAAEd,MAAM,CAACC,GAAG,EAAEG,cAAc,CAACO,KAAK,CAAC;EAC/CI,UAAU,EAAEf,MAAM,CAACC,GAAG,EAAEG,cAAc,CAACS,GAAG,CAAC;EAC3CG,EAAE,EAAEhB,MAAM,CAACC,GAAG,EAAEI,sBAAsB;AACxC,CAAU","ignoreList":[]}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ import { Markers } from "./markers.js";
4
+
5
+ /**
6
+ * Adds a bullet point marker to the text at the current cursor position.
7
+ * If the cursor is not at the beginning of a line, a newline is added before the marker.
8
+ * If the cursor is at the beginning of a line, the marker is added directly.
9
+ */
10
+ const addBulletPointMarker = (text, selection) => {
11
+ if (!text) {
12
+ return Markers.UL;
13
+ }
14
+
15
+ // Split text at the current selection.
16
+ const {
17
+ before,
18
+ selected,
19
+ after
20
+ } = splitBySelection(text, selection);
21
+
22
+ // Ensure that the marker begins on a new line.
23
+ let prefix = '';
24
+ if (before.length > 0 && !before.endsWith('\n')) {
25
+ prefix = '\n';
26
+ }
27
+
28
+ // Append the marker
29
+ const insertion = prefix + Markers.UL;
30
+ return before + insertion + selected + after;
31
+ };
32
+
33
+ /**
34
+ * Inserts a headline start marker into the text at the current cursor position.
35
+ * The marker encodes two bytes:
36
+ * - Byte 0: marker type (0x10 for headline)
37
+ * - Byte 1: headline level (here: 1)
38
+ *
39
+ * The marker is inserted so that it starts on a new line.
40
+ */
41
+ const addHeadlineMarker = (marker, text, selection) => {
42
+ if (!text) {
43
+ return marker;
44
+ }
45
+ // Split text at the current selection.
46
+ const {
47
+ before,
48
+ after
49
+ } = splitBySelection(text, selection);
50
+
51
+ // Do not add multiple consecutive markers, ZWS is the basis of each marker
52
+ // if (before.endsWith(ZWS) || after.startsWith(ZWS)) {
53
+ // return before + after;
54
+ // }
55
+
56
+ // Ensure that the marker begins on a new line.
57
+ let prefix = '';
58
+ if (!before.endsWith('\n')) {
59
+ prefix = '\n';
60
+ }
61
+ // Append the marker followed by a newline so that following text starts on a new line.
62
+ const insertion = prefix + marker;
63
+ return before + insertion + after;
64
+ };
65
+ const FontStyleMarkers = {
66
+ bold: {
67
+ START: Markers.BOLD_START,
68
+ END: Markers.BOLD_END
69
+ },
70
+ italic: {
71
+ START: Markers.ITALIC_START,
72
+ END: Markers.ITALIC_END
73
+ }
74
+ };
75
+ const addFontStyleEndMarker = (text, selection, style) => {
76
+ const {
77
+ before,
78
+ selected,
79
+ after
80
+ } = splitBySelection(text, selection);
81
+ return {
82
+ text: before + selected + FontStyleMarkers[style].END + after,
83
+ selection
84
+ };
85
+ };
86
+ const addFontStyleMarkers = (text, selection, style) => {
87
+ const {
88
+ before,
89
+ selected,
90
+ after
91
+ } = splitBySelection(text, selection);
92
+
93
+ // effectively no selection
94
+ if (selection.end - selection.start === 0) {
95
+ let prefix = '';
96
+ if (!before.endsWith('\n') && !before.endsWith(' ')) {
97
+ prefix += ' ';
98
+ }
99
+ return {
100
+ text: before + prefix + FontStyleMarkers[style].START,
101
+ selection
102
+ };
103
+ }
104
+ return {
105
+ text: before + FontStyleMarkers[style].START + selected + FontStyleMarkers[style].END + after,
106
+ selection
107
+ };
108
+ };
109
+ function splitBySelection(text, selection) {
110
+ return {
111
+ before: text.substring(0, selection.start),
112
+ selected: text.substring(selection.start, selection.end),
113
+ after: text.substring(selection.end)
114
+ };
115
+ }
116
+ export { addBulletPointMarker, addHeadlineMarker, addFontStyleMarkers, addFontStyleEndMarker, splitBySelection };
117
+ //# sourceMappingURL=text-manipulation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Markers","addBulletPointMarker","text","selection","UL","before","selected","after","splitBySelection","prefix","length","endsWith","insertion","addHeadlineMarker","marker","FontStyleMarkers","bold","START","BOLD_START","END","BOLD_END","italic","ITALIC_START","ITALIC_END","addFontStyleEndMarker","style","addFontStyleMarkers","end","start","substring"],"sourceRoot":"../../../../../src","sources":["internal/text-formats/unicode-markers-format/text-manipulation.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,cAAW;;AAEnC;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAGA,CAC3BC,IAAY,EACZC,SAAyC,KACtC;EACH,IAAI,CAACD,IAAI,EAAE;IACT,OAAOF,OAAO,CAACI,EAAE;EACnB;;EAEA;EACA,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGC,gBAAgB,CAACN,IAAI,EAAEC,SAAS,CAAC;;EAErE;EACA,IAAIM,MAAM,GAAG,EAAE;EACf,IAAIJ,MAAM,CAACK,MAAM,GAAG,CAAC,IAAI,CA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rBhB,gBAAgB","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * React Native Simple Rich Text Editor
3
+ *
4
+ * Documentation of the public API:
5
+ * - SimpleRichTextEditor Component
6
+ * -> let user specifiy when to emit (e.g. on keyboard dismiss)
7
+ * -> let user pass custom H1, H2, Bold, Italic, List buttons
8
+ *
9
+ * Internals:
10
+ * - RichTextEditor is a controlled component. The user provides `state` and `setState` to receive markdown output.
11
+ * - Only a subset of markdown will be supported. Unsupported markdown like images will be rendered as plain markdown text.
12
+ * - Receive text prop -> convert markdown to internal representation -> render
13
+ * - onEmitText: convert internal representation to markdown -> setState(markdown)
14
+ *
15
+ * Usage Example:
16
+ *
17
+ * ```typescript
18
+ * import RichTextEditor from "react-native-simple-rich-text-editor";
19
+ * import { useState } from "react";
20
+ *
21
+ *
22
+ * const Screen = () => {
23
+ * const [markdownText, setMarkdownText] = useState("# Hello World\nA paragraph."); // or with backticks ``
24
+ *
25
+ * return (
26
+ * <RichTextEditor text={markdownText} onEmitText={setMarkdownText} style={styles.editor} />
27
+ * );
28
+ * };
29
+ * ```
30
+ */
31
+ import type { Dispatch, SetStateAction } from 'react';
32
+ declare const RichTextEditor: ({ text, onEmitText, }: {
33
+ text: string;
34
+ onEmitText: Dispatch<SetStateAction<string>>;
35
+ }) => import("react/jsx-runtime").JSX.Element;
36
+ export default RichTextEditor;
37
+ export { RichTextEditor };
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAoBtD,QAAA,MAAM,cAAc,GAAI,uBAGrB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAC9C,4CAwFA,CAAC;AAgCF,eAAe,cAAc,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ export declare const Bold: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=Bold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bold.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/rendering/components/Bold.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,eAAO,MAAM,IAAI,GAAI,cAAc,iBAAiB,4CAEnD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type PropsWithChildren } from 'react';
2
+ export declare const BulletPoint: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=BulletPoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BulletPoint.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/rendering/components/BulletPoint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAIzD,eAAO,MAAM,WAAW,GAAI,cAAc,iBAAiB,4CAO1D,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type PropsWithChildren } from 'react';
2
+ import { Markers } from '../../text-formats/unicode-markers-format/markers.ts';
3
+ export declare const Headline: ({ level, children, }: PropsWithChildren<{
4
+ level: keyof typeof styles;
5
+ }>) => import("react/jsx-runtime").JSX.Element;
6
+ declare const styles: {
7
+ [Markers.H1]: {
8
+ fontSize: number;
9
+ fontWeight: "bold";
10
+ marginVertical: number;
11
+ };
12
+ [Markers.H2]: {
13
+ fontSize: number;
14
+ fontWeight: "bold";
15
+ marginVertical: number;
16
+ };
17
+ [Markers.H3]: {
18
+ fontSize: number;
19
+ fontWeight: "bold";
20
+ marginVertical: number;
21
+ };
22
+ };
23
+ export {};
24
+ //# sourceMappingURL=Headline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Headline.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/rendering/components/Headline.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,sDAAsD,CAAC;AAE/E,eAAO,MAAM,QAAQ,GAAI,sBAGtB,iBAAiB,CAAC;IACnB,KAAK,EAAE,MAAM,OAAO,MAAM,CAAC;CAC5B,CAAC,4CAID,CAAC;AAEF,QAAA,MAAM,MAAM;IACV,CAAC,OAAO,CAAC,EAAE,CAAC;;;;MAIX;IACD,CAAC,OAAO,CAAC,EAAE,CAAC;;;;MAIX;IACD,CAAC,OAAO,CAAC,EAAE,CAAC;;;;MAIX;CACD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ export declare const Italic: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=Italic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Italic.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/rendering/components/Italic.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,eAAO,MAAM,MAAM,GAAI,cAAc,iBAAiB,4CAErD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const Render: ({ encodedText }: {
2
+ encodedText: string;
3
+ }) => (import("react/jsx-runtime").JSX.Element | "")[];
4
+ //# sourceMappingURL=Render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Render.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/rendering/components/Render.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,MAAM,GAAI,iBAAiB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,qDAwE9D,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare function intersperse<T>(arr: T[], separator: T | string): (T | string)[];
2
+ export { intersperse };
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/rendering/utils.ts"],"names":[],"mappings":"AACA,iBAAS,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,CAWvE;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ type MarkdownString = string;
2
+ /**
3
+ * convertInternalFormatToMarkdown converts text from the internal format to Markdown
4
+ * @param internalText rich text in the internal format
5
+ * @returns markdown formatted text
6
+ */
7
+ declare const convertInternalFormatToMarkdown: (internalText: string) => MarkdownString;
8
+ export { convertInternalFormatToMarkdown };
9
+ //# sourceMappingURL=conversions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/text-formats/conversions.ts"],"names":[],"mappings":"AAcA,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B;;;;GAIG;AACH,QAAA,MAAM,+BAA+B,GACnC,cAAc,MAAM,KACnB,cAsBF,CAAC;AAgBF,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=markdown-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-format.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/text-formats/markdown-format.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Constants for rich text markers.
3
+ */
4
+ declare const ZWS = "\u200B";
5
+ declare const MARKER_BYTE_LENGTH = 6;
6
+ declare const MARKER_STRING_LENGTH: number;
7
+ declare const HEADLINE_MARKER_TYPE = 16;
8
+ declare const HEADLINE_LEVELS: {
9
+ readonly H1: 1;
10
+ readonly H2: 2;
11
+ readonly H3: 3;
12
+ };
13
+ declare const HEADLINE_MARKERS: Record<keyof typeof HEADLINE_LEVELS, Uint8Array>;
14
+ declare const BOLD_MARKER_TYPE = 32;
15
+ declare const BOLD_MARKERS: {
16
+ readonly START: Uint8Array<ArrayBuffer>;
17
+ readonly END: Uint8Array<ArrayBuffer>;
18
+ };
19
+ declare const ITALIC_MARKERS: {
20
+ readonly START: Uint8Array<ArrayBuffer>;
21
+ readonly END: Uint8Array<ArrayBuffer>;
22
+ };
23
+ declare const BULLET_POINT_UL_MARKER: Uint8Array<ArrayBuffer>;
24
+ declare const BULLET_POINT_STRING_REPRESENTATION = "\u2022 ";
25
+ export { ZWS, MARKER_STRING_LENGTH, MARKER_BYTE_LENGTH, HEADLINE_MARKER_TYPE, HEADLINE_LEVELS, HEADLINE_MARKERS, BOLD_MARKER_TYPE, BOLD_MARKERS, ITALIC_MARKERS, BULLET_POINT_UL_MARKER, BULLET_POINT_STRING_REPRESENTATION, };
26
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/text-formats/unicode-markers-format/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,GAAG,WAAW,CAAC;AACrB,QAAA,MAAM,kBAAkB,IAAI,CAAC;AAC7B,QAAA,MAAM,oBAAoB,QAAyB,CAAC;AACpD,QAAA,MAAM,oBAAoB,KAAO,CAAC;AAElC,QAAA,MAAM,eAAe;;;;CAIX,CAAC;AACX,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,OAAO,eAAe,EAAE,UAAU,CAI7D,CAAC;AAEX,QAAA,MAAM,gBAAgB,KAAO,CAAC;AAI9B,QAAA,MAAM,YAAY;;;CAGR,CAAC;AAMX,QAAA,MAAM,cAAc;;;CAGV,CAAC;AAIX,QAAA,MAAM,sBAAsB,yBAG1B,CAAC;AACH,QAAA,MAAM,kCAAkC,YAAO,CAAC;AAQhD,OAAO,EACL,GAAG,EACH,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,kCAAkC,GACnC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The encode function leverages a concept from the Unicode spec - Variant Selectors - which enables arbitrary bytes to be appended invisibly to a unicode char.
3
+ * @param base string, usually a single char, to which bytes are appended. These bytes remain invisible when base is rendered
4
+ * @param bytes to added to the base string/char.
5
+ * @returns string
6
+ */
7
+ declare function encode(base: string, bytes: Uint8Array): string;
8
+ /**
9
+ * The decode function extracts data hidden inside a string masquerading as variation selectors.
10
+ * @param variationSelectors string that may contain bytes hidden as variation selectors
11
+ * @returns a list of numbers/bytes
12
+ */
13
+ declare function decode(variationSelectors: string): number[];
14
+ export { encode, decode };
15
+ //# sourceMappingURL=encode-decode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode-decode.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/text-formats/unicode-markers-format/encode-decode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAMvD;AAED;;;;GAIG;AACH,iBAAS,MAAM,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM,EAAE,CAepD;AAyBD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const Markers: {
2
+ readonly H1: string;
3
+ readonly H2: string;
4
+ readonly H3: string;
5
+ readonly BOLD_START: string;
6
+ readonly BOLD_END: string;
7
+ readonly ITALIC_START: string;
8
+ readonly ITALIC_END: string;
9
+ readonly UL: string;
10
+ };
11
+ //# sourceMappingURL=markers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/text-formats/unicode-markers-format/markers.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,OAAO;;;;;;;;;CASV,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Adds a bullet point marker to the text at the current cursor position.
3
+ * If the cursor is not at the beginning of a line, a newline is added before the marker.
4
+ * If the cursor is at the beginning of a line, the marker is added directly.
5
+ */
6
+ declare const addBulletPointMarker: (text: string, selection: {
7
+ start: number;
8
+ end: number;
9
+ }) => string;
10
+ /**
11
+ * Inserts a headline start marker into the text at the current cursor position.
12
+ * The marker encodes two bytes:
13
+ * - Byte 0: marker type (0x10 for headline)
14
+ * - Byte 1: headline level (here: 1)
15
+ *
16
+ * The marker is inserted so that it starts on a new line.
17
+ */
18
+ declare const addHeadlineMarker: (marker: string, // marker already contains the headline level encoded
19
+ text: string, selection: {
20
+ start: number;
21
+ end: number;
22
+ }) => string;
23
+ declare const addFontStyleEndMarker: (text: string, selection: {
24
+ start: number;
25
+ end: number;
26
+ }, style: "bold" | "italic") => {
27
+ text: string;
28
+ selection: {
29
+ start: number;
30
+ end: number;
31
+ };
32
+ };
33
+ declare const addFontStyleMarkers: (text: string, selection: {
34
+ start: number;
35
+ end: number;
36
+ }, style: "bold" | "italic") => {
37
+ text: string;
38
+ selection: {
39
+ start: number;
40
+ end: number;
41
+ };
42
+ };
43
+ declare function splitBySelection(text: string, selection: {
44
+ start: number;
45
+ end: number;
46
+ }): {
47
+ before: string;
48
+ selected: string;
49
+ after: string;
50
+ };
51
+ export { addBulletPointMarker, addHeadlineMarker, addFontStyleMarkers, addFontStyleEndMarker, splitBySelection, };
52
+ //# sourceMappingURL=text-manipulation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-manipulation.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/text-formats/unicode-markers-format/text-manipulation.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,oBAAoB,GACxB,MAAM,MAAM,EACZ,WAAW;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,WAkB1C,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,iBAAiB,GACrB,QAAQ,MAAM,EAAE,qDAAqD;AACrE,MAAM,MAAM,EACZ,WAAW;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,WAqB1C,CAAC;AAaF,QAAA,MAAM,qBAAqB,GACzB,MAAM,MAAM,EACZ,WAAW;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACzC,OAAO,MAAM,GAAG,QAAQ;;;eADJ,MAAM;aAAO,MAAM;;CAQxC,CAAC;AAEF,QAAA,MAAM,mBAAmB,GACvB,MAAM,MAAM,EACZ,WAAW;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACzC,OAAO,MAAM,GAAG,QAAQ;;;eADJ,MAAM;aAAO,MAAM;;CA2BxC,CAAC;AAEF,iBAAS,gBAAgB,CACvB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAMrD;AAED,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * React Native Simple Rich Text Editor
3
+ *
4
+ * Documentation of the public API:
5
+ * - SimpleRichTextEditor Component
6
+ * -> let user specifiy when to emit (e.g. on keyboard dismiss)
7
+ * -> let user pass custom H1, H2, Bold, Italic, List buttons
8
+ *
9
+ * Internals:
10
+ * - RichTextEditor is a controlled component. The user provides `state` and `setState` to receive markdown output.
11
+ * - Only a subset of markdown will be supported. Unsupported markdown like images will be rendered as plain markdown text.
12
+ * - Receive text prop -> convert markdown to internal representation -> render
13
+ * - onEmitText: convert internal representation to markdown -> setState(markdown)
14
+ *
15
+ * Usage Example:
16
+ *
17
+ * ```typescript
18
+ * import RichTextEditor from "react-native-simple-rich-text-editor";
19
+ * import { useState } from "react";
20
+ *
21
+ *
22
+ * const Screen = () => {
23
+ * const [markdownText, setMarkdownText] = useState("# Hello World\nA paragraph."); // or with backticks ``
24
+ *
25
+ * return (
26
+ * <RichTextEditor text={markdownText} onEmitText={setMarkdownText} style={styles.editor} />
27
+ * );
28
+ * };
29
+ * ```
30
+ */
31
+ import type { Dispatch, SetStateAction } from 'react';
32
+ declare const RichTextEditor: ({ text, onEmitText, }: {
33
+ text: string;
34
+ onEmitText: Dispatch<SetStateAction<string>>;
35
+ }) => import("react/jsx-runtime").JSX.Element;
36
+ export default RichTextEditor;
37
+ export { RichTextEditor };
38
+ //# sourceMappingURL=index.d.ts.map