fix
This commit is contained in:
202
book/node_modules/@honkit/honkit-plugin-fontsettings/LICENSE
generated
vendored
Normal file
202
book/node_modules/@honkit/honkit-plugin-fontsettings/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
298
book/node_modules/@honkit/honkit-plugin-fontsettings/README.md
generated
vendored
Normal file
298
book/node_modules/@honkit/honkit-plugin-fontsettings/README.md
generated
vendored
Normal file
@@ -0,0 +1,298 @@
|
||||
# @honkit-plugin-fontsettings
|
||||
|
||||
`@honkit/honkit-plugin-fontsettings` is a fork of [Gitbook/plugin-fontsettings]@2.0.0.
|
||||
|
||||
This plugin adds font settings button in the HonKit website.
|
||||
|
||||
### Disable this plugin
|
||||
|
||||
This is a default plugin and it can be disabled using a `book.json` configuration:
|
||||
|
||||
```
|
||||
{
|
||||
plugins: ["-fontsettings"]
|
||||
}
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
This plugin can be configured in the `book.json`:
|
||||
|
||||
Default configuration is:
|
||||
|
||||
```js
|
||||
{
|
||||
"pluginsConfig": {
|
||||
"fontsettings": {
|
||||
"theme": 'white', // 'sepia', 'night' or 'white',
|
||||
"family": 'sans', // 'serif' or 'sans',
|
||||
"size": 2 // 1 - 4
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Plugin API
|
||||
|
||||
This plugin exposes the following API to easily allow new themes to manage the plugin behavior.
|
||||
|
||||
All API functions are called using the prefix `gitbook.fontsettings.`, for instance `gitbook.fontsettings.enlargeFontSize()`.
|
||||
|
||||
#### Font manipulation
|
||||
|
||||
##### `gitbook.fontsettings.enlargeFontSize()`
|
||||
|
||||
Increases the font size of the document by one. Max value is `4`.
|
||||
|
||||
##### `gitbook.fontsettings.reduceFontSize()`
|
||||
|
||||
Decreases the font size of the document by one. Min value is `1`.
|
||||
|
||||
#### Font families
|
||||
|
||||
Each font family should be described as:
|
||||
|
||||
```js
|
||||
var fontFamily = {
|
||||
config: 'sans', // name of the font family in book.json for your theme
|
||||
text: 'Sans', // display name of the font family in menu
|
||||
id: 0 // the id appended to the CSS class for this font-family
|
||||
};
|
||||
```
|
||||
|
||||
The `text` property will be used to display the font-family name in the fontsettings dropdown menu.
|
||||
|
||||
The `config` property allows you to let the users of your theme choose a default font family in their `book.json`. You will have to handle setting the chosen font family in your theme's frontend JavaScript.
|
||||
|
||||
For instance:
|
||||
|
||||
```json
|
||||
// book.json
|
||||
{
|
||||
plugins: ["my-theme"],
|
||||
pluginsConfig: {
|
||||
"my-theme": {
|
||||
"font-family": "sans"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
// my-theme.js
|
||||
require('gitbook', function(gitbook) {
|
||||
var FONT_FAMILIES = [
|
||||
{
|
||||
config: 'sans',
|
||||
text: 'Sans',
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: 'serif',
|
||||
text: 'Serif',
|
||||
id: 1
|
||||
}
|
||||
];
|
||||
|
||||
gitbook.events.on('start', function(e, config) {
|
||||
// Read configuration
|
||||
var themeConfig = config['my-theme'],
|
||||
defaultFont = themeConfig['font-family'];
|
||||
|
||||
// Initialize new font families
|
||||
gitbook.fontsettings.setFamilies(FONT_FAMILIES);
|
||||
// Set to configured font-family
|
||||
gitbook.fontsettings.setFamily(defaultFont);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
The `id` property lets you define a specific id to use for your CSS rules as explained below.
|
||||
|
||||
##### CSS rules
|
||||
|
||||
The CSS class `font-family-<id>` will be applied to the theme book's root element `<div class="book">` when a font family is selected in the menu.
|
||||
|
||||
The CSS rules for the font-family can then easily be defined using the parent selector `.book.font-family-<id>`:
|
||||
|
||||
```CSS
|
||||
.book.font-family-<id> {
|
||||
font-family: 'My Awesome Font';
|
||||
}
|
||||
```
|
||||
|
||||
##### Managing the font families
|
||||
|
||||
##### `gitbook.fontsettings.getFamilies()`
|
||||
|
||||
Returns the currently set font families.
|
||||
|
||||
By default, the font families are:
|
||||
|
||||
```js
|
||||
// Default font families
|
||||
var FAMILIES = [
|
||||
{
|
||||
config: 'serif',
|
||||
text: 'Serif',
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: 'sans',
|
||||
text: 'Sans',
|
||||
id: 1
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
##### `gitbook.fontsettings.setFamilies()`
|
||||
|
||||
Set the new font families configuration, as an array of font family objects, used by the `plugin-fontsettings` in the form:
|
||||
|
||||
```js
|
||||
var FONT_FAMILIES = [
|
||||
{
|
||||
config: 'sans',
|
||||
text: 'Sans',
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: 'serif',
|
||||
text: 'Serif',
|
||||
id: 1
|
||||
}
|
||||
];
|
||||
|
||||
gitbook.fontsettings.setFamilies(FONT_FAMILIES);
|
||||
```
|
||||
|
||||
This will recreate the fontsettings menu to reflect the changes.
|
||||
|
||||
##### `gitbook.fontsettings.setFamily()`
|
||||
|
||||
Takes a font-family `config` key as an argument and updates the font-family used for this book.
|
||||
|
||||
This will basically apply the CSS class with the corresponding family `id`: `.font-family-<id>`.
|
||||
|
||||
#### Color themes
|
||||
|
||||
Setting and manipulating color themes follow the exact same rules as font families.
|
||||
|
||||
Here are the default value for the color themes in the plugin:
|
||||
|
||||
```js
|
||||
// Default themes
|
||||
var THEMES = [
|
||||
{
|
||||
config: 'white',
|
||||
text: 'White',
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: 'sepia',
|
||||
text: 'Sepia',
|
||||
id: 1
|
||||
},
|
||||
{
|
||||
config: 'night',
|
||||
text: 'Night',
|
||||
id: 2
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
##### CSS rules
|
||||
|
||||
The applied CSS classes for color themes will be in the form: `.color-theme-<id>`.
|
||||
|
||||
**Caution**: No CSS class for color theme with `id: 0` will be applied. Basically, the first color theme corresponds to your default theme's colors.
|
||||
|
||||
For instance, using the default color themes:
|
||||
|
||||
```js
|
||||
gitbook.fontsettings.setTheme('night');
|
||||
```
|
||||
|
||||
will result in the following HTML state for the root element:
|
||||
|
||||
```HTML
|
||||
<div class="book color-theme-2">
|
||||
```
|
||||
|
||||
While:
|
||||
|
||||
```js
|
||||
gitbook.fontsettings.setTheme('white');
|
||||
```
|
||||
|
||||
will reset the HTML state for the root element:
|
||||
|
||||
```HTML
|
||||
<div class="book">
|
||||
```
|
||||
|
||||
##### Managing the color themes
|
||||
|
||||
##### `gitbook.fontsettings.getFamilies()`
|
||||
|
||||
Returns the currently set color themes.
|
||||
|
||||
By default, the font families are:
|
||||
|
||||
```js
|
||||
// Default themes
|
||||
var THEMES = [
|
||||
{
|
||||
config: 'white',
|
||||
text: 'White',
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: 'sepia',
|
||||
text: 'Sepia',
|
||||
id: 1
|
||||
},
|
||||
{
|
||||
config: 'night',
|
||||
text: 'Night',
|
||||
id: 2
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
##### `gitbook.fontsettings.setThemes()`
|
||||
|
||||
Set the new color themes configuration, as an array of font family objects, used by the `plugin-fontsettings` in the form:
|
||||
|
||||
```js
|
||||
var COLOR_THEMES = [
|
||||
{
|
||||
config: 'light',
|
||||
text: 'Light',
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: 'dark',
|
||||
text: 'Dark',
|
||||
id: 1
|
||||
}
|
||||
];
|
||||
|
||||
gitbook.fontsettings.setThemes(COLOR_THEMES);
|
||||
```
|
||||
|
||||
This will recreate the fontsettings menu to reflect the changes.
|
||||
|
||||
##### `gitbook.fontsettings.setTheme()`
|
||||
|
||||
Takes a color theme `config` key as an argument and updates the color theme used for this book.
|
||||
|
||||
This will basically apply the CSS class with the corresponding theme `id`: `.color-theme-<id>`, or remove the applied CSS class if the selected theme `id` is `0`.
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0 (same as [Gitbook/plugin-fontsettings])
|
||||
|
||||
[Gitbook/plugin-fontsettings]: https://github.com/GitbookIO/plugin-fontsettings
|
||||
[gitbook-tester]: https://github.com/todvora/gitbook-tester
|
||||
[honkit-tester]: https://github.com/vowstar/honkit-tester
|
||||
238
book/node_modules/@honkit/honkit-plugin-fontsettings/assets/fontsettings.js
generated
vendored
Normal file
238
book/node_modules/@honkit/honkit-plugin-fontsettings/assets/fontsettings.js
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
require(["gitbook", "jquery"], (gitbook, $) => {
|
||||
// Configuration
|
||||
const MAX_SIZE = 4;
|
||||
const MIN_SIZE = 0;
|
||||
let BUTTON_ID;
|
||||
|
||||
// Current fontsettings state
|
||||
let fontState;
|
||||
|
||||
// Default themes
|
||||
let THEMES = [
|
||||
{
|
||||
config: "white",
|
||||
text: "White",
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: "sepia",
|
||||
text: "Sepia",
|
||||
id: 1
|
||||
},
|
||||
{
|
||||
config: "night",
|
||||
text: "Night",
|
||||
id: 2
|
||||
}
|
||||
];
|
||||
|
||||
// Default font families
|
||||
let FAMILIES = [
|
||||
{
|
||||
config: "serif",
|
||||
text: "Serif",
|
||||
id: 0
|
||||
},
|
||||
{
|
||||
config: "sans",
|
||||
text: "Sans",
|
||||
id: 1
|
||||
}
|
||||
];
|
||||
|
||||
// Return configured themes
|
||||
function getThemes() {
|
||||
return THEMES;
|
||||
}
|
||||
|
||||
// Modify configured themes
|
||||
function setThemes(themes) {
|
||||
THEMES = themes;
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
// Return configured font families
|
||||
function getFamilies() {
|
||||
return FAMILIES;
|
||||
}
|
||||
|
||||
// Modify configured font families
|
||||
function setFamilies(families) {
|
||||
FAMILIES = families;
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
// Save current font settings
|
||||
function saveFontSettings() {
|
||||
gitbook.storage.set("fontState", fontState);
|
||||
update();
|
||||
}
|
||||
|
||||
// Increase font size
|
||||
function enlargeFontSize(e) {
|
||||
e.preventDefault();
|
||||
if (fontState.size >= MAX_SIZE) return;
|
||||
|
||||
fontState.size++;
|
||||
saveFontSettings();
|
||||
}
|
||||
|
||||
// Decrease font size
|
||||
function reduceFontSize(e) {
|
||||
e.preventDefault();
|
||||
if (fontState.size <= MIN_SIZE) return;
|
||||
|
||||
fontState.size--;
|
||||
saveFontSettings();
|
||||
}
|
||||
|
||||
// Change font family
|
||||
function changeFontFamily(configName, e) {
|
||||
if (e && e instanceof Event) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
const familyId = getFontFamilyId(configName);
|
||||
fontState.family = familyId;
|
||||
saveFontSettings();
|
||||
}
|
||||
|
||||
// Change type of color theme
|
||||
function changeColorTheme(configName, e) {
|
||||
if (e && e instanceof Event) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
const $book = gitbook.state.$book;
|
||||
|
||||
// Remove currently applied color theme
|
||||
if (fontState.theme !== 0) $book.removeClass(`color-theme-${fontState.theme}`);
|
||||
|
||||
// Set new color theme
|
||||
const themeId = getThemeId(configName);
|
||||
fontState.theme = themeId;
|
||||
if (fontState.theme !== 0) $book.addClass(`color-theme-${fontState.theme}`);
|
||||
|
||||
saveFontSettings();
|
||||
}
|
||||
|
||||
// Return the correct id for a font-family config key
|
||||
// Default to first font-family
|
||||
function getFontFamilyId(configName) {
|
||||
// Search for plugin configured font family
|
||||
const configFamily = $.grep(FAMILIES, (family) => {
|
||||
return family.config == configName;
|
||||
})[0];
|
||||
|
||||
// Fallback to default font family
|
||||
return (configFamily && configFamily.id) || 0;
|
||||
}
|
||||
|
||||
// Return the correct id for a theme config key
|
||||
// Default to first theme
|
||||
function getThemeId(configName) {
|
||||
// Search for plugin configured theme
|
||||
const configTheme = $.grep(THEMES, (theme) => {
|
||||
return theme.config == configName;
|
||||
})[0];
|
||||
|
||||
// Fallback to default theme
|
||||
return (configTheme && configTheme.id) || 0;
|
||||
}
|
||||
|
||||
function update() {
|
||||
const $book = gitbook.state.$book;
|
||||
|
||||
$(".font-settings .font-family-list li").removeClass("active");
|
||||
$(`.font-settings .font-family-list li:nth-child(${fontState.family + 1})`).addClass("active");
|
||||
|
||||
$book[0].className = $book[0].className.replace(/\bfont-\S+/g, "");
|
||||
$book.addClass(`font-size-${fontState.size}`);
|
||||
$book.addClass(`font-family-${fontState.family}`);
|
||||
|
||||
if (fontState.theme !== 0) {
|
||||
$book[0].className = $book[0].className.replace(/\bcolor-theme-\S+/g, "");
|
||||
$book.addClass(`color-theme-${fontState.theme}`);
|
||||
}
|
||||
}
|
||||
|
||||
function init(config) {
|
||||
// Search for plugin configured font family
|
||||
const configFamily = getFontFamilyId(config.family);
|
||||
const configTheme = getThemeId(config.theme);
|
||||
|
||||
// Instantiate font state object
|
||||
fontState = gitbook.storage.get("fontState", {
|
||||
size: config.size || 2,
|
||||
family: configFamily,
|
||||
theme: configTheme
|
||||
});
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
function updateButtons() {
|
||||
// Remove existing fontsettings buttons
|
||||
if (BUTTON_ID) {
|
||||
gitbook.toolbar.removeButton(BUTTON_ID);
|
||||
}
|
||||
|
||||
// Create buttons in toolbar
|
||||
BUTTON_ID = gitbook.toolbar.createButton({
|
||||
icon: "fa fa-font",
|
||||
label: "Font Settings",
|
||||
className: "font-settings",
|
||||
dropdown: [
|
||||
[
|
||||
{
|
||||
text: "A",
|
||||
className: "font-reduce",
|
||||
onClick: reduceFontSize
|
||||
},
|
||||
{
|
||||
text: "A",
|
||||
className: "font-enlarge",
|
||||
onClick: enlargeFontSize
|
||||
}
|
||||
],
|
||||
$.map(FAMILIES, (family) => {
|
||||
family.onClick = function (e) {
|
||||
return changeFontFamily(family.config, e);
|
||||
};
|
||||
|
||||
return family;
|
||||
}),
|
||||
$.map(THEMES, (theme) => {
|
||||
theme.onClick = function (e) {
|
||||
return changeColorTheme(theme.config, e);
|
||||
};
|
||||
|
||||
return theme;
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
// Init configuration at start
|
||||
gitbook.events.bind("start", (e, config) => {
|
||||
const opts = config.fontsettings;
|
||||
|
||||
// Generate buttons at start
|
||||
updateButtons();
|
||||
|
||||
// Init current settings
|
||||
init(opts);
|
||||
});
|
||||
|
||||
// Expose API
|
||||
gitbook.fontsettings = {
|
||||
enlargeFontSize: enlargeFontSize,
|
||||
reduceFontSize: reduceFontSize,
|
||||
setTheme: changeColorTheme,
|
||||
setFamily: changeFontFamily,
|
||||
getThemes: getThemes,
|
||||
setThemes: setThemes,
|
||||
getFamilies: getFamilies,
|
||||
setFamilies: setFamilies
|
||||
};
|
||||
});
|
||||
309
book/node_modules/@honkit/honkit-plugin-fontsettings/assets/website.css
generated
vendored
Normal file
309
book/node_modules/@honkit/honkit-plugin-fontsettings/assets/website.css
generated
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
* Theme 1
|
||||
*/
|
||||
.color-theme-1 .dropdown-menu {
|
||||
background-color: #111;
|
||||
border-color: hsl(194, 5%, 52%);
|
||||
}
|
||||
.color-theme-1 .dropdown-menu .dropdown-caret .caret-inner {
|
||||
border-bottom: 9px solid #111;
|
||||
}
|
||||
.color-theme-1 .dropdown-menu .buttons {
|
||||
border-color: hsl(194, 5%, 52%);
|
||||
}
|
||||
.color-theme-1 .dropdown-menu .button {
|
||||
color: #AFA790;
|
||||
}
|
||||
.color-theme-1 .dropdown-menu .button:hover {
|
||||
color: #73553C;
|
||||
}
|
||||
/*
|
||||
* Theme 2
|
||||
*/
|
||||
.color-theme-2 .dropdown-menu {
|
||||
background-color: hsl(229, 20%, 22%);
|
||||
border-color: hsl(230, 19%, 19%);
|
||||
}
|
||||
.color-theme-2 .dropdown-menu .dropdown-caret .caret-inner {
|
||||
border-bottom: 9px solid hsl(229, 20%, 22%);
|
||||
}
|
||||
.color-theme-2 .dropdown-menu .buttons {
|
||||
border-color: hsl(230, 19%, 19%);
|
||||
}
|
||||
.color-theme-2 .dropdown-menu .button {
|
||||
color: hsl(228, 13%, 44%);
|
||||
}
|
||||
.color-theme-2 .dropdown-menu .button:hover {
|
||||
color: hsl(240, 5%, 96%);
|
||||
}
|
||||
.book .book-header .font-settings .font-enlarge {
|
||||
line-height: 30px;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
.book .book-header .font-settings .font-reduce {
|
||||
line-height: 30px;
|
||||
font-size: 1em;
|
||||
}
|
||||
.book.color-theme-1 .book-body {
|
||||
color: #704214;
|
||||
background: #F3EACB;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section {
|
||||
background: #F3EACB;
|
||||
}
|
||||
.book.color-theme-1 #book-search-input {
|
||||
background: transparent;
|
||||
}
|
||||
.book.color-theme-1 #book-search-results .search-results .has-results .search-results-item {
|
||||
color: #b16820;
|
||||
}
|
||||
.book.color-theme-2 .book-body {
|
||||
color: hsl(214, 29%, 80%);
|
||||
background: hsl(228, 21%, 14%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section {
|
||||
background: hsl(228, 21%, 14%);
|
||||
}
|
||||
.book.color-theme-2 #book-search-input {
|
||||
background: transparent;
|
||||
}
|
||||
.book.color-theme-2 #book-search-results .search-results .has-results .search-results-item {
|
||||
color: hsl(214, 29%, 65%);
|
||||
}
|
||||
.book.font-size-0 .book-body .page-inner section {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.book.font-size-1 .book-body .page-inner section {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
.book.font-size-2 .book-body .page-inner section {
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
.book.font-size-3 .book-body .page-inner section {
|
||||
font-size: 2.2rem;
|
||||
}
|
||||
.book.font-size-4 .book-body .page-inner section {
|
||||
font-size: 4rem;
|
||||
}
|
||||
.book.font-family-0 {
|
||||
font-family: Georgia, serif;
|
||||
}
|
||||
.book.font-family-1 {
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal {
|
||||
color: #704214;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal a {
|
||||
color: inherit;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h3,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h4,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h5,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
|
||||
color: inherit;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2 {
|
||||
border-color: inherit;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
|
||||
color: inherit;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal hr {
|
||||
background-color: inherit;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal blockquote {
|
||||
border-color: inherit;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code {
|
||||
background: #fdf6e3;
|
||||
color: #657b83;
|
||||
border-color: #f8df9c;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal .highlight {
|
||||
background-color: inherit;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table th,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table td {
|
||||
border-color: #f5d06c;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr {
|
||||
color: inherit;
|
||||
background-color: #fdf6e3;
|
||||
border-color: #444;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
|
||||
background-color: #fbeecb;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal {
|
||||
color: hsl(214, 29%, 80%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal a {
|
||||
color: hsl(193, 61%, 53%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h3,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h4,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h5,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
|
||||
color: hsl(60, 100%, 99%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2 {
|
||||
border-color: hsl(230, 17%, 26%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
|
||||
color: hsl(230, 17%, 26%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal hr {
|
||||
background-color: hsl(230, 17%, 26%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal blockquote {
|
||||
border-color: hsl(230, 17%, 26%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code {
|
||||
color: hsl(206, 43%, 73%);
|
||||
background: hsl(229, 20%, 22%);
|
||||
border-color: hsl(229, 20%, 22%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal .highlight {
|
||||
background-color: hsl(233, 18%, 19%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table th,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table td {
|
||||
border-color: hsl(230, 17%, 28%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr {
|
||||
color: hsl(216, 24%, 77%);
|
||||
background-color: hsl(229, 19%, 22%);
|
||||
border-color: hsl(230, 17%, 28%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
|
||||
background-color: hsl(229, 17%, 25%);
|
||||
}
|
||||
.book.color-theme-1 .book-header {
|
||||
color: #AFA790;
|
||||
background: transparent;
|
||||
}
|
||||
.book.color-theme-1 .book-header .btn {
|
||||
color: #AFA790;
|
||||
}
|
||||
.book.color-theme-1 .book-header .btn:hover {
|
||||
color: #73553C;
|
||||
background: none;
|
||||
}
|
||||
.book.color-theme-1 .book-header h1 {
|
||||
color: #704214;
|
||||
}
|
||||
.book.color-theme-2 .book-header {
|
||||
color: #7e888b;
|
||||
background: transparent;
|
||||
}
|
||||
.book.color-theme-2 .book-header .btn {
|
||||
color: hsl(230, 17%, 28%);
|
||||
}
|
||||
.book.color-theme-2 .book-header .btn:hover {
|
||||
color: hsl(60, 100%, 98%);
|
||||
background: none;
|
||||
}
|
||||
.book.color-theme-2 .book-header h1 {
|
||||
color: hsl(214, 29%, 80%);
|
||||
}
|
||||
.book.color-theme-1 .book-body .navigation {
|
||||
color: #AFA790;
|
||||
}
|
||||
.book.color-theme-1 .book-body .navigation:hover {
|
||||
color: #73553C;
|
||||
}
|
||||
.book.color-theme-2 .book-body .navigation {
|
||||
color: hsl(224, 19%, 27%);
|
||||
}
|
||||
.book.color-theme-2 .book-body .navigation:hover {
|
||||
color: hsl(60, 100%, 98%);
|
||||
}
|
||||
/*
|
||||
* Theme 1
|
||||
*/
|
||||
.book.color-theme-1 .book-summary {
|
||||
color: #AFA790;
|
||||
background: #111;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.07);
|
||||
}
|
||||
.book.color-theme-1 .book-summary .book-search,
|
||||
.book.color-theme-1 .book-summary #book-search-input {
|
||||
background: transparent;
|
||||
}
|
||||
.book.color-theme-1 .book-summary .book-search input,
|
||||
.book.color-theme-1 .book-summary #book-search-input input,
|
||||
.book.color-theme-1 .book-summary .book-search input:focus,
|
||||
.book.color-theme-1 .book-summary #book-search-input input:focus {
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.book.color-theme-1 .book-summary ul.summary li.divider {
|
||||
background: hsl(194, 5%, 52%);
|
||||
box-shadow: none;
|
||||
}
|
||||
.book.color-theme-1 .book-summary ul.summary li i.fa-check {
|
||||
color: hsl(120, 60%, 50%);
|
||||
}
|
||||
.book.color-theme-1 .book-summary ul.summary li.done > a {
|
||||
color: #877F6A;
|
||||
}
|
||||
.book.color-theme-1 .book-summary ul.summary li a,
|
||||
.book.color-theme-1 .book-summary ul.summary li span {
|
||||
color: #877F6A;
|
||||
background: transparent;
|
||||
font-weight: normal;
|
||||
}
|
||||
.book.color-theme-1 .book-summary ul.summary li.active > a,
|
||||
.book.color-theme-1 .book-summary ul.summary li a:hover {
|
||||
color: #704214;
|
||||
background: transparent;
|
||||
font-weight: normal;
|
||||
}
|
||||
/*
|
||||
* Theme 2
|
||||
*/
|
||||
.book.color-theme-2 .book-summary {
|
||||
color: hsl(226, 20%, 78%);
|
||||
background: hsl(229, 20%, 22%);
|
||||
border-right: none;
|
||||
}
|
||||
.book.color-theme-2 .book-summary .book-search,
|
||||
.book.color-theme-2 .book-summary #book-search-input {
|
||||
background: transparent;
|
||||
}
|
||||
.book.color-theme-2 .book-summary .book-search input,
|
||||
.book.color-theme-2 .book-summary #book-search-input input,
|
||||
.book.color-theme-2 .book-summary .book-search input:focus,
|
||||
.book.color-theme-2 .book-summary #book-search-input input:focus {
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.book.color-theme-2 .book-summary ul.summary li.divider {
|
||||
background: hsl(230, 19%, 19%);
|
||||
box-shadow: none;
|
||||
}
|
||||
.book.color-theme-2 .book-summary ul.summary li i.fa-check {
|
||||
color: hsl(120, 60%, 50%);
|
||||
}
|
||||
.book.color-theme-2 .book-summary ul.summary li.done > a {
|
||||
color: hsl(227, 13%, 44%);
|
||||
}
|
||||
.book.color-theme-2 .book-summary ul.summary li a,
|
||||
.book.color-theme-2 .book-summary ul.summary li span {
|
||||
color: hsl(226, 22%, 80%);
|
||||
background: transparent;
|
||||
font-weight: 600;
|
||||
}
|
||||
.book.color-theme-2 .book-summary ul.summary li.active > a,
|
||||
.book.color-theme-2 .book-summary ul.summary li a:hover {
|
||||
color: hsl(240, 5%, 96%);
|
||||
background: hsl(233, 19%, 18%);
|
||||
font-weight: 600;
|
||||
}
|
||||
4
book/node_modules/@honkit/honkit-plugin-fontsettings/eslint.config.mjs
generated
vendored
Normal file
4
book/node_modules/@honkit/honkit-plugin-fontsettings/eslint.config.mjs
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// eslint.config.mjs
|
||||
import { eslintConfig } from "@honkit/cleaning-tools";
|
||||
|
||||
export default [...eslintConfig];
|
||||
7
book/node_modules/@honkit/honkit-plugin-fontsettings/index.js
generated
vendored
Normal file
7
book/node_modules/@honkit/honkit-plugin-fontsettings/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
book: {
|
||||
assets: "./assets",
|
||||
js: ["fontsettings.js"],
|
||||
css: ["website.css"]
|
||||
}
|
||||
};
|
||||
63
book/node_modules/@honkit/honkit-plugin-fontsettings/package.json
generated
vendored
Normal file
63
book/node_modules/@honkit/honkit-plugin-fontsettings/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@honkit/honkit-plugin-fontsettings",
|
||||
"description": "Fonts and colors themes settings the website for a better reading experience",
|
||||
"main": "index.js",
|
||||
"version": "6.0.2",
|
||||
"license": "Apache-2.0",
|
||||
"homepage": "https://github.com/honkit/honkit",
|
||||
"engines": {
|
||||
"gitbook": ">=2.4.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/honkit/honkit.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/honkit/honkit/issues"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@honkit/cleaning-tools": "6.0.2",
|
||||
"eslint": "^9.12.0",
|
||||
"less": "^4.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:css --scripts-prepend-node-path",
|
||||
"build:css": "lessc ./less/website.less ./assets/website.css",
|
||||
"prepublish": "npm run build",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"gitbook": {
|
||||
"properties": {
|
||||
"theme": {
|
||||
"type": "string",
|
||||
"default": "white",
|
||||
"title": "Default theme",
|
||||
"enum": [
|
||||
"white",
|
||||
"sepia",
|
||||
"night"
|
||||
]
|
||||
},
|
||||
"family": {
|
||||
"type": "string",
|
||||
"default": "sans",
|
||||
"title": "Default font family",
|
||||
"enum": [
|
||||
"sans",
|
||||
"serif"
|
||||
]
|
||||
},
|
||||
"size": {
|
||||
"type": "number",
|
||||
"default": 2,
|
||||
"title": "Default font size",
|
||||
"min": 1,
|
||||
"max": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
"gitHead": "9dcd51c588177ee3a684788c633a67b82dea82a5"
|
||||
}
|
||||
Reference in New Issue
Block a user