Skip to content

Commit

Permalink
chore(richtext-lexical): add missing 'use client' directives
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioGr committed Aug 15, 2024
1 parent 0957278 commit 12a836c
Show file tree
Hide file tree
Showing 31 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { ToolbarGroup, ToolbarGroupItem } from '../../toolbars/types.js'

import { AlignLeftIcon } from '../../../lexical/ui/icons/AlignLeft/index.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { FormState } from 'payload'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { LexicalCommand } from 'lexical'

import { createCommand } from 'lexical'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
// Copied & modified from https://github.com/lodash/lodash/blob/main/src/debounce.ts
/*
The MIT License
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { useMemo, useRef } from 'react'

import debounce from './debounce.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { ToolbarGroup, ToolbarGroupItem } from '../../toolbars/types.js'

export const toolbarFormatGroupWithItems = (items: ToolbarGroupItem[]): ToolbarGroup => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { ToolbarGroup, ToolbarGroupItem } from '../../toolbars/types.js'

export const toolbarIndentGroupWithItems = (items: ToolbarGroupItem[]): ToolbarGroup => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { LexicalCommand } from 'lexical'

import { createCommand } from 'lexical'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { LexicalEditor } from 'lexical'

import { useCallback } from 'react'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export function debounce(func: Function, wait: number) {
let timeout: null | number = null
return function (...args: any[]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export function getBoundingClientRectWithoutTransform(elem: HTMLElement): DOMRect {
const rect = elem.getBoundingClientRect()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type React from 'react'

import { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import { getCollapsedMargins } from '../utils/getCollapsedMargins.js'
import { getBoundingClientRectWithoutTransform } from './getBoundingRectWithoutTransform.js'
import { highlightElemOriginalPosition } from './highlightElemOriginalPosition.js'
const TARGET_LINE_HALF_HEIGHT = 25
const TEXT_BOX_HORIZONTAL_PADDING = -24
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
/**
* Calculate distance between scrollerElem and target if target is not in scrollerElem
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
const replacedElements = [
'IMG',
'INPUT',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export function getCollapsedMargins(elem: HTMLElement): {
marginBottom: number
marginTop: number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { LexicalEditor, LexicalNode } from 'lexical'

import { $getNodeByKey } from 'lexical'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { LexicalEditor } from 'lexical'

import { $getRoot } from 'lexical'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export function isOnHandleElement(element: HTMLElement, handleElementClassName: string): boolean {
return !!element.closest(`.${handleElementClassName}`)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { doesLineHeightAffectElement } from './doesLineHeightAffectElement.js'

export function setHandlePosition(
Expand Down
1 change: 1 addition & 0 deletions packages/richtext-lexical/src/lexical/utils/canUseDOM.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export const CAN_USE_DOM: boolean =
typeof window !== 'undefined' &&
typeof window.document !== 'undefined' &&
Expand Down
1 change: 1 addition & 0 deletions packages/richtext-lexical/src/lexical/utils/environment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { CAN_USE_DOM } from './canUseDOM.js'

declare global {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect {
const domRange = nativeSelection.getRangeAt(0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { ElementNode, RangeSelection, TextNode } from 'lexical'

import { $isAtNodeEnd } from '@lexical/selection'
Expand Down
1 change: 1 addition & 0 deletions packages/richtext-lexical/src/lexical/utils/guard.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export function isHTMLElement(x: unknown): x is HTMLElement {
return x instanceof HTMLElement
}
1 change: 1 addition & 0 deletions packages/richtext-lexical/src/lexical/utils/joinClasses.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export function joinClasses(...args: Array<boolean | null | string | undefined>): string {
return args.filter(Boolean).join(' ')
}
1 change: 1 addition & 0 deletions packages/richtext-lexical/src/lexical/utils/point.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
export class Point {
private readonly _x: number

Expand Down
1 change: 1 addition & 0 deletions packages/richtext-lexical/src/lexical/utils/rect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import { type Point, isPoint } from './point.js'

interface ContainsPointReturn {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
const VERTICAL_GAP = 10
const HORIZONTAL_OFFSET = 5

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
const VERTICAL_GAP = 10
const HORIZONTAL_OFFSET = 5

Expand Down
1 change: 1 addition & 0 deletions packages/richtext-lexical/src/lexical/utils/swipe.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
type Force = [number, number]
type Listener = (force: Force, e: TouchEvent) => void
interface ElementValues {
Expand Down

0 comments on commit 12a836c

Please sign in to comment.