{"id":16799116,"url":"https://github.com/rostimelk/pt-string","last_synced_at":"2025-03-22T02:30:54.585Z","repository":{"id":250539005,"uuid":"823703389","full_name":"RostiMelk/pt-string","owner":"RostiMelk","description":"Single line portable text","archived":false,"fork":false,"pushed_at":"2024-08-13T10:18:02.000Z","size":322,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T11:05:46.575Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RostiMelk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-03T14:41:02.000Z","updated_at":"2025-03-07T15:29:40.000Z","dependencies_parsed_at":"2024-07-28T09:42:41.679Z","dependency_job_id":"936460e9-f5e1-4ba8-9ee1-30b5875c714c","html_url":"https://github.com/RostiMelk/pt-string","commit_stats":null,"previous_names":["rostimelk/pt-string"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RostiMelk%2Fpt-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RostiMelk%2Fpt-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RostiMelk%2Fpt-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RostiMelk%2Fpt-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RostiMelk","download_url":"https://codeload.github.com/RostiMelk/pt-string/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244897780,"owners_count":20528289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T09:27:54.634Z","updated_at":"2025-03-22T02:30:54.266Z","avatar_url":"https://github.com/RostiMelk.png","language":"TypeScript","readme":"# pt-string\n\n[![NPM Version](https://img.shields.io/npm/v/sanity-plugin-pt-string)](https://www.npmjs.com/package/sanity-plugin-pt-string)\n\nA single line portable text input.\n\n![Screenshot](./assets/screenshot-dark.png#gh-dark-mode-only)\n![Screenshot](./assets/screenshot-light.png#gh-light-mode-only)\n\n\u003e This is a **Sanity Studio v3** plugin.\n\n## Installation\n\n```sh\nnpm install sanity-plugin-pt-string\n```\n\n## Usage\n\nAdd it as a plugin in `sanity.config.ts` (or .js):\n\n```ts\nimport {defineConfig} from 'sanity'\nimport {ptString} from 'sanity-plugin-pt-string'\n\nexport default defineConfig({\n  //...\n  plugins: [ptString()],\n})\n```\n\nUse in your schema:\n\n```ts\nimport {defineType} from 'sanity'\n\nexport default defineType({\n  name: 'myType',\n  type: 'document',\n  fields: [\n    {\n      name: 'myField',\n      type: 'pt-string',\n      title: 'My Field',\n    },\n  ],\n})\n```\n\n### Preview\n\nAdd a preview config your schema type: `schemaTypes/schema.ts`:\n\n```ts\nimport {defineType, defineField} from 'sanity'\nimport {ptStringPreview} from 'sanity-plugin-pt-string'\n\nexport default defineType({\n  name: 'myType',\n  type: 'document',\n  fields: [\n    defineField({\n      name: 'myField',\n      type: 'pt-string',\n      title: 'My Field',\n      preview: ptStringPreview,\n    }),\n  ],\n  preview: ptStringPreview('myField'),\n})\n```\n\n### Options\n\nCustomize decorators by passing an object with the following properties:\n\n```ts\nimport {defineType} from 'sanity'\n\nexport default defineType({\n  name: 'myType',\n  type: 'document',\n  fields: [\n    {\n      name: 'myField',\n      type: 'pt-string',\n      title: 'My Field',\n      options: {\n        decorators: [\n          {title: 'Strong', value: 'strong'},\n          {title: 'Emphasis', value: 'em'},\n          {title: 'Code', value: 'code'},\n          {title: 'Underline', value: 'underline'},\n          {title: 'Strike', value: 'strike-through'},\n        ],\n      },\n    },\n  ],\n})\n```\n\nAdd your own custom decorators:\n\n```ts\nimport { defineType } from 'sanity';\nimport { HighlightIcon } from '@sanity/icons';\n\nconst HighlightDecorator = (props) =\u003e \u003cspan style={{ backgroundColor: '#ff0', color: '#000' }}\u003e{props.children}\u003c/span\u003e;\n\nexport default defineType({\n  name: 'myType',\n  type: 'document',\n  fields: [\n    {\n      name: 'myField',\n      type: 'pt-string',\n      title: 'My Field',\n      options: {\n        decorators: [\n          { title: 'Strong', value: 'strong' },\n          { title: 'Emphasis', value: 'em' },\n          { title: 'Code', value: 'code' },\n          { title: 'Underline', value: 'underline' },\n          { title: 'Strike', value: 'strike-through' },\n          // Custom highlight decorator\n          {\n            title: 'Highlight',\n            value: 'highlight',\n            icon: HighlightIcon,\n            component: HighlightDecorator,\n          },\n        ],\n      },\n    },\n  ],\n});\n```\n\n## Usage\n\nThe data is output as a Portable Text block. You can use the `PortableText` component from `@portabletext/react` to render it in React:\n\n```tsx\nimport {PortableText} from '@portabletext/react'\n\nconst PortableTextParagraph = (props) =\u003e {\n  return \u003cPortableText value={props.value} /\u003e\n}\n```\n\nIf you want to customize the rendering of the blocks, you can pass a `components` prop to the `PortableText` component. Following is an example of how to render your content within a `h2` tag:\n\n```tsx\nimport {PortableText} from '@portabletext/react'\n\nconst components = {\n  block: {\n    normal: ({ children }) =\u003e \u003ch2\u003e{children}\u003c/h2\u003e\n  }\n}\n\nconst PortableTextHeading = (props) =\u003e {\n  return \u003cPortableText value={props.value} components={components} /\u003e\n}\n```\n\n## Migrations\n\nSee the migration script inside ./migrations/transformStringToPortableText.js of this Repo.\n\nFollow the instructions inside the script and set the \\_type and field name you wish to target.\n\nPlease take a backup first!\n\n## License\n\n[MIT](LICENSE) © Rostislav Melkumyan\n\n## Develop \u0026 test\n\nThis plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)\nwith default configuration for build \u0026 watch scripts.\n\nSee [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)\non how to run this plugin with hotreload in the studio.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frostimelk%2Fpt-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frostimelk%2Fpt-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frostimelk%2Fpt-string/lists"}