@scottjgilbert/lexical-blog-editor 1.0.0-beta.2 → 1.0.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.
package/README.md CHANGED
@@ -193,7 +193,7 @@ import { Viewer } from "@scottjgilbert/lexical-blog-editor/viewer";
193
193
  - FloatingTextFormatToolbarPlugin
194
194
  - HashtagPlugin
195
195
  - HistoryPlugin
196
- - HorizontalRule**Extension**
196
+ - HorizontalRulePlugin
197
197
  - ImagesPlugin
198
198
  - KeywordsPlugin
199
199
  - LayoutPlugin
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AA+DA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,OAAO,KAAkB,MAAM,OAAO,CAAC;AAKvC,OAAO,aAAa,CAAC;AAcrB,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,GAAI,4BAG7B;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC,4CAwIA,CAAC;AAEF;;;;GAIG;AAEH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA8BxC,CAAC"}
1
+ {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../src/Editor.tsx"],"names":[],"mappings":"AA+DA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAM3C,OAAO,KAAkB,MAAM,OAAO,CAAC;AAKvC,OAAO,aAAa,CAAC;AAcrB,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,GAAI,4BAG7B;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC,4CAyIA,CAAC;AAEF;;;;GAIG;AAEH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA8BxC,CAAC"}
package/build/Editor.js CHANGED
@@ -7,7 +7,6 @@ import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
7
7
  import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
8
8
  import { ClickableLinkPlugin } from "@lexical/react/LexicalClickableLinkPlugin";
9
9
  import { HashtagPlugin } from "@lexical/react/LexicalHashtagPlugin";
10
- // import { HorizontalRulePlugin } from "@lexical/react/LexicalHorizontalRulePlugin";
11
10
  import { ListPlugin } from "@lexical/react/LexicalListPlugin";
12
11
  import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
13
12
  import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin";
@@ -33,6 +32,7 @@ import EquationsPlugin from "./plugins/EquationsPlugin";
33
32
  import FigmaPlugin from "./plugins/FigmaPlugin";
34
33
  import FloatingLinkEditorPlugin from "./plugins/FloatingLinkEditorPlugin";
35
34
  import FloatingTextFormatToolbarPlugin from "./plugins/FloatingTextFormatToolbarPlugin";
35
+ import HorizontalRulePlugin from "./plugins/HorizontalRulePlugin";
36
36
  import ImagesPlugin from "./plugins/ImagesPlugin";
37
37
  import KeywordsPlugin from "./plugins/KeywordsPlugin";
38
38
  import { LayoutPlugin } from "./plugins/LayoutPlugin/LayoutPlugin";
@@ -60,7 +60,7 @@ import PlaygroundNodes from "./nodes/PlaygroundNodes/PlaygroundNodes";
60
60
  import { buildHTMLConfig } from "./buildHTMLConfig";
61
61
  import "./index.css";
62
62
  import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
63
- import { HorizontalRuleExtension } from "@lexical/extension";
63
+ // import { HorizontalRuleExtension } from "@lexical/extension";
64
64
  function $prepopulatedRichText() {
65
65
  const root = $getRoot();
66
66
  const heading = $createHeadingNode("h1");
@@ -106,7 +106,7 @@ export const EditorComponent = ({ placeholder = "Enter some text...", onChange,
106
106
  window.removeEventListener("resize", updateViewPortWidth);
107
107
  };
108
108
  }, [isSmallWidthViewport]);
109
- return (_jsxs(_Fragment, { children: [_jsx(ToolbarPlugin, { editor: editor, activeEditor: activeEditor, setActiveEditor: setActiveEditor, setIsLinkEditMode: setIsLinkEditMode }), _jsx(ShortcutsPlugin, { editor: activeEditor, setIsLinkEditMode: setIsLinkEditMode }), _jsxs("div", { className: `editor-container`, children: [_jsx(DragDropPaste, {}), _jsx(AutoFocusPlugin, {}), _jsx(ClearEditorPlugin, {}), _jsx(ComponentPickerPlugin, {}), _jsx(EmojiPickerPlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(EmojisPlugin, {}), _jsx(HashtagPlugin, {}), _jsx(KeywordsPlugin, {}), _jsx(SpeechToTextPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(DateTimePlugin, {}), _jsx(HistoryPlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx("div", { className: "editor-scroller", children: _jsx("div", { className: "editor", ref: onRef, children: _jsx(ContentEditable, { placeholder: placeholder }) }) }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: onChange }), _jsx(MarkdownShortcutPlugin, {}), _jsx(CodeHighlightShikiPlugin, {}), _jsx(ListPlugin, { hasStrictIndent: true }), _jsx(CheckListPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizer, {}), _jsx(TableScrollShadowPlugin, {}), _jsx(ImagesPlugin, {}), _jsx(LinkPlugin, { hasLinkAttributes: true }), _jsx(TwitterPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(FigmaPlugin, {}), _jsx(ClickableLinkPlugin, { disabled: isEditable }), _jsx(EquationsPlugin, {}), _jsx(TabFocusPlugin, {}), _jsx(TabIndentationPlugin, { maxIndent: 7 }), _jsx(CollapsiblePlugin, {}), _jsx(LayoutPlugin, {}), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem, isLinkEditMode: isLinkEditMode, setIsLinkEditMode: setIsLinkEditMode }), _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true })] })), floatingAnchorElem && !isSmallWidthViewport && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), _jsx(TableHoverActionsV2Plugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode })] })), _jsx(ActionsPlugin, { shouldPreserveNewLinesInMarkdown: true, useCollabV2: false })] }), " "] }));
109
+ return (_jsxs(_Fragment, { children: [_jsx(ToolbarPlugin, { editor: editor, activeEditor: activeEditor, setActiveEditor: setActiveEditor, setIsLinkEditMode: setIsLinkEditMode }), _jsx(ShortcutsPlugin, { editor: activeEditor, setIsLinkEditMode: setIsLinkEditMode }), _jsxs("div", { className: `editor-container`, children: [_jsx(DragDropPaste, {}), _jsx(AutoFocusPlugin, {}), _jsx(ClearEditorPlugin, {}), _jsx(ComponentPickerPlugin, {}), _jsx(EmojiPickerPlugin, {}), _jsx(AutoEmbedPlugin, {}), _jsx(EmojisPlugin, {}), _jsx(HashtagPlugin, {}), _jsx(HorizontalRulePlugin, {}), _jsx(KeywordsPlugin, {}), _jsx(SpeechToTextPlugin, {}), _jsx(AutoLinkPlugin, {}), _jsx(DateTimePlugin, {}), _jsx(HistoryPlugin, {}), _jsx(RichTextPlugin, { contentEditable: _jsx("div", { className: "editor-scroller", children: _jsx("div", { className: "editor", ref: onRef, children: _jsx(ContentEditable, { placeholder: placeholder }) }) }), ErrorBoundary: LexicalErrorBoundary }), _jsx(OnChangePlugin, { onChange: onChange }), _jsx(MarkdownShortcutPlugin, {}), _jsx(CodeHighlightShikiPlugin, {}), _jsx(ListPlugin, { hasStrictIndent: true }), _jsx(CheckListPlugin, {}), _jsx(TablePlugin, {}), _jsx(TableCellResizer, {}), _jsx(TableScrollShadowPlugin, {}), _jsx(ImagesPlugin, {}), _jsx(LinkPlugin, { hasLinkAttributes: true }), _jsx(TwitterPlugin, {}), _jsx(YouTubePlugin, {}), _jsx(FigmaPlugin, {}), _jsx(ClickableLinkPlugin, { disabled: isEditable }), _jsx(EquationsPlugin, {}), _jsx(TabFocusPlugin, {}), _jsx(TabIndentationPlugin, { maxIndent: 7 }), _jsx(CollapsiblePlugin, {}), _jsx(LayoutPlugin, {}), floatingAnchorElem && (_jsxs(_Fragment, { children: [_jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem, isLinkEditMode: isLinkEditMode, setIsLinkEditMode: setIsLinkEditMode }), _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true })] })), floatingAnchorElem && !isSmallWidthViewport && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), _jsx(TableHoverActionsV2Plugin, { anchorElem: floatingAnchorElem }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem, setIsLinkEditMode: setIsLinkEditMode })] })), _jsx(ActionsPlugin, { shouldPreserveNewLinesInMarkdown: true, useCollabV2: false })] }), " "] }));
110
110
  };
111
111
  /**
112
112
  * A full Rich Text Editor component.
@@ -121,7 +121,7 @@ export const Editor = ({ placeholder = "Enter some text...", initialState, onCha
121
121
  namespace: "BlogEditor",
122
122
  nodes: PlaygroundNodes,
123
123
  theme: PlaygroundEditorTheme,
124
- dependencies: [HorizontalRuleExtension],
124
+ // dependencies: [HorizontalRuleExtension],
125
125
  }), [initialState]);
126
126
  return (_jsx("div", { className: "editor-shell", children: _jsx(LexicalExtensionComposer, { extension: app, contentEditable: null, children: _jsx(TableContext, { children: _jsx(ToolbarContext, { children: _jsx(EditorComponent, { placeholder: placeholder, onChange: onChange }) }) }) }) }));
127
127
  };
@@ -0,0 +1,2 @@
1
+ export default function HorizontalRulePlugin(): null;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/HorizontalRulePlugin/index.tsx"],"names":[],"mappings":"AAgBA,MAAM,CAAC,OAAO,UAAU,oBAAoB,IAAI,IAAI,CA4BnD"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
+ import { $createHorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND, } from "@lexical/extension";
4
+ import { $createParagraphNode, $getSelection, $isRangeSelection, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR, } from "lexical";
5
+ import { useEffect } from "react";
6
+ export default function HorizontalRulePlugin() {
7
+ const [editor] = useLexicalComposerContext();
8
+ useEffect(() => {
9
+ return editor.registerCommand(INSERT_HORIZONTAL_RULE_COMMAND, () => {
10
+ const selection = $getSelection();
11
+ if (!$isRangeSelection(selection)) {
12
+ return false;
13
+ }
14
+ const horizontalRuleNode = $createHorizontalRuleNode();
15
+ selection.insertNodes([horizontalRuleNode]);
16
+ if ($isRootOrShadowRoot(horizontalRuleNode.getParent())) {
17
+ const paragraphNode = $createParagraphNode();
18
+ horizontalRuleNode.insertAfter(paragraphNode);
19
+ paragraphNode.select();
20
+ }
21
+ return true;
22
+ }, COMMAND_PRIORITY_EDITOR);
23
+ }, [editor]);
24
+ return null;
25
+ }
@@ -183,7 +183,7 @@
183
183
  min-width: 25px;
184
184
  }
185
185
  .PlaygroundEditorTheme__code span {
186
- white-space: nowrap;
186
+ white-space: pre;
187
187
  }
188
188
  .PlaygroundEditorTheme__tableScrollableWrapper {
189
189
  overflow-x: auto;
@@ -170,7 +170,7 @@
170
170
  white-space: pre;
171
171
  }
172
172
  .ViewerTheme__code span {
173
- white-space: nowrap;
173
+ white-space: pre;
174
174
  }
175
175
  /* Apply padding if the pre is empty OR if the last child isn't a span */
176
176
  .ViewerTheme__code:empty::after,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scottjgilbert/lexical-blog-editor",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0",
4
4
  "description": "Prebuilt components for editing and rendering rich blog content with Lexical. Modified wrapper of the Lexical Playground editor.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",