UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

10 lines (8 loc) • 931 B
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import{getScrollParent as t}from"@lexical/utils";import{createCommand as e}from"lexical";import{useCallback as n}from"react";const r="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;",l=/* @__PURE__ */e("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND"),i=t;function o(t,{minLength:e=1,maxLength:l=75,punctuation:i=r,allowWhitespace:o=!1}){return n(n=>{const r=new RegExp("(^|\\s|\\()(["+t+"]((?:"+("[^"+t+i+(o?"":"\\s")+"]")+"){0,"+l+"}))$").exec(n);if(null!==r){const t=r[1],n=r[3];if(n.length>=e)return{leadOffset:r.index+t.length,matchingString:n,replaceableString:r[2]}}return null},[o,t,i,l,e])}export{r as PUNCTUATION,l as SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,i as getScrollParent,o as useBasicTypeaheadTriggerMatch};