UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

12 lines (10 loc) • 1.48 kB
/** * 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{CAN_USE_DOM as r}from"lexical";import{createContext as o,useContext as n}from"react";const e=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]];let l;const t= /* @__PURE__ */ o(null);function i(){const[o,n]=r?(void 0===l&&(l=e[Math.floor(Math.random()*e.length)]),l):e[0];return{color:n,isCollabActive:!1,name:o,yjsDocMap:new Map}}const a=/* @__PURE__ */i();function g(r,o){let e=n(t);return null==e&&function(r,...o){const n=new URL("https://lexical.dev/docs/error"),e=new URLSearchParams;e.append("code",r);for(const r of o)e.append("v",r);n.search=e.toString(),console.warn(`Minified Lexical warning #${r}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(319),e=e??a,null!=r&&(e.name=r),null!=o&&(e.color=o),e}export{t as CollaborationContext,i as newContext,g as useCollaborationContext};