@churchapps/apphelper 0.3.16 → 0.3.17
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/dist/components/markdownEditor/Editor.d.ts +3 -1
- package/dist/components/markdownEditor/Editor.d.ts.map +1 -1
- package/dist/components/markdownEditor/Editor.js +25 -4
- package/dist/components/markdownEditor/Editor.js.map +1 -1
- package/dist/components/markdownEditor/MarkdownPreview.d.ts +3 -1
- package/dist/components/markdownEditor/MarkdownPreview.d.ts.map +1 -1
- package/dist/components/markdownEditor/MarkdownPreview.js +14 -2
- package/dist/components/markdownEditor/MarkdownPreview.js.map +1 -1
- package/dist/components/markdownEditor/MarkdownPreviewLight.d.ts.map +1 -1
- package/dist/components/markdownEditor/MarkdownPreviewLight.js +5 -1
- package/dist/components/markdownEditor/MarkdownPreviewLight.js.map +1 -1
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/FloatingTextFormatToolbarPlugin.d.ts +13 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/FloatingTextFormatToolbarPlugin.d.ts.map +1 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/FloatingTextFormatToolbarPlugin.js +311 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/FloatingTextFormatToolbarPlugin.js.map +1 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getDOMRangeRect.d.ts +2 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getDOMRangeRect.d.ts.map +1 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getDOMRangeRect.js +20 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getDOMRangeRect.js.map +1 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getSelectNode.d.ts +2 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getSelectNode.d.ts.map +1 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getSelectNode.js +22 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/getSelectNode.js.map +1 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.d.ts +2 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.d.ts.map +1 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.js +30 -0
- package/dist/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.js.map +1 -0
- package/dist/components/markdownEditor/plugins/MarkdownTransformers.js +2 -2
- package/dist/components/markdownEditor/plugins/MarkdownTransformers.js.map +1 -1
- package/package.json +1 -1
- package/src/components/markdownEditor/Editor.tsx +33 -16
- package/src/components/markdownEditor/MarkdownPreview.tsx +5 -3
- package/src/components/markdownEditor/MarkdownPreviewLight.tsx +5 -1
- package/src/components/markdownEditor/plugins/FloatingTextMenu/FloatingTextFormatToolbarPlugin.tsx +445 -0
- package/src/components/markdownEditor/plugins/FloatingTextMenu/getDOMRangeRect.tsx +17 -0
- package/src/components/markdownEditor/plugins/FloatingTextMenu/getSelectNode.tsx +17 -0
- package/src/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.tsx +33 -0
- package/src/components/markdownEditor/plugins/MarkdownTransformers.ts +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function getDOMRangeRect(nativeSelection: any, rootElement: any) {
|
|
2
|
+
const domRange = nativeSelection.getRangeAt(0);
|
|
3
|
+
|
|
4
|
+
let rect;
|
|
5
|
+
|
|
6
|
+
if (nativeSelection.anchorNode === rootElement) {
|
|
7
|
+
let inner = rootElement;
|
|
8
|
+
while (inner.firstElementChild != null) {
|
|
9
|
+
inner = inner.firstElementChild;
|
|
10
|
+
}
|
|
11
|
+
rect = inner.getBoundingClientRect();
|
|
12
|
+
} else {
|
|
13
|
+
rect = domRange.getBoundingClientRect();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return rect;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $isAtNodeEnd } from "@lexical/selection";
|
|
2
|
+
|
|
3
|
+
export function getSelectedNode(selection: any) {
|
|
4
|
+
const anchor = selection.anchor;
|
|
5
|
+
const focus = selection.focus;
|
|
6
|
+
const anchorNode = selection.anchor.getNode();
|
|
7
|
+
const focusNode = selection.focus.getNode();
|
|
8
|
+
if (anchorNode === focusNode) {
|
|
9
|
+
return anchorNode;
|
|
10
|
+
}
|
|
11
|
+
const isBackward = selection.isBackward();
|
|
12
|
+
if (isBackward) {
|
|
13
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
14
|
+
} else {
|
|
15
|
+
return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const VERTICAL_GAP = 10;
|
|
2
|
+
const HORIZONTAL_OFFSET = 5;
|
|
3
|
+
|
|
4
|
+
export function setFloatingElemPosition( targetRect: any, floatingElem: any, anchorElem: any, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET ) {
|
|
5
|
+
const scrollerElem = anchorElem.parentElement;
|
|
6
|
+
|
|
7
|
+
if (targetRect === null || !scrollerElem) {
|
|
8
|
+
floatingElem.style.opacity = "0";
|
|
9
|
+
floatingElem.style.transform = "translate(-10000px, -10000px)";
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const floatingElemRect = floatingElem.getBoundingClientRect();
|
|
14
|
+
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
15
|
+
const editorScrollerRect = scrollerElem.getBoundingClientRect();
|
|
16
|
+
|
|
17
|
+
let top = targetRect.top - floatingElemRect.height - verticalGap;
|
|
18
|
+
let left = targetRect.left - horizontalOffset;
|
|
19
|
+
|
|
20
|
+
if (top < editorScrollerRect.top) {
|
|
21
|
+
top += floatingElemRect.height + targetRect.height + verticalGap * 2;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (left + floatingElemRect.width > editorScrollerRect.right) {
|
|
25
|
+
left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
top -= anchorElementRect.top;
|
|
29
|
+
left -= anchorElementRect.left;
|
|
30
|
+
|
|
31
|
+
floatingElem.style.opacity = "1";
|
|
32
|
+
floatingElem.style.transform = `translate(${left}px, ${top}px)`;
|
|
33
|
+
}
|
|
@@ -61,7 +61,7 @@ export type TextMatchTransformer = Readonly<{
|
|
|
61
61
|
export const UNDERLINE: TextFormatTransformer = {
|
|
62
62
|
format: ["underline"],
|
|
63
63
|
intraword: false,
|
|
64
|
-
tag: "
|
|
64
|
+
tag: "__",
|
|
65
65
|
type: "text-format"
|
|
66
66
|
};
|
|
67
67
|
/*
|
|
@@ -96,11 +96,11 @@ export const UNDERLINE: TextMatchTransformer = {
|
|
|
96
96
|
const modifiedTextTransformers = [EMOJI_NODE_MARKDOWN_TRANSFORM];
|
|
97
97
|
|
|
98
98
|
export const PLAYGROUND_TRANSFORMERS: Array<Transformer> = [
|
|
99
|
-
UNDERLINE,
|
|
100
99
|
...modifiedTextTransformers,
|
|
101
100
|
HR,
|
|
102
101
|
...ELEMENT_TRANSFORMERS,
|
|
103
102
|
|
|
104
103
|
CUSTOM_LINK_NODE_TRANSFORMER,
|
|
105
104
|
...TRANSFORMERS.splice(0, 13),
|
|
105
|
+
UNDERLINE,
|
|
106
106
|
];
|