@box/threaded-annotations 4.10.2 → 4.10.4

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.
@@ -1 +1 @@
1
- import{THREADED_ANNOTATIONS_PORTAL}from"../esm/lib/v2/constants.js";import{BUBBLE_MENU_PLUGIN_KEY,formattingBarDismissedPluginKey}from"../esm/lib/components/v2/message-editor/editor-extensions/dismiss-bar-on-escape.js";import messages from"../esm/lib/components/v2/message-editor/messages.js";import{Toolbar}from"@box/blueprint-web";import{memo,useCallback}from"react";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{Bold,BulletList,Italic,NumberList,Underline}from"@box/blueprint-web-assets/icons/Medium";import{useEditorState}from"@tiptap/react";import{BubbleMenu}from"@tiptap/react/menus";import '../styles/message-editor-bubble-menu.css';var message_editor_bubble_menu_module_default={bubbleMenu:`_bubbleMenu_lm6yy_1`},shouldShowBubbleMenu=({editor,state,from,to})=>{let{doc,selection}=state,{empty}=selection;return!editor.isEditable||empty||formattingBarDismissedPluginKey.getState(state)?.dismissed||!(doc.textBetween(from,to).length>0)?!1:editor.isFocused},BUBBLE_MENU_OPTIONS={placement:`top`},toggleCommands={bold:editor=>editor.chain().focus().toggleBold().run(),bulletList:editor=>editor.chain().focus().toggleBulletList().run(),italic:editor=>editor.chain().focus().toggleItalic().run(),orderedList:editor=>editor.chain().focus().toggleOrderedList().run(),underline:editor=>editor.chain().focus().toggleUnderline().run()},MARK_ITEMS=[{format:`bold`,icon:Bold,message:messages.formatBold},{format:`italic`,icon:Italic,message:messages.formatItalic},{format:`underline`,icon:Underline,message:messages.formatUnderline}],LIST_ITEMS=[{format:`bulletList`,icon:BulletList,message:messages.formatBulletList},{format:`orderedList`,icon:NumberList,message:messages.formatNumberedList}],MessageEditorBubbleMenuComponent=({editor,menuAnchorRef,onFormatToggle})=>{let intl=useIntl(),activeFormats=useEditorState({editor,selector:({editor:editorInstance})=>({bold:editorInstance.isActive(`bold`),bulletList:editorInstance.isActive(`bulletList`),italic:editorInstance.isActive(`italic`),orderedList:editorInstance.isActive(`orderedList`),underline:editorInstance.isActive(`underline`)})}),appendToAnchor=useCallback(()=>menuAnchorRef.current??document.body,[menuAnchorRef]),handleToggle=useCallback(format=>{toggleCommands[format](editor),onFormatToggle?.(format,editor.isActive(format))},[editor,onFormatToggle]),handleToolbarKeyDown=useCallback(event=>{event.key===`Escape`&&(event.preventDefault(),event.stopPropagation(),editor.chain().focus().dismissFormattingBar().run())},[editor]),renderToggleItem=({format,icon,message})=>jsx(Toolbar.ToggleItem,{"aria-label":intl.formatMessage(message),icon,onClick:()=>handleToggle(format),onMouseDown:event=>{event.preventDefault()},value:format},format);return jsx(BubbleMenu,{appendTo:appendToAnchor,className:message_editor_bubble_menu_module_default.bubbleMenu,editor,options:BUBBLE_MENU_OPTIONS,pluginKey:BUBBLE_MENU_PLUGIN_KEY,shouldShow:shouldShowBubbleMenu,updateDelay:0,...THREADED_ANNOTATIONS_PORTAL,children:jsxs(Toolbar.Root,{onKeyDown:handleToolbarKeyDown,children:[jsx(Toolbar.ToggleGroup,{type:`multiple`,value:MARK_ITEMS.filter(({format})=>activeFormats[format]).map(({format})=>format),children:MARK_ITEMS.map(renderToggleItem)}),jsx(Toolbar.Separator,{}),jsx(Toolbar.ToggleGroup,{type:`multiple`,value:LIST_ITEMS.filter(({format})=>activeFormats[format]).map(({format})=>format),children:LIST_ITEMS.map(renderToggleItem)})]})})},MessageEditorBubbleMenu=memo(({editor,menuAnchorRef,onFormatToggle})=>editor?jsx(MessageEditorBubbleMenuComponent,{editor,menuAnchorRef,onFormatToggle}):null);MessageEditorBubbleMenu.displayName=`MessageEditorBubbleMenu`;export{MessageEditorBubbleMenu as t};
1
+ import{THREADED_ANNOTATIONS_PORTAL}from"../esm/lib/v2/constants.js";import{BUBBLE_MENU_PLUGIN_KEY,formattingBarDismissedPluginKey}from"../esm/lib/components/v2/message-editor/editor-extensions/dismiss-bar-on-escape.js";import messages from"../esm/lib/components/v2/message-editor/messages.js";import{Toolbar}from"@box/blueprint-web";import{memo,useCallback}from"react";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{Bold,BulletList,Italic,NumberList,Underline}from"@box/blueprint-web-assets/icons/Medium";import{useEditorState}from"@tiptap/react";import{posToDOMRect}from"@tiptap/core";import{AllSelection,Selection}from"@tiptap/pm/state";import{BubbleMenu}from"@tiptap/react/menus";import '../styles/message-editor-bubble-menu.css';var message_editor_bubble_menu_module_default={bubbleMenu:`_bubbleMenu_lm6yy_1`},shouldShowBubbleMenu=({editor,state,from,to})=>{let{doc,selection}=state,{empty}=selection;return!editor.isEditable||empty||formattingBarDismissedPluginKey.getState(state)?.dismissed||!(doc.textBetween(from,to).length>0)?!1:editor.isFocused},BUBBLE_MENU_OPTIONS={placement:`top`},getSelectionReferenceElement=editor=>{let{doc,selection}=editor.state;if(!(selection instanceof AllSelection))return null;let{from}=Selection.near(doc.resolve(selection.from),1),{to}=Selection.near(doc.resolve(selection.to),-1),rect=posToDOMRect(editor.view,from,to);return{getBoundingClientRect:()=>rect,getClientRects:()=>[rect]}},toggleCommands={bold:editor=>editor.chain().focus().toggleBold().run(),bulletList:editor=>editor.chain().focus().toggleBulletList().run(),italic:editor=>editor.chain().focus().toggleItalic().run(),orderedList:editor=>editor.chain().focus().toggleOrderedList().run(),underline:editor=>editor.chain().focus().toggleUnderline().run()},MARK_ITEMS=[{format:`bold`,icon:Bold,message:messages.formatBold},{format:`italic`,icon:Italic,message:messages.formatItalic},{format:`underline`,icon:Underline,message:messages.formatUnderline}],LIST_ITEMS=[{format:`bulletList`,icon:BulletList,message:messages.formatBulletList},{format:`orderedList`,icon:NumberList,message:messages.formatNumberedList}],MessageEditorBubbleMenuComponent=({editor,menuAnchorRef,onFormatToggle})=>{let intl=useIntl(),activeFormats=useEditorState({editor,selector:({editor:editorInstance})=>({bold:editorInstance.isActive(`bold`),bulletList:editorInstance.isActive(`bulletList`),italic:editorInstance.isActive(`italic`),orderedList:editorInstance.isActive(`orderedList`),underline:editorInstance.isActive(`underline`)})}),appendToAnchor=useCallback(()=>menuAnchorRef.current??document.body,[menuAnchorRef]),getReferencedVirtualElement=useCallback(()=>getSelectionReferenceElement(editor),[editor]),handleToggle=useCallback(format=>{toggleCommands[format](editor),onFormatToggle?.(format,editor.isActive(format))},[editor,onFormatToggle]),handleToolbarKeyDown=useCallback(event=>{event.key===`Escape`&&(event.preventDefault(),event.stopPropagation(),editor.chain().focus().dismissFormattingBar().run())},[editor]),renderToggleItem=({format,icon,message})=>jsx(Toolbar.ToggleItem,{"aria-label":intl.formatMessage(message),icon,onClick:()=>handleToggle(format),onMouseDown:event=>{event.preventDefault()},value:format},format);return jsx(BubbleMenu,{appendTo:appendToAnchor,className:message_editor_bubble_menu_module_default.bubbleMenu,editor,getReferencedVirtualElement,options:BUBBLE_MENU_OPTIONS,pluginKey:BUBBLE_MENU_PLUGIN_KEY,shouldShow:shouldShowBubbleMenu,updateDelay:0,...THREADED_ANNOTATIONS_PORTAL,children:jsxs(Toolbar.Root,{onKeyDown:handleToolbarKeyDown,children:[jsx(Toolbar.ToggleGroup,{type:`multiple`,value:MARK_ITEMS.filter(({format})=>activeFormats[format]).map(({format})=>format),children:MARK_ITEMS.map(renderToggleItem)}),jsx(Toolbar.Separator,{}),jsx(Toolbar.ToggleGroup,{type:`multiple`,value:LIST_ITEMS.filter(({format})=>activeFormats[format]).map(({format})=>format),children:LIST_ITEMS.map(renderToggleItem)})]})})},MessageEditorBubbleMenu=memo(({editor,menuAnchorRef,onFormatToggle})=>editor?jsx(MessageEditorBubbleMenuComponent,{editor,menuAnchorRef,onFormatToggle}):null);MessageEditorBubbleMenu.displayName=`MessageEditorBubbleMenu`;export{MessageEditorBubbleMenu as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/threaded-annotations",
3
- "version": "4.10.2",
3
+ "version": "4.10.4",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "dependencies": {
6
6
  "@floating-ui/dom": "^1.6.0",
@@ -21,23 +21,23 @@
21
21
  "uuid": "^9.0.1"
22
22
  },
23
23
  "peerDependencies": {
24
- "@box/blueprint-web": "^17.7.0",
25
- "@box/blueprint-web-assets": "^5.9.11",
26
- "@box/collaboration-popover": "^2.2.42",
27
- "@box/readable-time": "^2.2.42",
28
- "@box/user-selector": "^3.0.21",
24
+ "@box/blueprint-web": "^17.7.2",
25
+ "@box/blueprint-web-assets": "^5.10.0",
26
+ "@box/collaboration-popover": "^2.2.44",
27
+ "@box/readable-time": "^2.2.44",
28
+ "@box/user-selector": "^3.0.23",
29
29
  "clsx": "^1.2.1",
30
30
  "react": "^18.0.0",
31
31
  "react-dom": "^18.0.0",
32
32
  "react-intl": "^6.4.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@box/blueprint-web": "^17.7.0",
36
- "@box/blueprint-web-assets": "^5.9.11",
37
- "@box/eslint-plugin-blueprint": "2.2.13",
38
- "@box/readable-time": "^2.2.42",
39
- "@box/storybook-utils": "^1.2.42",
40
- "@box/user-selector": "^3.0.21",
35
+ "@box/blueprint-web": "^17.7.2",
36
+ "@box/blueprint-web-assets": "^5.10.0",
37
+ "@box/eslint-plugin-blueprint": "2.2.14",
38
+ "@box/readable-time": "^2.2.44",
39
+ "@box/storybook-utils": "^1.2.44",
40
+ "@box/user-selector": "^3.0.23",
41
41
  "react": "^18.0.0",
42
42
  "react-dom": "^18.0.0"
43
43
  },