@redocly/theme 0.45.11 → 0.46.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.
Files changed (34) hide show
  1. package/lib/components/CodeBlock/CodeBlock.d.ts +2 -1
  2. package/lib/components/CodeBlock/CodeBlock.js +33 -9
  3. package/lib/components/CodeBlock/CodeBlockContainer.d.ts +1 -0
  4. package/lib/components/CodeBlock/CodeBlockContainer.js +242 -68
  5. package/lib/components/CodeBlock/variables.js +43 -0
  6. package/lib/components/Link/Link.js +1 -1
  7. package/lib/core/hooks/use-theme-config.js +1 -1
  8. package/lib/core/hooks/use-theme-hooks.js +1 -0
  9. package/lib/core/types/hooks.d.ts +7 -0
  10. package/lib/core/utils/add-line-numbers.d.ts +6 -0
  11. package/lib/core/utils/add-line-numbers.js +18 -0
  12. package/lib/core/utils/index.d.ts +1 -1
  13. package/lib/core/utils/index.js +1 -1
  14. package/lib/markdoc/components/Cards/Card.d.ts +2 -1
  15. package/lib/markdoc/components/Cards/Card.js +2 -2
  16. package/lib/markdoc/components/Cards/CardIcon.d.ts +2 -1
  17. package/lib/markdoc/components/Cards/CardIcon.js +3 -3
  18. package/lib/markdoc/tags/card.js +5 -0
  19. package/package.json +1 -3
  20. package/src/components/CodeBlock/CodeBlock.tsx +21 -7
  21. package/src/components/CodeBlock/CodeBlockContainer.tsx +243 -68
  22. package/src/components/CodeBlock/variables.ts +43 -0
  23. package/src/components/Link/Link.tsx +1 -1
  24. package/src/core/hooks/use-theme-config.ts +1 -1
  25. package/src/core/hooks/use-theme-hooks.ts +1 -0
  26. package/src/core/types/hooks.ts +11 -0
  27. package/src/core/utils/add-line-numbers.ts +16 -0
  28. package/src/core/utils/index.ts +1 -1
  29. package/src/markdoc/components/Cards/Card.tsx +10 -1
  30. package/src/markdoc/components/Cards/CardIcon.tsx +5 -4
  31. package/src/markdoc/tags/card.ts +5 -0
  32. package/lib/core/utils/highlight.d.ts +0 -35
  33. package/lib/core/utils/highlight.js +0 -129
  34. package/src/core/utils/highlight.ts +0 -125
@@ -28,6 +28,11 @@ export const card: MarkdocSchemaWrapper = {
28
28
  matches: ['start', 'end'],
29
29
  default: 'start',
30
30
  },
31
+ iconPosition: {
32
+ type: String,
33
+ matches: ['auto', 'start', 'center', 'end'],
34
+ default: 'auto',
35
+ },
31
36
  layout: {
32
37
  type: String,
33
38
  matches: ['horizontal', 'combined', 'vertical'],
@@ -1,35 +0,0 @@
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;
@@ -1,129 +0,0 @@
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,125 +0,0 @@
1
- import * as Prism from 'prismjs';
2
- import 'prismjs/components/prism-bash.js';
3
- import 'prismjs/components/prism-c.js';
4
- import 'prismjs/components/prism-clike.js';
5
- import 'prismjs/components/prism-coffeescript.js';
6
- import 'prismjs/components/prism-cpp.js';
7
- import 'prismjs/components/prism-csharp.js';
8
- import 'prismjs/components/prism-go.js';
9
- import 'prismjs/components/prism-http.js';
10
- import 'prismjs/components/prism-java.js';
11
- import 'prismjs/components/prism-lua.js';
12
- import 'prismjs/components/prism-markdown.js';
13
- import 'prismjs/components/prism-markup-templating.js'; // dep of php
14
- import 'prismjs/components/prism-markup.js'; // xml
15
- import 'prismjs/components/prism-objectivec.js';
16
- import 'prismjs/components/prism-perl.js';
17
- import 'prismjs/components/prism-php.js';
18
- import 'prismjs/components/prism-python.js';
19
- import 'prismjs/components/prism-ruby.js';
20
- import 'prismjs/components/prism-scala.js';
21
- import 'prismjs/components/prism-sql.js';
22
- import 'prismjs/components/prism-swift.js';
23
- import 'prismjs/components/prism-graphql.js';
24
- import 'prismjs/plugins/treeview/prism-treeview.js';
25
-
26
- const DEFAULT_LANG = 'clike';
27
- const NEW_LINE_EXP = /\n(?!$)/g;
28
-
29
- Prism.languages.insertBefore(
30
- 'javascript',
31
- 'string',
32
- {
33
- 'property string': {
34
- pattern: /([{,]\s*)"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
35
- lookbehind: true,
36
- },
37
- },
38
- undefined,
39
- );
40
-
41
- Prism.languages.insertBefore(
42
- 'javascript',
43
- 'punctuation',
44
- {
45
- property: {
46
- pattern: /([{,]\s*)[a-z]\w*(?=\s*:)/i,
47
- lookbehind: true,
48
- },
49
- },
50
- undefined,
51
- );
52
-
53
- Prism.languages.markdoc = {
54
- ...Prism.languages.markdown,
55
- tag: {
56
- pattern: /{%(.|\n)*?%}/i,
57
- inside: {
58
- keyword: {
59
- pattern: /^({%\s*\/?)(\w*|-)*\b/i,
60
- lookbehind: true,
61
- },
62
- id: /#(\w|-)*\b/,
63
- string: /".*?"/,
64
- equals: /=/,
65
- number: /\b\d+\b/i,
66
- variable: {
67
- pattern: /\$[\w.]+/i,
68
- inside: {
69
- punctuation: /\./i,
70
- },
71
- },
72
- function: /\b\w+(?=\()/,
73
- punctuation: /({%|\/?%})/i,
74
- boolean: /false|true/,
75
- },
76
- },
77
- variable: {
78
- pattern: /\$\w+/i,
79
- },
80
- function: {
81
- pattern: /\b\w+(?=\()/i,
82
- },
83
- };
84
-
85
- /**
86
- * map language names to Prism.js names
87
- */
88
- export function mapLang(lang: string): string {
89
- return (
90
- {
91
- json: 'js',
92
- 'c++': 'cpp',
93
- 'c#': 'csharp',
94
- 'c#+newtonsoft': 'csharp',
95
- 'java8+apache': 'java',
96
- 'objective-c': 'objectivec',
97
- shell: 'bash',
98
- viml: 'vim',
99
- curl: 'bash',
100
- 'node.js': 'js',
101
- }[lang] || DEFAULT_LANG
102
- );
103
- }
104
-
105
- /**
106
- * Highlight source code string using Prism.js
107
- * @param source source code to highlight
108
- * @param lang highlight language
109
- * @return highlighted source code as **html string**
110
- */
111
- export function highlight(source: string | number | boolean, lang: string = DEFAULT_LANG): string {
112
- lang = lang.toLowerCase();
113
- const grammar = Prism.languages[lang] || Prism.languages[mapLang(lang)];
114
- return Prism.highlight(source.toString(), grammar, lang);
115
- }
116
-
117
- export function addLineNumbers(highlightedCode: string, start = 1): string {
118
- const codeLines = highlightedCode.split(NEW_LINE_EXP);
119
-
120
- return codeLines
121
- .map((line, i) => {
122
- return `<span class="code-line" data-line-number=${start + i}>${line}</span>`;
123
- })
124
- .join('\n');
125
- }