react-native-enriched-markdown-scaffold 1.0.2-scaffold.1 → 1.0.2-scaffold.10
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/android/build.gradle +2 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java +4 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerDelegate.java +18 -0
- package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownTextManagerInterface.java +4 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp +148 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h +120 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.cpp +30 -0
- package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/Props.h +210 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdown.kt +176 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownInternalText.kt +45 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownManager.kt +35 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownText.kt +112 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/EnrichedMarkdownTextManager.kt +34 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/MeasurementStore.kt +46 -8
- package/android/src/main/java/com/swmansion/enriched/markdown/events/CopyRequestEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/LinkLayoutEvent.kt +36 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/events/SelectionChangeEvent.kt +43 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/input/EnrichedMarkdownTextInputView.kt +25 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/input/editing/InputConnectionWrapper.kt +7 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt +37 -7
- package/android/src/main/java/com/swmansion/enriched/markdown/renderer/SpanStyleCache.kt +5 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/CodeBackgroundSpan.kt +13 -99
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/InlineChipPainter.kt +140 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkChipSpans.kt +177 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt +1 -6
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/InlineMathStyle.kt +16 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkStyle.kt +36 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt +7 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/styles/MathStyle.kt +3 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/common/MarkdownViewManagerUtils.kt +51 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/input/PasteTextUtils.kt +34 -2
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt +2 -1
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt +6 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/HeadlessActionMode.kt +88 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/LinkLayoutCollector.kt +100 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionActionMode.kt +53 -14
- package/android/src/main/java/com/swmansion/enriched/markdown/utils/text/view/SelectionChangeReporter.kt +232 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/BlockMenuOptions.kt +64 -0
- package/android/src/main/java/com/swmansion/enriched/markdown/views/CodeBlockContainerView.kt +29 -3
- package/android/src/main/java/com/swmansion/enriched/markdown/views/TableContainerView.kt +30 -7
- package/android/src/math/java/com/swmansion/enriched/markdown/renderer/MathInlineRenderer.kt +1 -0
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathInlineSpan.kt +13 -6
- package/android/src/math/java/com/swmansion/enriched/markdown/spans/MathMeasureHelper.kt +2 -1
- package/android/src/math/java/com/swmansion/enriched/markdown/views/MathContainerView.kt +25 -9
- package/docs/API_REFERENCE.md +183 -4
- package/docs/COPY_OPTIONS.md +40 -0
- package/docs/INPUT.md +3 -1
- package/docs/MENTIONS.md +8 -1
- package/docs/STYLES.md +27 -0
- package/docs/TEXT.md +2 -0
- package/docs/WEB.md +1 -0
- package/ios/EnrichedMarkdown.mm +321 -9
- package/ios/EnrichedMarkdownText.mm +203 -6
- package/ios/attachments/ENRMMathInlineAttachment+macOS.m +2 -1
- package/ios/attachments/ENRMMathInlineAttachment.h +3 -0
- package/ios/attachments/ENRMMathInlineAttachment.m +2 -1
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.cpp +148 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/EventEmitters.h +120 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.cpp +30 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/Props.h +210 -0
- package/ios/generated/ReactCodegen/EnrichedMarkdownTextSpec/RCTComponentViewHelpers.h +50 -2
- package/ios/internals/MeasurementCache.h +8 -2
- package/ios/math/ENRMRaTeXBridge.swift +23 -5
- package/ios/renderer/ENRMMathInlineRenderer.m +1 -0
- package/ios/renderer/LinkRenderer.m +47 -15
- package/ios/styles/StyleConfig.h +20 -0
- package/ios/styles/StyleConfig.mm +84 -0
- package/ios/utils/CodeBackground.m +3 -65
- package/ios/utils/ENRMBlockMenu.h +66 -0
- package/ios/utils/ENRMChipDrawing.h +24 -0
- package/ios/utils/ENRMChipDrawing.m +83 -0
- package/ios/utils/ENRMLinkChip.h +70 -0
- package/ios/utils/ENRMLinkChip.m +213 -0
- package/ios/utils/ENRMLinkLayout.h +50 -0
- package/ios/utils/ENRMLinkLayout.m +45 -0
- package/ios/utils/ENRMSelectionChange.h +120 -0
- package/ios/utils/ENRMSelectionChange.m +282 -0
- package/ios/utils/EditMenuUtils+macOS.m +4 -1
- package/ios/utils/EditMenuUtils.h +35 -6
- package/ios/utils/EditMenuUtils.m +171 -15
- package/ios/utils/HTMLGenerator.m +2 -1
- package/ios/utils/MarkdownAccessibilityElementBuilder.m +3 -1
- package/ios/utils/MarkdownExtractor.m +2 -1
- package/ios/utils/RTFExportUtils.m +2 -0
- package/ios/utils/StylePropsUtils.h +47 -1
- package/ios/utils/TextViewLayoutManager.mm +3 -0
- package/ios/views/ENRMCodeBlockContainerView.h +16 -2
- package/ios/views/ENRMCodeBlockContainerView.m +22 -19
- package/ios/views/ENRMMathContainerView.h +11 -0
- package/ios/views/ENRMMathContainerView.m +17 -20
- package/ios/views/TableContainerView.h +14 -0
- package/ios/views/TableContainerView.m +34 -18
- package/lib/module/EnrichedMarkdownNativeComponent.ts +138 -1
- package/lib/module/EnrichedMarkdownTextNativeComponent.ts +138 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest/index.js +14 -0
- package/lib/module/jest/index.js.map +1 -1
- package/lib/module/native/EnrichedMarkdownText.js +169 -11
- package/lib/module/native/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.js +17 -4
- package/lib/module/normalizeMarkdownStyle.js.map +1 -1
- package/lib/module/normalizeMarkdownStyle.web.js +17 -4
- package/lib/module/normalizeMarkdownStyle.web.js.map +1 -1
- package/lib/module/web/EnrichedMarkdownText.js +6 -3
- package/lib/module/web/EnrichedMarkdownText.js.map +1 -1
- package/lib/module/web/renderers/InlineRenderers.js +96 -3
- package/lib/module/web/renderers/InlineRenderers.js.map +1 -1
- package/lib/module/web/styles.js +18 -0
- package/lib/module/web/styles.js.map +1 -1
- package/lib/module/web/utils.js +13 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts +123 -2
- package/lib/typescript/src/EnrichedMarkdownNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts +123 -2
- package/lib/typescript/src/EnrichedMarkdownTextNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/jest/index.d.ts +1 -1
- package/lib/typescript/src/jest/index.d.ts.map +1 -1
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts +5 -5
- package/lib/typescript/src/native/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/normalizeMarkdownStyle.web.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyle.d.ts +50 -5
- package/lib/typescript/src/types/MarkdownStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts +12 -0
- package/lib/typescript/src/types/MarkdownStyleInternal.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.d.ts +144 -11
- package/lib/typescript/src/types/MarkdownTextProps.d.ts.map +1 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts +41 -1
- package/lib/typescript/src/types/MarkdownTextProps.web.d.ts.map +1 -1
- package/lib/typescript/src/types/events.d.ts +66 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts +1 -1
- package/lib/typescript/src/web/EnrichedMarkdownText.d.ts.map +1 -1
- package/lib/typescript/src/web/renderers/InlineRenderers.d.ts.map +1 -1
- package/lib/typescript/src/web/styles.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +4 -0
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils.d.ts +4 -0
- package/lib/typescript/src/web/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/EnrichedMarkdownNativeComponent.ts +138 -1
- package/src/EnrichedMarkdownTextNativeComponent.ts +138 -1
- package/src/index.tsx +6 -0
- package/src/index.web.tsx +5 -1
- package/src/jest/index.tsx +22 -1
- package/src/native/EnrichedMarkdownText.tsx +220 -9
- package/src/normalizeMarkdownStyle.ts +15 -0
- package/src/normalizeMarkdownStyle.web.ts +13 -0
- package/src/types/MarkdownStyle.ts +51 -5
- package/src/types/MarkdownStyleInternal.ts +12 -0
- package/src/types/MarkdownTextProps.ts +151 -11
- package/src/types/MarkdownTextProps.web.ts +43 -1
- package/src/types/events.ts +69 -0
- package/src/web/EnrichedMarkdownText.tsx +10 -3
- package/src/web/renderers/InlineRenderers.tsx +111 -3
- package/src/web/styles.ts +25 -0
- package/src/web/types.ts +4 -0
- package/src/web/utils.ts +8 -0
package/android/build.gradle
CHANGED
|
@@ -270,6 +270,8 @@ dependencies {
|
|
|
270
270
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
271
271
|
// Baseline Profile installer for AOT compilation hints
|
|
272
272
|
implementation "androidx.profileinstaller:profileinstaller:1.3.1"
|
|
273
|
+
// AppCompatTextView draws emoji through EmojiCompat; measurement must apply it too
|
|
274
|
+
implementation "androidx.emoji2:emoji2:1.4.0"
|
|
273
275
|
// LaTeX math rendering (optional — set enrichedMarkdown.enableMath=false in gradle.properties to exclude)
|
|
274
276
|
if (enableMath) {
|
|
275
277
|
implementation("io.github.erweixin:ratex-android:0.1.10")
|
package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerDelegate.java
CHANGED
|
@@ -32,12 +32,21 @@ public class EnrichedMarkdownManagerDelegate<T extends View, U extends BaseViewM
|
|
|
32
32
|
case "markdownStyle":
|
|
33
33
|
mViewManager.setMarkdownStyle(view, (ReadableMap) value);
|
|
34
34
|
break;
|
|
35
|
+
case "emitLinkLayout":
|
|
36
|
+
mViewManager.setEmitLinkLayout(view, value == null ? false : (boolean) value);
|
|
37
|
+
break;
|
|
38
|
+
case "emitSelectionChange":
|
|
39
|
+
mViewManager.setEmitSelectionChange(view, value == null ? false : (boolean) value);
|
|
40
|
+
break;
|
|
35
41
|
case "enableTaskListItemToggle":
|
|
36
42
|
mViewManager.setEnableTaskListItemToggle(view, value == null ? true : (boolean) value);
|
|
37
43
|
break;
|
|
38
44
|
case "enableLinkPreview":
|
|
39
45
|
mViewManager.setEnableLinkPreview(view, value == null ? true : (boolean) value);
|
|
40
46
|
break;
|
|
47
|
+
case "linkLongPressSelects":
|
|
48
|
+
mViewManager.setLinkLongPressSelects(view, value == null ? false : (boolean) value);
|
|
49
|
+
break;
|
|
41
50
|
case "selectable":
|
|
42
51
|
mViewManager.setSelectable(view, value == null ? false : (boolean) value);
|
|
43
52
|
break;
|
|
@@ -96,4 +105,13 @@ public class EnrichedMarkdownManagerDelegate<T extends View, U extends BaseViewM
|
|
|
96
105
|
super.setProperty(view, propName, value);
|
|
97
106
|
}
|
|
98
107
|
}
|
|
108
|
+
|
|
109
|
+
@Override
|
|
110
|
+
public void receiveCommand(T view, String commandName, ReadableArray args) {
|
|
111
|
+
switch (commandName) {
|
|
112
|
+
case "clearSelection":
|
|
113
|
+
mViewManager.clearSelection(view);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
99
117
|
}
|
package/android/generated/java/com/facebook/react/viewmanagers/EnrichedMarkdownManagerInterface.java
CHANGED
|
@@ -18,8 +18,11 @@ import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
|
18
18
|
public interface EnrichedMarkdownManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
19
19
|
void setMarkdown(T view, @Nullable String value);
|
|
20
20
|
void setMarkdownStyle(T view, @Nullable ReadableMap value);
|
|
21
|
+
void setEmitLinkLayout(T view, boolean value);
|
|
22
|
+
void setEmitSelectionChange(T view, boolean value);
|
|
21
23
|
void setEnableTaskListItemToggle(T view, boolean value);
|
|
22
24
|
void setEnableLinkPreview(T view, boolean value);
|
|
25
|
+
void setLinkLongPressSelects(T view, boolean value);
|
|
23
26
|
void setSelectable(T view, boolean value);
|
|
24
27
|
void setSelectionColor(T view, @Nullable Integer value);
|
|
25
28
|
void setSelectionHandleColor(T view, @Nullable Integer value);
|
|
@@ -38,4 +41,5 @@ public interface EnrichedMarkdownManagerInterface<T extends View> extends ViewMa
|
|
|
38
41
|
void setTextBreakStrategy(T view, @Nullable String value);
|
|
39
42
|
void setLineBreakStrategyIOS(T view, @Nullable String value);
|
|
40
43
|
void setWritingDirection(T view, @Nullable String value);
|
|
44
|
+
void clearSelection(T view);
|
|
41
45
|
}
|
|
@@ -32,12 +32,21 @@ public class EnrichedMarkdownTextManagerDelegate<T extends View, U extends BaseV
|
|
|
32
32
|
case "markdownStyle":
|
|
33
33
|
mViewManager.setMarkdownStyle(view, (ReadableMap) value);
|
|
34
34
|
break;
|
|
35
|
+
case "emitLinkLayout":
|
|
36
|
+
mViewManager.setEmitLinkLayout(view, value == null ? false : (boolean) value);
|
|
37
|
+
break;
|
|
38
|
+
case "emitSelectionChange":
|
|
39
|
+
mViewManager.setEmitSelectionChange(view, value == null ? false : (boolean) value);
|
|
40
|
+
break;
|
|
35
41
|
case "enableTaskListItemToggle":
|
|
36
42
|
mViewManager.setEnableTaskListItemToggle(view, value == null ? true : (boolean) value);
|
|
37
43
|
break;
|
|
38
44
|
case "enableLinkPreview":
|
|
39
45
|
mViewManager.setEnableLinkPreview(view, value == null ? true : (boolean) value);
|
|
40
46
|
break;
|
|
47
|
+
case "linkLongPressSelects":
|
|
48
|
+
mViewManager.setLinkLongPressSelects(view, value == null ? false : (boolean) value);
|
|
49
|
+
break;
|
|
41
50
|
case "selectable":
|
|
42
51
|
mViewManager.setSelectable(view, value == null ? false : (boolean) value);
|
|
43
52
|
break;
|
|
@@ -96,4 +105,13 @@ public class EnrichedMarkdownTextManagerDelegate<T extends View, U extends BaseV
|
|
|
96
105
|
super.setProperty(view, propName, value);
|
|
97
106
|
}
|
|
98
107
|
}
|
|
108
|
+
|
|
109
|
+
@Override
|
|
110
|
+
public void receiveCommand(T view, String commandName, ReadableArray args) {
|
|
111
|
+
switch (commandName) {
|
|
112
|
+
case "clearSelection":
|
|
113
|
+
mViewManager.clearSelection(view);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
99
117
|
}
|
|
@@ -18,8 +18,11 @@ import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
|
18
18
|
public interface EnrichedMarkdownTextManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
19
19
|
void setMarkdown(T view, @Nullable String value);
|
|
20
20
|
void setMarkdownStyle(T view, @Nullable ReadableMap value);
|
|
21
|
+
void setEmitLinkLayout(T view, boolean value);
|
|
22
|
+
void setEmitSelectionChange(T view, boolean value);
|
|
21
23
|
void setEnableTaskListItemToggle(T view, boolean value);
|
|
22
24
|
void setEnableLinkPreview(T view, boolean value);
|
|
25
|
+
void setLinkLongPressSelects(T view, boolean value);
|
|
23
26
|
void setSelectable(T view, boolean value);
|
|
24
27
|
void setSelectionColor(T view, @Nullable Integer value);
|
|
25
28
|
void setSelectionHandleColor(T view, @Nullable Integer value);
|
|
@@ -38,4 +41,5 @@ public interface EnrichedMarkdownTextManagerInterface<T extends View> extends Vi
|
|
|
38
41
|
void setTextBreakStrategy(T view, @Nullable String value);
|
|
39
42
|
void setLineBreakStrategyIOS(T view, @Nullable String value);
|
|
40
43
|
void setWritingDirection(T view, @Nullable String value);
|
|
44
|
+
void clearSelection(T view);
|
|
41
45
|
}
|
package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.cpp
CHANGED
|
@@ -31,6 +31,68 @@ void EnrichedMarkdownEventEmitter::onLinkLongPress(OnLinkLongPress event) const
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
|
|
34
|
+
void EnrichedMarkdownEventEmitter::onLinkLayout(OnLinkLayout event) const {
|
|
35
|
+
dispatchEvent("linkLayout", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
36
|
+
auto payload = jsi::Object(runtime);
|
|
37
|
+
|
|
38
|
+
auto fragments = jsi::Array(runtime, event.fragments.size());
|
|
39
|
+
size_t fragmentsIndex = 0;
|
|
40
|
+
for (auto fragmentsValue : event.fragments) {
|
|
41
|
+
auto fragmentsObject = jsi::Object(runtime);
|
|
42
|
+
fragmentsObject.setProperty(runtime, "linkIndex", fragmentsValue.linkIndex);
|
|
43
|
+
fragmentsObject.setProperty(runtime, "url", fragmentsValue.url);
|
|
44
|
+
fragmentsObject.setProperty(runtime, "text", fragmentsValue.text);
|
|
45
|
+
fragmentsObject.setProperty(runtime, "x", fragmentsValue.x);
|
|
46
|
+
fragmentsObject.setProperty(runtime, "y", fragmentsValue.y);
|
|
47
|
+
fragmentsObject.setProperty(runtime, "width", fragmentsValue.width);
|
|
48
|
+
fragmentsObject.setProperty(runtime, "height", fragmentsValue.height);
|
|
49
|
+
fragments.setValueAtIndex(runtime, fragmentsIndex++, fragmentsObject);
|
|
50
|
+
}
|
|
51
|
+
payload.setProperty(runtime, "fragments", fragments);
|
|
52
|
+
|
|
53
|
+
return payload;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
void EnrichedMarkdownEventEmitter::onSelectionChange(OnSelectionChange event) const {
|
|
59
|
+
dispatchEvent("selectionChange", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
60
|
+
auto payload = jsi::Object(runtime);
|
|
61
|
+
payload.setProperty(runtime, "active", event.active);
|
|
62
|
+
payload.setProperty(runtime, "source", event.source);
|
|
63
|
+
payload.setProperty(runtime, "text", event.text);
|
|
64
|
+
payload.setProperty(runtime, "markdown", event.markdown);
|
|
65
|
+
payload.setProperty(runtime, "whole", event.whole);
|
|
66
|
+
{
|
|
67
|
+
auto rect = jsi::Object(runtime);
|
|
68
|
+
rect.setProperty(runtime, "x", event.rect.x);
|
|
69
|
+
rect.setProperty(runtime, "y", event.rect.y);
|
|
70
|
+
rect.setProperty(runtime, "width", event.rect.width);
|
|
71
|
+
rect.setProperty(runtime, "height", event.rect.height);
|
|
72
|
+
payload.setProperty(runtime, "rect", rect);
|
|
73
|
+
}
|
|
74
|
+
{
|
|
75
|
+
auto startRect = jsi::Object(runtime);
|
|
76
|
+
startRect.setProperty(runtime, "x", event.startRect.x);
|
|
77
|
+
startRect.setProperty(runtime, "y", event.startRect.y);
|
|
78
|
+
startRect.setProperty(runtime, "width", event.startRect.width);
|
|
79
|
+
startRect.setProperty(runtime, "height", event.startRect.height);
|
|
80
|
+
payload.setProperty(runtime, "startRect", startRect);
|
|
81
|
+
}
|
|
82
|
+
{
|
|
83
|
+
auto endRect = jsi::Object(runtime);
|
|
84
|
+
endRect.setProperty(runtime, "x", event.endRect.x);
|
|
85
|
+
endRect.setProperty(runtime, "y", event.endRect.y);
|
|
86
|
+
endRect.setProperty(runtime, "width", event.endRect.width);
|
|
87
|
+
endRect.setProperty(runtime, "height", event.endRect.height);
|
|
88
|
+
payload.setProperty(runtime, "endRect", endRect);
|
|
89
|
+
}
|
|
90
|
+
payload.setProperty(runtime, "adjusting", event.adjusting);
|
|
91
|
+
return payload;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
34
96
|
void EnrichedMarkdownEventEmitter::onTaskListItemPress(OnTaskListItemPress event) const {
|
|
35
97
|
dispatchEvent("taskListItemPress", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
36
98
|
auto payload = jsi::Object(runtime);
|
|
@@ -52,6 +114,18 @@ payload.setProperty(runtime, "language", event.language);
|
|
|
52
114
|
}
|
|
53
115
|
|
|
54
116
|
|
|
117
|
+
void EnrichedMarkdownEventEmitter::onCopyRequest(OnCopyRequest event) const {
|
|
118
|
+
dispatchEvent("copyRequest", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
119
|
+
auto payload = jsi::Object(runtime);
|
|
120
|
+
payload.setProperty(runtime, "source", event.source);
|
|
121
|
+
payload.setProperty(runtime, "markdown", event.markdown);
|
|
122
|
+
payload.setProperty(runtime, "text", event.text);
|
|
123
|
+
payload.setProperty(runtime, "whole", event.whole);
|
|
124
|
+
return payload;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
55
129
|
void EnrichedMarkdownEventEmitter::onContextMenuItemPress(OnContextMenuItemPress event) const {
|
|
56
130
|
dispatchEvent("contextMenuItemPress", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
57
131
|
auto payload = jsi::Object(runtime);
|
|
@@ -358,6 +432,68 @@ void EnrichedMarkdownTextEventEmitter::onLinkLongPress(OnLinkLongPress event) co
|
|
|
358
432
|
}
|
|
359
433
|
|
|
360
434
|
|
|
435
|
+
void EnrichedMarkdownTextEventEmitter::onLinkLayout(OnLinkLayout event) const {
|
|
436
|
+
dispatchEvent("linkLayout", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
437
|
+
auto payload = jsi::Object(runtime);
|
|
438
|
+
|
|
439
|
+
auto fragments = jsi::Array(runtime, event.fragments.size());
|
|
440
|
+
size_t fragmentsIndex = 0;
|
|
441
|
+
for (auto fragmentsValue : event.fragments) {
|
|
442
|
+
auto fragmentsObject = jsi::Object(runtime);
|
|
443
|
+
fragmentsObject.setProperty(runtime, "linkIndex", fragmentsValue.linkIndex);
|
|
444
|
+
fragmentsObject.setProperty(runtime, "url", fragmentsValue.url);
|
|
445
|
+
fragmentsObject.setProperty(runtime, "text", fragmentsValue.text);
|
|
446
|
+
fragmentsObject.setProperty(runtime, "x", fragmentsValue.x);
|
|
447
|
+
fragmentsObject.setProperty(runtime, "y", fragmentsValue.y);
|
|
448
|
+
fragmentsObject.setProperty(runtime, "width", fragmentsValue.width);
|
|
449
|
+
fragmentsObject.setProperty(runtime, "height", fragmentsValue.height);
|
|
450
|
+
fragments.setValueAtIndex(runtime, fragmentsIndex++, fragmentsObject);
|
|
451
|
+
}
|
|
452
|
+
payload.setProperty(runtime, "fragments", fragments);
|
|
453
|
+
|
|
454
|
+
return payload;
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
void EnrichedMarkdownTextEventEmitter::onSelectionChange(OnSelectionChange event) const {
|
|
460
|
+
dispatchEvent("selectionChange", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
461
|
+
auto payload = jsi::Object(runtime);
|
|
462
|
+
payload.setProperty(runtime, "active", event.active);
|
|
463
|
+
payload.setProperty(runtime, "source", event.source);
|
|
464
|
+
payload.setProperty(runtime, "text", event.text);
|
|
465
|
+
payload.setProperty(runtime, "markdown", event.markdown);
|
|
466
|
+
payload.setProperty(runtime, "whole", event.whole);
|
|
467
|
+
{
|
|
468
|
+
auto rect = jsi::Object(runtime);
|
|
469
|
+
rect.setProperty(runtime, "x", event.rect.x);
|
|
470
|
+
rect.setProperty(runtime, "y", event.rect.y);
|
|
471
|
+
rect.setProperty(runtime, "width", event.rect.width);
|
|
472
|
+
rect.setProperty(runtime, "height", event.rect.height);
|
|
473
|
+
payload.setProperty(runtime, "rect", rect);
|
|
474
|
+
}
|
|
475
|
+
{
|
|
476
|
+
auto startRect = jsi::Object(runtime);
|
|
477
|
+
startRect.setProperty(runtime, "x", event.startRect.x);
|
|
478
|
+
startRect.setProperty(runtime, "y", event.startRect.y);
|
|
479
|
+
startRect.setProperty(runtime, "width", event.startRect.width);
|
|
480
|
+
startRect.setProperty(runtime, "height", event.startRect.height);
|
|
481
|
+
payload.setProperty(runtime, "startRect", startRect);
|
|
482
|
+
}
|
|
483
|
+
{
|
|
484
|
+
auto endRect = jsi::Object(runtime);
|
|
485
|
+
endRect.setProperty(runtime, "x", event.endRect.x);
|
|
486
|
+
endRect.setProperty(runtime, "y", event.endRect.y);
|
|
487
|
+
endRect.setProperty(runtime, "width", event.endRect.width);
|
|
488
|
+
endRect.setProperty(runtime, "height", event.endRect.height);
|
|
489
|
+
payload.setProperty(runtime, "endRect", endRect);
|
|
490
|
+
}
|
|
491
|
+
payload.setProperty(runtime, "adjusting", event.adjusting);
|
|
492
|
+
return payload;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
|
|
361
497
|
void EnrichedMarkdownTextEventEmitter::onTaskListItemPress(OnTaskListItemPress event) const {
|
|
362
498
|
dispatchEvent("taskListItemPress", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
363
499
|
auto payload = jsi::Object(runtime);
|
|
@@ -379,6 +515,18 @@ payload.setProperty(runtime, "language", event.language);
|
|
|
379
515
|
}
|
|
380
516
|
|
|
381
517
|
|
|
518
|
+
void EnrichedMarkdownTextEventEmitter::onCopyRequest(OnCopyRequest event) const {
|
|
519
|
+
dispatchEvent("copyRequest", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
520
|
+
auto payload = jsi::Object(runtime);
|
|
521
|
+
payload.setProperty(runtime, "source", event.source);
|
|
522
|
+
payload.setProperty(runtime, "markdown", event.markdown);
|
|
523
|
+
payload.setProperty(runtime, "text", event.text);
|
|
524
|
+
payload.setProperty(runtime, "whole", event.whole);
|
|
525
|
+
return payload;
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
|
|
382
530
|
void EnrichedMarkdownTextEventEmitter::onContextMenuItemPress(OnContextMenuItemPress event) const {
|
|
383
531
|
dispatchEvent("contextMenuItemPress", [event=std::move(event)](jsi::Runtime &runtime) {
|
|
384
532
|
auto payload = jsi::Object(runtime);
|
package/android/generated/jni/react/renderer/components/EnrichedMarkdownTextSpec/EventEmitters.h
CHANGED
|
@@ -25,6 +25,53 @@ class EnrichedMarkdownEventEmitter : public ViewEventEmitter {
|
|
|
25
25
|
std::string url;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
struct OnLinkLayoutFragments {
|
|
29
|
+
int linkIndex;
|
|
30
|
+
std::string url;
|
|
31
|
+
std::string text;
|
|
32
|
+
double x;
|
|
33
|
+
double y;
|
|
34
|
+
double width;
|
|
35
|
+
double height;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
struct OnLinkLayout {
|
|
39
|
+
std::vector<OnLinkLayoutFragments> fragments;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
struct OnSelectionChangeRect {
|
|
43
|
+
double x;
|
|
44
|
+
double y;
|
|
45
|
+
double width;
|
|
46
|
+
double height;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
struct OnSelectionChangeStartRect {
|
|
50
|
+
double x;
|
|
51
|
+
double y;
|
|
52
|
+
double width;
|
|
53
|
+
double height;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
struct OnSelectionChangeEndRect {
|
|
57
|
+
double x;
|
|
58
|
+
double y;
|
|
59
|
+
double width;
|
|
60
|
+
double height;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
struct OnSelectionChange {
|
|
64
|
+
bool active;
|
|
65
|
+
std::string source;
|
|
66
|
+
std::string text;
|
|
67
|
+
std::string markdown;
|
|
68
|
+
bool whole;
|
|
69
|
+
OnSelectionChangeRect rect;
|
|
70
|
+
OnSelectionChangeStartRect startRect;
|
|
71
|
+
OnSelectionChangeEndRect endRect;
|
|
72
|
+
bool adjusting;
|
|
73
|
+
};
|
|
74
|
+
|
|
28
75
|
struct OnTaskListItemPress {
|
|
29
76
|
int index;
|
|
30
77
|
bool checked;
|
|
@@ -36,6 +83,13 @@ class EnrichedMarkdownEventEmitter : public ViewEventEmitter {
|
|
|
36
83
|
std::string language;
|
|
37
84
|
};
|
|
38
85
|
|
|
86
|
+
struct OnCopyRequest {
|
|
87
|
+
std::string source;
|
|
88
|
+
std::string markdown;
|
|
89
|
+
std::string text;
|
|
90
|
+
bool whole;
|
|
91
|
+
};
|
|
92
|
+
|
|
39
93
|
struct OnContextMenuItemPress {
|
|
40
94
|
std::string itemText;
|
|
41
95
|
std::string selectedText;
|
|
@@ -46,10 +100,16 @@ class EnrichedMarkdownEventEmitter : public ViewEventEmitter {
|
|
|
46
100
|
|
|
47
101
|
void onLinkLongPress(OnLinkLongPress value) const;
|
|
48
102
|
|
|
103
|
+
void onLinkLayout(OnLinkLayout value) const;
|
|
104
|
+
|
|
105
|
+
void onSelectionChange(OnSelectionChange value) const;
|
|
106
|
+
|
|
49
107
|
void onTaskListItemPress(OnTaskListItemPress value) const;
|
|
50
108
|
|
|
51
109
|
void onCopyPress(OnCopyPress value) const;
|
|
52
110
|
|
|
111
|
+
void onCopyRequest(OnCopyRequest value) const;
|
|
112
|
+
|
|
53
113
|
void onContextMenuItemPress(OnContextMenuItemPress value) const;
|
|
54
114
|
};
|
|
55
115
|
class EnrichedMarkdownTextInputEventEmitter : public ViewEventEmitter {
|
|
@@ -292,6 +352,53 @@ class EnrichedMarkdownTextEventEmitter : public ViewEventEmitter {
|
|
|
292
352
|
std::string url;
|
|
293
353
|
};
|
|
294
354
|
|
|
355
|
+
struct OnLinkLayoutFragments {
|
|
356
|
+
int linkIndex;
|
|
357
|
+
std::string url;
|
|
358
|
+
std::string text;
|
|
359
|
+
double x;
|
|
360
|
+
double y;
|
|
361
|
+
double width;
|
|
362
|
+
double height;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
struct OnLinkLayout {
|
|
366
|
+
std::vector<OnLinkLayoutFragments> fragments;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
struct OnSelectionChangeRect {
|
|
370
|
+
double x;
|
|
371
|
+
double y;
|
|
372
|
+
double width;
|
|
373
|
+
double height;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
struct OnSelectionChangeStartRect {
|
|
377
|
+
double x;
|
|
378
|
+
double y;
|
|
379
|
+
double width;
|
|
380
|
+
double height;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
struct OnSelectionChangeEndRect {
|
|
384
|
+
double x;
|
|
385
|
+
double y;
|
|
386
|
+
double width;
|
|
387
|
+
double height;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
struct OnSelectionChange {
|
|
391
|
+
bool active;
|
|
392
|
+
std::string source;
|
|
393
|
+
std::string text;
|
|
394
|
+
std::string markdown;
|
|
395
|
+
bool whole;
|
|
396
|
+
OnSelectionChangeRect rect;
|
|
397
|
+
OnSelectionChangeStartRect startRect;
|
|
398
|
+
OnSelectionChangeEndRect endRect;
|
|
399
|
+
bool adjusting;
|
|
400
|
+
};
|
|
401
|
+
|
|
295
402
|
struct OnTaskListItemPress {
|
|
296
403
|
int index;
|
|
297
404
|
bool checked;
|
|
@@ -303,6 +410,13 @@ class EnrichedMarkdownTextEventEmitter : public ViewEventEmitter {
|
|
|
303
410
|
std::string language;
|
|
304
411
|
};
|
|
305
412
|
|
|
413
|
+
struct OnCopyRequest {
|
|
414
|
+
std::string source;
|
|
415
|
+
std::string markdown;
|
|
416
|
+
std::string text;
|
|
417
|
+
bool whole;
|
|
418
|
+
};
|
|
419
|
+
|
|
306
420
|
struct OnContextMenuItemPress {
|
|
307
421
|
std::string itemText;
|
|
308
422
|
std::string selectedText;
|
|
@@ -313,10 +427,16 @@ class EnrichedMarkdownTextEventEmitter : public ViewEventEmitter {
|
|
|
313
427
|
|
|
314
428
|
void onLinkLongPress(OnLinkLongPress value) const;
|
|
315
429
|
|
|
430
|
+
void onLinkLayout(OnLinkLayout value) const;
|
|
431
|
+
|
|
432
|
+
void onSelectionChange(OnSelectionChange value) const;
|
|
433
|
+
|
|
316
434
|
void onTaskListItemPress(OnTaskListItemPress value) const;
|
|
317
435
|
|
|
318
436
|
void onCopyPress(OnCopyPress value) const;
|
|
319
437
|
|
|
438
|
+
void onCopyRequest(OnCopyRequest value) const;
|
|
439
|
+
|
|
320
440
|
void onContextMenuItemPress(OnContextMenuItemPress value) const;
|
|
321
441
|
};
|
|
322
442
|
} // namespace facebook::react
|
|
@@ -21,8 +21,11 @@ EnrichedMarkdownProps::EnrichedMarkdownProps(
|
|
|
21
21
|
|
|
22
22
|
markdown(convertRawProp(context, rawProps, "markdown", sourceProps.markdown, {})),
|
|
23
23
|
markdownStyle(convertRawProp(context, rawProps, "markdownStyle", sourceProps.markdownStyle, {})),
|
|
24
|
+
emitLinkLayout(convertRawProp(context, rawProps, "emitLinkLayout", sourceProps.emitLinkLayout, {false})),
|
|
25
|
+
emitSelectionChange(convertRawProp(context, rawProps, "emitSelectionChange", sourceProps.emitSelectionChange, {false})),
|
|
24
26
|
enableTaskListItemToggle(convertRawProp(context, rawProps, "enableTaskListItemToggle", sourceProps.enableTaskListItemToggle, {true})),
|
|
25
27
|
enableLinkPreview(convertRawProp(context, rawProps, "enableLinkPreview", sourceProps.enableLinkPreview, {true})),
|
|
28
|
+
linkLongPressSelects(convertRawProp(context, rawProps, "linkLongPressSelects", sourceProps.linkLongPressSelects, {false})),
|
|
26
29
|
selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})),
|
|
27
30
|
selectionColor(convertRawProp(context, rawProps, "selectionColor", sourceProps.selectionColor, {})),
|
|
28
31
|
selectionHandleColor(convertRawProp(context, rawProps, "selectionHandleColor", sourceProps.selectionHandleColor, {})),
|
|
@@ -66,6 +69,14 @@ folly::dynamic EnrichedMarkdownProps::getDiffProps(
|
|
|
66
69
|
result["markdownStyle"] = toDynamic(markdownStyle);
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
if (emitLinkLayout != oldProps->emitLinkLayout) {
|
|
73
|
+
result["emitLinkLayout"] = emitLinkLayout;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (emitSelectionChange != oldProps->emitSelectionChange) {
|
|
77
|
+
result["emitSelectionChange"] = emitSelectionChange;
|
|
78
|
+
}
|
|
79
|
+
|
|
69
80
|
if (enableTaskListItemToggle != oldProps->enableTaskListItemToggle) {
|
|
70
81
|
result["enableTaskListItemToggle"] = enableTaskListItemToggle;
|
|
71
82
|
}
|
|
@@ -74,6 +85,10 @@ folly::dynamic EnrichedMarkdownProps::getDiffProps(
|
|
|
74
85
|
result["enableLinkPreview"] = enableLinkPreview;
|
|
75
86
|
}
|
|
76
87
|
|
|
88
|
+
if (linkLongPressSelects != oldProps->linkLongPressSelects) {
|
|
89
|
+
result["linkLongPressSelects"] = linkLongPressSelects;
|
|
90
|
+
}
|
|
91
|
+
|
|
77
92
|
if (selectable != oldProps->selectable) {
|
|
78
93
|
result["selectable"] = selectable;
|
|
79
94
|
}
|
|
@@ -304,8 +319,11 @@ EnrichedMarkdownTextProps::EnrichedMarkdownTextProps(
|
|
|
304
319
|
|
|
305
320
|
markdown(convertRawProp(context, rawProps, "markdown", sourceProps.markdown, {})),
|
|
306
321
|
markdownStyle(convertRawProp(context, rawProps, "markdownStyle", sourceProps.markdownStyle, {})),
|
|
322
|
+
emitLinkLayout(convertRawProp(context, rawProps, "emitLinkLayout", sourceProps.emitLinkLayout, {false})),
|
|
323
|
+
emitSelectionChange(convertRawProp(context, rawProps, "emitSelectionChange", sourceProps.emitSelectionChange, {false})),
|
|
307
324
|
enableTaskListItemToggle(convertRawProp(context, rawProps, "enableTaskListItemToggle", sourceProps.enableTaskListItemToggle, {true})),
|
|
308
325
|
enableLinkPreview(convertRawProp(context, rawProps, "enableLinkPreview", sourceProps.enableLinkPreview, {true})),
|
|
326
|
+
linkLongPressSelects(convertRawProp(context, rawProps, "linkLongPressSelects", sourceProps.linkLongPressSelects, {false})),
|
|
309
327
|
selectable(convertRawProp(context, rawProps, "selectable", sourceProps.selectable, {false})),
|
|
310
328
|
selectionColor(convertRawProp(context, rawProps, "selectionColor", sourceProps.selectionColor, {})),
|
|
311
329
|
selectionHandleColor(convertRawProp(context, rawProps, "selectionHandleColor", sourceProps.selectionHandleColor, {})),
|
|
@@ -349,6 +367,14 @@ folly::dynamic EnrichedMarkdownTextProps::getDiffProps(
|
|
|
349
367
|
result["markdownStyle"] = toDynamic(markdownStyle);
|
|
350
368
|
}
|
|
351
369
|
|
|
370
|
+
if (emitLinkLayout != oldProps->emitLinkLayout) {
|
|
371
|
+
result["emitLinkLayout"] = emitLinkLayout;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (emitSelectionChange != oldProps->emitSelectionChange) {
|
|
375
|
+
result["emitSelectionChange"] = emitSelectionChange;
|
|
376
|
+
}
|
|
377
|
+
|
|
352
378
|
if (enableTaskListItemToggle != oldProps->enableTaskListItemToggle) {
|
|
353
379
|
result["enableTaskListItemToggle"] = enableTaskListItemToggle;
|
|
354
380
|
}
|
|
@@ -357,6 +383,10 @@ folly::dynamic EnrichedMarkdownTextProps::getDiffProps(
|
|
|
357
383
|
result["enableLinkPreview"] = enableLinkPreview;
|
|
358
384
|
}
|
|
359
385
|
|
|
386
|
+
if (linkLongPressSelects != oldProps->linkLongPressSelects) {
|
|
387
|
+
result["linkLongPressSelects"] = linkLongPressSelects;
|
|
388
|
+
}
|
|
389
|
+
|
|
360
390
|
if (selectable != oldProps->selectable) {
|
|
361
391
|
result["selectable"] = selectable;
|
|
362
392
|
}
|