@portabletext/editor 1.33.0 → 1.33.2
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/lib/_chunks-cjs/plugin.event-listener.cjs +1 -1
- package/lib/_chunks-cjs/plugin.event-listener.cjs.map +1 -1
- package/lib/_chunks-es/plugin.event-listener.js +4 -4
- package/lib/_chunks-es/plugin.event-listener.js.map +1 -1
- package/lib/plugins/index.cjs +10 -3
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.js +10 -3
- package/lib/plugins/index.js.map +1 -1
- package/package.json +6 -6
- package/src/behavior-actions/behavior.actions.ts +2 -8
- package/src/behaviors/behavior.markdown-emphasis.ts +6 -9
- package/src/internal-utils/get-text-to-emphasize.test.ts +60 -0
- package/src/internal-utils/get-text-to-emphasize.ts +18 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const asteriskPairRegex = '(?<!\\*)\\*(?!\\s)([^*\\n]+?)(?<!\\s)\\*(?!\\*)'
|
|
2
|
+
const underscorePairRegex = '(?<!_)_(?!\\s)([^_\\n]+?)(?<!\\s)_(?!_)'
|
|
3
|
+
const italicRegex = new RegExp(`(${asteriskPairRegex}|${underscorePairRegex})$`)
|
|
4
|
+
|
|
5
|
+
const doubleAsteriskPairRegex =
|
|
6
|
+
'(?<!\\*)\\*\\*(?!\\s)([^*\\n]+?)(?<!\\s)\\*\\*(?!\\*)'
|
|
7
|
+
const doubleUnderscorePairRegex = '(?<!_)__(?!\\s)([^_\\n]+?)(?<!\\s)__(?!_)'
|
|
8
|
+
const boldRegex = new RegExp(
|
|
9
|
+
`(${doubleAsteriskPairRegex}|${doubleUnderscorePairRegex})$`,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
export function getTextToItalic(text: string) {
|
|
13
|
+
return text.match(italicRegex)?.at(0)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getTextToBold(text: string) {
|
|
17
|
+
return text.match(boldRegex)?.at(0)
|
|
18
|
+
}
|