@readme/markdown 6.75.0-beta.28 → 6.75.0-beta.29

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.
@@ -0,0 +1,31 @@
1
+ import React, { useContext } from 'react';
2
+ import Tooltip from '@tippyjs/react';
3
+ import GlossaryContext from '../../contexts/GlossaryTerms';
4
+ import type { GlossaryItem, GlossaryTerm } from '../../contexts/GlossaryTerms';
5
+
6
+ const GlossaryItem = ({ term, terms }: { term: string; terms: GlossaryTerm[] }) => {
7
+ const foundTerm = terms.find(i => term.toLowerCase() === i.term.toLowerCase());
8
+
9
+ if (!foundTerm) return <span>{term}</span>;
10
+
11
+ return (
12
+ <Tooltip
13
+ content={
14
+ <div className="GlossaryItem-tooltip-content">
15
+ <strong className="GlossaryItem-term">{foundTerm.term}</strong> - {foundTerm.definition}
16
+ </div>
17
+ }
18
+ offset={[-5, 5]}
19
+ placement="bottom-start"
20
+ >
21
+ <span className="GlossaryItem-trigger">{term}</span>
22
+ </Tooltip>
23
+ );
24
+ };
25
+
26
+ const GlossaryItemWithContext = props => {
27
+ const terms = useContext(GlossaryContext);
28
+ return terms ? <GlossaryItem {...props} terms={terms} /> : null;
29
+ };
30
+
31
+ export { GlossaryItem, GlossaryItemWithContext as default, GlossaryContext };
@@ -0,0 +1,111 @@
1
+ import * as React from 'react';
2
+
3
+ interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLImageElement>> {
4
+ align: string;
5
+ alt: string;
6
+ border: boolean;
7
+ caption: string;
8
+ className: string;
9
+ height: string;
10
+ lazy: boolean;
11
+ src: string;
12
+ title: string;
13
+ width: string;
14
+ }
15
+
16
+ const Image = (props: Props) => {
17
+ const [lightbox, setLightbox] = React.useState(false);
18
+
19
+ const {
20
+ align = '',
21
+ alt = '',
22
+ border = false,
23
+ caption,
24
+ className = '',
25
+ height = 'auto',
26
+ lazy,
27
+ src = '',
28
+ title = '',
29
+ width = 'auto',
30
+ } = props;
31
+
32
+ if (className === 'emoji') {
33
+ return <img src={src} width={width} height={height} title={title} alt={alt} loading={lazy ? 'lazy' : 'eager'} />;
34
+ }
35
+
36
+ const handleKeyDown = ({ key, metaKey: cmd }: React.KeyboardEvent<HTMLImageElement>) => {
37
+ const cmdKey = cmd ? 'cmd+' : '';
38
+ key = `${cmdKey}${key.toLowerCase()}`;
39
+
40
+ switch (key) {
41
+ case 'cmd+.':
42
+ case 'escape':
43
+ // CLOSE
44
+ setLightbox(false);
45
+ break;
46
+ case ' ':
47
+ case 'enter':
48
+ // OPEN
49
+ if (!lightbox) setLightbox(true);
50
+ default:
51
+ }
52
+ };
53
+
54
+ const toggle = () => {
55
+ if (className === 'emoji') return;
56
+ setLightbox(!lightbox);
57
+ };
58
+
59
+ if (caption) {
60
+ return (
61
+ <figure>
62
+ <span
63
+ aria-label={alt}
64
+ className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
65
+ onClick={toggle}
66
+ onKeyDown={handleKeyDown}
67
+ role={'button'}
68
+ tabIndex={0}
69
+ >
70
+ <span className="lightbox-inner">
71
+ <img
72
+ src={src}
73
+ width={width}
74
+ height={height}
75
+ title={title}
76
+ className={`img img-align-center ${border ? 'border' : ''}`}
77
+ alt={alt}
78
+ loading={lazy ? 'lazy' : 'eager'}
79
+ />
80
+ </span>
81
+ </span>
82
+ <figcaption>{caption}</figcaption>
83
+ </figure>
84
+ );
85
+ }
86
+
87
+ return (
88
+ <span
89
+ aria-label={alt}
90
+ className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
91
+ onClick={toggle}
92
+ onKeyDown={handleKeyDown}
93
+ role={'button'}
94
+ tabIndex={0}
95
+ >
96
+ <span className="lightbox-inner">
97
+ <img
98
+ src={src}
99
+ width={width}
100
+ height={height}
101
+ title={title}
102
+ className={`img img-align-${align} ${border ? 'border' : ''}`}
103
+ alt={alt}
104
+ loading={lazy ? 'lazy' : 'eager'}
105
+ />
106
+ </span>
107
+ </span>
108
+ );
109
+ };
110
+
111
+ export default Image;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import GlossaryContext from '../../contexts/GlossaryTerms';
3
+ import type { GlossaryItem, GlossaryTerm } from '../../contexts/GlossaryTerms';
4
+ declare const GlossaryItem: ({ term, terms }: {
5
+ term: string;
6
+ terms: GlossaryTerm[];
7
+ }) => React.JSX.Element;
8
+ declare const GlossaryItemWithContext: (props: any) => React.JSX.Element;
9
+ export { GlossaryItem, GlossaryItemWithContext as default, GlossaryContext };
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLImageElement>> {
3
+ align: string;
4
+ alt: string;
5
+ border: boolean;
6
+ caption: string;
7
+ className: string;
8
+ height: string;
9
+ lazy: boolean;
10
+ src: string;
11
+ title: string;
12
+ width: string;
13
+ }
14
+ declare const Image: (props: Props) => React.JSX.Element;
15
+ export default Image;
@@ -0,0 +1,12 @@
1
+ export { default as Anchor } from './Anchor';
2
+ export { default as Callout } from './Callout';
3
+ export { default as Code } from './Code';
4
+ export { default as CodeTabs } from './CodeTabs';
5
+ export { default as Embed } from './Embed';
6
+ export { default as GlossaryItem } from './GlossaryItem';
7
+ export { default as HTMLBlock } from './HTMLBlock';
8
+ export { default as Heading } from './Heading';
9
+ export { default as Image } from './Image';
10
+ export { default as Style } from './Style';
11
+ export { default as Table } from './Table';
12
+ export { default as TableOfContents } from './TableOfContents';
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from "react";
2
+ export type GlossaryTerm = {
3
+ term: string;
4
+ definition: string;
5
+ _id?: string;
6
+ };
7
+ export type GlossaryItem = {
8
+ term?: string;
9
+ terms: GlossaryTerm[];
10
+ };
11
+ declare const GlossaryContext: import("react").Context<GlossaryTerm[]>;
12
+ export default GlossaryContext;
13
+ export declare function Provider(Provider: any, arg1: {
14
+ value: GlossaryTerm[];
15
+ }): ReactNode;
package/dist/enums.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export declare enum NodeTypes {
2
2
  codeTabs = "code-tabs",
3
3
  emoji = "emoji",
4
- i = "i"
4
+ i = "i",
5
+ image = "image"
5
6
  }
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare const utils: {
10
10
  readonly options: any;
11
11
  BaseUrlContext: any;
12
12
  getHref: any;
13
- GlossaryContext: any;
13
+ GlossaryContext: React.Context<import("./contexts/GlossaryTerms").GlossaryTerm[]>;
14
14
  VariablesContext: any;
15
15
  calloutIcons: {};
16
16
  };