@redocly/theme 0.45.2-rc.0 → 0.45.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.
Files changed (34) hide show
  1. package/lib/components/CodeBlock/CodeBlock.js +5 -11
  2. package/lib/components/CodeBlock/CodeBlockContainer.d.ts +1 -1
  3. package/lib/components/CodeBlock/CodeBlockContainer.js +13 -227
  4. package/lib/components/CodeBlock/variables.js +0 -30
  5. package/lib/components/Filter/FilterContent.js +4 -1
  6. package/lib/components/Footer/FooterColumn.js +1 -1
  7. package/lib/components/Markdown/variables.js +1 -1
  8. package/lib/components/Search/SearchFilterField.js +2 -2
  9. package/lib/components/UserMenu/LogoutMenuItem.js +1 -1
  10. package/lib/components/UserMenu/UserMenu.js +2 -2
  11. package/lib/core/types/hooks.d.ts +0 -6
  12. package/lib/core/utils/highlight.d.ts +35 -0
  13. package/lib/core/utils/highlight.js +129 -0
  14. package/lib/core/utils/index.d.ts +1 -1
  15. package/lib/core/utils/index.js +1 -1
  16. package/lib/core/utils/type-guards.d.ts +6 -0
  17. package/lib/core/utils/type-guards.js +9 -1
  18. package/package.json +3 -1
  19. package/src/components/CodeBlock/CodeBlock.tsx +7 -13
  20. package/src/components/CodeBlock/CodeBlockContainer.tsx +14 -228
  21. package/src/components/CodeBlock/variables.ts +0 -30
  22. package/src/components/Filter/FilterContent.tsx +6 -1
  23. package/src/components/Footer/FooterColumn.tsx +2 -2
  24. package/src/components/Markdown/variables.ts +1 -1
  25. package/src/components/Search/SearchFilterField.tsx +1 -1
  26. package/src/components/UserMenu/LogoutMenuItem.tsx +1 -2
  27. package/src/components/UserMenu/UserMenu.tsx +1 -1
  28. package/src/core/types/hooks.ts +0 -7
  29. package/src/core/utils/highlight.ts +125 -0
  30. package/src/core/utils/index.ts +1 -1
  31. package/src/core/utils/type-guards.ts +12 -0
  32. package/lib/core/utils/add-line-numbers.d.ts +0 -6
  33. package/lib/core/utils/add-line-numbers.js +0 -19
  34. package/src/core/utils/add-line-numbers.ts +0 -17
@@ -37,15 +37,7 @@ const CodeBlockControls_1 = require("../../components/CodeBlock/CodeBlockControl
37
37
  function CodeBlock({ lang, source, externalSource, header, dataTestId = 'source-code', codeBlockRef, highlightedHtml, withLineNumbers, startLineNumber, className, codeBlockMaxHeight, tabs, hideCodeColors, wrapContents = false, children, }) {
38
38
  var _a, _b, _c, _d, _e, _f;
39
39
  const [sourceCode, setSourceCode] = (0, react_1.useState)((_c = (source || ((_b = (_a = externalSource === null || externalSource === void 0 ? void 0 : externalSource.sample) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.call(_a, externalSource)))) !== null && _c !== void 0 ? _c : '');
40
- const { useCodeHighlight } = (0, hooks_1.useThemeHooks)();
41
- const { highlight } = useCodeHighlight() || {};
42
- const highlightedCode = highlightedHtml
43
- ? withLineNumbers
44
- ? (0, utils_1.addLineNumbers)(highlightedHtml, startLineNumber)
45
- : highlightedHtml
46
- : children
47
- ? null
48
- : highlight === null || highlight === void 0 ? void 0 : highlight(sourceCode, lang, { withLineNumbers, startLineNumber });
40
+ const highlightedCode = highlightedHtml || (children ? null : (0, utils_1.highlight)(sourceCode, lang));
49
41
  // The same initial value should be returned for ssr and frontend to avoid issues
50
42
  // Because we don't have session storage in ssr and can't get the security details there
51
43
  // Issue for more details https://github.com/Redocly/reference-docs/issues/888
@@ -62,9 +54,11 @@ function CodeBlock({ lang, source, externalSource, header, dataTestId = 'source-
62
54
  return (react_1.default.createElement(CodeBlockWrapper, { "data-component-name": "CodeBlock/CodeBlock", className: className },
63
55
  react_1.default.createElement(ContainerWrapper, null,
64
56
  react_1.default.createElement(CodeBlockControls_1.CodeBlockControls, { tabs: tabs, className: header === null || header === void 0 ? void 0 : header.className, title: header === null || header === void 0 ? void 0 : header.title, controls: controls }),
65
- react_1.default.createElement(CodeBlockContainer_1.CodeBlockContainer, { ref: codeBlockRef, withLineNumbers: withLineNumbers, dangerouslySetInnerHTML: highlightedCode
57
+ react_1.default.createElement(CodeBlockContainer_1.CodeBlockContainer, { ref: codeBlockRef, className: withLineNumbers ? 'line-numbers' : '', dangerouslySetInnerHTML: highlightedCode
66
58
  ? {
67
- __html: highlightedCode,
59
+ __html: withLineNumbers
60
+ ? (0, utils_1.addLineNumbers)(highlightedCode, startLineNumber)
61
+ : highlightedCode,
68
62
  }
69
63
  : undefined, suppressHydrationWarning // TODO: investigate issue
70
64
  : true, "data-testid": dataTestId, hideCodeColors: hideCodeColors, maxHeight: codeBlockMaxHeight, wrapContents: wrapContents, tabIndex: 0 }, children),
@@ -4,7 +4,7 @@ export type CodeBlockContainerProps = PropsWithChildren<{
4
4
  maxHeight?: string;
5
5
  wrapContents?: boolean;
6
6
  ref?: (instance: HTMLPreElement | null) => void;
7
- withLineNumbers?: boolean;
7
+ className?: string;
8
8
  dangerouslySetInnerHTML?: {
9
9
  __html: string;
10
10
  };
@@ -127,243 +127,29 @@ const CodeBlockContainerComponent = styled_components_1.default.pre `
127
127
  cursor: help;
128
128
  }
129
129
 
130
- .line-number {
131
- display: inline-block;
132
- min-width: 2.5em;
133
- padding-right: 0.8em;
134
- text-align: right;
135
- pointer-events: none;
136
- user-select: none;
130
+ .code-line {
131
+ &:before {
132
+ content: attr(data-line-number);
133
+ display: inline-block;
134
+ min-width: 2em;
135
+ padding-right: 0.8em;
136
+ text-align: right;
137
+ pointer-events: none;
138
+ user-select: none;
139
+ }
137
140
  }
138
141
 
139
142
  .highlighted {
140
143
  background: var(--tag-basic-bg-color);
141
144
  }
142
145
 
143
- /*
144
- * Shiki styles
145
- */
146
-
147
- .line {
148
- display: block;
149
- }
150
-
151
- .has-diff {
152
- > .line {
153
- &:before {
154
- content: ' ';
155
- display: inline-block;
156
- min-width: 1em;
157
- padding-right: 0.4em;
158
- text-align: right;
159
- pointer-events: none;
160
- user-select: none;
161
- }
162
- }
163
- }
164
-
165
- .diff {
166
- &.add {
167
- background: var(--color-grass-2);
168
- &:before {
169
- content: '+';
170
- }
171
- }
172
- &.remove {
173
- background: var(--color-red-2);
174
-
175
- &:before {
176
- content: '-';
177
- }
178
- }
179
- }
180
-
181
- .highlighted-word {
182
- background: var(--color-carrot-2);
183
- border: 1px solid var(--color-carrot-5);
184
- border-radius: 4px;
185
- }
186
-
187
- .has-focused {
188
- .line {
189
- opacity: 0.7;
190
- filter: blur(0.095rem);
191
- transition:
192
- filter 0.35s,
193
- opacity 0.35s;
194
- &.focused {
195
- opacity: 1;
196
- filter: blur(0);
197
- }
198
- }
199
-
200
- &:hover {
201
- .line {
202
- opacity: 1;
203
- filter: blur(0);
204
- }
205
- }
206
- }
207
-
208
- /*
209
- * Tree view styles
210
- */
211
-
212
- .tree-view-line {
213
- display: flex;
214
- }
215
-
216
- .tree-view-branch {
217
- color: var(--code-block-tree-view-lines-color);
218
- }
219
-
220
- .tree-view-file {
221
- display: inline-flex;
222
- &::before {
223
- content: '\\ea01';
224
- margin-right: 0.5rem;
225
- font-family: 'TreeViewIcons';
226
- }
227
-
228
- &.no-file {
229
- &::before {
230
- content: '';
231
- margin-right: 0;
232
- }
233
- }
234
-
235
- &.ext-folder {
236
- &::before {
237
- content: '\\ea02';
238
- }
239
- }
240
-
241
- &.ext-img,
242
- &.ext-png,
243
- &.ext-jpg,
244
- &.ext-jpeg,
245
- &.ext-gif,
246
- &.ext-svg {
247
- &::before {
248
- content: '\\ea03';
249
- }
250
- }
251
-
252
- &.ext-mp2,
253
- &.ext-mp3,
254
- &.ext-wav,
255
- &.ext-ogg,
256
- &.ext-flac {
257
- &::before {
258
- content: '\\ea04';
259
- margin-right: 0.5rem;
260
- }
261
- }
262
-
263
- &.ext-mp4,
264
- &.ext-mkv,
265
- &.ext-avi,
266
- &.ext-mov,
267
- &.ext-wmv,
268
- &.ext-flv {
269
- &::before {
270
- content: '\\ea05';
271
- margin-right: 0.5rem;
272
- }
273
- }
274
-
275
- &.ext-txt,
276
- &.ext-text,
277
- &.ext-md,
278
- &.ext-markdown {
279
- &::before {
280
- content: '\\ea06';
281
- margin-right: 0.5rem;
282
- }
283
- }
284
-
285
- &.ext-js,
286
- &.ext-ts,
287
- &.ext-jsx,
288
- &.ext-tsx,
289
- &.ext-json,
290
- &.ext-yaml,
291
- &.ext-yml,
292
- &.ext-xml,
293
- &.ext-html,
294
- &.ext-css,
295
- &.ext-scss,
296
- &.ext-less,
297
- &.ext-sass,
298
- &.ext-java,
299
- &.ext-c,
300
- &.ext-cpp,
301
- &.ext-cs,
302
- &.ext-php,
303
- &.ext-py,
304
- &.ext-rb,
305
- &.ext-go,
306
- &.ext-swift,
307
- &.ext-sql,
308
- &.ext-perl,
309
- &.ext-lua,
310
- &.ext-scala,
311
- &.ext-sh {
312
- &::before {
313
- content: '\\ea07';
314
- margin-right: 0.5rem;
315
- }
316
- }
317
-
318
- &.ext-zip,
319
- &.ext-rar,
320
- &.ext-tar,
321
- &.ext-gz,
322
- &.ext-iso {
323
- &::before {
324
- content: '\\ea08';
325
- }
326
- }
327
-
328
- &.ext-pdf,
329
- &.ext-PDF {
330
- &::before {
331
- content: '\\ea09';
332
- }
333
- }
334
-
335
- &.ext-excel,
336
- &.ext-xls,
337
- &.ext-xlsx {
338
- &::before {
339
- content: '\\ea0a';
340
- }
341
- }
342
-
343
- &.ext-powerpoint,
344
- &.ext-ppt,
345
- &.ext-pptx {
346
- &::before {
347
- content: '\\ea0b';
348
- }
349
- }
350
-
351
- &.ext-doc,
352
- &.ext-docx,
353
- &.ext-rtf {
354
- &::before {
355
- content: '\\ea0c';
356
- }
357
- }
358
- }
359
-
360
146
  ${(0, utils_1.generateCodeBlockTokens)()}
361
147
 
362
148
  ${({ hideCodeColors }) => hideCodeColors &&
363
149
  (0, styled_components_1.css) `
364
- .line-number:not(.highlighted),
365
- .line-number:not(.highlighted) > span,
366
- .line-number:not(.highlighted) > span > span {
150
+ .code-line:not(.highlighted),
151
+ .code-line:not(.highlighted) > span,
152
+ .code-line:not(.highlighted) > span > span {
367
153
  color: grey;
368
154
  }
369
155
  `}
@@ -3,30 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.code = void 0;
4
4
  const styled_components_1 = require("styled-components");
5
5
  exports.code = (0, styled_components_1.css) `
6
- /**
7
- * Tree view icons font
8
- */
9
- @font-face {
10
- font-family: 'TreeViewIcons';
11
- /**
12
- * Use the following escape sequences to refer to a specific icon:
13
- *
14
- * - \\ea01 file
15
- * - \\ea02 folder
16
- * - \\ea03 image
17
- * - \\ea04 audio
18
- * - \\ea05 video
19
- * - \\ea06 text
20
- * - \\ea07 code
21
- * - \\ea08 archive
22
- * - \\ea09 pdf
23
- * - \\ea0a excel
24
- * - \\ea0b powerpoint
25
- * - \\ea0c word
26
- */
27
- src: url('data:application/font-woff;base64,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') format('woff');
28
- }
29
-
30
6
  /**
31
7
  * @tokens Code base styles
32
8
  */
@@ -114,12 +90,6 @@ exports.code = (0, styled_components_1.css) `
114
90
  --code-block-tokens-class-name-color: var(--color-carrot-7); // @presenter Color
115
91
  --code-block-tokens-function-color: var(--color-carrot-7); // @presenter Color
116
92
 
117
- /**
118
- * @tokens Code Block tree view
119
- */
120
- --code-block-tree-view-icon-font-family: 'TreeViewIcons'; // @presenter FontFamily
121
- --code-block-tree-view-lines-color: var(--border-color-primary); // @presenter Color
122
-
123
93
  // @tokens End
124
94
  `;
125
95
  //# sourceMappingURL=variables.js.map
@@ -10,6 +10,7 @@ const FilterInput_1 = require("../../components/Filter/FilterInput");
10
10
  const hooks_1 = require("../../core/hooks");
11
11
  const Button_1 = require("../../components/Button/Button");
12
12
  const Filter_1 = require("../../components/Filter/Filter");
13
+ const utils_1 = require("../../core/utils");
13
14
  function FilterContent({ setFilterTerm, filters, filterTerm, filterValuesCasing, }) {
14
15
  const { useTranslate } = (0, hooks_1.useThemeHooks)();
15
16
  const { translate } = useTranslate();
@@ -19,7 +20,9 @@ function FilterContent({ setFilterTerm, filters, filterTerm, filterValuesCasing,
19
20
  if (filter.selectedOptions && filter.selectedOptions instanceof Set) {
20
21
  return filter.selectedOptions.size;
21
22
  }
22
- else if (filter.selectedOptions.from && filter.selectedOptions.to) {
23
+ else if ((0, utils_1.isFromToSelectedOptions)(filter.selectedOptions) &&
24
+ filter.selectedOptions.from &&
25
+ filter.selectedOptions.to) {
23
26
  return true;
24
27
  }
25
28
  });
@@ -17,7 +17,7 @@ function FooterColumn({ column, className }) {
17
17
  const iconsOnly = items.every((item) => item.label === item.link && (item.icon || item.srcSet));
18
18
  const label = translate(column.labelTranslationKey, column.label);
19
19
  return (react_1.default.createElement(FooterColumnWrapper, { "data-component-name": "Footer/FooterColumn", className: className },
20
- react_1.default.createElement(FooterColumnTitle, null, column.link ? (react_1.default.createElement(Link_1.Link, { to: column.link, external: column.external, target: column.target }, label)) : (label)),
20
+ react_1.default.createElement(FooterColumnTitle, null, (0, utils_1.isNavLinkItem)(column) ? (react_1.default.createElement(Link_1.Link, { to: column.link, external: column.external, target: column.target }, label)) : (label)),
21
21
  react_1.default.createElement(FooterColumnItems, { iconsOnly: iconsOnly }, items === null || items === void 0 ? void 0 : items.map((columnItem, columnItemIndex) => (react_1.default.createElement(FooterItem_1.FooterItem, { item: columnItem, iconsOnly: iconsOnly, key: columnItemIndex }))))));
22
22
  }
23
23
  const FooterColumnWrapper = styled_components_1.default.div `
@@ -7,7 +7,7 @@ exports.markdown = (0, styled_components_1.css) `
7
7
  * @tokens Markdown Content
8
8
  */
9
9
 
10
- --md-content-max-width: 910px;
10
+ --md-content-max-width: 688px;
11
11
  --md-content-padding: 25px 0px 25px 0px; // @presenter Spacing
12
12
  --md-content-font-size: var(--font-size-base); // @presenter FontSize
13
13
  --md-content-font-family: var(--font-family-base); // @presenter FontFamily
@@ -8,12 +8,12 @@ const react_1 = __importDefault(require("react"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
9
  const Button_1 = require("../../components/Button/Button");
10
10
  const ResetIcon_1 = require("../../icons/ResetIcon/ResetIcon");
11
- const core_1 = require("../../core");
11
+ const hooks_1 = require("../../core/hooks");
12
12
  const SearchFilterFieldSelect_1 = require("../../components/Search/FilterFields/SearchFilterFieldSelect");
13
13
  const SearchFilterFieldTags_1 = require("../../components/Search/FilterFields/SearchFilterFieldTags");
14
14
  function SearchFilterField({ className, facet, filter, query, onFilterChange, onFacetReset, }) {
15
15
  var _a;
16
- const { useTranslate } = (0, core_1.useThemeHooks)();
16
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
17
17
  const { translate } = useTranslate();
18
18
  const selectedValues = ((_a = filter.find((item) => item.field === facet.field)) === null || _a === void 0 ? void 0 : _a.values) || [];
19
19
  const onChange = (value) => {
@@ -7,7 +7,7 @@ exports.LogoutMenuItem = LogoutMenuItem;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const hooks_1 = require("../../core/hooks");
9
9
  const LogoutIcon_1 = require("../../icons/LogoutIcon/LogoutIcon");
10
- const DropdownMenuItem_1 = require("../Dropdown/DropdownMenuItem");
10
+ const DropdownMenuItem_1 = require("../../components/Dropdown/DropdownMenuItem");
11
11
  function LogoutMenuItem({ iconOnly, className }) {
12
12
  const { useTranslate, useTelemetry, useUserMenu } = (0, hooks_1.useThemeHooks)();
13
13
  const { handleLogout } = useUserMenu();
@@ -15,7 +15,7 @@ const UserAvatar_1 = require("../../components/UserMenu/UserAvatar");
15
15
  const UserInfoMenuItem_1 = require("../../components/UserMenu/UserInfoMenuItem");
16
16
  const Dropdown_1 = require("../../components/Dropdown/Dropdown");
17
17
  const LogoutMenuItem_1 = require("../../components/UserMenu/LogoutMenuItem");
18
- const core_1 = require("../../core");
18
+ const utils_1 = require("../../core/utils");
19
19
  function UserMenu({ className }) {
20
20
  const { userMenu } = (0, hooks_1.useThemeConfig)();
21
21
  const { useTranslate, useUserMenu } = (0, hooks_1.useThemeHooks)();
@@ -52,7 +52,7 @@ function UserMenu({ className }) {
52
52
  const UserMenuWrapper = styled_components_1.default.div `
53
53
  display: none;
54
54
 
55
- @media screen and (min-width: ${core_1.breakpoints.medium}) {
55
+ @media screen and (min-width: ${utils_1.breakpoints.medium}) {
56
56
  display: block;
57
57
  }
58
58
  `;
@@ -95,12 +95,6 @@ export type ThemeHooks = {
95
95
  };
96
96
  useUserTeams: () => string[];
97
97
  usePageProps: <T extends Record<string, unknown>>() => PageProps & T;
98
- useCodeHighlight: () => {
99
- highlight: (code: string, language: string | undefined, { withLineNumbers, startLineNumber }: {
100
- withLineNumbers?: boolean;
101
- startLineNumber?: number;
102
- }) => string;
103
- };
104
98
  };
105
99
  export type L10nConfig = {
106
100
  currentLocale: string;
@@ -0,0 +1,35 @@
1
+ import 'prismjs/components/prism-bash.js';
2
+ import 'prismjs/components/prism-c.js';
3
+ import 'prismjs/components/prism-clike.js';
4
+ import 'prismjs/components/prism-coffeescript.js';
5
+ import 'prismjs/components/prism-cpp.js';
6
+ import 'prismjs/components/prism-csharp.js';
7
+ import 'prismjs/components/prism-go.js';
8
+ import 'prismjs/components/prism-http.js';
9
+ import 'prismjs/components/prism-java.js';
10
+ import 'prismjs/components/prism-lua.js';
11
+ import 'prismjs/components/prism-markdown.js';
12
+ import 'prismjs/components/prism-markup-templating.js';
13
+ import 'prismjs/components/prism-markup.js';
14
+ import 'prismjs/components/prism-objectivec.js';
15
+ import 'prismjs/components/prism-perl.js';
16
+ import 'prismjs/components/prism-php.js';
17
+ import 'prismjs/components/prism-python.js';
18
+ import 'prismjs/components/prism-ruby.js';
19
+ import 'prismjs/components/prism-scala.js';
20
+ import 'prismjs/components/prism-sql.js';
21
+ import 'prismjs/components/prism-swift.js';
22
+ import 'prismjs/components/prism-graphql.js';
23
+ import 'prismjs/plugins/treeview/prism-treeview.js';
24
+ /**
25
+ * map language names to Prism.js names
26
+ */
27
+ export declare function mapLang(lang: string): string;
28
+ /**
29
+ * Highlight source code string using Prism.js
30
+ * @param source source code to highlight
31
+ * @param lang highlight language
32
+ * @return highlighted source code as **html string**
33
+ */
34
+ export declare function highlight(source: string | number | boolean, lang?: string): string;
35
+ export declare function addLineNumbers(highlightedCode: string, start?: number): string;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.mapLang = mapLang;
27
+ exports.highlight = highlight;
28
+ exports.addLineNumbers = addLineNumbers;
29
+ const Prism = __importStar(require("prismjs"));
30
+ require("prismjs/components/prism-bash.js");
31
+ require("prismjs/components/prism-c.js");
32
+ require("prismjs/components/prism-clike.js");
33
+ require("prismjs/components/prism-coffeescript.js");
34
+ require("prismjs/components/prism-cpp.js");
35
+ require("prismjs/components/prism-csharp.js");
36
+ require("prismjs/components/prism-go.js");
37
+ require("prismjs/components/prism-http.js");
38
+ require("prismjs/components/prism-java.js");
39
+ require("prismjs/components/prism-lua.js");
40
+ require("prismjs/components/prism-markdown.js");
41
+ require("prismjs/components/prism-markup-templating.js"); // dep of php
42
+ require("prismjs/components/prism-markup.js"); // xml
43
+ require("prismjs/components/prism-objectivec.js");
44
+ require("prismjs/components/prism-perl.js");
45
+ require("prismjs/components/prism-php.js");
46
+ require("prismjs/components/prism-python.js");
47
+ require("prismjs/components/prism-ruby.js");
48
+ require("prismjs/components/prism-scala.js");
49
+ require("prismjs/components/prism-sql.js");
50
+ require("prismjs/components/prism-swift.js");
51
+ require("prismjs/components/prism-graphql.js");
52
+ require("prismjs/plugins/treeview/prism-treeview.js");
53
+ const DEFAULT_LANG = 'clike';
54
+ const NEW_LINE_EXP = /\n(?!$)/g;
55
+ Prism.languages.insertBefore('javascript', 'string', {
56
+ 'property string': {
57
+ pattern: /([{,]\s*)"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
58
+ lookbehind: true,
59
+ },
60
+ }, undefined);
61
+ Prism.languages.insertBefore('javascript', 'punctuation', {
62
+ property: {
63
+ pattern: /([{,]\s*)[a-z]\w*(?=\s*:)/i,
64
+ lookbehind: true,
65
+ },
66
+ }, undefined);
67
+ Prism.languages.markdoc = Object.assign(Object.assign({}, Prism.languages.markdown), { tag: {
68
+ pattern: /{%(.|\n)*?%}/i,
69
+ inside: {
70
+ keyword: {
71
+ pattern: /^({%\s*\/?)(\w*|-)*\b/i,
72
+ lookbehind: true,
73
+ },
74
+ id: /#(\w|-)*\b/,
75
+ string: /".*?"/,
76
+ equals: /=/,
77
+ number: /\b\d+\b/i,
78
+ variable: {
79
+ pattern: /\$[\w.]+/i,
80
+ inside: {
81
+ punctuation: /\./i,
82
+ },
83
+ },
84
+ function: /\b\w+(?=\()/,
85
+ punctuation: /({%|\/?%})/i,
86
+ boolean: /false|true/,
87
+ },
88
+ }, variable: {
89
+ pattern: /\$\w+/i,
90
+ }, function: {
91
+ pattern: /\b\w+(?=\()/i,
92
+ } });
93
+ /**
94
+ * map language names to Prism.js names
95
+ */
96
+ function mapLang(lang) {
97
+ return ({
98
+ json: 'js',
99
+ 'c++': 'cpp',
100
+ 'c#': 'csharp',
101
+ 'c#+newtonsoft': 'csharp',
102
+ 'java8+apache': 'java',
103
+ 'objective-c': 'objectivec',
104
+ shell: 'bash',
105
+ viml: 'vim',
106
+ curl: 'bash',
107
+ 'node.js': 'js',
108
+ }[lang] || DEFAULT_LANG);
109
+ }
110
+ /**
111
+ * Highlight source code string using Prism.js
112
+ * @param source source code to highlight
113
+ * @param lang highlight language
114
+ * @return highlighted source code as **html string**
115
+ */
116
+ function highlight(source, lang = DEFAULT_LANG) {
117
+ lang = lang.toLowerCase();
118
+ const grammar = Prism.languages[lang] || Prism.languages[mapLang(lang)];
119
+ return Prism.highlight(source.toString(), grammar, lang);
120
+ }
121
+ function addLineNumbers(highlightedCode, start = 1) {
122
+ const codeLines = highlightedCode.split(NEW_LINE_EXP);
123
+ return codeLines
124
+ .map((line, i) => {
125
+ return `<span class="code-line" data-line-number=${start + i}>${line}</span>`;
126
+ })
127
+ .join('\n');
128
+ }
129
+ //# sourceMappingURL=highlight.js.map
@@ -1,6 +1,6 @@
1
1
  export * from '../../core/utils/clipboard-service';
2
2
  export * from '../../core/utils/css-variables';
3
- export * from '../../core/utils/add-line-numbers';
3
+ export * from '../../core/utils/highlight';
4
4
  export * from '../../core/utils/media-css';
5
5
  export * from '../../core/utils/theme-helpers';
6
6
  export * from '../../core/utils/class-names';
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("../../core/utils/clipboard-service"), exports);
18
18
  __exportStar(require("../../core/utils/css-variables"), exports);
19
- __exportStar(require("../../core/utils/add-line-numbers"), exports);
19
+ __exportStar(require("../../core/utils/highlight"), exports);
20
20
  __exportStar(require("../../core/utils/media-css"), exports);
21
21
  __exportStar(require("../../core/utils/theme-helpers"), exports);
22
22
  __exportStar(require("../../core/utils/class-names"), exports);
@@ -1,5 +1,11 @@
1
+ import { ResolvedNavItem, ResolvedNavLinkItem } from '@redocly/config';
1
2
  export declare function isUndefined<T>(value: T | undefined): value is undefined;
2
3
  export declare function isNull<T>(value: T | null): value is null;
3
4
  export declare function isString<T>(value: T | string): value is string;
4
5
  export declare function isNotNull<T>(value: T): value is NonNullable<T>;
5
6
  export declare const isObject: (item: unknown) => item is object;
7
+ export declare const isNavLinkItem: (item: ResolvedNavItem) => item is ResolvedNavLinkItem;
8
+ export declare const isFromToSelectedOptions: (options: unknown) => options is {
9
+ from: string;
10
+ to: string;
11
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isObject = void 0;
3
+ exports.isFromToSelectedOptions = exports.isNavLinkItem = exports.isObject = void 0;
4
4
  exports.isUndefined = isUndefined;
5
5
  exports.isNull = isNull;
6
6
  exports.isString = isString;
@@ -21,4 +21,12 @@ const isObject = (item) => {
21
21
  return isNotNull(item) && typeof item === 'object';
22
22
  };
23
23
  exports.isObject = isObject;
24
+ const isNavLinkItem = (item) => {
25
+ return item.link !== undefined;
26
+ };
27
+ exports.isNavLinkItem = isNavLinkItem;
28
+ const isFromToSelectedOptions = (options) => {
29
+ return (0, exports.isObject)(options) && 'from' in options && 'to' in options;
30
+ };
31
+ exports.isFromToSelectedOptions = isFromToSelectedOptions;
24
32
  //# sourceMappingURL=type-guards.js.map