<commit_before>/* eslint-disable react/prop-types */
import React, {FunctionComponent, SyntheticEvent} from 'react'
import classNames from 'classnames'
import {PortableTextChild, Type, RenderAttributes} from '@sanity/portable-text-editor'
import {ChangeIndicatorWithProvidedFullPath} from '@sanity/base/lib/change-indicators'

import {FOCUS_TERMINATOR} from '@sanity/util/paths'
import {Path, Marker, isValidationErrorMarker} from '@sanity/types'
import {PatchEvent} from '../../../PatchEvent'

import styles from './Annotation.css'

type Props = {
  value: PortableTextChild
  type: Type
  children: JSX.Element
  attributes: RenderAttributes
  readOnly: boolean
  markers: Marker[]
  onFocus: (arg0: Path) => void
  onChange: (patchEvent: PatchEvent, path: Path) => void
}

export const Annotation: FunctionComponent<Props> = ({
  children,
  markers,
  attributes: {focused, selected, path},
  value,
  onFocus
}) => {
  const errors = markers.filter(isValidationErrorMarker)
  const classnames = classNames([
    styles.root,
    focused && styles.focused,
    selected && styles.selected,
    errors.length > 0 ? styles.error : styles.valid
  ])

  const handleOpen = (event: SyntheticEvent<HTMLSpanElement>): void => {
    event.preventDefault()
    event.stopPropagation()
    onFocus([...path.slice(0, 1), 'markDefs', {_key: value._key}, FOCUS_TERMINATOR])
  }
  return (
    <span className={classnames} onClick={handleOpen}>
      {children}
      <ChangeIndicatorWithProvidedFullPath
        className={styles.changeIndicator}
        compareDeep
        value={value}
        hasFocus={focused}
        path={path}
        hidden
      />
    </span>
  )
}
<commit_msg>[form-builder] PTE: add some invisible content to the hidden ChangeIndicator<commit_after>/* eslint-disable react/prop-types */
import React, {FunctionComponent, SyntheticEvent} from 'react'
import classNames from 'classnames'
import {PortableTextChild, Type, RenderAttributes} from '@sanity/portable-text-editor'
import {ChangeIndicatorWithProvidedFullPath} from '@sanity/base/lib/change-indicators'

import {FOCUS_TERMINATOR} from '@sanity/util/paths'
import {Path, Marker, isValidationErrorMarker} from '@sanity/types'
import {PatchEvent} from '../../../PatchEvent'

import styles from './Annotation.css'

type Props = {
  value: PortableTextChild
  type: Type
  children: JSX.Element
  attributes: RenderAttributes
  readOnly: boolean
  markers: Marker[]
  onFocus: (arg0: Path) => void
  onChange: (patchEvent: PatchEvent, path: Path) => void
}

export const Annotation: FunctionComponent<Props> = ({
  children,
  markers,
  attributes: {focused, selected, path},
  value,
  onFocus
}) => {
  const errors = markers.filter(isValidationErrorMarker)
  const classnames = classNames([
    styles.root,
    focused && styles.focused,
    selected && styles.selected,
    errors.length > 0 ? styles.error : styles.valid
  ])

  const handleOpen = (event: SyntheticEvent<HTMLSpanElement>): void => {
    event.preventDefault()
    event.stopPropagation()
    onFocus([...path.slice(0, 1), 'markDefs', {_key: value._key}, FOCUS_TERMINATOR])
  }
  return (
    <span className={classnames} onClick={handleOpen}>
      {children}
      <ChangeIndicatorWithProvidedFullPath
        className={styles.changeIndicator}
        compareDeep
        value={value}
        hasFocus={focused}
        path={path}
        hidden
      >
        {'\u200B'}
      </ChangeIndicatorWithProvidedFullPath>
    </span>
  )
}

{'fraction_non_alphanumeric': 0.12356651376146789, 'fraction_numerical': 0.0031536697247706424, 'mean_word_length': 3.97008547008547, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1567300', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1058, 'n_words': 247}