@takeshape/util 8.86.1 → 8.87.1
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/es/draftjs.js +22 -3
- package/lib/draftjs.d.ts.map +1 -1
- package/lib/draftjs.js +22 -3
- package/package.json +2 -2
package/es/draftjs.js
CHANGED
|
@@ -734,7 +734,8 @@ const blockStarts = [{
|
|
|
734
734
|
replacement: '```'
|
|
735
735
|
}];
|
|
736
736
|
const blockEnds = [{
|
|
737
|
-
|
|
737
|
+
lookBehind: '<TSImage.*(?=/>)',
|
|
738
|
+
regex: '/>',
|
|
738
739
|
replacement: '/>'
|
|
739
740
|
}, {
|
|
740
741
|
regex: '</TSOembed>',
|
|
@@ -746,10 +747,24 @@ const blockEnds = [{
|
|
|
746
747
|
regex: '```',
|
|
747
748
|
replacement: '```'
|
|
748
749
|
}];
|
|
750
|
+
|
|
751
|
+
const getLookBehindValue = (end, str) => {
|
|
752
|
+
if (end.lookBehind) {
|
|
753
|
+
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
754
|
+
const behindMatch = new RegExp(end.lookBehind).exec(str);
|
|
755
|
+
|
|
756
|
+
if (behindMatch) {
|
|
757
|
+
return behindMatch[0];
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
return '';
|
|
762
|
+
};
|
|
749
763
|
/**
|
|
750
764
|
* Make sure there is a place to put the cursor around block-level items such as images and oembeds
|
|
751
765
|
*/
|
|
752
766
|
|
|
767
|
+
|
|
753
768
|
export function insertBreaksAroundBlocks(mdx) {
|
|
754
769
|
for (const start of blockStarts) {
|
|
755
770
|
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
@@ -758,11 +773,15 @@ export function insertBreaksAroundBlocks(mdx) {
|
|
|
758
773
|
|
|
759
774
|
for (const end of blockEnds) {
|
|
760
775
|
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
761
|
-
mdx = mdx.replace(new RegExp(`${end.regex}\\s*$`, 'g'),
|
|
776
|
+
mdx = mdx.replace(new RegExp(`${end.lookBehind ?? ''}${end.regex}\\s*$`, 'g'), match => {
|
|
777
|
+
return `${getLookBehindValue(end, match)}${end.replacement}\n\n<br/>`;
|
|
778
|
+
});
|
|
762
779
|
|
|
763
780
|
for (const start of blockStarts) {
|
|
764
781
|
mdx = mdx.replace( // eslint-disable-next-line security-node/non-literal-reg-expr
|
|
765
|
-
new RegExp(`${end.regex}\\s*${start.regex}`, 'g'),
|
|
782
|
+
new RegExp(`${end.lookBehind ?? ''}${end.regex}\\s*${start.regex}`, 'g'), match => {
|
|
783
|
+
return `${getLookBehindValue(end, match)}${end.replacement ?? 'FFF'}\n\n<br/>\n\n${start.replacement}`;
|
|
784
|
+
});
|
|
766
785
|
}
|
|
767
786
|
}
|
|
768
787
|
|
package/lib/draftjs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draftjs.d.ts","sourceRoot":"","sources":["../../src/draftjs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,oBAAoB,EAAwB,MAAM,EAAiB,MAAM,UAAU,CAAC;AAqB5F,MAAM,WAAW,OAAO;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oBAAY,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/C,UAAU,mBAAoB,SAAQ,MAAM;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AA2BD,aAAK,2BAA2B,GAAG,MAAM,CACvC,MAAM,EACN;IACE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAC;CACjD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;AAiCF,wBAAgB,WAAW,CACzB,OAAO,EAAE,oBAAoB,EAC7B,UAAU,CAAC,EAAE,2BAA2B,EACxC,WAAW,CAAC,EAAE,2BAA2B,GACxC,MAAM,CAyER;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CA0DvG;AAmBD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EACpC,MAAM,8BAAqB,GAC1B,MAAM,CAyDR;AA4MD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAgD7D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AA6ND;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAwB5D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CA0G9D"}
|
package/lib/draftjs.js
CHANGED
|
@@ -763,7 +763,8 @@ const blockStarts = [{
|
|
|
763
763
|
replacement: '```'
|
|
764
764
|
}];
|
|
765
765
|
const blockEnds = [{
|
|
766
|
-
|
|
766
|
+
lookBehind: '<TSImage.*(?=/>)',
|
|
767
|
+
regex: '/>',
|
|
767
768
|
replacement: '/>'
|
|
768
769
|
}, {
|
|
769
770
|
regex: '</TSOembed>',
|
|
@@ -775,10 +776,24 @@ const blockEnds = [{
|
|
|
775
776
|
regex: '```',
|
|
776
777
|
replacement: '```'
|
|
777
778
|
}];
|
|
779
|
+
|
|
780
|
+
const getLookBehindValue = (end, str) => {
|
|
781
|
+
if (end.lookBehind) {
|
|
782
|
+
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
783
|
+
const behindMatch = new RegExp(end.lookBehind).exec(str);
|
|
784
|
+
|
|
785
|
+
if (behindMatch) {
|
|
786
|
+
return behindMatch[0];
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
return '';
|
|
791
|
+
};
|
|
778
792
|
/**
|
|
779
793
|
* Make sure there is a place to put the cursor around block-level items such as images and oembeds
|
|
780
794
|
*/
|
|
781
795
|
|
|
796
|
+
|
|
782
797
|
function insertBreaksAroundBlocks(mdx) {
|
|
783
798
|
for (const start of blockStarts) {
|
|
784
799
|
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
@@ -787,11 +802,15 @@ function insertBreaksAroundBlocks(mdx) {
|
|
|
787
802
|
|
|
788
803
|
for (const end of blockEnds) {
|
|
789
804
|
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
790
|
-
mdx = mdx.replace(new RegExp(`${end.regex}\\s*$`, 'g'),
|
|
805
|
+
mdx = mdx.replace(new RegExp(`${end.lookBehind ?? ''}${end.regex}\\s*$`, 'g'), match => {
|
|
806
|
+
return `${getLookBehindValue(end, match)}${end.replacement}\n\n<br/>`;
|
|
807
|
+
});
|
|
791
808
|
|
|
792
809
|
for (const start of blockStarts) {
|
|
793
810
|
mdx = mdx.replace( // eslint-disable-next-line security-node/non-literal-reg-expr
|
|
794
|
-
new RegExp(`${end.regex}\\s*${start.regex}`, 'g'),
|
|
811
|
+
new RegExp(`${end.lookBehind ?? ''}${end.regex}\\s*${start.regex}`, 'g'), match => {
|
|
812
|
+
return `${getLookBehindValue(end, match)}${end.replacement ?? 'FFF'}\n\n<br/>\n\n${start.replacement}`;
|
|
813
|
+
});
|
|
795
814
|
}
|
|
796
815
|
}
|
|
797
816
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/util",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.87.1",
|
|
4
4
|
"description": "Shared utilities",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"es"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@takeshape/routing": "8.
|
|
24
|
+
"@takeshape/routing": "8.87.1",
|
|
25
25
|
"@types/url-parse": "^1.4.4",
|
|
26
26
|
"aws-sdk": "^2.802.0",
|
|
27
27
|
"classnames": "^2.2.5",
|