react-native-readium 3.0.2 → 4.0.0
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/README.md +2 -1
- package/android/src/main/java/com/reactnativereadium/ReadiumView.kt +10 -7
- package/android/src/main/java/com/reactnativereadium/ReadiumViewManager.kt +7 -6
- package/android/src/main/java/com/reactnativereadium/reader/EpubReaderFragment.kt +25 -47
- package/android/src/main/java/com/reactnativereadium/reader/ReaderService.kt +2 -15
- package/android/src/main/java/com/reactnativereadium/utils/FragmentFactory.kt +1 -1
- package/ios/App/AppModule.swift +1 -1
- package/ios/Common/EPUBPreferences.swift +8 -0
- package/ios/Reader/Common/ReaderViewController.swift +8 -14
- package/ios/Reader/EPUB/AssociatedColors.swift +7 -7
- package/ios/Reader/EPUB/EPUBModule.swift +6 -7
- package/ios/Reader/EPUB/EPUBViewController.swift +8 -10
- package/ios/Reader/ReaderFormatModule.swift +3 -4
- package/ios/Reader/ReaderModule.swift +3 -7
- package/ios/Reader/ReaderService.swift +4 -19
- package/ios/ReadiumView.swift +31 -33
- package/ios/ReadiumViewManager.m +1 -1
- package/lib/src/components/ReadiumView.d.ts +4 -2
- package/lib/src/components/ReadiumView.js +4 -4
- package/lib/src/components/ReadiumView.web.d.ts +5 -1
- package/lib/src/components/ReadiumView.web.js +2 -2
- package/lib/src/interfaces/BaseReadiumViewProps.d.ts +1 -2
- package/lib/src/interfaces/Preferences.d.ts +27 -0
- package/lib/src/interfaces/Preferences.js +1 -0
- package/lib/src/interfaces/index.d.ts +1 -1
- package/lib/src/interfaces/index.js +1 -1
- package/lib/src/utils/RANGES.js +1 -1
- package/lib/web/hooks/useSettingsObserver.d.ts +2 -2
- package/lib/web/hooks/useSettingsObserver.js +39 -5
- package/package.json +1 -1
- package/react-native-readium.podspec +2 -0
- package/src/components/ReadiumView.tsx +16 -7
- package/src/components/ReadiumView.web.tsx +7 -3
- package/src/interfaces/BaseReadiumViewProps.ts +1 -3
- package/src/interfaces/Preferences.ts +35 -0
- package/src/interfaces/index.ts +1 -1
- package/src/utils/RANGES.ts +1 -1
- package/web/hooks/useSettingsObserver.ts +52 -7
- package/android/src/main/java/com/reactnativereadium/epub/UserSettings.kt +0 -246
- package/lib/src/interfaces/Settings.d.ts +0 -40
- package/lib/src/interfaces/Settings.js +0 -61
- package/src/interfaces/Settings.ts +0 -75
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
package com.reactnativereadium.epub
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.content.SharedPreferences
|
|
5
|
-
import android.graphics.Color
|
|
6
|
-
import androidx.appcompat.app.AppCompatActivity
|
|
7
|
-
import org.json.JSONArray
|
|
8
|
-
import org.readium.r2.navigator.R2BasicWebView
|
|
9
|
-
import org.readium.r2.navigator.R2WebView
|
|
10
|
-
import org.readium.r2.navigator.epub.fxl.R2FXLLayout
|
|
11
|
-
import org.readium.r2.navigator.pager.R2ViewPager
|
|
12
|
-
import org.readium.r2.shared.*
|
|
13
|
-
import com.reactnativereadium.R
|
|
14
|
-
import java.io.File
|
|
15
|
-
|
|
16
|
-
class UserSettings(
|
|
17
|
-
var preferences: SharedPreferences,
|
|
18
|
-
val context: Context,
|
|
19
|
-
private val UIPreset: MutableMap<ReadiumCSSName, Boolean>
|
|
20
|
-
) {
|
|
21
|
-
|
|
22
|
-
lateinit var resourcePager: R2ViewPager
|
|
23
|
-
|
|
24
|
-
private val appearanceValues = listOf("readium-default-on", "readium-sepia-on", "readium-night-on")
|
|
25
|
-
private val fontFamilyValues = listOf("Original", "PT Serif", "Roboto", "Source Sans Pro", "Vollkorn", "OpenDyslexic", "AccessibleDfA", "IA Writer Duospace")
|
|
26
|
-
private val textAlignmentValues = listOf("justify", "start")
|
|
27
|
-
private val columnCountValues = listOf("auto", "1", "2")
|
|
28
|
-
|
|
29
|
-
private var fontSize = 100f
|
|
30
|
-
private var fontOverride = false
|
|
31
|
-
private var fontFamily = 0
|
|
32
|
-
private var appearance = 0
|
|
33
|
-
private var verticalScroll = false
|
|
34
|
-
|
|
35
|
-
//Advanced settings
|
|
36
|
-
private var publisherDefaults = false
|
|
37
|
-
private var textAlignment = 0
|
|
38
|
-
private var columnCount = 0
|
|
39
|
-
private var wordSpacing = 0f
|
|
40
|
-
private var letterSpacing = 0f
|
|
41
|
-
private var pageMargins = 2f
|
|
42
|
-
private var lineHeight = 1f
|
|
43
|
-
|
|
44
|
-
private var userProperties: UserProperties
|
|
45
|
-
|
|
46
|
-
init {
|
|
47
|
-
appearance = preferences.getInt(APPEARANCE_REF, appearance)
|
|
48
|
-
verticalScroll = preferences.getBoolean(SCROLL_REF, verticalScroll)
|
|
49
|
-
fontFamily = preferences.getInt(FONT_FAMILY_REF, fontFamily)
|
|
50
|
-
if (fontFamily != 0) {
|
|
51
|
-
fontOverride = true
|
|
52
|
-
}
|
|
53
|
-
publisherDefaults = preferences.getBoolean(PUBLISHER_DEFAULT_REF, publisherDefaults)
|
|
54
|
-
textAlignment = preferences.getInt(TEXT_ALIGNMENT_REF, textAlignment)
|
|
55
|
-
columnCount = preferences.getInt(COLUMN_COUNT_REF, columnCount)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
fontSize = preferences.getFloat(FONT_SIZE_REF, fontSize)
|
|
59
|
-
wordSpacing = preferences.getFloat(WORD_SPACING_REF, wordSpacing)
|
|
60
|
-
letterSpacing = preferences.getFloat(LETTER_SPACING_REF, letterSpacing)
|
|
61
|
-
pageMargins = preferences.getFloat(PAGE_MARGINS_REF, pageMargins)
|
|
62
|
-
lineHeight = preferences.getFloat(LINE_HEIGHT_REF, lineHeight)
|
|
63
|
-
userProperties = getUserSettings()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
fun updateSettingsFromMap(map: Map<String, Any>) {
|
|
67
|
-
userProperties.properties.forEach { property ->
|
|
68
|
-
val key = property.ref
|
|
69
|
-
val value = map[key]
|
|
70
|
-
|
|
71
|
-
val isPropertyModified = when (property) {
|
|
72
|
-
is Enumerable -> updateEnumerableFromKeyValue(property, key, value)
|
|
73
|
-
is Incremental -> updateIncrementalFromKeyValue(property, key, value)
|
|
74
|
-
is Switchable -> updateSwitchableFromKeyValue(property, key, value)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// update the resourcePager background to match the newly selected theme
|
|
78
|
-
if (isPropertyModified && property is Enumerable && property.ref == APPEARANCE_REF) {
|
|
79
|
-
when (property.index) {
|
|
80
|
-
0 -> {
|
|
81
|
-
resourcePager.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
82
|
-
}
|
|
83
|
-
1 -> {
|
|
84
|
-
resourcePager.setBackgroundColor(Color.parseColor("#faf4e8"))
|
|
85
|
-
}
|
|
86
|
-
2 -> {
|
|
87
|
-
resourcePager.setBackgroundColor(Color.parseColor("#000000"))
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// apply the changes to the view
|
|
93
|
-
if (isPropertyModified) {
|
|
94
|
-
updateViewCSS(key)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private fun updateEnumerableFromKeyValue(property: Enumerable, key: String, value: Any?): Boolean {
|
|
100
|
-
if (value == null) return false
|
|
101
|
-
var update: Int?
|
|
102
|
-
|
|
103
|
-
if (value is Int) {
|
|
104
|
-
update = value
|
|
105
|
-
} else if (value is Float) {
|
|
106
|
-
update = value.toInt()
|
|
107
|
-
} else if (value is Double) {
|
|
108
|
-
update = value.toInt()
|
|
109
|
-
} else {
|
|
110
|
-
throw Error("Invalid value type '${value.javaClass.simpleName}' passed for setting: $key = $value")
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
property.index = update
|
|
114
|
-
updateEnumerable(property)
|
|
115
|
-
return true
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private fun updateIncrementalFromKeyValue(property: Incremental, key: String, value: Any?): Boolean {
|
|
119
|
-
if (value == null) return false
|
|
120
|
-
var update: Float?
|
|
121
|
-
|
|
122
|
-
if (value is Int) {
|
|
123
|
-
update = value.toFloat()
|
|
124
|
-
} else if (value is Float) {
|
|
125
|
-
update = value
|
|
126
|
-
} else if (value is Double) {
|
|
127
|
-
update = value.toFloat()
|
|
128
|
-
} else {
|
|
129
|
-
throw Error("Invalid value type '${value.javaClass.simpleName}' passed for setting: $key = $value")
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
property.value = update
|
|
133
|
-
updateIncremental(property)
|
|
134
|
-
return true
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private fun updateSwitchableFromKeyValue(property: Switchable, key: String, value: Any?): Boolean {
|
|
138
|
-
if (value == null) return false
|
|
139
|
-
var update: Boolean?
|
|
140
|
-
|
|
141
|
-
if (value is Boolean) {
|
|
142
|
-
update = value
|
|
143
|
-
} else {
|
|
144
|
-
throw Error("Invalid value type '${value.javaClass.simpleName}' passed for setting: $key = $value")
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
property.on = update
|
|
148
|
-
updateSwitchable(property)
|
|
149
|
-
return true
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private fun getUserSettings(): UserProperties {
|
|
153
|
-
|
|
154
|
-
val userProperties = UserProperties()
|
|
155
|
-
// Publisher default system
|
|
156
|
-
userProperties.addSwitchable("readium-advanced-off", "readium-advanced-on", publisherDefaults, PUBLISHER_DEFAULT_REF, PUBLISHER_DEFAULT_NAME)
|
|
157
|
-
// Font override
|
|
158
|
-
userProperties.addSwitchable("readium-font-on", "readium-font-off", fontOverride, FONT_OVERRIDE_REF, FONT_OVERRIDE_NAME)
|
|
159
|
-
// Column count
|
|
160
|
-
userProperties.addEnumerable(columnCount, columnCountValues, COLUMN_COUNT_REF, COLUMN_COUNT_NAME)
|
|
161
|
-
// Appearance
|
|
162
|
-
userProperties.addEnumerable(appearance, appearanceValues, APPEARANCE_REF, APPEARANCE_NAME)
|
|
163
|
-
// Page margins
|
|
164
|
-
userProperties.addIncremental(pageMargins, 0.5f, 4f, 0.25f, "", PAGE_MARGINS_REF, PAGE_MARGINS_NAME)
|
|
165
|
-
// Text alignment
|
|
166
|
-
userProperties.addEnumerable(textAlignment, textAlignmentValues, TEXT_ALIGNMENT_REF, TEXT_ALIGNMENT_NAME)
|
|
167
|
-
// Font family
|
|
168
|
-
userProperties.addEnumerable(fontFamily, fontFamilyValues, FONT_FAMILY_REF, FONT_FAMILY_NAME)
|
|
169
|
-
// Font size
|
|
170
|
-
userProperties.addIncremental(fontSize, 100f, 300f, 25f, "%", FONT_SIZE_REF, FONT_SIZE_NAME)
|
|
171
|
-
// Line height
|
|
172
|
-
userProperties.addIncremental(lineHeight, 1f, 2f, 0.25f, "", LINE_HEIGHT_REF, LINE_HEIGHT_NAME)
|
|
173
|
-
// Word spacing
|
|
174
|
-
userProperties.addIncremental(wordSpacing, 0f, 0.5f, 0.25f, "rem", WORD_SPACING_REF, WORD_SPACING_NAME)
|
|
175
|
-
// Letter spacing
|
|
176
|
-
userProperties.addIncremental(letterSpacing, 0f, 0.5f, 0.0625f, "em", LETTER_SPACING_REF, LETTER_SPACING_NAME)
|
|
177
|
-
// Scroll
|
|
178
|
-
userProperties.addSwitchable("readium-scroll-on", "readium-scroll-off", verticalScroll, SCROLL_REF, SCROLL_NAME)
|
|
179
|
-
|
|
180
|
-
return userProperties
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
private fun makeJson(): JSONArray {
|
|
184
|
-
val array = JSONArray()
|
|
185
|
-
for (userProperty in userProperties.properties) {
|
|
186
|
-
array.put(userProperty.getJson())
|
|
187
|
-
}
|
|
188
|
-
return array
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
fun saveChanges() {
|
|
193
|
-
val json = makeJson()
|
|
194
|
-
val dir = File(context.filesDir.path + "/" + Injectable.Style.rawValue + "/")
|
|
195
|
-
dir.mkdirs()
|
|
196
|
-
val file = File(dir, "UserProperties.json")
|
|
197
|
-
file.printWriter().use { out ->
|
|
198
|
-
out.println(json)
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
private fun updateEnumerable(enumerable: Enumerable) {
|
|
203
|
-
preferences.edit().putInt(enumerable.ref, enumerable.index).apply()
|
|
204
|
-
saveChanges()
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
private fun updateSwitchable(switchable: Switchable) {
|
|
209
|
-
preferences.edit().putBoolean(switchable.ref, switchable.on).apply()
|
|
210
|
-
saveChanges()
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
private fun updateIncremental(incremental: Incremental) {
|
|
214
|
-
preferences.edit().putFloat(incremental.ref, incremental.value).apply()
|
|
215
|
-
saveChanges()
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
fun updateViewCSS(ref: String) {
|
|
219
|
-
for (i in 0 until resourcePager.childCount) {
|
|
220
|
-
val webView = resourcePager.getChildAt(i).findViewById(R.id.webView) as? R2WebView
|
|
221
|
-
webView?.let {
|
|
222
|
-
applyCSS(webView, ref)
|
|
223
|
-
} ?: run {
|
|
224
|
-
val zoomView = resourcePager.getChildAt(i).findViewById(R.id.r2FXLLayout) as R2FXLLayout
|
|
225
|
-
val webView1 = zoomView.findViewById(R.id.firstWebView) as? R2BasicWebView
|
|
226
|
-
val webView2 = zoomView.findViewById(R.id.secondWebView) as? R2BasicWebView
|
|
227
|
-
val webViewSingle = zoomView.findViewById(R.id.webViewSingle) as? R2BasicWebView
|
|
228
|
-
|
|
229
|
-
webView1?.let {
|
|
230
|
-
applyCSS(webView1, ref)
|
|
231
|
-
}
|
|
232
|
-
webView2?.let {
|
|
233
|
-
applyCSS(webView2, ref)
|
|
234
|
-
}
|
|
235
|
-
webViewSingle?.let {
|
|
236
|
-
applyCSS(webViewSingle, ref)
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
private fun applyCSS(view: R2BasicWebView, ref: String) {
|
|
243
|
-
val userSetting = userProperties.getByRef<UserProperty>(ref)
|
|
244
|
-
view.setProperty(userSetting.name, userSetting.toString())
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Appearance, FontFamily, TextAlignment, ColumnCount } from '../enums';
|
|
2
|
-
/**
|
|
3
|
-
* A reader settings object with sensible defaults.
|
|
4
|
-
*/
|
|
5
|
-
export declare class Settings {
|
|
6
|
-
appearance: Appearance;
|
|
7
|
-
fontFamily: FontFamily;
|
|
8
|
-
textAlign: TextAlignment;
|
|
9
|
-
colCount: ColumnCount;
|
|
10
|
-
scroll: boolean;
|
|
11
|
-
fontOverride: boolean;
|
|
12
|
-
verticalScroll: boolean;
|
|
13
|
-
bodyHyphens: boolean;
|
|
14
|
-
advancedSettings: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Range: 100.0 - 300.0
|
|
17
|
-
*/
|
|
18
|
-
fontSize: number;
|
|
19
|
-
/**
|
|
20
|
-
* Range: 0.0 - 0.5
|
|
21
|
-
*/
|
|
22
|
-
wordSpacing: number;
|
|
23
|
-
/**
|
|
24
|
-
* Range: 0.0 - 0.5
|
|
25
|
-
*/
|
|
26
|
-
letterSpacing: number;
|
|
27
|
-
/**
|
|
28
|
-
* Range: 0.5 - 4.0
|
|
29
|
-
*/
|
|
30
|
-
pageMargins: number;
|
|
31
|
-
/**
|
|
32
|
-
* Range: 1.0 - 2.0
|
|
33
|
-
*/
|
|
34
|
-
lineHeight: number;
|
|
35
|
-
/**
|
|
36
|
-
* Range: 0.0 - 2.0
|
|
37
|
-
*/
|
|
38
|
-
paragraphMargins?: number;
|
|
39
|
-
static map(settings: Partial<Settings>): any;
|
|
40
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Appearance, FontFamily, TextAlignment, ColumnCount } from '../enums';
|
|
2
|
-
import { RANGES, indexOfObjectValue, clamp } from '../utils';
|
|
3
|
-
/**
|
|
4
|
-
* A reader settings object with sensible defaults.
|
|
5
|
-
*/
|
|
6
|
-
export class Settings {
|
|
7
|
-
// TODO:
|
|
8
|
-
// - ligatures
|
|
9
|
-
// - paraIndent
|
|
10
|
-
appearance = Appearance.DEFAULT;
|
|
11
|
-
fontFamily = FontFamily.ORIGINAL;
|
|
12
|
-
textAlign = TextAlignment.JUSTIFY;
|
|
13
|
-
colCount = ColumnCount.AUTO;
|
|
14
|
-
scroll = false;
|
|
15
|
-
fontOverride = false;
|
|
16
|
-
verticalScroll = false;
|
|
17
|
-
bodyHyphens = false;
|
|
18
|
-
advancedSettings = true;
|
|
19
|
-
/**
|
|
20
|
-
* Range: 100.0 - 300.0
|
|
21
|
-
*/
|
|
22
|
-
fontSize = 100;
|
|
23
|
-
/**
|
|
24
|
-
* Range: 0.0 - 0.5
|
|
25
|
-
*/
|
|
26
|
-
wordSpacing = 0;
|
|
27
|
-
/**
|
|
28
|
-
* Range: 0.0 - 0.5
|
|
29
|
-
*/
|
|
30
|
-
letterSpacing = 0;
|
|
31
|
-
/**
|
|
32
|
-
* Range: 0.5 - 4.0
|
|
33
|
-
*/
|
|
34
|
-
pageMargins = 0;
|
|
35
|
-
/**
|
|
36
|
-
* Range: 1.0 - 2.0
|
|
37
|
-
*/
|
|
38
|
-
lineHeight = 1;
|
|
39
|
-
/**
|
|
40
|
-
* Range: 0.0 - 2.0
|
|
41
|
-
*/
|
|
42
|
-
paragraphMargins = 0;
|
|
43
|
-
static map(settings) {
|
|
44
|
-
const defaultValues = new Settings();
|
|
45
|
-
const mapped = {};
|
|
46
|
-
Object.keys(defaultValues).forEach((key) => {
|
|
47
|
-
mapped[key] =
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
settings[key] !== undefined ? settings[key] : defaultValues[key];
|
|
50
|
-
});
|
|
51
|
-
mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);
|
|
52
|
-
mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);
|
|
53
|
-
mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);
|
|
54
|
-
mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);
|
|
55
|
-
Object.keys(RANGES).forEach((key) => {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);
|
|
58
|
-
});
|
|
59
|
-
return mapped;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Appearance, FontFamily, TextAlignment, ColumnCount } from '../enums';
|
|
2
|
-
|
|
3
|
-
import { RANGES, indexOfObjectValue, clamp } from '../utils';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A reader settings object with sensible defaults.
|
|
7
|
-
*/
|
|
8
|
-
export class Settings {
|
|
9
|
-
// TODO:
|
|
10
|
-
// - ligatures
|
|
11
|
-
// - paraIndent
|
|
12
|
-
appearance: Appearance = Appearance.DEFAULT;
|
|
13
|
-
fontFamily: FontFamily = FontFamily.ORIGINAL;
|
|
14
|
-
textAlign: TextAlignment = TextAlignment.JUSTIFY;
|
|
15
|
-
colCount: ColumnCount = ColumnCount.AUTO;
|
|
16
|
-
|
|
17
|
-
scroll: boolean = false;
|
|
18
|
-
fontOverride: boolean = false;
|
|
19
|
-
verticalScroll: boolean = false;
|
|
20
|
-
bodyHyphens: boolean = false;
|
|
21
|
-
advancedSettings: boolean = true;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Range: 100.0 - 300.0
|
|
25
|
-
*/
|
|
26
|
-
fontSize: number = 100;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Range: 0.0 - 0.5
|
|
30
|
-
*/
|
|
31
|
-
wordSpacing: number = 0;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Range: 0.0 - 0.5
|
|
35
|
-
*/
|
|
36
|
-
letterSpacing: number = 0;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Range: 0.5 - 4.0
|
|
40
|
-
*/
|
|
41
|
-
pageMargins: number = 0;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Range: 1.0 - 2.0
|
|
45
|
-
*/
|
|
46
|
-
lineHeight: number = 1;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Range: 0.0 - 2.0
|
|
50
|
-
*/
|
|
51
|
-
paragraphMargins?: number = 0;
|
|
52
|
-
|
|
53
|
-
static map(settings: Partial<Settings>): any {
|
|
54
|
-
const defaultValues = new Settings();
|
|
55
|
-
const mapped: Record<string, any> = {};
|
|
56
|
-
|
|
57
|
-
Object.keys(defaultValues).forEach((key: string) => {
|
|
58
|
-
mapped[key] =
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
settings[key] !== undefined ? settings[key] : defaultValues[key];
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
mapped.appearance = indexOfObjectValue(Appearance, mapped.appearance);
|
|
64
|
-
mapped.fontFamily = indexOfObjectValue(FontFamily, mapped.fontFamily);
|
|
65
|
-
mapped.textAlign = indexOfObjectValue(TextAlignment, mapped.textAlign);
|
|
66
|
-
mapped.colCount = indexOfObjectValue(ColumnCount, mapped.colCount);
|
|
67
|
-
|
|
68
|
-
Object.keys(RANGES).forEach((key: string) => {
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
mapped[key] = clamp(mapped[key], RANGES[key][0], RANGES[key][1]);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return mapped;
|
|
74
|
-
}
|
|
75
|
-
}
|