book-source 0.3.5 → 0.3.7
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/StructuredDocument.js +17 -2
- package/lib/Style.js +10 -2
- package/lib/Theme.js +1 -1
- package/lib/textPostFilters.js +1 -1
- package/package.json +1 -1
|
@@ -1751,9 +1751,24 @@ function mergeInlineParts( parts , extraParts ) {
|
|
|
1751
1751
|
}
|
|
1752
1752
|
|
|
1753
1753
|
var lastPart = parts[ parts.length - 1 ] ,
|
|
1754
|
-
|
|
1754
|
+
lastTextPart = lastPart ,
|
|
1755
|
+
firstExtraPart = extraParts[ 0 ] ,
|
|
1756
|
+
firstExtraTextPart = firstExtraPart ;
|
|
1755
1757
|
|
|
1756
|
-
|
|
1758
|
+
while ( lastTextPart && lastTextPart.parts && lastTextPart.parts.length ) {
|
|
1759
|
+
lastTextPart = lastTextPart.parts[ lastTextPart.parts.length - 1 ] ;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
while ( firstExtraTextPart && firstExtraTextPart.parts && firstExtraTextPart.parts.length ) {
|
|
1763
|
+
firstExtraTextPart = firstExtraTextPart.parts[ 0 ] ;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
if ( ! lastTextPart?.text || ! firstExtraTextPart?.text ) {
|
|
1767
|
+
parts.push( ... extraParts ) ;
|
|
1768
|
+
return ;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
var needExtraSpace = ! WHITE_SPACES.has( lastTextPart.text[ lastTextPart.text.length - 1 ] ) && ! WHITE_SPACES.has( firstExtraTextPart.text[ 0 ] ) ;
|
|
1757
1772
|
|
|
1758
1773
|
if ( lastPart.type === 'text' && firstExtraPart.type === 'text' ) {
|
|
1759
1774
|
// Combine the last existing with the first additional part
|
package/lib/Style.js
CHANGED
|
@@ -38,6 +38,7 @@ function Style() {
|
|
|
38
38
|
this.bold = null ;
|
|
39
39
|
this.italic = null ;
|
|
40
40
|
this.underline = null ;
|
|
41
|
+
this.fx = null ;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
module.exports = Style ;
|
|
@@ -69,6 +70,7 @@ Style.merge = function( ... styles ) {
|
|
|
69
70
|
const BOOLEAN_PROPERTIES = new Set( [ 'bold' , 'italic' , 'underline' ] ) ;
|
|
70
71
|
const TEXT_COLOR_PROPERTIES = new Set( [ 'text' , 'tx' , 'foreground' , 'fg' ] ) ;
|
|
71
72
|
const BACKGROUND_COLOR_PROPERTIES = new Set( [ 'background' , 'bg' ] ) ;
|
|
73
|
+
const FX_PROPERTIES = new Set( [ 'fx' ] ) ;
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
|
|
@@ -79,9 +81,12 @@ Style.parse = function( str , forTextElement = true ) {
|
|
|
79
81
|
let [ property , value ] = part.split( ':' ) ;
|
|
80
82
|
|
|
81
83
|
if ( value ) {
|
|
82
|
-
property =
|
|
84
|
+
property =
|
|
85
|
+
TEXT_COLOR_PROPERTIES.has( property ) ? 'text' :
|
|
83
86
|
BACKGROUND_COLOR_PROPERTIES.has( property ) ? 'background' :
|
|
84
|
-
|
|
87
|
+
FX_PROPERTIES.has( property ) ? 'fx' :
|
|
88
|
+
forTextElement ? 'text' :
|
|
89
|
+
'background' ;
|
|
85
90
|
}
|
|
86
91
|
else {
|
|
87
92
|
if ( BOOLEAN_PROPERTIES.has( property ) ) {
|
|
@@ -100,6 +105,9 @@ Style.parse = function( str , forTextElement = true ) {
|
|
|
100
105
|
case 'background' :
|
|
101
106
|
style.backgroundColor = Color.parse( value ) ;
|
|
102
107
|
break ;
|
|
108
|
+
case 'fx' :
|
|
109
|
+
style.fx = value ;
|
|
110
|
+
break ;
|
|
103
111
|
}
|
|
104
112
|
}
|
|
105
113
|
|
package/lib/Theme.js
CHANGED
package/lib/textPostFilters.js
CHANGED