@eventuras/scribo 0.8.3 → 0.10.7

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 (164) hide show
  1. package/dist/App.d.ts +11 -0
  2. package/dist/App.d.ts.map +1 -0
  3. package/dist/MarkdownEditor.d.ts +18 -0
  4. package/dist/MarkdownEditor.d.ts.map +1 -0
  5. package/dist/MarkdownEditor2.js +111 -0
  6. package/dist/MarkdownEditor2.js.map +1 -0
  7. package/dist/MarkdownInput.d.ts +27 -0
  8. package/dist/MarkdownInput.d.ts.map +1 -0
  9. package/dist/MarkdownInput.js +57 -0
  10. package/dist/MarkdownInput.js.map +1 -0
  11. package/dist/callout.js +5 -0
  12. package/dist/context/SharedHistoryContext.d.ts +11 -0
  13. package/dist/context/SharedHistoryContext.d.ts.map +1 -0
  14. package/dist/context/SharedHistoryContext.js +12 -0
  15. package/dist/context/SharedHistoryContext.js.map +1 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/main.d.ts +5 -0
  19. package/dist/main.d.ts.map +1 -0
  20. package/dist/main.js +4 -0
  21. package/dist/nodes/EditorNodes.d.ts +4 -0
  22. package/dist/nodes/EditorNodes.d.ts.map +1 -0
  23. package/dist/nodes/EditorNodes.js +39 -0
  24. package/dist/nodes/EditorNodes.js.map +1 -0
  25. package/dist/nodes/callout/CalloutComponent.d.ts +6 -0
  26. package/dist/nodes/callout/CalloutComponent.d.ts.map +1 -0
  27. package/dist/nodes/callout/CalloutComponent.js +53 -0
  28. package/dist/nodes/callout/CalloutComponent.js.map +1 -0
  29. package/dist/nodes/callout/CalloutNode.d.ts +27 -0
  30. package/dist/nodes/callout/CalloutNode.d.ts.map +1 -0
  31. package/dist/nodes/callout/CalloutNode.js +153 -0
  32. package/dist/nodes/callout/CalloutNode.js.map +1 -0
  33. package/dist/nodes/callout/CalloutTransformer.d.ts +3 -0
  34. package/dist/nodes/callout/CalloutTransformer.d.ts.map +1 -0
  35. package/dist/nodes/callout/CalloutTransformer.js +48 -0
  36. package/dist/nodes/callout/CalloutTransformer.js.map +1 -0
  37. package/dist/nodes/callout/calloutPlugin.d.ts +3 -0
  38. package/dist/nodes/callout/calloutPlugin.d.ts.map +1 -0
  39. package/dist/nodes/callout/calloutPlugin.js +34 -0
  40. package/dist/nodes/callout/calloutPlugin.js.map +1 -0
  41. package/dist/nodes/callout/index.d.ts +6 -0
  42. package/dist/nodes/callout/index.d.ts.map +1 -0
  43. package/dist/nodes/schedule/ScheduleItemComponent.d.ts +9 -0
  44. package/dist/nodes/schedule/ScheduleItemComponent.d.ts.map +1 -0
  45. package/dist/nodes/schedule/ScheduleItemComponent.js +167 -0
  46. package/dist/nodes/schedule/ScheduleItemComponent.js.map +1 -0
  47. package/dist/nodes/schedule/ScheduleItemNode.d.ts +31 -0
  48. package/dist/nodes/schedule/ScheduleItemNode.d.ts.map +1 -0
  49. package/dist/nodes/schedule/ScheduleItemNode.js +94 -0
  50. package/dist/nodes/schedule/ScheduleItemNode.js.map +1 -0
  51. package/dist/nodes/schedule/ScheduleTransformer.d.ts +22 -0
  52. package/dist/nodes/schedule/ScheduleTransformer.d.ts.map +1 -0
  53. package/dist/nodes/schedule/ScheduleTransformer.js +60 -0
  54. package/dist/nodes/schedule/ScheduleTransformer.js.map +1 -0
  55. package/dist/nodes/schedule/index.d.ts +5 -0
  56. package/dist/nodes/schedule/index.d.ts.map +1 -0
  57. package/dist/nodes/schedule/schedulePlugin.d.ts +3 -0
  58. package/dist/nodes/schedule/schedulePlugin.d.ts.map +1 -0
  59. package/dist/nodes/schedule/schedulePlugin.js +33 -0
  60. package/dist/nodes/schedule/schedulePlugin.js.map +1 -0
  61. package/dist/plugins/AutoLinkPlugin.d.ts +3 -0
  62. package/dist/plugins/AutoLinkPlugin.d.ts.map +1 -0
  63. package/dist/plugins/AutoLinkPlugin.js +22 -0
  64. package/dist/plugins/AutoLinkPlugin.js.map +1 -0
  65. package/dist/plugins/FloatingLinkEditorPlugin.d.ts +7 -0
  66. package/dist/plugins/FloatingLinkEditorPlugin.d.ts.map +1 -0
  67. package/dist/plugins/FloatingLinkEditorPlugin2.js +302 -0
  68. package/dist/plugins/FloatingLinkEditorPlugin2.js.map +1 -0
  69. package/dist/plugins/HistoryPlugin.d.ts +26 -0
  70. package/dist/plugins/HistoryPlugin.d.ts.map +1 -0
  71. package/dist/plugins/LinkPlugin.d.ts +3 -0
  72. package/dist/plugins/LinkPlugin.d.ts.map +1 -0
  73. package/dist/plugins/LinkPlugin.js +18 -0
  74. package/dist/plugins/LinkPlugin.js.map +1 -0
  75. package/dist/plugins/ToolbarPlugin.d.ts +7 -0
  76. package/dist/plugins/ToolbarPlugin.d.ts.map +1 -0
  77. package/dist/plugins/ToolbarPlugin.js +372 -0
  78. package/dist/plugins/ToolbarPlugin.js.map +1 -0
  79. package/dist/schedule.js +4 -0
  80. package/dist/scribo.css +1977 -0
  81. package/dist/themes/EditorTheme.d.ts +4 -0
  82. package/dist/themes/EditorTheme.d.ts.map +1 -0
  83. package/dist/themes/EditorTheme2.js +107 -0
  84. package/dist/themes/EditorTheme2.js.map +1 -0
  85. package/dist/types.d.ts +26 -0
  86. package/dist/types.d.ts.map +1 -0
  87. package/dist/ui/ContentEditable.d.ts +6 -0
  88. package/dist/ui/ContentEditable.d.ts.map +1 -0
  89. package/dist/ui/ContentEditable2.js +14 -0
  90. package/dist/ui/ContentEditable2.js.map +1 -0
  91. package/dist/ui/DropDown.d.ts +18 -0
  92. package/dist/ui/DropDown.d.ts.map +1 -0
  93. package/dist/ui/DropDown.js +162 -0
  94. package/dist/ui/DropDown.js.map +1 -0
  95. package/dist/ui/Placeholder.d.ts +6 -0
  96. package/dist/ui/Placeholder.d.ts.map +1 -0
  97. package/dist/ui/Placeholder2.js +13 -0
  98. package/dist/ui/Placeholder2.js.map +1 -0
  99. package/dist/utils/environment.d.ts +24 -0
  100. package/dist/utils/environment.d.ts.map +1 -0
  101. package/dist/utils/environment.js +20 -0
  102. package/dist/utils/environment.js.map +1 -0
  103. package/dist/utils/getSelectedNode.d.ts +3 -0
  104. package/dist/utils/getSelectedNode.d.ts.map +1 -0
  105. package/dist/utils/getSelectedNode.js +23 -0
  106. package/dist/utils/getSelectedNode.js.map +1 -0
  107. package/dist/utils/setFloatingElemPosition.d.ts +2 -0
  108. package/dist/utils/setFloatingElemPosition.d.ts.map +1 -0
  109. package/dist/utils/setFloatingElemPositionForLinkEditor.d.ts +2 -0
  110. package/dist/utils/setFloatingElemPositionForLinkEditor.d.ts.map +1 -0
  111. package/dist/utils/setFloatingElemPositionForLinkEditor.js +33 -0
  112. package/dist/utils/setFloatingElemPositionForLinkEditor.js.map +1 -0
  113. package/dist/utils/url.d.ts +11 -0
  114. package/dist/utils/url.d.ts.map +1 -0
  115. package/dist/utils/url.js +33 -0
  116. package/dist/utils/url.js.map +1 -0
  117. package/dist/vite.svg +1 -0
  118. package/package.json +55 -38
  119. package/src/MarkdownEditor.css +61 -47
  120. package/src/MarkdownEditor.tsx +76 -29
  121. package/src/MarkdownInput.tsx +9 -10
  122. package/src/context/SharedHistoryContext.tsx +8 -16
  123. package/src/main.tsx +3 -3
  124. package/src/nodes/EditorNodes.ts +10 -10
  125. package/src/nodes/callout/Callout.css +94 -0
  126. package/src/nodes/callout/CalloutComponent.tsx +61 -0
  127. package/src/nodes/callout/CalloutNode.ts +197 -0
  128. package/src/nodes/callout/CalloutTransformer.ts +87 -0
  129. package/src/nodes/callout/calloutPlugin.ts +37 -0
  130. package/src/nodes/callout/index.ts +5 -0
  131. package/src/nodes/schedule/ScheduleItem.css +140 -0
  132. package/src/nodes/schedule/ScheduleItemComponent.tsx +195 -0
  133. package/src/nodes/schedule/ScheduleItemNode.ts +135 -0
  134. package/src/nodes/schedule/ScheduleTransformer.ts +80 -0
  135. package/src/nodes/schedule/index.ts +4 -0
  136. package/src/nodes/schedule/schedulePlugin.ts +33 -0
  137. package/src/plugins/AutoLinkPlugin.tsx +5 -10
  138. package/src/plugins/FloatingLinkEditorPlugin.tsx +42 -66
  139. package/src/plugins/HistoryPlugin.tsx +20 -30
  140. package/src/plugins/LinkPlugin.tsx +2 -3
  141. package/src/plugins/ToolbarPlugin.tsx +129 -141
  142. package/src/themes/EditorTheme.css +9 -5
  143. package/src/themes/EditorTheme.ts +89 -90
  144. package/src/types.ts +27 -0
  145. package/src/ui/ContentEditable.tsx +5 -5
  146. package/src/ui/DropDown.tsx +23 -41
  147. package/src/ui/Placeholder.tsx +21 -21
  148. package/src/utils/environment.ts +6 -12
  149. package/src/utils/getSelectedNode.ts +3 -5
  150. package/src/utils/setFloatingElemPosition.ts +2 -5
  151. package/src/utils/setFloatingElemPositionForLinkEditor.ts +1 -1
  152. package/src/utils/url.ts +4 -10
  153. package/tsconfig.json +8 -0
  154. package/CHANGELOG.md +0 -65
  155. package/README.md +0 -126
  156. package/RELEASE.md +0 -102
  157. package/eslint.config.js +0 -4
  158. package/src/App.css +0 -35
  159. package/src/App.tsx +0 -42
  160. package/src/index.tsx +0 -13
  161. package/tsconfig.node.json +0 -11
  162. package/vite.config.site.ts +0 -19
  163. package/vite.config.ts +0 -33
  164. /package/{src → dist}/vite-env.d.ts +0 -0
@@ -6,112 +6,111 @@
6
6
  *
7
7
  */
8
8
 
9
- import "./EditorTheme.css";
9
+ import './EditorTheme.css';
10
10
 
11
- import type { EditorThemeClasses } from "lexical";
11
+ import type { EditorThemeClasses } from 'lexical';
12
12
 
13
13
  const theme: EditorThemeClasses = {
14
- blockCursor: "EditorTheme__blockCursor",
15
- characterLimit: "EditorTheme__characterLimit",
16
- code: "EditorTheme__code",
14
+ blockCursor: 'EditorTheme__blockCursor',
15
+ characterLimit: 'EditorTheme__characterLimit',
16
+ code: 'EditorTheme__code',
17
17
  codeHighlight: {
18
- atrule: "EditorTheme__tokenAttr",
19
- attr: "EditorTheme__tokenAttr",
20
- boolean: "EditorTheme__tokenProperty",
21
- builtin: "EditorTheme__tokenSelector",
22
- cdata: "EditorTheme__tokenComment",
23
- char: "EditorTheme__tokenSelector",
24
- class: "EditorTheme__tokenFunction",
25
- "class-name": "EditorTheme__tokenFunction",
26
- comment: "EditorTheme__tokenComment",
27
- constant: "EditorTheme__tokenProperty",
28
- deleted: "EditorTheme__tokenProperty",
29
- doctype: "EditorTheme__tokenComment",
30
- entity: "EditorTheme__tokenOperator",
31
- function: "EditorTheme__tokenFunction",
32
- important: "EditorTheme__tokenVariable",
33
- inserted: "EditorTheme__tokenSelector",
34
- keyword: "EditorTheme__tokenAttr",
35
- namespace: "EditorTheme__tokenVariable",
36
- number: "EditorTheme__tokenProperty",
37
- operator: "EditorTheme__tokenOperator",
38
- prolog: "EditorTheme__tokenComment",
39
- property: "EditorTheme__tokenProperty",
40
- punctuation: "EditorTheme__tokenPunctuation",
41
- regex: "EditorTheme__tokenVariable",
42
- selector: "EditorTheme__tokenSelector",
43
- string: "EditorTheme__tokenSelector",
44
- symbol: "EditorTheme__tokenProperty",
45
- tag: "EditorTheme__tokenProperty",
46
- url: "EditorTheme__tokenOperator",
47
- variable: "EditorTheme__tokenVariable",
18
+ atrule: 'EditorTheme__tokenAttr',
19
+ attr: 'EditorTheme__tokenAttr',
20
+ boolean: 'EditorTheme__tokenProperty',
21
+ builtin: 'EditorTheme__tokenSelector',
22
+ cdata: 'EditorTheme__tokenComment',
23
+ char: 'EditorTheme__tokenSelector',
24
+ class: 'EditorTheme__tokenFunction',
25
+ 'class-name': 'EditorTheme__tokenFunction',
26
+ comment: 'EditorTheme__tokenComment',
27
+ constant: 'EditorTheme__tokenProperty',
28
+ deleted: 'EditorTheme__tokenProperty',
29
+ doctype: 'EditorTheme__tokenComment',
30
+ entity: 'EditorTheme__tokenOperator',
31
+ function: 'EditorTheme__tokenFunction',
32
+ important: 'EditorTheme__tokenVariable',
33
+ inserted: 'EditorTheme__tokenSelector',
34
+ keyword: 'EditorTheme__tokenAttr',
35
+ namespace: 'EditorTheme__tokenVariable',
36
+ number: 'EditorTheme__tokenProperty',
37
+ operator: 'EditorTheme__tokenOperator',
38
+ prolog: 'EditorTheme__tokenComment',
39
+ property: 'EditorTheme__tokenProperty',
40
+ punctuation: 'EditorTheme__tokenPunctuation',
41
+ regex: 'EditorTheme__tokenVariable',
42
+ selector: 'EditorTheme__tokenSelector',
43
+ string: 'EditorTheme__tokenSelector',
44
+ symbol: 'EditorTheme__tokenProperty',
45
+ tag: 'EditorTheme__tokenProperty',
46
+ url: 'EditorTheme__tokenOperator',
47
+ variable: 'EditorTheme__tokenVariable',
48
48
  },
49
49
  embedBlock: {
50
- base: "EditorTheme__embedBlock",
51
- focus: "EditorTheme__embedBlockFocus",
50
+ base: 'EditorTheme__embedBlock',
51
+ focus: 'EditorTheme__embedBlockFocus',
52
52
  },
53
- hashtag: "EditorTheme__hashtag",
53
+ hashtag: 'EditorTheme__hashtag',
54
54
  heading: {
55
- h1: "EditorTheme__h1",
56
- h2: "EditorTheme__h2",
57
- h3: "EditorTheme__h3",
58
- h4: "EditorTheme__h4",
59
- h5: "EditorTheme__h5",
60
- h6: "EditorTheme__h6",
55
+ h1: 'EditorTheme__h1',
56
+ h2: 'EditorTheme__h2',
57
+ h3: 'EditorTheme__h3',
58
+ h4: 'EditorTheme__h4',
59
+ h5: 'EditorTheme__h5',
60
+ h6: 'EditorTheme__h6',
61
61
  },
62
- image: "editor-image",
63
- indent: "EditorTheme__indent",
64
- inlineImage: "inline-editor-image",
65
- layoutContainer: "EditorTheme__layoutContaner",
66
- layoutItem: "EditorTheme__layoutItem",
67
- link: "EditorTheme__link",
62
+ image: 'editor-image',
63
+ indent: 'EditorTheme__indent',
64
+ inlineImage: 'inline-editor-image',
65
+ layoutContainer: 'EditorTheme__layoutContaner',
66
+ layoutItem: 'EditorTheme__layoutItem',
67
+ link: 'EditorTheme__link',
68
68
  list: {
69
- listitem: "EditorTheme__listItem",
70
- listitemChecked: "EditorTheme__listItemChecked",
71
- listitemUnchecked: "EditorTheme__listItemUnchecked",
69
+ listitem: 'EditorTheme__listItem',
70
+ listitemChecked: 'EditorTheme__listItemChecked',
71
+ listitemUnchecked: 'EditorTheme__listItemUnchecked',
72
72
  nested: {
73
- listitem: "EditorTheme__nestedListItem",
73
+ listitem: 'EditorTheme__nestedListItem',
74
74
  },
75
75
  olDepth: [
76
- "EditorTheme__ol1",
77
- "EditorTheme__ol2",
78
- "EditorTheme__ol3",
79
- "EditorTheme__ol4",
80
- "EditorTheme__ol5",
76
+ 'EditorTheme__ol1',
77
+ 'EditorTheme__ol2',
78
+ 'EditorTheme__ol3',
79
+ 'EditorTheme__ol4',
80
+ 'EditorTheme__ol5',
81
81
  ],
82
- ul: "EditorTheme__ul",
82
+ ul: 'EditorTheme__ul',
83
83
  },
84
- ltr: "EditorTheme__ltr",
85
- mark: "EditorTheme__mark",
86
- markOverlap: "EditorTheme__markOverlap",
87
- paragraph: "EditorTheme__paragraph",
88
- quote: "EditorTheme__quote",
89
- rtl: "EditorTheme__rtl",
90
- table: "EditorTheme__table",
91
- tableAddColumns: "EditorTheme__tableAddColumns",
92
- tableAddRows: "EditorTheme__tableAddRows",
93
- tableCell: "EditorTheme__tableCell",
94
- tableCellActionButton: "EditorTheme__tableCellActionButton",
95
- tableCellActionButtonContainer:
96
- "EditorTheme__tableCellActionButtonContainer",
97
- tableCellEditing: "EditorTheme__tableCellEditing",
98
- tableCellHeader: "EditorTheme__tableCellHeader",
99
- tableCellPrimarySelected: "EditorTheme__tableCellPrimarySelected",
100
- tableCellResizer: "EditorTheme__tableCellResizer",
101
- tableCellSelected: "EditorTheme__tableCellSelected",
102
- tableCellSortedIndicator: "EditorTheme__tableCellSortedIndicator",
103
- tableResizeRuler: "EditorTheme__tableCellResizeRuler",
104
- tableSelected: "EditorTheme__tableSelected",
105
- tableSelection: "EditorTheme__tableSelection",
84
+ ltr: 'EditorTheme__ltr',
85
+ mark: 'EditorTheme__mark',
86
+ markOverlap: 'EditorTheme__markOverlap',
87
+ paragraph: 'EditorTheme__paragraph',
88
+ quote: 'EditorTheme__quote',
89
+ rtl: 'EditorTheme__rtl',
90
+ table: 'EditorTheme__table',
91
+ tableAddColumns: 'EditorTheme__tableAddColumns',
92
+ tableAddRows: 'EditorTheme__tableAddRows',
93
+ tableCell: 'EditorTheme__tableCell',
94
+ tableCellActionButton: 'EditorTheme__tableCellActionButton',
95
+ tableCellActionButtonContainer: 'EditorTheme__tableCellActionButtonContainer',
96
+ tableCellEditing: 'EditorTheme__tableCellEditing',
97
+ tableCellHeader: 'EditorTheme__tableCellHeader',
98
+ tableCellPrimarySelected: 'EditorTheme__tableCellPrimarySelected',
99
+ tableCellResizer: 'EditorTheme__tableCellResizer',
100
+ tableCellSelected: 'EditorTheme__tableCellSelected',
101
+ tableCellSortedIndicator: 'EditorTheme__tableCellSortedIndicator',
102
+ tableResizeRuler: 'EditorTheme__tableCellResizeRuler',
103
+ tableSelected: 'EditorTheme__tableSelected',
104
+ tableSelection: 'EditorTheme__tableSelection',
106
105
  text: {
107
- bold: "EditorTheme__textBold",
108
- code: "EditorTheme__textCode",
109
- italic: "EditorTheme__textItalic",
110
- strikethrough: "EditorTheme__textStrikethrough",
111
- subscript: "EditorTheme__textSubscript",
112
- superscript: "EditorTheme__textSuperscript",
113
- underline: "EditorTheme__textUnderline",
114
- underlineStrikethrough: "EditorTheme__textUnderlineStrikethrough",
106
+ bold: 'EditorTheme__textBold',
107
+ code: 'EditorTheme__textCode',
108
+ italic: 'EditorTheme__textItalic',
109
+ strikethrough: 'EditorTheme__textStrikethrough',
110
+ subscript: 'EditorTheme__textSubscript',
111
+ superscript: 'EditorTheme__textSuperscript',
112
+ underline: 'EditorTheme__textUnderline',
113
+ underlineStrikethrough: 'EditorTheme__textUnderlineStrikethrough',
115
114
  },
116
115
  };
117
116
 
package/src/types.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { Transformer } from '@lexical/markdown';
2
+ import type { Klass, LexicalNode } from 'lexical';
3
+ import type { ComponentType } from 'react';
4
+
5
+ export interface ScriboToolbarButton {
6
+ /** Unique key */
7
+ key: string;
8
+ /** Tooltip / aria-label */
9
+ label: string;
10
+ /** CSS class for the icon */
11
+ iconClass?: string;
12
+ /** Called when the button is clicked */
13
+ onSelect: (editor: import('lexical').LexicalEditor) => void;
14
+ }
15
+
16
+ export interface ScriboPlugin {
17
+ /** Unique name for the plugin */
18
+ name: string;
19
+ /** Lexical nodes to register */
20
+ nodes?: Klass<LexicalNode>[];
21
+ /** Markdown transformers (placed before built-in transformers) */
22
+ transformers?: Transformer[];
23
+ /** Buttons to add to the toolbar */
24
+ toolbarButtons?: ScriboToolbarButton[];
25
+ /** React components to render inside the LexicalComposer (must accept no props) */
26
+ editorPlugins?: ComponentType<object>[];
27
+ }
@@ -6,16 +6,16 @@
6
6
  *
7
7
  */
8
8
  import type { JSX } from 'react';
9
- import "./ContentEditable.css";
9
+ import './ContentEditable.css';
10
10
 
11
- import { ContentEditable } from "@lexical/react/LexicalContentEditable";
11
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
12
12
 
13
13
  export default function LexicalContentEditable({
14
14
  className,
15
15
  id,
16
- }: {
16
+ }: Readonly<{
17
17
  className?: string;
18
18
  id?: string;
19
- }): JSX.Element {
20
- return <ContentEditable className={className || "ContentEditable__root"} id={id} />;
19
+ }>): JSX.Element {
20
+ return <ContentEditable className={className || 'ContentEditable__root'} id={id} />;
21
21
  }
@@ -6,19 +6,11 @@
6
6
  *
7
7
  */
8
8
 
9
- import type {JSX} from 'react';
10
-
11
- import {isDOMNode} from 'lexical';
9
+ import { isDOMNode } from 'lexical';
10
+ import type { JSX } from 'react';
12
11
  import * as React from 'react';
13
- import {
14
- ReactNode,
15
- useCallback,
16
- useEffect,
17
- useMemo,
18
- useRef,
19
- useState,
20
- } from 'react';
21
- import {createPortal} from 'react-dom';
12
+ import { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
+ import { createPortal } from 'react-dom';
22
14
 
23
15
  type DropDownContextType = {
24
16
  registerItem: (ref: React.RefObject<HTMLButtonElement>) => void;
@@ -47,21 +39,16 @@ export function DropDownItem({
47
39
  throw new Error('DropDownItem must be used within a DropDown');
48
40
  }
49
41
 
50
- const {registerItem} = dropDownContext;
42
+ const { registerItem } = dropDownContext;
51
43
 
52
44
  useEffect(() => {
53
- if (ref && ref.current) {
45
+ if (ref?.current) {
54
46
  registerItem(ref as React.RefObject<HTMLButtonElement>);
55
47
  }
56
48
  }, [ref, registerItem]);
57
49
 
58
50
  return (
59
- <button
60
- className={className}
61
- onClick={onClick}
62
- ref={ref}
63
- title={title}
64
- type="button">
51
+ <button className={className} onClick={onClick} ref={ref} title={title} type="button">
65
52
  {children}
66
53
  </button>
67
54
  );
@@ -71,20 +58,19 @@ function DropDownItems({
71
58
  children,
72
59
  dropDownRef,
73
60
  onClose,
74
- }: {
61
+ }: Readonly<{
75
62
  children: React.ReactNode;
76
63
  dropDownRef: React.Ref<HTMLDivElement>;
77
64
  onClose: () => void;
78
- }) {
65
+ }>) {
79
66
  const [items, setItems] = useState<React.RefObject<HTMLButtonElement>[]>();
80
- const [highlightedItem, setHighlightedItem] =
81
- useState<React.RefObject<HTMLButtonElement>>();
67
+ const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>();
82
68
 
83
69
  const registerItem = useCallback(
84
70
  (itemRef: React.RefObject<HTMLButtonElement>) => {
85
71
  setItems((prev) => (prev ? [...prev, itemRef] : [itemRef]));
86
72
  },
87
- [setItems],
73
+ [setItems]
88
74
  );
89
75
 
90
76
  const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
@@ -122,7 +108,7 @@ function DropDownItems({
122
108
  () => ({
123
109
  registerItem,
124
110
  }),
125
- [registerItem],
111
+ [registerItem]
126
112
  );
127
113
 
128
114
  useEffect(() => {
@@ -130,7 +116,7 @@ function DropDownItems({
130
116
  setHighlightedItem(items[0]);
131
117
  }
132
118
 
133
- if (highlightedItem && highlightedItem.current) {
119
+ if (highlightedItem?.current) {
134
120
  highlightedItem.current.focus();
135
121
  }
136
122
  }, [items, highlightedItem]);
@@ -167,7 +153,7 @@ export default function DropDown({
167
153
 
168
154
  const handleClose = () => {
169
155
  setShowDropDown(false);
170
- if (buttonRef && buttonRef.current) {
156
+ if (buttonRef?.current) {
171
157
  buttonRef.current.focus();
172
158
  }
173
159
  };
@@ -177,12 +163,9 @@ export default function DropDown({
177
163
  const dropDown = dropDownRef.current;
178
164
 
179
165
  if (showDropDown && button !== null && dropDown !== null) {
180
- const {top, left} = button.getBoundingClientRect();
166
+ const { top, left } = button.getBoundingClientRect();
181
167
  dropDown.style.top = `${top + button.offsetHeight + dropDownPadding}px`;
182
- dropDown.style.left = `${Math.min(
183
- left,
184
- window.innerWidth - dropDown.offsetWidth - 20,
185
- )}px`;
168
+ dropDown.style.left = `${Math.min(left, window.innerWidth - dropDown.offsetWidth - 20)}px`;
186
169
  }
187
170
  }, [dropDownRef, buttonRef, showDropDown]);
188
171
 
@@ -196,7 +179,7 @@ export default function DropDown({
196
179
  return;
197
180
  }
198
181
  if (stopCloseOnClickSelf) {
199
- if (dropDownRef.current && dropDownRef.current.contains(target)) {
182
+ if (dropDownRef.current?.contains(target)) {
200
183
  return;
201
184
  }
202
185
  }
@@ -218,7 +201,7 @@ export default function DropDown({
218
201
  const button = buttonRef.current;
219
202
  const dropDown = dropDownRef.current;
220
203
  if (button !== null && dropDown !== null) {
221
- const {top} = button.getBoundingClientRect();
204
+ const { top } = button.getBoundingClientRect();
222
205
  const newPosition = top + button.offsetHeight + dropDownPadding;
223
206
  if (newPosition !== dropDown.getBoundingClientRect().top) {
224
207
  dropDown.style.top = `${newPosition}px`;
@@ -242,11 +225,10 @@ export default function DropDown({
242
225
  aria-label={buttonAriaLabel || buttonLabel}
243
226
  className={buttonClassName}
244
227
  onClick={() => setShowDropDown(!showDropDown)}
245
- ref={buttonRef}>
228
+ ref={buttonRef}
229
+ >
246
230
  {buttonIconClassName && <span className={buttonIconClassName} />}
247
- {buttonLabel && (
248
- <span className="text dropdown-button-text">{buttonLabel}</span>
249
- )}
231
+ {buttonLabel && <span className="text dropdown-button-text">{buttonLabel}</span>}
250
232
  <i className="chevron-down" />
251
233
  </button>
252
234
 
@@ -255,8 +237,8 @@ export default function DropDown({
255
237
  <DropDownItems dropDownRef={dropDownRef} onClose={handleClose}>
256
238
  {children}
257
239
  </DropDownItems>,
258
- document.body,
240
+ document.body
259
241
  )}
260
242
  </>
261
243
  );
262
- }
244
+ }
@@ -1,21 +1,21 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import type {JSX} from 'react';
9
- import "./Placeholder.css";
10
-
11
- import { ReactNode } from "react";
12
-
13
- export default function Placeholder({
14
- children,
15
- className,
16
- }: {
17
- children: ReactNode;
18
- className?: string;
19
- }): JSX.Element {
20
- return <div className={className || "Placeholder__root"}>{children}</div>;
21
- }
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { JSX } from 'react';
9
+ import './Placeholder.css';
10
+
11
+ import type { ReactNode } from 'react';
12
+
13
+ export default function Placeholder({
14
+ children,
15
+ className,
16
+ }: Readonly<{
17
+ children: ReactNode;
18
+ className?: string;
19
+ }>): JSX.Element {
20
+ return <div className={className || 'Placeholder__root'}>{children}</div>;
21
+ }
@@ -7,9 +7,7 @@
7
7
  */
8
8
 
9
9
  export const CAN_USE_DOM: boolean =
10
- typeof window !== "undefined" &&
11
- typeof window.document !== "undefined" &&
12
- typeof window.document.createElement !== "undefined";
10
+ typeof window !== 'undefined' && typeof window.document?.createElement !== 'undefined';
13
11
 
14
12
  declare global {
15
13
  interface Document {
@@ -21,8 +19,7 @@ declare global {
21
19
  }
22
20
  }
23
21
 
24
- const documentMode =
25
- CAN_USE_DOM && "documentMode" in document ? document.documentMode : null;
22
+ const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null;
26
23
 
27
24
  //TODO forcing false on this to stop mismatch render between ssr and clientside
28
25
  export const IS_APPLE = false;
@@ -32,22 +29,19 @@ export const IS_FIREFOX: boolean =
32
29
  CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
33
30
 
34
31
  export const CAN_USE_BEFORE_INPUT: boolean =
35
- CAN_USE_DOM && "InputEvent" in window && !documentMode
36
- ? "getTargetRanges" in new window.InputEvent("input")
32
+ CAN_USE_DOM && 'InputEvent' in window && !documentMode
33
+ ? 'getTargetRanges' in new window.InputEvent('input')
37
34
  : false;
38
35
 
39
36
  export const IS_SAFARI: boolean =
40
37
  CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
41
38
 
42
39
  export const IS_IOS: boolean =
43
- CAN_USE_DOM &&
44
- /iPad|iPhone|iPod/.test(navigator.userAgent) &&
45
- !window.MSStream;
40
+ CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
46
41
 
47
42
  // Keep these in case we need to use them in the future.
48
43
  // export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
49
- export const IS_CHROME: boolean =
50
- CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
44
+ export const IS_CHROME: boolean = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
51
45
  // export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode;
52
46
 
53
47
  export const IS_APPLE_WEBKIT =
@@ -6,12 +6,10 @@
6
6
  *
7
7
  * source: https://github.com/facebook/lexical/blob/main/packages/lexical-playground/src/utils/getSelectedNode.ts
8
8
  */
9
- import { $isAtNodeEnd } from "@lexical/selection";
10
- import { ElementNode, RangeSelection, TextNode } from "lexical";
9
+ import { $isAtNodeEnd } from '@lexical/selection';
10
+ import type { ElementNode, RangeSelection, TextNode } from 'lexical';
11
11
 
12
- export function getSelectedNode(
13
- selection: RangeSelection,
14
- ): TextNode | ElementNode {
12
+ export function getSelectedNode(selection: RangeSelection): TextNode | ElementNode {
15
13
  const anchor = selection.anchor;
16
14
  const focus = selection.focus;
17
15
  const anchorNode = selection.anchor.getNode();
@@ -14,7 +14,7 @@ export function setFloatingElemPosition(
14
14
  anchorElem: HTMLElement,
15
15
  isLink: boolean = false,
16
16
  verticalGap: number = VERTICAL_GAP,
17
- horizontalOffset: number = HORIZONTAL_OFFSET,
17
+ horizontalOffset: number = HORIZONTAL_OFFSET
18
18
  ): void {
19
19
  const scrollerElem = anchorElem.parentElement;
20
20
 
@@ -33,10 +33,7 @@ export function setFloatingElemPosition(
33
33
 
34
34
  if (top < editorScrollerRect.top) {
35
35
  // adjusted height for link element if the element is at top
36
- top +=
37
- floatingElemRect.height +
38
- targetRect.height +
39
- verticalGap * (isLink ? 9 : 2);
36
+ top += floatingElemRect.height + targetRect.height + verticalGap * (isLink ? 9 : 2);
40
37
  }
41
38
 
42
39
  if (left + floatingElemRect.width > editorScrollerRect.right) {
@@ -13,7 +13,7 @@ export function setFloatingElemPositionForLinkEditor(
13
13
  floatingElem: HTMLElement,
14
14
  anchorElem: HTMLElement,
15
15
  verticalGap: number = VERTICAL_GAP,
16
- horizontalOffset: number = HORIZONTAL_OFFSET,
16
+ horizontalOffset: number = HORIZONTAL_OFFSET
17
17
  ): void {
18
18
  const scrollerElem = anchorElem.parentElement;
19
19
 
package/src/utils/url.ts CHANGED
@@ -7,20 +7,14 @@
7
7
  * Source: https://github.com/facebook/lexical/blob/main/packages/lexical-playground/src/utils/url.ts
8
8
  */
9
9
 
10
- const SUPPORTED_URL_PROTOCOLS = new Set([
11
- "http:",
12
- "https:",
13
- "mailto:",
14
- "sms:",
15
- "tel:",
16
- ]);
10
+ const SUPPORTED_URL_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'sms:', 'tel:']);
17
11
 
18
12
  export function sanitizeUrl(url: string): string {
19
13
  try {
20
14
  const parsedUrl = new URL(url);
21
15
  // eslint-disable-next-line no-script-url
22
16
  if (!SUPPORTED_URL_PROTOCOLS.has(parsedUrl.protocol)) {
23
- return "about:blank";
17
+ return 'about:blank';
24
18
  }
25
19
  } catch {
26
20
  return url;
@@ -30,10 +24,10 @@ export function sanitizeUrl(url: string): string {
30
24
 
31
25
  // Source: https://stackoverflow.com/a/8234912/2013580
32
26
  const urlRegExp = new RegExp(
33
- /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/,
27
+ /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-]*)?\??(?:[-+=&;%@.\w]*)#?(?:\w*))?)/
34
28
  );
35
29
  export function validateUrl(url: string): boolean {
36
30
  // TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.
37
31
  // Maybe show a dialog where they user can type the URL before inserting it.
38
- return url === "https://" || urlRegExp.test(url);
32
+ return url === 'https://' || urlRegExp.test(url);
39
33
  }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "@eventuras/typescript-config/react-library.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src"
5
+ },
6
+ "include": ["src"],
7
+ "exclude": ["node_modules", "dist"]
8
+ }
package/CHANGELOG.md DELETED
@@ -1,65 +0,0 @@
1
- # @eventuras/scribo
2
-
3
- ## 0.8.3
4
-
5
- ### Patch Changes
6
-
7
- - 4a6097f: Enhanced dark mode support across UI components.
8
-
9
- ## 0.8.2
10
-
11
- ### Patch Changes
12
-
13
- - chore: update deps
14
-
15
- ## 0.8.1
16
-
17
- ### Patch Changes
18
-
19
- - chore: update dependencies across frontend packages
20
-
21
- ## 0.8.0
22
-
23
- ### Minor Changes
24
-
25
- ### 🧱 Features
26
-
27
- - feat(scribo): auto heigh expanding (6ca2322) [@eventuras/scribo]
28
-
29
- ### 🐞 Bug Fixes
30
-
31
- - fix(scribo): import MarkdownEditor.css for styling (d1eec7a) [@eventuras/scribo]
32
- - fix(scribo): disable swc in scribo (ebce6db) [@eventuras/scribo]
33
-
34
- ### ♻️ Refactoring
35
-
36
- - refactor(scribo): merge markdowninput into scribo with flexible styling (373587e) [@eventuras/scribo]
37
-
38
- ### 🧹 Maintenance
39
-
40
- - chore(scribo): externalize Lexical packages in build configuration (7c7caaf) [@eventuras/scribo]
41
- - chore(convertoapi,docsite,web,markdown,scribo,sdk): upgrade deps (b2de638) [@eventuras/scribo]
42
-
43
- ### ⚙️ CI/CD
44
-
45
- - ci(scribo): implement automated release workflow for Scribo (36d6ba1) [@eventuras/scribo]
46
-
47
- ## 0.7.1
48
-
49
- ### Patch Changes
50
-
51
- - - chore(convertoapi,docsite,web,markdown,scribo,sdk): upgrade deps (51e931b) [@eventuras/scribo]
52
-
53
- ## 0.7.0
54
-
55
- ### Minor Changes
56
-
57
- - ## Initial history (pre-Changesets)
58
- - chore(scribo): upgrade lexical (f78dfa1)
59
- - chore(scribo): update packages (3475e0f)
60
- - feat(scribo): use readme as default content of editor page (428fc2b)
61
- - fix(scribo): add dependency (101954b)
62
- - feat(scribo): cache npm files for scribo build (a065b61)
63
- - feat(scribo): add undo/redo to markdown editor (b2482cc)
64
- - feat(scribo): adds links and link editing to editor (afe159d)
65
- - feat(scribo): set up scribo demo site (a467bc2)