@blocklet/editor 2.4.21 → 2.4.22

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.
@@ -33,7 +33,6 @@ import CollapsiblePlugin from './plugins/CollapsiblePlugin';
33
33
  import ComponentPickerPlugin from './plugins/ComponentPickerPlugin';
34
34
  import DragDropPaste from './plugins/DragDropPastePlugin';
35
35
  import DraggableBlockPlugin from './plugins/DraggableBlockPlugin';
36
- import EmojiPickerPlugin from './plugins/EmojiPickerPlugin';
37
36
  import ExcalidrawPlugin from './plugins/ExcalidrawPlugin';
38
37
  import FigmaPlugin from './plugins/FigmaPlugin';
39
38
  import FloatingLinkEditorPlugin from './plugins/FloatingLinkEditorPlugin';
@@ -108,5 +107,5 @@ export default function Editor({ children, prepend, placeholder, onChange, autoF
108
107
  if (minimalMode) {
109
108
  return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), _jsx(PasteSlackImagePlugin, {}), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('code') && _jsx(CodeCopyPlugin, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && hasNodes('link') && (_jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem })), !!characterLimitConfig?.maxLength && (_jsx(CharacterLimitPlugin, { maxLength: characterLimitConfig.maxLength, charLimitIndicatorStyle: characterLimitConfig.indicatorStyle, alignLeft: characterLimitConfig.alignLeft })), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), children] }));
110
109
  }
111
- return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), !!characterLimitConfig?.maxLength && (_jsx(CharacterLimitPlugin, { maxLength: characterLimitConfig.maxLength, charLimitIndicatorStyle: characterLimitConfig.indicatorStyle, alignLeft: characterLimitConfig.alignLeft })), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(EmojiPickerPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('hashtag') && _jsx(HashtagPlugin, {}), hasNodes('autolink') && !!editable && _jsx(AutoLinkPlugin, {}), isRichText ? (_jsxs(_Fragment, { children: [_jsx(PasteSlackImagePlugin, {}), _jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('code') && _jsx(CodeCopyPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('table', 'tablerow', 'tablecell') && editable && (_jsx(TablePlugin, { hasCellMerge: true, hasCellBackgroundColor: true, hasHorizontalScroll: true })), hasNodes('table', 'tablerow', 'tablecell') && _jsx(TableCellResizer, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(BilibiliPlugin, {}), _jsx(BlockletEmbedPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), _jsx(AidePlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), hasNodes('collapsible-container', 'collapsible-content', 'collapsible-title') && _jsx(CollapsiblePlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), hasNodes('table') && _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {})] })) : (_jsxs(_Fragment, { children: [_jsx(PlainTextPlugin, { contentEditable: _jsx(ContentEditable, {}), placeholder: _jsx(Placeholder, { children: "placeholder" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, { externalHistoryState: historyState })] })), _jsx("div", { children: showTableOfContents && _jsx(TableOfContentsPlugin, {}) }), _jsx(MarkdownHeadTextPlugin, {}), _jsx(EditorHolderPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), children] }));
110
+ return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), !!characterLimitConfig?.maxLength && (_jsx(CharacterLimitPlugin, { maxLength: characterLimitConfig.maxLength, charLimitIndicatorStyle: characterLimitConfig.indicatorStyle, alignLeft: characterLimitConfig.alignLeft })), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('hashtag') && _jsx(HashtagPlugin, {}), hasNodes('autolink') && !!editable && _jsx(AutoLinkPlugin, {}), isRichText ? (_jsxs(_Fragment, { children: [_jsx(PasteSlackImagePlugin, {}), _jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(StyledEditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('code') && _jsx(CodeCopyPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('table', 'tablerow', 'tablecell') && editable && (_jsx(TablePlugin, { hasCellMerge: true, hasCellBackgroundColor: true, hasHorizontalScroll: true })), hasNodes('table', 'tablerow', 'tablecell') && _jsx(TableCellResizer, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(BilibiliPlugin, {}), _jsx(BlockletEmbedPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), _jsx(AidePlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), hasNodes('collapsible-container', 'collapsible-content', 'collapsible-title') && _jsx(CollapsiblePlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), hasNodes('table') && _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {})] })) : (_jsxs(_Fragment, { children: [_jsx(PlainTextPlugin, { contentEditable: _jsx(ContentEditable, {}), placeholder: _jsx(Placeholder, { children: "placeholder" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, { externalHistoryState: historyState })] })), _jsx("div", { children: showTableOfContents && _jsx(TableOfContentsPlugin, {}) }), _jsx(MarkdownHeadTextPlugin, {}), _jsx(EditorHolderPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), children] }));
112
111
  }
@@ -928,96 +928,6 @@ button.action-button:disabled {
928
928
  margin: 0 4px;
929
929
  }
930
930
 
931
- .sticky-note-container {
932
- position: absolute;
933
- z-index: 9;
934
- width: 120px;
935
- display: inline-block;
936
- }
937
-
938
- .sticky-note {
939
- line-height: 1;
940
- text-align: left;
941
- width: 120px;
942
- margin: 25px;
943
- padding: 20px 10px;
944
- position: relative;
945
- border: 1px solid #e8e8e8;
946
- font-family: 'Reenie Beanie';
947
- font-size: 24px;
948
- border-bottom-right-radius: 60px 5px;
949
- display: block;
950
- cursor: move;
951
- }
952
-
953
- .sticky-note:after {
954
- content: '';
955
- position: absolute;
956
- z-index: -1;
957
- right: -0px;
958
- bottom: 20px;
959
- width: 120px;
960
- height: 25px;
961
- background: rgba(0, 0, 0, 0.2);
962
- box-shadow: 2px 15px 5px rgba(0, 0, 0, 0.4);
963
- transform: matrix(-1, -0.1, 0, 1, 0, 0);
964
- }
965
-
966
- .sticky-note.yellow {
967
- border-top: 1px solid #fdfd86;
968
- background: linear-gradient(135deg, #ffff88 81%, #ffff88 82%, #ffff88 82%, #ffffc6 100%);
969
- }
970
-
971
- .sticky-note.pink {
972
- border-top: 1px solid #e7d1e4;
973
- background: linear-gradient(135deg, #f7cbe8 81%, #f7cbe8 82%, #f7cbe8 82%, #e7bfe1 100%);
974
- }
975
-
976
- .sticky-note-container.dragging {
977
- transition: none !important;
978
- }
979
-
980
- .sticky-note div {
981
- cursor: text;
982
- }
983
-
984
- .sticky-note .delete {
985
- border: 0;
986
- background: none;
987
- position: absolute;
988
- top: 8px;
989
- right: 10px;
990
- font-size: 10px;
991
- cursor: pointer;
992
- opacity: 0.5;
993
- }
994
-
995
- .sticky-note .delete:hover {
996
- font-weight: bold;
997
- opacity: 1;
998
- }
999
-
1000
- .sticky-note .color {
1001
- border: 0;
1002
- background: none;
1003
- position: absolute;
1004
- top: 8px;
1005
- right: 25px;
1006
- cursor: pointer;
1007
- opacity: 0.5;
1008
- }
1009
-
1010
- .sticky-note .color:hover {
1011
- opacity: 1;
1012
- }
1013
-
1014
- .sticky-note .color i {
1015
- display: block;
1016
- width: 12px;
1017
- height: 12px;
1018
- background-size: contain;
1019
- }
1020
-
1021
931
  .excalidraw-button {
1022
932
  border: 0;
1023
933
  padding: 0;
@@ -25,7 +25,6 @@ import { ImageNode } from './ImageNode';
25
25
  import { MermaidNode } from './MermaidNode';
26
26
  import { KeywordNode } from './KeywordNode';
27
27
  import { MentionNode } from './MentionNode';
28
- import { StickyNode } from './StickyNode';
29
28
  import { TweetNode } from './TweetNode';
30
29
  import { YouTubeNode } from './YouTubeNode';
31
30
  import { BilibiliNode } from '../../ext/BilibiliPlugin/BilibiliNode';
@@ -54,7 +53,6 @@ const PlaygroundNodes = [
54
53
  AutoLinkNode,
55
54
  LinkNode,
56
55
  OverflowNode,
57
- StickyNode,
58
56
  ImageNode,
59
57
  VideoNode,
60
58
  MentionNode,
@@ -16,7 +16,6 @@ import { IS_APPLE } from '../../../shared/environment';
16
16
  import useHasNodes from '../../hooks/useHasNodes';
17
17
  import useModal from '../../hooks/useModal';
18
18
  // import catTypingGif from "../../images/cat-typing.gif";
19
- // import { $createStickyNode } from "../../nodes/StickyNode";
20
19
  import ColorPicker from '../../ui/ColorPicker';
21
20
  import DropDown, { DropDownItem } from '../../ui/DropDown';
22
21
  import { getSelectedNode } from '../../utils/getSelectedNode';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/editor",
3
- "version": "2.4.21",
3
+ "version": "2.4.22",
4
4
  "main": "lib/index.js",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -69,7 +69,7 @@
69
69
  "ufo": "^1.5.4",
70
70
  "url-join": "^4.0.1",
71
71
  "zustand": "^4.5.5",
72
- "@blocklet/pdf": "^2.4.21"
72
+ "@blocklet/pdf": "^2.4.22"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@babel/core": "^7.25.2",
@@ -1,17 +0,0 @@
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 { LexicalEditor, NodeKey } from 'lexical';
9
- import { type JSX } from 'react';
10
- import './StickyNode.css';
11
- export default function StickyComponent({ x, y, nodeKey, color, caption, }: {
12
- caption: LexicalEditor;
13
- color: 'pink' | 'yellow';
14
- nodeKey: NodeKey;
15
- x: number;
16
- y: number;
17
- }): JSX.Element;
@@ -1,158 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- */
9
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
10
- import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
11
- import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
12
- import { LexicalNestedComposer } from '@lexical/react/LexicalNestedComposer';
13
- import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
14
- import { $getNodeByKey } from 'lexical';
15
- import { useEffect, useRef } from 'react';
16
- import useLayoutEffect from '../../shared/useLayoutEffect';
17
- import { useSharedHistoryContext } from '../context/SharedHistoryContext';
18
- import defaultTheme from '../themes/defaultTheme';
19
- import ContentEditable from '../ui/ContentEditable';
20
- import Placeholder from '../ui/Placeholder';
21
- import { $isStickyNode } from './StickyNode';
22
- import './StickyNode.css';
23
- function positionSticky(stickyElem, positioning) {
24
- const { style } = stickyElem;
25
- const { rootElementRect } = positioning;
26
- const rectLeft = rootElementRect !== null ? rootElementRect.left : 0;
27
- const rectTop = rootElementRect !== null ? rootElementRect.top : 0;
28
- style.top = `${rectTop + positioning.y}px`;
29
- style.left = `${rectLeft + positioning.x}px`;
30
- }
31
- export default function StickyComponent({ x, y, nodeKey, color, caption, }) {
32
- const [editor] = useLexicalComposerContext();
33
- const stickyContainerRef = useRef(null);
34
- const positioningRef = useRef({
35
- isDragging: false,
36
- offsetX: 0,
37
- offsetY: 0,
38
- rootElementRect: null,
39
- x: 0,
40
- y: 0,
41
- });
42
- useEffect(() => {
43
- const position = positioningRef.current;
44
- position.x = x;
45
- position.y = y;
46
- const stickyContainer = stickyContainerRef.current;
47
- if (stickyContainer !== null) {
48
- positionSticky(stickyContainer, position);
49
- }
50
- }, [x, y]);
51
- useLayoutEffect(() => {
52
- const position = positioningRef.current;
53
- const resizeObserver = new ResizeObserver((entries) => {
54
- for (let i = 0; i < entries.length; i++) {
55
- const entry = entries[i];
56
- const { target } = entry;
57
- position.rootElementRect = target.getBoundingClientRect();
58
- const stickyContainer = stickyContainerRef.current;
59
- if (stickyContainer !== null) {
60
- positionSticky(stickyContainer, position);
61
- }
62
- }
63
- });
64
- const removeRootListener = editor.registerRootListener((nextRootElem, prevRootElem) => {
65
- if (prevRootElem !== null) {
66
- resizeObserver.unobserve(prevRootElem);
67
- }
68
- if (nextRootElem !== null) {
69
- resizeObserver.observe(nextRootElem);
70
- }
71
- });
72
- const handleWindowResize = () => {
73
- const rootElement = editor.getRootElement();
74
- const stickyContainer = stickyContainerRef.current;
75
- if (rootElement !== null && stickyContainer !== null) {
76
- position.rootElementRect = rootElement.getBoundingClientRect();
77
- positionSticky(stickyContainer, position);
78
- }
79
- };
80
- window.addEventListener('resize', handleWindowResize);
81
- return () => {
82
- window.removeEventListener('resize', handleWindowResize);
83
- removeRootListener();
84
- };
85
- }, [editor]);
86
- useEffect(() => {
87
- const stickyContainer = stickyContainerRef.current;
88
- if (stickyContainer !== null) {
89
- // Delay adding transition so we don't trigger the
90
- // transition on load of the sticky.
91
- setTimeout(() => {
92
- stickyContainer.style.setProperty('transition', 'top 0.3s ease 0s, left 0.3s ease 0s');
93
- }, 500);
94
- }
95
- }, []);
96
- const handlePointerMove = (event) => {
97
- const stickyContainer = stickyContainerRef.current;
98
- const positioning = positioningRef.current;
99
- const { rootElementRect } = positioning;
100
- if (stickyContainer !== null && positioning.isDragging && rootElementRect !== null) {
101
- positioning.x = event.pageX - positioning.offsetX - rootElementRect.left;
102
- positioning.y = event.pageY - positioning.offsetY - rootElementRect.top;
103
- positionSticky(stickyContainer, positioning);
104
- }
105
- };
106
- const handlePointerUp = (event) => {
107
- const stickyContainer = stickyContainerRef.current;
108
- const positioning = positioningRef.current;
109
- if (stickyContainer !== null) {
110
- positioning.isDragging = false;
111
- stickyContainer.classList.remove('dragging');
112
- editor.update(() => {
113
- const node = $getNodeByKey(nodeKey);
114
- if ($isStickyNode(node)) {
115
- node.setPosition(positioning.x, positioning.y);
116
- }
117
- });
118
- }
119
- document.removeEventListener('pointermove', handlePointerMove);
120
- document.removeEventListener('pointerup', handlePointerUp);
121
- };
122
- const handleDelete = () => {
123
- editor.update(() => {
124
- const node = $getNodeByKey(nodeKey);
125
- if ($isStickyNode(node)) {
126
- node.remove();
127
- }
128
- });
129
- };
130
- const handleColorChange = () => {
131
- editor.update(() => {
132
- const node = $getNodeByKey(nodeKey);
133
- if ($isStickyNode(node)) {
134
- node.toggleColor();
135
- }
136
- });
137
- };
138
- const { historyState } = useSharedHistoryContext();
139
- return (_jsx("div", { ref: stickyContainerRef, className: "sticky-note-container", children: _jsxs("div", { className: `sticky-note ${color}`, onPointerDown: (event) => {
140
- const stickyContainer = stickyContainerRef.current;
141
- if (stickyContainer == null || event.button === 2 || event.target !== stickyContainer.firstChild) {
142
- // Right click or click on editor should not work
143
- return;
144
- }
145
- const stickContainer = stickyContainer;
146
- const positioning = positioningRef.current;
147
- if (stickContainer !== null) {
148
- const { top, left } = stickContainer.getBoundingClientRect();
149
- positioning.offsetX = event.clientX - left;
150
- positioning.offsetY = event.clientY - top;
151
- positioning.isDragging = true;
152
- stickContainer.classList.add('dragging');
153
- document.addEventListener('pointermove', handlePointerMove);
154
- document.addEventListener('pointerup', handlePointerUp);
155
- event.preventDefault();
156
- }
157
- }, children: [_jsx("button", { onClick: handleDelete, className: "delete", "aria-label": "Delete sticky note", title: "Delete", children: "X" }), _jsx("button", { onClick: handleColorChange, className: "color", "aria-label": "Change sticky note color", title: "Color", children: _jsx("i", { className: "bucket" }) }), _jsxs(LexicalNestedComposer, { initialEditor: caption, initialTheme: defaultTheme, children: [_jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(PlainTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "StickyNode__contentEditable" }), placeholder: _jsx(Placeholder, { className: "StickyNode__placeholder", children: "What's up?" }), ErrorBoundary: LexicalErrorBoundary })] })] }) }));
158
- }
@@ -1,38 +0,0 @@
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
- */
9
- .StickyNode__contentEditable {
10
- min-height: 20px;
11
- border: 0;
12
- resize: none;
13
- cursor: text;
14
- font-size: 24px;
15
- caret-color: rgb(5, 5, 5);
16
- display: block;
17
- position: relative;
18
- tab-size: 1;
19
- outline: 0;
20
- padding: 10px;
21
- user-select: text;
22
- white-space: pre-wrap;
23
- word-wrap: break-word;
24
- }
25
- .StickyNode__placeholder {
26
- font-size: 24px;
27
- color: #999;
28
- overflow: hidden;
29
- position: absolute;
30
- text-overflow: ellipsis;
31
- top: 30px;
32
- left: 20px;
33
- width: 120px;
34
- user-select: none;
35
- white-space: nowrap;
36
- display: inline-block;
37
- pointer-events: none;
38
- }
@@ -1,39 +0,0 @@
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 { EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
9
- import { DecoratorNode } from 'lexical';
10
- import { type JSX } from 'react';
11
- type StickyNoteColor = 'pink' | 'yellow';
12
- export type SerializedStickyNode = Spread<{
13
- xOffset: number;
14
- yOffset: number;
15
- color: StickyNoteColor;
16
- caption: LexicalEditor;
17
- type: 'sticky';
18
- version: 1;
19
- }, SerializedLexicalNode>;
20
- export declare class StickyNode extends DecoratorNode<JSX.Element> {
21
- __x: number;
22
- __y: number;
23
- __color: StickyNoteColor;
24
- __caption: LexicalEditor;
25
- static getType(): string;
26
- static clone(node: StickyNode): StickyNode;
27
- static importJSON(serializedNode: SerializedStickyNode): StickyNode;
28
- constructor(x: number, y: number, color: 'pink' | 'yellow', caption?: LexicalEditor, key?: NodeKey);
29
- exportJSON(): SerializedStickyNode;
30
- createDOM(config: EditorConfig): HTMLElement;
31
- updateDOM(): false;
32
- setPosition(x: number, y: number): void;
33
- toggleColor(): void;
34
- decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element;
35
- isIsolated(): true;
36
- }
37
- export declare function $isStickyNode(node: LexicalNode | null | undefined): node is StickyNode;
38
- export declare function $createStickyNode(xOffset: number, yOffset: number): StickyNode;
39
- export {};
@@ -1,70 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { $setSelection, createEditor, DecoratorNode } from 'lexical';
3
- import { lazyRetry as lazy } from '@arcblock/ux/lib/Util';
4
- import { Suspense } from 'react';
5
- import { createPortal } from 'react-dom';
6
- const StickyComponent = lazy(
7
- // @ts-ignore
8
- () => import('./StickyComponent'));
9
- export class StickyNode extends DecoratorNode {
10
- __x;
11
- __y;
12
- __color;
13
- __caption;
14
- static getType() {
15
- return 'sticky';
16
- }
17
- static clone(node) {
18
- return new StickyNode(node.__x, node.__y, node.__color, node.__caption, node.__key);
19
- }
20
- static importJSON(serializedNode) {
21
- return new StickyNode(serializedNode.xOffset, serializedNode.yOffset, serializedNode.color, serializedNode.caption);
22
- }
23
- constructor(x, y, color, caption, key) {
24
- super(key);
25
- this.__x = x;
26
- this.__y = y;
27
- this.__caption = caption || createEditor();
28
- this.__color = color;
29
- }
30
- exportJSON() {
31
- return {
32
- caption: this.__caption,
33
- color: this.__color,
34
- type: 'sticky',
35
- version: 1,
36
- xOffset: this.__x,
37
- yOffset: this.__y,
38
- };
39
- }
40
- createDOM(config) {
41
- const div = document.createElement('div');
42
- div.style.display = 'contents';
43
- return div;
44
- }
45
- updateDOM() {
46
- return false;
47
- }
48
- setPosition(x, y) {
49
- const writable = this.getWritable();
50
- writable.__x = x;
51
- writable.__y = y;
52
- $setSelection(null);
53
- }
54
- toggleColor() {
55
- const writable = this.getWritable();
56
- writable.__color = writable.__color === 'pink' ? 'yellow' : 'pink';
57
- }
58
- decorate(editor, config) {
59
- return createPortal(_jsx(Suspense, { fallback: null, children: _jsx(StickyComponent, { color: this.__color, x: this.__x, y: this.__y, nodeKey: this.getKey(), caption: this.__caption }) }), document.body);
60
- }
61
- isIsolated() {
62
- return true;
63
- }
64
- }
65
- export function $isStickyNode(node) {
66
- return node instanceof StickyNode;
67
- }
68
- export function $createStickyNode(xOffset, yOffset) {
69
- return new StickyNode(xOffset, yOffset, 'yellow');
70
- }
@@ -1,27 +0,0 @@
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
- declare const _default: ({
9
- description: string;
10
- emoji: string;
11
- category: string;
12
- aliases: string[];
13
- tags: string[];
14
- unicode_version: string;
15
- ios_version: string;
16
- skin_tones?: undefined;
17
- } | {
18
- emoji: string;
19
- description: string;
20
- category: string;
21
- aliases: string[];
22
- tags: string[];
23
- unicode_version: string;
24
- ios_version: string;
25
- skin_tones: boolean;
26
- })[];
27
- export default _default;