@churchapps/apphelper 0.3.15 → 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/dist/pageComponents/components/SelectChurchSearch.d.ts.map +1 -1
- package/dist/pageComponents/components/SelectChurchSearch.js +1 -1
- package/dist/pageComponents/components/SelectChurchSearch.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
- package/src/pageComponents/components/SelectChurchSearch.tsx +48 -48
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectNode.js","sourceRoot":"","sources":["../../../../../src/components/markdownEditor/plugins/FloatingTextMenu/getSelectNode.tsx"],"names":[],"mappings":";;;AAAA,kDAAkD;AAElD,SAAgB,eAAe,CAAC,SAAc;IAC5C,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAChC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;IAC9B,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC9C,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC5C,IAAI,UAAU,KAAK,SAAS,EAAE;QAC5B,OAAO,UAAU,CAAC;KACnB;IACD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;IAC1C,IAAI,UAAU,EAAE;QACd,OAAO,IAAA,wBAAY,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;KACrD;SAAM;QACL,OAAO,IAAA,wBAAY,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;KACtD;AACH,CAAC;AAdD,0CAcC"}
|
package/dist/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setFloatingElemPosition.d.ts","sourceRoot":"","sources":["../../../../../src/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.tsx"],"names":[],"mappings":"AAGA,wBAAgB,uBAAuB,CAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,SAAe,EAAE,gBAAgB,SAAoB,QA6B7J"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setFloatingElemPosition = void 0;
|
|
4
|
+
const VERTICAL_GAP = 10;
|
|
5
|
+
const HORIZONTAL_OFFSET = 5;
|
|
6
|
+
function setFloatingElemPosition(targetRect, floatingElem, anchorElem, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) {
|
|
7
|
+
const scrollerElem = anchorElem.parentElement;
|
|
8
|
+
if (targetRect === null || !scrollerElem) {
|
|
9
|
+
floatingElem.style.opacity = "0";
|
|
10
|
+
floatingElem.style.transform = "translate(-10000px, -10000px)";
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const floatingElemRect = floatingElem.getBoundingClientRect();
|
|
14
|
+
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
15
|
+
const editorScrollerRect = scrollerElem.getBoundingClientRect();
|
|
16
|
+
let top = targetRect.top - floatingElemRect.height - verticalGap;
|
|
17
|
+
let left = targetRect.left - horizontalOffset;
|
|
18
|
+
if (top < editorScrollerRect.top) {
|
|
19
|
+
top += floatingElemRect.height + targetRect.height + verticalGap * 2;
|
|
20
|
+
}
|
|
21
|
+
if (left + floatingElemRect.width > editorScrollerRect.right) {
|
|
22
|
+
left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset;
|
|
23
|
+
}
|
|
24
|
+
top -= anchorElementRect.top;
|
|
25
|
+
left -= anchorElementRect.left;
|
|
26
|
+
floatingElem.style.opacity = "1";
|
|
27
|
+
floatingElem.style.transform = `translate(${left}px, ${top}px)`;
|
|
28
|
+
}
|
|
29
|
+
exports.setFloatingElemPosition = setFloatingElemPosition;
|
|
30
|
+
//# sourceMappingURL=setFloatingElemPosition.js.map
|
package/dist/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setFloatingElemPosition.js","sourceRoot":"","sources":["../../../../../src/components/markdownEditor/plugins/FloatingTextMenu/setFloatingElemPosition.tsx"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,SAAgB,uBAAuB,CAAE,UAAe,EAAE,YAAiB,EAAE,UAAe,EAAE,WAAW,GAAG,YAAY,EAAE,gBAAgB,GAAG,iBAAiB;IAC5J,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC;IAE9C,IAAI,UAAU,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE;QACxC,YAAY,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QACjC,YAAY,CAAC,KAAK,CAAC,SAAS,GAAG,+BAA+B,CAAC;QAC/D,OAAO;KACR;IAED,MAAM,gBAAgB,GAAG,YAAY,CAAC,qBAAqB,EAAE,CAAC;IAC9D,MAAM,iBAAiB,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;IAC7D,MAAM,kBAAkB,GAAG,YAAY,CAAC,qBAAqB,EAAE,CAAC;IAEhE,IAAI,GAAG,GAAG,UAAU,CAAC,GAAG,GAAG,gBAAgB,CAAC,MAAM,GAAG,WAAW,CAAC;IACjE,IAAI,IAAI,GAAG,UAAU,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAE9C,IAAI,GAAG,GAAG,kBAAkB,CAAC,GAAG,EAAE;QAChC,GAAG,IAAI,gBAAgB,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,WAAW,GAAG,CAAC,CAAC;KACtE;IAED,IAAI,IAAI,GAAG,gBAAgB,CAAC,KAAK,GAAG,kBAAkB,CAAC,KAAK,EAAE;QAC5D,IAAI,GAAG,kBAAkB,CAAC,KAAK,GAAG,gBAAgB,CAAC,KAAK,GAAG,gBAAgB,CAAC;KAC7E;IAED,GAAG,IAAI,iBAAiB,CAAC,GAAG,CAAC;IAC7B,IAAI,IAAI,iBAAiB,CAAC,IAAI,CAAC;IAE/B,YAAY,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;IACjC,YAAY,CAAC,KAAK,CAAC,SAAS,GAAG,aAAa,IAAI,OAAO,GAAG,KAAK,CAAC;AAClE,CAAC;AA7BD,0DA6BC"}
|
|
@@ -42,7 +42,7 @@ export type TextMatchTransformer = Readonly<{
|
|
|
42
42
|
exports.UNDERLINE = {
|
|
43
43
|
format: ["underline"],
|
|
44
44
|
intraword: false,
|
|
45
|
-
tag: "
|
|
45
|
+
tag: "__",
|
|
46
46
|
type: "text-format"
|
|
47
47
|
};
|
|
48
48
|
/*
|
|
@@ -75,11 +75,11 @@ export const UNDERLINE: TextMatchTransformer = {
|
|
|
75
75
|
*/
|
|
76
76
|
const modifiedTextTransformers = [EmojiNodeTransform_1.EMOJI_NODE_MARKDOWN_TRANSFORM];
|
|
77
77
|
exports.PLAYGROUND_TRANSFORMERS = [
|
|
78
|
-
exports.UNDERLINE,
|
|
79
78
|
...modifiedTextTransformers,
|
|
80
79
|
exports.HR,
|
|
81
80
|
...markdown_1.ELEMENT_TRANSFORMERS,
|
|
82
81
|
CustomLinkNodeTransformer_1.CUSTOM_LINK_NODE_TRANSFORMER,
|
|
83
82
|
...markdown_1.TRANSFORMERS.splice(0, 13),
|
|
83
|
+
exports.UNDERLINE,
|
|
84
84
|
];
|
|
85
85
|
//# sourceMappingURL=MarkdownTransformers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownTransformers.js","sourceRoot":"","sources":["../../../../src/components/markdownEditor/plugins/MarkdownTransformers.ts"],"names":[],"mappings":";;;AAGA,gDAI2B;AAC3B,wFAIkD;AAClD,sFAAsF;AACtF,mEAA2E;AAG9D,QAAA,EAAE,GAAuB;IACpC,YAAY,EAAE,CAAC,8CAAkB,CAAC;IAClC,MAAM,EAAE,CAAC,IAAiB,EAAE,EAAE,CAAC,CAAC,IAAA,iDAAqB,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,MAAM,EAAE,uBAAuB;IAC/B,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,IAAA,qDAAyB,GAAE,CAAC;QAEzC,iCAAiC;QACjC,IAAI,QAAQ,IAAI,UAAU,CAAC,cAAc,EAAE,IAAI,IAAI,EAAE;YACnD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;aAAM;YACL,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IACD,IAAI,EAAE,SAAS;CAChB,CAAC;AAQF;;;;;;;;;;;;;;;;EAgBE;AAEW,QAAA,SAAS,GAA0B;IAC9C,MAAM,EAAE,CAAC,WAAW,CAAC;IACrB,SAAS,EAAE,KAAK;IAChB,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"MarkdownTransformers.js","sourceRoot":"","sources":["../../../../src/components/markdownEditor/plugins/MarkdownTransformers.ts"],"names":[],"mappings":";;;AAGA,gDAI2B;AAC3B,wFAIkD;AAClD,sFAAsF;AACtF,mEAA2E;AAG9D,QAAA,EAAE,GAAuB;IACpC,YAAY,EAAE,CAAC,8CAAkB,CAAC;IAClC,MAAM,EAAE,CAAC,IAAiB,EAAE,EAAE,CAAC,CAAC,IAAA,iDAAqB,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,MAAM,EAAE,uBAAuB;IAC/B,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,IAAA,qDAAyB,GAAE,CAAC;QAEzC,iCAAiC;QACjC,IAAI,QAAQ,IAAI,UAAU,CAAC,cAAc,EAAE,IAAI,IAAI,EAAE;YACnD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;aAAM;YACL,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IACD,IAAI,EAAE,SAAS;CAChB,CAAC;AAQF;;;;;;;;;;;;;;;;EAgBE;AAEW,QAAA,SAAS,GAA0B;IAC9C,MAAM,EAAE,CAAC,WAAW,CAAC;IACrB,SAAS,EAAE,KAAK;IAChB,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,aAAa;CACpB,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BE;AAEF,MAAM,wBAAwB,GAAG,CAAC,kDAA6B,CAAC,CAAC;AAEpD,QAAA,uBAAuB,GAAuB;IACzD,GAAG,wBAAwB;IAC3B,UAAE;IACF,GAAG,+BAAoB;IAEvB,wDAA4B;IAC5B,GAAG,uBAAY,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;IAC7B,iBAAS;CACV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectChurchSearch.d.ts","sourceRoot":"","sources":["../../../src/pageComponents/components/SelectChurchSearch.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,UAAU,KAAK;
|
|
1
|
+
{"version":3,"file":"SelectChurchSearch.d.ts","sourceRoot":"","sources":["../../../src/pageComponents/components/SelectChurchSearch.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,UAAU,KAAK;IACd,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,wBAAwB,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7D,OAAO,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuD9C,CAAC"}
|
|
@@ -18,7 +18,7 @@ const SelectChurchSearch = (props) => {
|
|
|
18
18
|
const handleSubmit = (e) => {
|
|
19
19
|
if (e !== null)
|
|
20
20
|
e.preventDefault();
|
|
21
|
-
let term =
|
|
21
|
+
let term = searchText.trim();
|
|
22
22
|
helpers_1.ApiHelper.post("/churches/search", { name: term }, "MembershipApi").then(data => setChurches(data));
|
|
23
23
|
};
|
|
24
24
|
const handleChange = (e) => setSearchText(e.currentTarget.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectChurchSearch.js","sourceRoot":"","sources":["../../../src/pageComponents/components/SelectChurchSearch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,4CAAkD;AAClD,kDAA0B;AAC1B,2CAAiD;AAEjD,yDAAsD;AACtD,iEAA8D;AAQvD,MAAM,kBAAkB,GAAoB,CAAC,KAAK,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"SelectChurchSearch.js","sourceRoot":"","sources":["../../../src/pageComponents/components/SelectChurchSearch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,4CAAkD;AAClD,kDAA0B;AAC1B,2CAAiD;AAEjD,yDAAsD;AACtD,iEAA8D;AAQvD,MAAM,kBAAkB,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC5D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAoB,IAAI,CAAC,CAAC;IACxE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,YAAY,GAAG,CAAC,CAAmB,EAAE,EAAE;QAC5C,IAAI,CAAC,KAAK,IAAI;YAAE,CAAC,CAAC,cAAc,EAAE,CAAC;QACnC,IAAI,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;QAC7B,mBAAS,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACrG,CAAC,CAAA;IAED,MAAM,YAAY,GAAG,CAAC,CAAsC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAEtG,MAAM,aAAa,GAAG,CAAC,CAA2B,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE;QAAE,CAAC,CAAC,cAAc,EAAE,CAAC;QAAC,YAAY,CAAC,IAAI,CAAC,CAAC;KAAE,CAAC,CAAC,CAAA;IAE7H,MAAM,mBAAmB,GAAG,CAAC,CAAmB,EAAE,EAAE;QACnD,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC,EAAE;YACjE,eAAe,CAAC,IAAI,CAAC,CAAC;SACtB;IACF,CAAC,CAAA;IAED,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAC7B,0CACC,8BAAG,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAC,aAAa,EAAC,OAAO,EAAE,mBAAmB,YAClG,gBAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,GACnC,GACC,CACN,CAAA;IAED,MAAM,WAAW,GAAG,GAAG,EAAE;QACxB,MAAM,MAAM,GAAkB,EAAE,CAAC;QACjC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,CAAC,IAAI,CAAC,uBAAC,mCAAgB,IAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,GAAI,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC;IACf,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,GAAG,EAAE;QACvB,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO;aACzB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,6DAAE,wCAAI,gBAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,GAAK,EAAC,eAAe,EAAE,IAAI,CAAA;;YACzG,OAAO,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAA;IAED,IAAI,YAAY;QAAE,OAAO,CAAC,uBAAC,2CAAoB,IAAC,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,wBAAwB,EAAE,KAAK,CAAC,wBAAwB,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,iBAAiB,EAAE,UAAU,GAAI,CAAC,CAAA;;QACjM,OAAO,CACX,6DACC,uBAAC,oBAAS,IAAC,SAAS,QAAC,IAAI,EAAC,YAAY,EAAC,KAAK,EAAC,MAAM,EAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EACtH,UAAU,EAAE,EAAE,YAAY,EAAE,uBAAC,iBAAM,IAAC,OAAO,EAAC,WAAW,EAAC,EAAE,EAAC,cAAc,aAAS,eAAe,EAAC,OAAO,EAAE,YAAY,YAAG,gBAAM,CAAC,KAAK,CAAC,eAAe,CAAC,GAAU,EAAE,GAClK,EACD,UAAU,EAAE,IACX,CAEH,CAAC;AACH,CAAC,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B"}
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
|
19
19
|
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
20
20
|
import { theme } from "./theme";
|
|
21
21
|
import { ToolbarPlugin, CustomAutoLinkPlugin, ListMaxIndentLevelPlugin, PLAYGROUND_TRANSFORMERS, ReadOnlyPlugin, ControlledEditorPlugin } from "./plugins";
|
|
22
|
+
import FloatingTextFormatToolbarPlugin from "./plugins/FloatingTextMenu/FloatingTextFormatToolbarPlugin";
|
|
22
23
|
import { MarkdownModal } from "./MarkdownModal";
|
|
23
24
|
import CustomLinkNodePlugin from "./plugins/customLink/CustomLinkNodePlugin";
|
|
24
25
|
import { CustomLinkNode } from "./plugins/customLink/CustomLinkNode";
|
|
@@ -33,9 +34,11 @@ interface Props {
|
|
|
33
34
|
style?: any;
|
|
34
35
|
textAlign?: "left" | "center" | "right";
|
|
35
36
|
placeholder?: string;
|
|
37
|
+
element?: any;
|
|
38
|
+
showFloatingEditor?: boolean;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
function Editor({ value, onChange = () => {
|
|
41
|
+
function Editor({ value, onChange = () => {}, mode = "interactive", textAlign = "left", style, placeholder = "Enter some text...", showFloatingEditor = false, ...props }: Props) {
|
|
39
42
|
const [fullScreen, setFullScreen] = React.useState(false);
|
|
40
43
|
|
|
41
44
|
const handleChange = (editorState: any) => {
|
|
@@ -49,7 +52,7 @@ function Editor({ value, onChange = () => { }, mode = "interactive", textAlign =
|
|
|
49
52
|
console.error(error);
|
|
50
53
|
};
|
|
51
54
|
|
|
52
|
-
const handleModalOnChange = (value
|
|
55
|
+
const handleModalOnChange = (value: string) => {
|
|
53
56
|
onChange(value);
|
|
54
57
|
};
|
|
55
58
|
|
|
@@ -81,38 +84,52 @@ function Editor({ value, onChange = () => { }, mode = "interactive", textAlign =
|
|
|
81
84
|
with: (node: LinkNode) => (
|
|
82
85
|
new CustomLinkNode(node.getURL(), node.getTarget(), [])
|
|
83
86
|
)
|
|
84
|
-
}
|
|
85
|
-
]
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
markdown: { transformers: PLAYGROUND_TRANSFORMERS }
|
|
86
90
|
};
|
|
87
91
|
|
|
88
|
-
let textAlignClass = ""
|
|
92
|
+
let textAlignClass = "";
|
|
89
93
|
switch (textAlign) {
|
|
90
94
|
case "center":
|
|
91
|
-
textAlignClass = "text-center"
|
|
95
|
+
textAlignClass = "text-center";
|
|
92
96
|
break;
|
|
93
97
|
case "right":
|
|
94
|
-
textAlignClass = "text-right"
|
|
98
|
+
textAlignClass = "text-right";
|
|
95
99
|
break;
|
|
96
100
|
case "left":
|
|
97
101
|
default:
|
|
98
|
-
textAlignClass = "text-left"
|
|
102
|
+
textAlignClass = "text-left";
|
|
99
103
|
break;
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
return (
|
|
103
107
|
<>
|
|
104
108
|
<LexicalComposer initialConfig={initialConfig}>
|
|
105
|
-
<div
|
|
106
|
-
{mode
|
|
109
|
+
<div
|
|
110
|
+
className={mode === "preview" ? `editor-container preview ${textAlignClass}` : `editor-container ${textAlignClass}`}
|
|
111
|
+
style={Object.assign({ border: mode === "preview" ? "none" : "1px solid lightgray" }, style)}
|
|
112
|
+
>
|
|
113
|
+
{mode !== "preview" && (<ToolbarPlugin goFullScreen={() => { setFullScreen(true); }} />)}
|
|
107
114
|
<div className="editor-inner">
|
|
108
|
-
{!fullScreen &&
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
{!fullScreen && (
|
|
116
|
+
<RichTextPlugin
|
|
117
|
+
contentEditable={
|
|
118
|
+
<ContentEditable
|
|
119
|
+
className="editor-input"
|
|
120
|
+
style={{ minHeight: mode === "preview" ? "auto" : "150px" }}
|
|
121
|
+
//@ts-ignore
|
|
122
|
+
ref={(node) => { if (node) { const editor = node.closest("[data-lexical-editor]") as HTMLElement; if (editor) { editor.dataset.element = JSON.stringify(props.element) } } }} //Store element in dataset
|
|
123
|
+
/>
|
|
124
|
+
}
|
|
125
|
+
placeholder={mode !== "preview" ? (<div className="editor-placeholder">{placeholder}</div>) : null}
|
|
126
|
+
ErrorBoundary={LexicalErrorBoundary}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
113
129
|
<CustomLinkNodePlugin />
|
|
114
130
|
{mode !== "preview" && <EmojiPickerPlugin />}
|
|
115
131
|
<EmojisPlugin />
|
|
132
|
+
{showFloatingEditor && <FloatingTextFormatToolbarPlugin />}
|
|
116
133
|
<OnChangePlugin onChange={handleChange} />
|
|
117
134
|
{mode !== "preview" && <AutoFocusPlugin />}
|
|
118
135
|
<HistoryPlugin />
|
|
@@ -126,7 +143,7 @@ function Editor({ value, onChange = () => { }, mode = "interactive", textAlign =
|
|
|
126
143
|
</div>
|
|
127
144
|
</div>
|
|
128
145
|
</LexicalComposer>
|
|
129
|
-
{fullScreen && <MarkdownModal onChange={handleModalOnChange} value={value} hideModal={handleCloseFullScreen} />}
|
|
146
|
+
{fullScreen && (<MarkdownModal onChange={handleModalOnChange} value={value} hideModal={handleCloseFullScreen} />)}
|
|
130
147
|
</>
|
|
131
148
|
);
|
|
132
149
|
}
|
|
@@ -6,11 +6,13 @@ const Editor = lazy(() => import('./Editor'));
|
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
value: string;
|
|
9
|
-
textAlign?: "left" | "center" | "right"
|
|
9
|
+
textAlign?: "left" | "center" | "right",
|
|
10
|
+
element?: any,
|
|
11
|
+
showFloatingEditor?: boolean
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export function MarkdownPreview({ value: markdownString = "", textAlign }: Props) {
|
|
14
|
+
export function MarkdownPreview({ value: markdownString = "", textAlign, showFloatingEditor = false, ...props }: Props) {
|
|
13
15
|
return <Suspense fallback={<div>{markdownString || ""}</div>}>
|
|
14
|
-
<Editor mode="preview" value={markdownString || ""} textAlign={textAlign} />
|
|
16
|
+
<Editor mode="preview" value={markdownString || ""} textAlign={textAlign} element={props.element} showFloatingEditor={showFloatingEditor} />
|
|
15
17
|
</Suspense>
|
|
16
18
|
}
|
|
@@ -42,7 +42,11 @@ export function MarkdownPreviewLight({ value: markdownString = "", textAlign }:
|
|
|
42
42
|
if (markdownString === null || markdownString === undefined || !markdownString) return <></>;
|
|
43
43
|
else {
|
|
44
44
|
const convertedText = getSpecialLinks(markdownString || "");
|
|
45
|
-
|
|
45
|
+
let processedMarkdown = convertedText;
|
|
46
|
+
processedMarkdown = convertedText.replace(/__(.*?)__/g, "<u>$1</u>"); //Replace `__underlined__` with `<u>underlined</u>`
|
|
47
|
+
processedMarkdown = processedMarkdown.replace(/```([\s\S]+?)```/g, "<pre class='code-block'><code>$1</code></pre>"); //Convert block code ```code``` to <pre><code>code</code></pre>
|
|
48
|
+
processedMarkdown = processedMarkdown.replace(/`([^`]+)`/g, "<code>$1</code>"); //Convert inline code `code` to <code>code</code>
|
|
49
|
+
const html = marked.parse(processedMarkdown || "")
|
|
46
50
|
const style = (textAlign) ? {textAlign} : {}
|
|
47
51
|
return <div style={style} dangerouslySetInnerHTML={{__html: html as string}}></div>
|
|
48
52
|
}
|