@box/threaded-annotations 4.7.3 → 4.8.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/dist/chunks/text-message.module.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/components/v2/text-message/subcomponents/message-renderer.js +1 -1
- package/dist/esm/lib/components/v2/text-message/subcomponents/truncate-document.js +1 -1
- package/dist/esm/lib/v2/types/document-node-types.js +0 -1
- package/dist/esm/lib/v2/types/index.js +1 -1
- package/dist/esm/lib/v2/utils/document-node-guards.js +1 -0
- package/dist/styles/text-message2.css +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/lib/v2/types/document-node-types.d.ts +4 -6
- package/dist/types/lib/v2/utils/document-node-guards.d.ts +11 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import '../styles/text-message2.css';var text_message_module_default={textMessage:`
|
|
1
|
+
import '../styles/text-message2.css';var text_message_module_default={textMessage:`_textMessage_4txis_29`,contentWrapper:`_contentWrapper_4txis_38`,threadedIndicator:`_threadedIndicator_4txis_43`,threadedIndicatorHidden:`_threadedIndicatorHidden_4txis_59`,messageContent:`_messageContent_4txis_62`,inlineEditSlot:`_inlineEditSlot_4txis_69`,annotationBadgeWrapper:`_annotationBadgeWrapper_4txis_72`,messageFooter:`_messageFooter_4txis_81`,readableTimeWrapper:`_readableTimeWrapper_4txis_89`,replyButton:`_replyButton_4txis_93`,seeMoreButton:`_seeMoreButton_4txis_108`,richTextList:`_richTextList_4txis_112`};export{text_message_module_default as t};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./lib/document-node-types.js";import{MentionContextProvider,useMentionContext}from"./lib/components/mention-component/mention-context.js";import{t as ThreadedAnnotations}from"../chunks/threaded-annotations.js";import{MessageEditor}from"./lib/components/v2/message-editor/message-editor.js";import{AnnotationBadgeType}from"./lib/v2/types/annotation-badge-types.js";import{t as ThreadedAnnotations$1}from"../chunks/threaded-annotations2.js";import{serializeMentionMarkup}from"./lib/v2/utils/serialize-mention-markup.js";export{AnnotationBadgeType,MentionContextProvider,MessageEditor as MessageEditorV2,ThreadedAnnotations,ThreadedAnnotations$1 as ThreadedAnnotationsV2,serializeMentionMarkup,useMentionContext};
|
|
1
|
+
import"./lib/document-node-types.js";import{MentionContextProvider,useMentionContext}from"./lib/components/mention-component/mention-context.js";import{t as ThreadedAnnotations}from"../chunks/threaded-annotations.js";import{MessageEditor}from"./lib/components/v2/message-editor/message-editor.js";import{AnnotationBadgeType}from"./lib/v2/types/annotation-badge-types.js";import{isKnownBlockNode,isListNode}from"./lib/v2/utils/document-node-guards.js";import{t as ThreadedAnnotations$1}from"../chunks/threaded-annotations2.js";import{serializeMentionMarkup}from"./lib/v2/utils/serialize-mention-markup.js";export{AnnotationBadgeType,MentionContextProvider,MessageEditor as MessageEditorV2,ThreadedAnnotations,ThreadedAnnotations$1 as ThreadedAnnotationsV2,isKnownBlockNode,isListNode,serializeMentionMarkup,useMentionContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as MentionComponent}from"../../../../../../chunks/mention-component.js";import
|
|
1
|
+
import{t as MentionComponent}from"../../../../../../chunks/mention-component.js";import messages from"../messages.js";import{t as text_message_module_default}from"../../../../../../chunks/text-message.module.js";import{isKnownBlockNode,isListNode}from"../../../../v2/utils/document-node-guards.js";import"../constants.js";import{groupInlineNodes,segmentTextNodes}from"./text-node-segments.js";import{getDocumentLength,truncateDocument}from"./truncate-document.js";import{Link,Text,TextButton}from"@box/blueprint-web";import React,{useState}from"react";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";var renderMentionNode=({node,index,paragraphIndex})=>{let key=`mention-${node.attrs.mentionedUserId}-${paragraphIndex}-${index}`;return jsx(MentionComponent,{authorId:node.attrs.authorId,mentionedUserEmail:node.attrs.mentionedUserEmail,mentionedUserId:node.attrs.mentionedUserId,mentionedUserName:node.attrs.mentionedUserName,mentionId:node.attrs.mentionId},key)},handleMessageLinkClick=event=>{event.currentTarget.closest(`[data-thread-expandable]`)&&event.preventDefault()},applyTextMarks=(content,node)=>node.marks?.reduce((markedContent,mark)=>{switch(mark.type){case`bold`:return jsx(`strong`,{children:markedContent});case`italic`:return jsx(`em`,{children:markedContent});case`underline`:return jsx(`u`,{children:markedContent});default:return markedContent}},content)??content,renderTextNodes=({nodes,paragraphIndex,index,intl,isRichTextEnabled})=>{let key=`text-nodes-${paragraphIndex}-${index}`,segments=segmentTextNodes(nodes);return jsx(Text,{"aria-label":intl.formatMessage(messages.textMessageAriaLabel),as:`span`,color:`textOnLightDefault`,variant:`bodyDefault`,children:segments.map((segment,segmentIndex)=>segment.type===`url`?jsx(Link,{href:segment.value,inheritFont:!0,rel:`noopener noreferrer`,target:`_blank`,onClick:handleMessageLinkClick,children:segment.fragments.map((fragment,fragmentIndex)=>jsx(React.Fragment,{children:isRichTextEnabled?applyTextMarks(fragment.value,fragment.sourceNode):fragment.value},`${key}-segment-${segmentIndex}-fragment-${fragmentIndex}`))},`${key}-segment-${segmentIndex}`):segment.fragments.map((fragment,fragmentIndex)=>jsx(React.Fragment,{children:isRichTextEnabled?applyTextMarks(fragment.value,fragment.sourceNode):fragment.value},`${key}-segment-${segmentIndex}-fragment-${fragmentIndex}`)))},key)},renderParagraphContent=({content,paragraphIndex,intl,isRichTextEnabled})=>groupInlineNodes(content).map((group,groupIndex)=>group.kind===`mention`?renderMentionNode({node:group.node,index:groupIndex,paragraphIndex}):renderTextNodes({nodes:group.nodes,paragraphIndex,index:groupIndex,intl,isRichTextEnabled})),renderParagraphNode=({paragraph,index,intl,inlineSuffix,isRichTextEnabled})=>{let content=paragraph.content||[],key=`paragraph-${index}`;return jsxs(Text,{as:`p`,variant:`bodyDefault`,children:[content.length>0?renderParagraphContent({content,paragraphIndex:index,intl,isRichTextEnabled}):jsx(`br`,{}),inlineSuffix]},key)},renderListItem=({item,itemIndex,listIndex,intl,isRichTextEnabled,inlineSuffix})=>{let children=(item.content||[]).filter(isKnownBlockNode);return jsx(`li`,{children:children.map((child,childIndex)=>{let childSuffix=childIndex===children.length-1?inlineSuffix:void 0;return child.type===`paragraph`?renderParagraphNode({paragraph:child,index:childIndex,intl,isRichTextEnabled,inlineSuffix:childSuffix}):renderListNode({list:child,listIndex:childIndex,intl,isRichTextEnabled,inlineSuffix:childSuffix})})},`list-${listIndex}-item-${itemIndex}`)},renderListNode=({list,listIndex,intl,isRichTextEnabled,inlineSuffix})=>{let ListElement=list.type===`bulletList`?`ul`:`ol`,items=list.content||[],start=list.type===`orderedList`&&typeof list.attrs?.start==`number`?list.attrs.start:void 0;return jsx(ListElement,{className:text_message_module_default.richTextList,...start===void 0?{}:{start},children:items.map((item,itemIndex)=>renderListItem({item,itemIndex,listIndex,intl,isRichTextEnabled,inlineSuffix:itemIndex===items.length-1?inlineSuffix:void 0}))},`${list.type}-${listIndex}`)},flattenBlocksToParagraphs=blocks=>blocks.flatMap(block=>block.type===`paragraph`?[block]:isListNode(block)?(block.content||[]).flatMap(item=>flattenBlocksToParagraphs(item.content||[])):[]),MessageRenderer=({isRichTextEnabled=!1,messageObject})=>{let intl=useIntl(),[isExpanded,setIsExpanded]=useState(!1);if(!messageObject.content||messageObject.content.length===0)return null;let totalLength=getDocumentLength(messageObject),isTruncated=!isExpanded&&totalLength>450,documentToRender=isTruncated?truncateDocument(messageObject,450):messageObject,seeMoreButton=isTruncated?jsx(TextButton,{className:text_message_module_default.seeMoreButton,color:`textOnLightLink`,"data-no-expand":!0,onClick:()=>setIsExpanded(!0),variant:`bodyDefaultBold`,children:intl.formatMessage(messages.seeMore)}):null;if(!isRichTextEnabled){let paragraphsToRender=flattenBlocksToParagraphs(documentToRender.content);return paragraphsToRender.map((paragraph,index)=>renderParagraphNode({paragraph,index,intl,inlineSuffix:index===paragraphsToRender.length-1?seeMoreButton:null,isRichTextEnabled:!1}))}let blocksToRender=documentToRender.content.filter(isKnownBlockNode);return blocksToRender.map((block,index)=>{let inlineSuffix=index===blocksToRender.length-1?seeMoreButton:null;return block.type===`paragraph`?renderParagraphNode({paragraph:block,index,intl,inlineSuffix,isRichTextEnabled:!0}):renderListNode({list:block,listIndex:index,intl,isRichTextEnabled:!0,inlineSuffix})})};export{MessageRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isListNode}from"../../../../v2/utils/document-node-guards.js";import{groupInlineNodes,segmentTextNodes}from"./text-node-segments.js";var TRUNCATION_ELLIPSIS=`…`,getMentionDisplayLength=node=>`@${node.attrs.mentionedUserName}`.length,getInlineLength=nodes=>{let total=0;for(let node of nodes||[])node.type===`text`?total+=node.text.length:node.type===`mention`&&(total+=getMentionDisplayLength(node));return total},getListLength=list=>(list.content||[]).reduce((total,item)=>total+getListItemLength(item),0),getListItemLength=item=>(item.content||[]).reduce((total,child)=>total+getBlockLength(child),0),getBlockLength=block=>block.type===`paragraph`?getInlineLength(block.content):isListNode(block)?getListLength(block):0,getDocumentLength=document=>document.content.reduce((total,block)=>total+getBlockLength(block),0),textSegmentToAtoms=segment=>segment.type===`url`?[{kind:`url`,value:segment.value,fragments:segment.fragments}]:segment.fragments.map(fragment=>({kind:`text`,value:fragment.value,sourceNode:fragment.sourceNode})),groupToAtoms=group=>group.kind===`mention`?[{kind:`mention`,node:group.node}]:segmentTextNodes(group.nodes).flatMap(textSegmentToAtoms),flattenInlineContent=nodes=>groupInlineNodes(nodes).flatMap(groupToAtoms),collectAtomsWithinThreshold=(atoms,threshold)=>{let collected=[],remaining=threshold;for(let atom of atoms){if(remaining<=0)return{collected,truncated:!0,used:threshold-remaining};if(atom.kind===`mention`){let length=getMentionDisplayLength(atom.node);if(length>remaining)return{collected,truncated:!0,used:threshold-remaining};collected.push(atom),remaining-=length}else if(atom.kind===`url`){if(atom.value.length>remaining)return{collected,truncated:!0,used:threshold-remaining};collected.push(atom),remaining-=atom.value.length}else if(atom.value.length<=remaining)collected.push(atom),remaining-=atom.value.length;else return collected.push({...atom,value:atom.value.slice(0,remaining)}),{collected,truncated:!0,used:threshold}}return{collected,truncated:!1,used:threshold-remaining}},reassembleInlineContent=atoms=>{let nodes=[],lastTextSourceNode=null;for(let atom of atoms)if(atom.kind===`mention`)nodes.push(atom.node),lastTextSourceNode=null;else if(atom.kind===`url`)for(let fragment of atom.fragments)if(lastTextSourceNode===fragment.sourceNode){let previousTextNode=nodes[nodes.length-1];nodes[nodes.length-1]={...previousTextNode,text:previousTextNode.text+fragment.value}}else nodes.push({...fragment.sourceNode,text:fragment.value}),lastTextSourceNode=fragment.sourceNode;else if(lastTextSourceNode===atom.sourceNode){let previousTextNode=nodes[nodes.length-1];nodes[nodes.length-1]={...previousTextNode,text:previousTextNode.text+atom.value}}else nodes.push({...atom.sourceNode,text:atom.value}),lastTextSourceNode=atom.sourceNode;return nodes},truncateInlineContent=(nodes,threshold)=>{let{collected,truncated,used}=collectAtomsWithinThreshold(flattenInlineContent(nodes),threshold);return{content:reassembleInlineContent(collected),truncated,used}},truncateParagraph=(paragraph,threshold)=>{let{content,truncated,used}=truncateInlineContent(paragraph.content,threshold);return{paragraph:{...paragraph,content},truncated,used}},truncateListItem=(item,threshold)=>{if((item.content?.length??0)===0)return{item,truncated:!1,used:0};let children=[],remaining=threshold,truncated=!1;for(let child of item.content||[]){if(remaining<=0){truncated=!0;break}if(child.type===`paragraph`){let result=truncateParagraph(child,remaining);if(result.truncated&&result.used===0){truncated=!0;break}if(children.push(result.paragraph),remaining-=result.used,result.truncated){truncated=!0;break}}else if(isListNode(child)){let result=truncateList(child,remaining);if(result.list&&children.push(result.list),remaining-=result.used,result.truncated){truncated=!0;break}}}return children.length===0?{item:null,truncated,used:0}:{item:{...item,content:children},truncated,used:threshold-remaining}},truncateList=(list,threshold)=>{if((list.content?.length??0)===0)return{list,truncated:!1,used:0};let items=[],remaining=threshold,truncated=!1;for(let item of list.content||[]){if(remaining<=0){truncated=!0;break}let result=truncateListItem(item,remaining);if(result.item&&items.push(result.item),remaining-=result.used,result.truncated){truncated=!0;break}}return items.length===0?{list:null,truncated,used:0}:{list:{...list,content:items},truncated,used:threshold-remaining}},truncateBlocks=(blocks,threshold)=>{let result=[],remaining=threshold;for(let block of blocks){if(remaining<=0)return{blocks:result,truncated:!0};if(block.type===`paragraph`){let truncatedParagraph=truncateParagraph(block,remaining);if(truncatedParagraph.truncated&&truncatedParagraph.used===0||(result.push(truncatedParagraph.paragraph),remaining-=truncatedParagraph.used,truncatedParagraph.truncated))return{blocks:result,truncated:!0}}else if(isListNode(block)){let truncatedList=truncateList(block,remaining);if(truncatedList.list&&result.push(truncatedList.list),remaining-=truncatedList.used,truncatedList.truncated)return{blocks:result,truncated:!0}}}return{blocks:result,truncated:!1}},findLastLeafParagraph=blocks=>{for(let blockIndex=blocks.length-1;blockIndex>=0;--blockIndex){let block=blocks[blockIndex];if(block.type===`paragraph`){if((block.content?.length??0)>0)return{blockIndex,path:[],paragraph:block}}else if(isListNode(block)){let items=block.content||[];for(let itemIndex=items.length-1;itemIndex>=0;--itemIndex){let nested=findLastLeafParagraph(items[itemIndex].content||[]);if(nested)return{blockIndex,path:[itemIndex,nested.blockIndex,...nested.path],paragraph:nested.paragraph}}}}return null},appendEllipsisToParagraph=paragraph=>{let content=paragraph.content||[],lastChild=content[content.length-1];return lastChild?.type===`text`?lastChild.text.endsWith(TRUNCATION_ELLIPSIS)?paragraph:{...paragraph,content:[...content.slice(0,-1),{...lastChild,text:`${lastChild.text}${TRUNCATION_ELLIPSIS}`}]}:{...paragraph,content:[...content,{type:`text`,text:TRUNCATION_ELLIPSIS}]}},keepBlocksThroughParagraph=(blocks,pathToParagraph,updatedParagraph)=>{let[blockIndex,...pathWithinBlock]=pathToParagraph,keptBlocks=blocks.slice(0,blockIndex+1),lastKeptBlock=keptBlocks[blockIndex];if(lastKeptBlock.type===`paragraph`)return keptBlocks[blockIndex]=updatedParagraph,keptBlocks;let[itemIndex,...pathWithinItem]=pathWithinBlock,keptItems=(lastKeptBlock.content||[]).slice(0,itemIndex+1),lastKeptItem=keptItems[itemIndex];return keptItems[itemIndex]={...lastKeptItem,content:keepBlocksThroughParagraph(lastKeptItem.content||[],pathWithinItem,updatedParagraph)},keptBlocks[blockIndex]={...lastKeptBlock,content:keptItems},keptBlocks},withTruncationEllipsis=blocks=>{let lastLeaf=findLastLeafParagraph(blocks);return lastLeaf?keepBlocksThroughParagraph(blocks,[lastLeaf.blockIndex,...lastLeaf.path],appendEllipsisToParagraph(lastLeaf.paragraph)):[...blocks,{type:`paragraph`,content:[{type:`text`,text:TRUNCATION_ELLIPSIS}]}]},truncateDocument=(document,threshold)=>{if(document.content.length===0)return document;let{blocks,truncated}=truncateBlocks(document.content,threshold),finalBlocks=truncated?withTruncationEllipsis(blocks):blocks;return{...document,content:finalBlocks}};export{getDocumentLength,truncateDocument};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var isParagraphNode=node=>node.type===`paragraph`;export{isParagraphNode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AnnotationBadgeType}from"./annotation-badge-types.js";
|
|
1
|
+
import{AnnotationBadgeType}from"./annotation-badge-types.js";export{AnnotationBadgeType};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var isListNode=node=>node.type===`bulletList`||node.type===`orderedList`,isKnownBlockNode=node=>node.type===`paragraph`||isListNode(node);export{isKnownBlockNode,isListNode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._textMessage_4txis_29{flex-direction:column;flex:1;width:100%;height:100%;display:flex;position:relative;overflow:visible}._textMessage_4txis_29 ._contentWrapper_4txis_38{gap:var(--space-2);margin-top:.125rem;display:flex}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._threadedIndicator_4txis_43{width:var(--space-7);flex-shrink:0;position:relative}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._threadedIndicator_4txis_43:after{content:"";left:50%;top:var(--space-05);bottom:var(--space-05);width:var(--border-2);background-color:var(--border-divider-border);border-radius:var(--radius-1);position:absolute;transform:translate(-50%)}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._threadedIndicatorHidden_4txis_59:after{visibility:hidden}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._messageContent_4txis_62{overflow-wrap:break-word;flex-direction:column;flex:1;min-width:0;display:flex}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._messageContent_4txis_62 ._inlineEditSlot_4txis_69{margin-top:var(--space-2)}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._messageContent_4txis_62 ._annotationBadgeWrapper_4txis_72{min-width:0;max-width:100%;padding-bottom:var(--space-1);flex-direction:column;align-items:flex-start;display:flex;overflow:hidden}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._messageFooter_4txis_81{align-items:center;gap:var(--space-1);padding-bottom:var(--space-2);margin-top:var(--space-1);flex-direction:row;display:flex}._textMessage_4txis_29 ._contentWrapper_4txis_38 ._messageFooter_4txis_81 ._readableTimeWrapper_4txis_89{cursor:auto}._replyButton_4txis_93{padding-top:var(--space-05);padding-bottom:var(--space-05);opacity:0;transition:opacity .1s}[data-message-wrapper]:hover ._replyButton_4txis_93,[data-message-wrapper]:focus-within ._replyButton_4txis_93{opacity:1}@media (pointer:coarse),(hover:none){._replyButton_4txis_93{opacity:1}}._seeMoreButton_4txis_108{margin-inline-start:var(--bp-space-010)}._richTextList_4txis_112{margin:0;padding-inline-start:var(--bp-space-060)}._richTextList_4txis_112 li{margin:0;padding:0}._richTextList_4txis_112 li+li{margin-block-start:var(--bp-space-005)}._richTextList_4txis_112 p{margin:0}._richTextList_4txis_112 ._richTextList_4txis_112{margin-block-start:var(--bp-space-005)}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ export { MentionContextProvider, useMentionContext, type MentionContextData, typ
|
|
|
5
5
|
export { MessageEditor as MessageEditorV2, type CreateMessageEditorProps as CreateMessageEditorPropsV2, type MessageEditorProps as MessageEditorPropsV2, } from './lib/components/v2/message-editor/message-editor';
|
|
6
6
|
export { type VideoTimestampOptions as VideoTimestampOptionsV2 } from './lib/components/v2/message-editor/message-editor.types';
|
|
7
7
|
export { ThreadedAnnotations as ThreadedAnnotationsV2, type ThreadedAnnotationsProps as ThreadedAnnotationsPropsV2, } from './lib/v2/threaded-annotations';
|
|
8
|
-
export { type DocumentNode as DocumentNodeV2, type EditorMentionAttributes as EditorMentionAttributesV2, type MentionNode as MentionNodeV2, type MentionRenderAttributes as MentionRenderAttributesV2, type ParagraphNode as ParagraphNodeV2, type TextNode as TextNodeV2, } from './lib/v2/types/document-node-types';
|
|
8
|
+
export { type BlockNode as BlockNodeV2, type BulletListNode as BulletListNodeV2, type DocumentNode as DocumentNodeV2, type EditorMentionAttributes as EditorMentionAttributesV2, type InlineNode as InlineNodeV2, type ListItemNode as ListItemNodeV2, type ListNode as ListNodeV2, type MentionNode as MentionNodeV2, type MentionRenderAttributes as MentionRenderAttributesV2, type OrderedListNode as OrderedListNodeV2, type ParagraphNode as ParagraphNodeV2, type TextMark as TextMarkV2, type TextMarkType as TextMarkTypeV2, type TextNode as TextNodeV2, } from './lib/v2/types/document-node-types';
|
|
9
9
|
export { type Permissions, type TextMessageAuthorType as TextMessageAuthorTypeV2, type TextMessageType as TextMessageTypeV2, } from './lib/v2/types/message-types';
|
|
10
10
|
export { AnnotationBadgeType } from './lib/v2/types/annotation-badge-types';
|
|
11
11
|
export type { AnnotationBadgeTargetType } from './lib/v2/types/annotation-badge-types';
|
|
12
|
+
export { isKnownBlockNode, isListNode } from './lib/v2/utils/document-node-guards';
|
|
12
13
|
export { serializeMentionMarkup } from './lib/v2/utils/serialize-mention-markup';
|
|
@@ -47,13 +47,11 @@ export type DocumentNode = {
|
|
|
47
47
|
content: (BulletListNode | OrderedListNode | ParagraphNode)[];
|
|
48
48
|
attrs?: Record<string, unknown>;
|
|
49
49
|
};
|
|
50
|
+
/** A top-level document block. */
|
|
51
|
+
export type BlockNode = DocumentNode['content'][number];
|
|
52
|
+
/** Either list block type. */
|
|
53
|
+
export type ListNode = BulletListNode | OrderedListNode;
|
|
50
54
|
/** Nodes that can appear inside a paragraph. */
|
|
51
55
|
export type InlineNode = MentionNode | TextNode;
|
|
52
56
|
/** Formats toggleable from the rich text formatting bar (or their keyboard shortcuts). */
|
|
53
57
|
export type RichTextFormat = TextMarkType | 'bulletList' | 'orderedList';
|
|
54
|
-
/**
|
|
55
|
-
* Narrows a top-level document block to a paragraph. Consumers that only
|
|
56
|
-
* support paragraph blocks (renderer, truncation — dedicated list support
|
|
57
|
-
* lands separately) use this to skip list blocks.
|
|
58
|
-
*/
|
|
59
|
-
export declare const isParagraphNode: (node: DocumentNode["content"][number]) => node is ParagraphNode;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BlockNode, ListNode } from '../types';
|
|
2
|
+
/** Narrows a block to a list. */
|
|
3
|
+
export declare const isListNode: (node: BlockNode) => node is ListNode;
|
|
4
|
+
/**
|
|
5
|
+
* The block union is closed at compile time, but blocks arrive across an
|
|
6
|
+
* untyped boundary — hosts cast, and a newer editor can emit block types this
|
|
7
|
+
* version predates. Consumers drop what they don't know rather than letting
|
|
8
|
+
* "not a paragraph" imply "list", which would render an unknown block as an
|
|
9
|
+
* empty <ol> and silently lose its text.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isKnownBlockNode: (node: BlockNode) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/threaded-annotations",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@floating-ui/dom": "^1.6.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@box/blueprint-web-assets": "^5.7.8",
|
|
26
26
|
"@box/collaboration-popover": "^2.2.17",
|
|
27
27
|
"@box/readable-time": "^2.2.17",
|
|
28
|
-
"@box/user-selector": "^2.2.
|
|
28
|
+
"@box/user-selector": "^2.2.18",
|
|
29
29
|
"clsx": "^1.2.1",
|
|
30
30
|
"react": "^18.0.0",
|
|
31
31
|
"react-dom": "^18.0.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@box/eslint-plugin-blueprint": "2.2.4",
|
|
38
38
|
"@box/readable-time": "^2.2.17",
|
|
39
39
|
"@box/storybook-utils": "^1.2.17",
|
|
40
|
-
"@box/user-selector": "^2.2.
|
|
40
|
+
"@box/user-selector": "^2.2.18",
|
|
41
41
|
"react": "^18.0.0",
|
|
42
42
|
"react-dom": "^18.0.0"
|
|
43
43
|
},
|