index
int64
0
0
repo_id
stringlengths
16
181
file_path
stringlengths
28
270
content
stringlengths
1
11.6M
__index_level_0__
int64
0
10k
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/patchExamples/incDec.ts
import type {PatchExample} from './types' const examples: PatchExample[] = [ { name: 'Inc and dec', before: { a: [0, 1, 2, 3, 4], b: 4, c: 5, }, patch: { id: 'a', inc: { 'a[2]': 1, b: 2, }, dec: { c: 1, }, }, after: { ...
2,100
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/patchExamples/insert.ts
import type {PatchExample} from './types' const examples: PatchExample[] = [ { name: 'Insert before index', before: { a: [0, 1, 2, 3, 4], }, patch: { id: 'a', insert: { before: 'a[2]', items: [-1, -2], }, }, after: { a: [0, 1, -1, -2, 2, 3, 4], ...
2,101
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/patchExamples/mixed.ts
import type {PatchExample} from './types' const examples: PatchExample[] = [ { name: 'Mix `setIfMissing` and `set`', before: { a: {}, }, patch: { id: 'a', setIfMissing: { 'a.b': 10, }, set: { 'a.b': 20, }, }, after: { a: { b: 2...
2,102
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/patchExamples/set.ts
import type {PatchExample} from './types' const examples: PatchExample[] = [ { name: 'Simple path set', before: { a: { b: 7, }, }, patch: { id: 'a', set: { 'a.b': 10, }, }, after: { a: { b: 10, }, }, }, { name: 'Arr...
2,103
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/patchExamples/setIfMissing.ts
import type {PatchExample} from './types' const examples: PatchExample[] = [ { name: 'Simple path setIfMissing, value not missing', before: { a: { b: 7, }, }, patch: { id: 'a', setIfMissing: { 'a.b': 10, }, }, after: { a: { b: 7, ...
2,104
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/patchExamples/types.ts
import type {SingleDocumentPatch} from '../../src/patch/types' export interface PatchExample { name: string before: Record<string, unknown> after: Record<string, unknown> patch: SingleDocumentPatch | SingleDocumentPatch[] }
2,105
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/patchExamples/unset.ts
import type {PatchExample} from './types' const examples: PatchExample[] = [ { name: 'Simple path unset', before: { a: { b: 7, c: 10, }, }, patch: { id: 'a', unset: ['a.b'], }, after: { a: { c: 10, }, }, }, { name: 'Simpl...
2,106
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/util/BufferedDocumentTester.ts
// A test jig for the BufferedDocument model import debugLogger from 'debug' import type {PatchMutationOperation} from '@sanity/types' import type {CommitHandlerMessage} from '../../src/document/BufferedDocument' import type {Doc, Mut} from '../../src/document/types' import {BufferedDocument, Mutation} from '../../src/...
2,107
0
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test
petrpan-code/sanity-io/sanity/packages/@sanity/mutator/test/util/DocumentTester.ts
// A test jig for the Document model import type {PatchMutationOperation} from '@sanity/types' import type {SubmissionResponder} from '../../src/document/Document' import type {Doc} from '../../src/document/types' import {Document, Mutation} from '../../src/document' import {extract} from '../../src/jsonpath' export c...
2,108
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/.depcheckignore.json
{ "ignore": ["@optimize-lodash/rollup-plugin", "@sanity/pkg-utils"] }
2,109
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/.eslintrc.cjs
'use strict' const path = require('path') const ROOT_PATH = path.resolve(__dirname, '../../..') module.exports = { rules: { 'import/no-extraneous-dependencies': ['error', {packageDir: [ROOT_PATH, __dirname]}], }, }
2,110
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/LICENSE
MIT License Copyright (c) 2016 - 2023 Sanity.io Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, ...
2,111
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/README.md
# @sanity/portable-text-editor More info to come!
2,112
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/jest.config.cjs
'use strict' const {createJestConfig} = require('../../../test/config.cjs') module.exports = createJestConfig({ displayName: require('./package.json').name, modulePathIgnorePatterns: ['<rootDir>/e2e-tests'], })
2,113
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/package.config.ts
import {defineConfig} from '@sanity/pkg-utils' import baseConfig from '../../../package.config' export default defineConfig({...baseConfig})
2,114
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/package.json
{ "name": "@sanity/portable-text-editor", "version": "3.20.1", "description": "Portable Text Editor made in React", "keywords": [ "sanity", "cms", "headless", "realtime", "content", "portable-text-editor", "structure", "api", "collaborative", "editor", "text", "po...
2,115
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/tsconfig.json
{ "extends": "../../../tsconfig.settings", "include": ["./src", "./test"], "compilerOptions": { "composite": true, "rootDir": ".", "outDir": "./lib/dts", "jsx": "react-jsx", "isolatedModules": false }, "references": [ {"path": "../block-tools/tsconfig.lib.json"}, {"path": "../sche...
2,116
0
petrpan-code/sanity-io/sanity/packages/@sanity
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/tsconfig.lib.json
{ "extends": "../../../tsconfig.settings", "include": ["./src"], "compilerOptions": { "composite": true, "rootDir": ".", "outDir": "./lib/dts", "jsx": "react-jsx", "isolatedModules": false }, "references": [ {"path": "../block-tools/tsconfig.lib.json"}, {"path": "../schema/tsconfi...
2,117
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/e2e.config.cjs
'use strict' const {createJestConfig} = require('../../../../test/config.cjs') // eslint-disable-next-line no-console console.info('Running collaborate editing tests for the Portable Text Editor') module.exports = createJestConfig({ displayName: require('../package.json').name, globalSetup: './setup/globalSetup....
2,118
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/schema.ts
import {defineType} from '@sanity/types' export const imageType = { type: 'image', name: 'blockImage', } export const someObject = { type: 'object', name: 'someObject', fields: [{type: 'string', name: 'color'}], } export const blockType = { type: 'block', name: 'block', styles: [ {title: 'Normal'...
2,119
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/serve.ts
// Start servers file for 'npm start' import globalSetup from './setup/globalSetup' globalSetup().then(() => { // eslint-disable-next-line no-console console.log( 'Started web and websocket servers.\n\nhttp://localhost:3000 (web)\n\nhttp://localhost:3001 (ws)', ) })
2,120
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/tsconfig.json
{ "extends": "../tsconfig.json", "ts-node": { // these options are overrides used only by ts-node "compilerOptions": { "module": "commonjs" } }, "compilerOptions": { "target": "ESNext" } }
2,121
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/__tests__/.eslintrc
{ "env": { "browser": false, "node": true }, "rules": { "import/no-unassigned-import": "off", "tsdoc/syntax": "off" } }
2,122
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/__tests__/pasting.collaborative.test.ts
/** @jest-environment ./setup/collaborative.jest.env.ts */ import os from 'os' import '../setup/globals.jest' import {noop} from 'lodash' function isMacOs() { return os.platform() === 'darwin' } // Ideally pasting should be tested in a testing-library test, but I have not found a way to do it natively with testing-...
2,123
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/__tests__/selectionAdjustment.collaborative.test.ts
/** @jest-environment ./setup/collaborative.jest.env.ts */ import '../setup/globals.jest' describe('selection adjustment', () => { describe('insert and unset blocks', () => { it('will keep A on same line if B insert above', async () => { await setDocumentValue([ { _key: 'someKey', ...
2,124
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/__tests__/undoRedo.collborative.test.ts
/** @jest-environment ./setup/collaborative.jest.env.ts */ import {toPlainText} from '@portabletext/toolkit' import '../setup/globals.jest' import type {PortableTextBlock} from '@sanity/types' const initialValue: PortableTextBlock[] = [ { _key: 'randomKey0', _type: 'block', markDefs: [], style: 'norm...
2,125
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/__tests__/writingTogether.collaborative.test.ts
/** @jest-environment ./setup/collaborative.jest.env.ts */ import '../setup/globals.jest' import type {PortableTextBlock} from '@sanity/types' const initialValue: PortableTextBlock[] = [ { _key: 'randomKey0', _type: 'block', markDefs: [], style: 'normal', children: [{_key: 'randomKey1', _type: '...
2,126
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/setup/afterEnv.ts
jest.setTimeout(20 * 1000) export {}
2,127
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/setup/collaborative.jest.env.ts
import {chromium, Browser, Page, ElementHandle, BrowserContext} from '@playwright/test' import NodeEnvironment from 'jest-environment-node' import {isEqual} from 'lodash' import ipc from 'node-ipc' import {PortableTextBlock} from '@sanity/types' import {normalizeSelection} from '../../src/utils/selection' import type {...
2,128
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/setup/globalSetup.ts
import path from 'path' import {setup as setupDevServer} from 'jest-dev-server' const testFolderPath = path.resolve(__dirname, '..') declare global { // eslint-disable-next-line no-var var servers: any[] // For the globalSetup and globalTeardown script } export default async function globalSetup(): Promise<void>...
2,129
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/setup/globalTeardown.ts
import {teardown as teardownDevServer} from 'jest-dev-server' export default async function globalTeardown(): Promise<void> { await teardownDevServer(globalThis.servers) }
2,130
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/setup/globals.jest.ts
import {PortableTextBlock} from '@sanity/types' import {EditorSelection} from '../../src' export {} type Value = PortableTextBlock[] | undefined type Editor = { editorId: string focus: () => Promise<void> getSelection: () => Promise<EditorSelection | null> getValue: () => Promise<Value> insertText: (text: ...
2,131
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server/app.tsx
import {PortableTextBlock} from '@sanity/types' import {Box, Card, Heading, Stack, studioTheme, ThemeProvider, Text, Inline} from '@sanity/ui' import React, {useCallback, useMemo, useState} from 'react' import {Subject} from 'rxjs' import {EditorSelection, Patch} from '../../src' import {Editor} from './components/Edit...
2,132
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server/entry.tsx
import React from 'react' import {createRoot} from 'react-dom/client' import {App} from './app' const rootEl = document.getElementById('root') if (!rootEl) { throw new Error('Root element not found') } const root = createRoot(rootEl) root.render(<App />)
2,133
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server/index.html
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Test Editor</title> </head> <body> <div id="root"></div> <script type="module" src="./entry.tsx"></script> </body> </html>
2,134
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server/keyGenerator.ts
// Example of custom keyGenerator const _createKeyGenerator = (prefix: string): (() => string) => { let key = 0 const fn = (): string => { return `${prefix}-${key++}` } return fn } export const createKeyGenerator = _createKeyGenerator
2,135
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server/vite.config.js
import path from 'path' import {defineConfig} from 'vite' import viteReact from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [viteReact()], build: { minify: false, }, server: { host: true, }, resolve: { alias: { '@sanity/schema': path.join(__...
2,136
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server/components/Editor.tsx
import React, {useCallback, useMemo, useRef, useState, useEffect} from 'react' import {Text, Box, Card, Code, Heading} from '@sanity/ui' import styled from 'styled-components' import {Subject} from 'rxjs' import {PortableTextBlock} from '@sanity/types' import { BlockDecoratorRenderProps, BlockRenderProps, Portabl...
2,137
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/web-server/components/Value.tsx
import React from 'react' import {PortableTextBlock} from '@sanity/types' import {Card, Heading, Code, Box} from '@sanity/ui' type Props = {value: PortableTextBlock[] | undefined; revId: string} export function Value({value, revId}: Props) { return ( <Card> <Box paddingBottom={4}> <Heading as="h2"...
2,138
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/e2e-tests/ws-server/index.ts
import ipc from 'node-ipc' import express from 'express' import expressWS from 'express-ws' import {Subject} from 'rxjs' import type {WebSocket} from 'ws' import {PortableTextBlock} from '@sanity/types' import {applyAll} from '../../src/patch/applyPatch' import {Patch} from '../../src' const WEBSOCKET_PORT = 3001 ipc...
2,139
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/index.ts
export {PortableTextEditor} from './editor/PortableTextEditor' export type {PortableTextEditorProps} from './editor/PortableTextEditor' export * from './types/editor' export * from './types/patch' export * from './types/options' export {compactPatches} from './utils/patches' export {PortableTextEditable} from './editor...
2,140
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/Editable.tsx
import {BaseRange, Transforms, Text, select, Editor} from 'slate' import React, {useCallback, useMemo, useEffect, forwardRef, useState, KeyboardEvent} from 'react' import { Editable as SlateEditable, ReactEditor, RenderElementProps, RenderLeafProps, useSlate, } from 'slate-react' import {noop} from 'lodash' i...
2,141
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/PortableTextEditor.tsx
import React, {PropsWithChildren} from 'react' import { ArrayDefinition, ArraySchemaType, BlockSchemaType, ObjectSchemaType, Path, PortableTextBlock, PortableTextChild, PortableTextObject, SpanSchemaType, } from '@sanity/types' import {Subject} from 'rxjs' import {compileType} from '../utils/schema' i...
2,142
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/__tests__/PortableTextEditor.test.tsx
/* eslint-disable no-irregular-whitespace */ import React from 'react' import {render, waitFor} from '@testing-library/react' import {PortableTextBlock} from '@sanity/types' import {PortableTextEditor} from '../PortableTextEditor' import {EditorSelection} from '../..' import {PortableTextEditorTester, schemaType} from...
2,143
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/__tests__/PortableTextEditorTester.tsx
import React, {ForwardedRef, forwardRef, useCallback, useEffect} from 'react' import {Schema} from '@sanity/schema' import {defineArrayMember, defineField} from '@sanity/types' import {PortableTextEditor, PortableTextEditable} from '../../index' import type {PortableTextEditorProps, PortableTextEditableProps} from '.....
2,144
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/components/DraggableBlock.tsx
import React, {useState, useRef, useMemo, useCallback, DragEvent, useEffect} from 'react' import {Element as SlateElement, Transforms, Path, Editor} from 'slate' import {ReactEditor, useSlateStatic} from 'slate-react' import {debugWithName} from '../../utils/debug' import { IS_DRAGGING_ELEMENT_TARGET, IS_DRAGGING_B...
2,145
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/components/Element.tsx
/* eslint-disable complexity */ /* eslint-disable max-statements */ import React, {ReactElement, FunctionComponent, useRef, useMemo} from 'react' import {Element as SlateElement, Editor, Range} from 'slate' import {Path, PortableTextChild, PortableTextObject, PortableTextTextBlock} from '@sanity/types' import {useSelec...
2,146
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/components/Leaf.tsx
import React, { ReactElement, startTransition, useCallback, useEffect, useMemo, useState, } from 'react' import {Text} from 'slate' import {RenderLeafProps, useSelected} from 'slate-react' import {isEqual, uniq} from 'lodash' import {Path, PortableTextObject, PortableTextTextBlock} from '@sanity/types' impo...
2,147
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/components/SlateContainer.tsx
import React, {PropsWithChildren, useEffect, useMemo} from 'react' import {Slate, withReact} from 'slate-react' import {createEditor} from 'slate' import {KEY_TO_SLATE_ELEMENT, KEY_TO_VALUE_ELEMENT} from '../../utils/weakMaps' import {debugWithName} from '../../utils/debug' import {PatchObservable} from '../../types/ed...
2,148
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/components/Synchronizer.tsx
import React, { PropsWithChildren, startTransition, useCallback, useEffect, useMemo, useRef, useState, } from 'react' import {PortableTextBlock} from '@sanity/types' import {throttle} from 'lodash' import {useSlate} from 'slate-react' import {Editor} from 'slate' import {EditorChange, EditorChanges, Edito...
2,149
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/useForwardedRef.ts
import React, {useRef, useLayoutEffect, useEffect} from 'react' const useIsomorphicEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect export function useForwardedRef<T>(ref: React.ForwardedRef<T>): React.MutableRefObject<T | null> { const innerRef = useRef<T | null>(null) useIsomorphicEffect(()...
2,150
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/usePortableTextEditor.ts
import {createContext, useContext} from 'react' import {PortableTextEditor} from '../PortableTextEditor' /** * A React context for sharing the editor object. */ export const PortableTextEditorContext = createContext<PortableTextEditor | null>(null) /** * Get the current editor object from the React context. */ e...
2,151
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/usePortableTextEditorKeyGenerator.ts
import {randomKey} from '@sanity/util/content' import {createContext, useContext} from 'react' export const defaultKeyGenerator = (): string => randomKey(12) /** * A React context for sharing the editor's keyGenerator. */ export const PortableTextEditorKeyGeneratorContext = createContext<() => string>(defaultKeyG...
2,152
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/usePortableTextEditorSelection.ts
import {createContext, useContext} from 'react' import {EditorSelection} from '../../types/editor' /** * A React context for sharing the editor selection. */ export const PortableTextEditorSelectionContext = createContext<EditorSelection | null>(null) /** * Get the current editor selection from the React context. ...
2,153
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/usePortableTextEditorValue.ts
import {PortableTextBlock} from '@sanity/types' import {createContext, useContext} from 'react' /** * A React context for sharing the editor value. */ export const PortableTextEditorValueContext = createContext<PortableTextBlock[] | undefined>( undefined, ) /** * Get the current editor value from the React conte...
2,154
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/usePortableTextReadOnly.ts
import {createContext, useContext} from 'react' /** * A React context for sharing the editor's readOnly status. */ export const PortableTextEditorReadOnlyContext = createContext<boolean>(false) /** * Get the current editor selection from the React context. */ export const usePortableTextEditorReadOnlyStatus = ():...
2,155
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/useSyncValue.test.tsx
import {render, waitFor} from '@testing-library/react' import React from 'react' import {PortableTextEditor} from '../PortableTextEditor' import {PortableTextEditorTester, schemaType} from '../__tests__/PortableTextEditorTester' const initialValue = [ { _key: '77071c3af231', _type: 'myTestBlockType', ch...
2,156
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/hooks/useSyncValue.ts
/* eslint-disable max-nested-callbacks */ import {useCallback, useMemo, useRef} from 'react' import {PortableTextBlock} from '@sanity/types' import {debounce, isEqual} from 'lodash' import {Editor, Transforms, Node, Descendant, Text} from 'slate' import {useSlate} from 'slate-react' import {PortableTextEditor} from '.....
2,157
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/nodes/DefaultAnnotation.tsx
import {PortableTextObject} from '@sanity/types' import React, {useCallback} from 'react' type Props = { annotation: PortableTextObject children: React.ReactNode } export function DefaultAnnotation(props: Props) { // eslint-disable-next-line no-alert const handleClick = useCallback(() => alert(JSON.stringify(p...
2,158
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/nodes/DefaultObject.tsx
import {PortableTextBlock, PortableTextChild} from '@sanity/types' import React from 'react' type Props = { value: PortableTextBlock | PortableTextChild } const DefaultObject = (props: Props): JSX.Element => { return ( <div> <pre>{JSON.stringify(props.value, null, 2)}</pre> </div> ) } export defa...
2,159
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/nodes/index.ts
import styled from 'styled-components' export const DefaultBlockObject = styled.div<{selected: boolean}>` user-select: none; border: ${(props) => { if (props.selected) { return '1px solid blue' } return '1px solid transparent' }}; ` export const DefaultInlineObject = styled.span<{selected: boo...
2,160
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithEditableAPI.ts
import { Text, Range, Transforms, Editor, Element as SlateElement, Node, Path as SlatePath, } from 'slate' import { ObjectSchemaType, Path, PortableTextBlock, PortableTextChild, PortableTextObject, PortableTextTextBlock, SchemaType, } from '@sanity/types' import {ReactEditor} from 'slate-rea...
2,161
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithHotKeys.ts
/* eslint-disable max-statements */ /* eslint-disable complexity */ import {Editor, Transforms, Path, Range, Node} from 'slate' import isHotkey from 'is-hotkey' import {ReactEditor} from 'slate-react' import {isPortableTextSpan, isPortableTextTextBlock} from '@sanity/types' import {PortableTextMemberSchemaTypes, Portab...
2,162
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithInsertData.ts
import {Node, Transforms, Editor, Descendant, Range} from 'slate' import {htmlToBlocks, normalizeBlock} from '@sanity/block-tools' import {ReactEditor} from 'slate-react' import {PortableTextBlock, PortableTextChild} from '@sanity/types' import {isEqual, uniq} from 'lodash' import { EditorChanges, PortableTextMembe...
2,163
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithMaxBlocks.ts
import {PortableTextSlateEditor} from '../../types/editor' /** * This plugin makes sure that the PTE maxBlocks prop is respected * */ export function createWithMaxBlocks(maxBlocks: number) { return function withMaxBlocks(editor: PortableTextSlateEditor): PortableTextSlateEditor { const {apply} = editor ed...
2,164
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithObjectKeys.ts
import {Element, Transforms, Node, Editor} from 'slate' import {PortableTextMemberSchemaTypes, PortableTextSlateEditor} from '../../types/editor' import {isPreservingKeys, PRESERVE_KEYS} from '../../utils/withPreserveKeys' /** * This plugin makes sure that every new node in the editor get a new _key prop when created...
2,165
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPatches.ts
/* eslint-disable max-nested-callbacks */ import {Subject} from 'rxjs' import { Descendant, Editor, InsertNodeOperation, InsertTextOperation, MergeNodeOperation, MoveNodeOperation, Operation, RemoveNodeOperation, RemoveTextOperation, SetNodeOperation, SplitNodeOperation, } from 'slate' import {ins...
2,166
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPlaceholderBlock.ts
import {Descendant} from 'slate' import {PortableTextMemberSchemaTypes, PortableTextSlateEditor} from '../../types/editor' import {debugWithName} from '../../utils/debug' const debug = debugWithName('plugin:withPlaceholderBlock') interface Options { schemaTypes: PortableTextMemberSchemaTypes keyGenerator: () => s...
2,167
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPortableTextBlockStyle.ts
import {Editor, Transforms, Element, Path, Text as SlateText, Node} from 'slate' import {PortableTextMemberSchemaTypes, PortableTextSlateEditor} from '../../types/editor' import {debugWithName} from '../../utils/debug' const debug = debugWithName('plugin:withPortableTextBlockStyle') export function createWithPortable...
2,168
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPortableTextLists.ts
import {Editor, Transforms, Element, Text, Node} from 'slate' import {PortableTextMemberSchemaTypes, PortableTextSlateEditor} from '../../types/editor' import {debugWithName} from '../../utils/debug' const debug = debugWithName('plugin:withPortableTextLists') const MAX_LIST_LEVEL = 10 export function createWithPortab...
2,169
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPortableTextMarkModel.ts
/* eslint-disable complexity */ /** * * This plugin will change Slate's default marks model (every prop is a mark) with the Portable Text model (marks is an array of strings on prop .marks). * */ import {isEqual, flatten, uniq} from 'lodash' import {Editor, Range, Transforms, Text, Path, NodeEntry, Element, Descen...
2,170
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithPortableTextSelections.ts
import {Subject} from 'rxjs' import {BaseRange} from 'slate' import { EditorChange, EditorSelection, PortableTextMemberSchemaTypes, PortableTextSlateEditor, } from '../../types/editor' import {debugWithName} from '../../utils/debug' import {ObjectWithKeyAndType, toPortableTextRange} from '../../utils/ranges' im...
2,171
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithSchemaTypes.ts
import {Element, Operation, InsertNodeOperation, Text as SlateText, Transforms} from 'slate' import { isPortableTextTextBlock, PortableTextTextBlock, isPortableTextSpan, PortableTextSpan, PortableTextListBlock, isPortableTextListBlock, } from '@sanity/types' import {debugWithName} from '../../utils/debug' i...
2,172
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithUndoRedo.ts
/** * This plugin will make the editor support undo/redo on the local state only. * The undo/redo steps are rebased against incoming patches since the step occurred. */ import {isEqual, flatten} from 'lodash' import {Descendant, Editor, Operation, Path, SelectionOperation, Transforms} from 'slate' import {DIFF_DELE...
2,173
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/createWithUtils.ts
import {Editor, Range, Transforms, Text} from 'slate' import {PortableTextMemberSchemaTypes, PortableTextSlateEditor} from '../../types/editor' import {debugWithName} from '../../utils/debug' const debug = debugWithName('plugin:withUtils') interface Options { schemaTypes: PortableTextMemberSchemaTypes keyGenerato...
2,174
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/index.ts
import {BaseOperation, Editor, NodeEntry, Node} from 'slate' import {noop} from 'lodash' import {PortableTextSlateEditor} from '../../types/editor' import {createEditorOptions} from '../../types/options' import {createOperationToPatches} from '../../utils/operationToPatches' import {createWithEditableAPI} from './creat...
2,175
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx
import {render, waitFor} from '@testing-library/react' import React from 'react' import {PortableTextEditor} from '../../PortableTextEditor' import {PortableTextEditorTester, schemaType} from '../../__tests__/PortableTextEditorTester' const initialValue = [ { _key: 'a', _type: 'myTestBlockType', childre...
2,176
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx
import {render, waitFor} from '@testing-library/react' import React from 'react' import {PortableTextEditor} from '../../PortableTextEditor' import {PortableTextEditorTester, schemaType} from '../../__tests__/PortableTextEditorTester' const initialValue = [ { _key: 'a', _type: 'myTestBlockType', childre...
2,177
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx
/* eslint-disable max-nested-callbacks */ import {render, waitFor} from '@testing-library/react' import React from 'react' import {PortableTextEditor} from '../../PortableTextEditor' import {PortableTextEditorTester, schemaType} from '../../__tests__/PortableTextEditorTester' import {EditorSelection} from '../../../ty...
2,178
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/PatchEvent.ts
import {PathSegment} from '@sanity/types' import {flatten} from 'lodash' import type {Patch} from '../types/patch' import {prefixPath, set, unset, setIfMissing, insert, diffMatchPatch} from './patches' type PatchArg = Patch | Array<Patch> export default class PatchEvent { static from(...patches: Array<PatchArg>) {...
2,179
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/applyPatch.ts
import {isObject, isString} from 'lodash' import applyArrayPatch from './array' import applyObjectPatch from './object' import applyPrimitivePatch from './primitive' import applyStringPatch from './string' export function applyAll(value: any, patches: any[]) { return patches.reduce(_apply, value) } function applyPa...
2,180
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/array.ts
import {PathSegment} from '@sanity/types' import {findIndex} from 'lodash' import applyPatch from './applyPatch' import insert from './arrayInsert' const hasOwn = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty) function move(arr: any[], from: number, to: any) { const nextValue = arr.slice...
2,181
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/arrayInsert.ts
export const BEFORE = 'before' export const AFTER = 'after' export default function insert(array: any[], position: string, index: number, ...args: any[]) { if (position !== BEFORE && position !== AFTER) { throw new Error(`Invalid position "${position}", must be either ${BEFORE} or ${AFTER}`) } const items =...
2,182
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/object.ts
import {omit, clone, isObject} from 'lodash' import applyPatch from './applyPatch' export default function apply(value: any, patch: {type: any; path: any; value: any}) { const nextValue = clone(value) if (patch.path.length === 0) { // its directed to me if (patch.type === 'set') { if (!isObject(patch...
2,183
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/patches.ts
import type {Path, PathSegment} from '@sanity/types' import {makePatches, stringifyPatches} from '@sanity/diff-match-patch' import type { SetIfMissingPatch, InsertPatch, InsertPosition, SetPatch, UnsetPatch, DiffMatchPatch, } from '../types/patch' export function setIfMissing(value: any, path: Path = []):...
2,184
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/primitive.ts
const OPERATIONS: Record<string, any> = { replace(_currentValue: any, nextValue: any) { return nextValue }, set(_currentValue: any, nextValue: any) { return nextValue }, setIfMissing(currentValue: any, nextValue: any) { return currentValue === undefined ? nextValue : currentValue }, unset(_cur...
2,185
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/patch/string.ts
import {applyPatches, parsePatch} from '@sanity/diff-match-patch' type fn = (oldVal: any, newVal: any) => any const OPERATIONS: Record<string, fn> = { replace(currentValue: any, nextValue: any) { return nextValue }, set(currentValue: any, nextValue: any) { return nextValue }, setIfMissing(currentValu...
2,186
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/types/editor.ts
import { ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockSchemaType, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, PortableTextChild, PortableTextListBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock, SpanSchemaType, TypedObject, } f...
2,187
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/types/options.ts
import {PortableTextEditor} from '../editor/PortableTextEditor' import {PatchObservable} from './editor' export type createEditorOptions = { keyGenerator: () => string patches$?: PatchObservable portableTextEditor: PortableTextEditor readOnly: boolean maxBlocks?: number } export type HotkeyOptions = { mar...
2,188
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/types/patch.ts
import type {Path} from '@sanity/types' export type JSONValue = number | string | boolean | {[key: string]: JSONValue} | JSONValue[] export type Origin = 'remote' | 'local' | 'internal' export type IncPatch = { path: Path origin?: Origin type: 'inc' value: JSONValue } export type DecPatch = { path: Path ...
2,189
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/types/slate.ts
import {BaseEditor, Descendant} from 'slate' import {ReactEditor} from 'slate-react' import {PortableTextSpan, PortableTextTextBlock} from '@sanity/types' import {PortableTextSlateEditor} from '..' export interface VoidElement { _type: string _key: string children: Descendant[] __inline: boolean value: Recor...
2,190
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/applyPatch.ts
/* eslint-disable max-statements */ import {Transforms, Element, Path as SlatePath, Descendant, Text, Node} from 'slate' import { applyPatches as diffMatchPatchApplyPatches, cleanupEfficiency, makeDiff, parsePatch, DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, } from '@sanity/diff-match-patch' import { type Pat...
2,191
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/bufferUntil.ts
import {EMPTY, Observable, OperatorFunction, defer, of, switchMap, tap} from 'rxjs' export function bufferUntil<T>( emitWhen: (currentBuffer: T[]) => boolean, ): OperatorFunction<T, T[]> { return (source: Observable<T>) => defer(() => { let buffer: T[] = [] // custom buffer return source.pipe( ...
2,192
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/debug.ts
import debug from 'debug' const rootName = 'sanity-pte:' export default debug(rootName) export function debugWithName(name: string): debug.Debugger { const namespace = `${rootName}${name}` if (debug && debug.enabled(namespace)) { return debug(namespace) } return debug(rootName) }
2,193
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/getPortableTextMemberSchemaTypes.ts
import { ArraySchemaType, BlockSchemaType, ObjectSchemaType, PortableTextBlock, SchemaType, SpanSchemaType, } from '@sanity/types' import {PortableTextMemberSchemaTypes} from '../types/editor' export function getPortableTextMemberSchemaTypes( portableTextType: ArraySchemaType<PortableTextBlock>, ): Porta...
2,194
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/operationToPatches.ts
import {Path, PortableTextSpan, PortableTextTextBlock} from '@sanity/types' import {omitBy, isUndefined, get} from 'lodash' import { Descendant, InsertNodeOperation, InsertTextOperation, MergeNodeOperation, MoveNodeOperation, RemoveNodeOperation, RemoveTextOperation, SetNodeOperation, SplitNodeOperati...
2,195
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/patches.ts
import {isEqual} from 'lodash' import type {Patch} from '../types/patch' /** * Try to compact a set of patches * */ export function compactPatches(patches: Patch[]) { // If the last patch is unsetting everything, just do that const lastPatch = patches.slice(-1)[0] if (lastPatch && lastPatch.type === 'unset' &...
2,196
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/paths.ts
import {isEqual} from 'lodash' import {Editor, Point, Path as SlatePath, Element, Descendant} from 'slate' import {isKeySegment, Path} from '@sanity/types' import {EditorSelectionPoint, PortableTextMemberSchemaTypes} from '../types/editor' import {ObjectWithKeyAndType} from './ranges' export function createKeyedPath( ...
2,197
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/ranges.ts
import {BaseRange, Editor, Range} from 'slate' import {EditorSelection, EditorSelectionPoint, PortableTextMemberSchemaTypes} from '../types/editor' import {createArrayedPath, createKeyedPath} from './paths' export interface ObjectWithKeyAndType { _key: string _type: string children?: ObjectWithKeyAndType[] } ex...
2,198
0
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src
petrpan-code/sanity-io/sanity/packages/@sanity/portable-text-editor/src/utils/schema.ts
import {Schema} from '@sanity/schema' export function compileType(rawType: any) { return Schema.compile({ name: 'blockTypeSchema', types: [rawType], }).get(rawType.name) }
2,199