Skip to content

Commit

Permalink
feat!: initial studio v3 version
Browse files Browse the repository at this point in the history
BREAKING CHANGE: this version does not work in Studio V2
  • Loading branch information
snorrees committed Jun 15, 2022
1 parent 9b98821 commit 37cdfdb
Show file tree
Hide file tree
Showing 20 changed files with 25,089 additions and 6,147 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.eslintrc.js
commitlint.config.js
lib
lint-staged.config.js
rollup.config.js
node_modules
*.js
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
env: {
browser: true,
node: false,
},
extends: [
'sanity/react', // must come before sanity/typescript
'sanity/typescript',
'plugin:prettier/recommended',
],
overrides: [
{
files: ['*.{ts,tsx}'],
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: './tsconfig.json',
},
plugins: ['prettier'],
rules: {
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-unused-vars': 1,
'no-shadow': 'off',
'react/display-name': 0,
'react/jsx-no-bind': 0,
},
settings: {
'import/ignore': ['\\.css$', '.*node_modules.*', '.*:.*'],
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
};
61 changes: 23 additions & 38 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
name: CI
on: [push]
on:
- push
- pull_request
jobs:
build:
runs-on: ubuntu-latest

test:
runs-on: ${{ matrix.platform }}
name: Node.js ${{ matrix.node-version }} / ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
node-version:
- 16
steps:
- name: Begin CI...
uses: actions/checkout@v2

- name: Use Node 12
uses: actions/setup-node@v1
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Use cached node_modules
uses: actions/cache@v1
with:
path: node_modules
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
nodeModules-
- name: Install dependencies
run: yarn install --frozen-lockfile
env:
CI: true

- name: Lint
run: yarn lint
env:
CI: true

- name: Test
run: yarn test --ci --coverage --maxWorkers=2
env:
CI: true

- name: Build
run: yarn build
env:
CI: true
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run build
#- run: npm test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.DS_Store
package-lock.json
yarn.lock
node_modules
example/node_modules
*.log
.cache
dist
lib/
.idea/
.parcel-cache
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit ""
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.DS_Store
/src
/example
/node_modules
/test
65 changes: 62 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
# LaTeX input for Sanity

https://sanity.io
> **NOTE**
>
> This is the **Sanity Studio v3 version** of sanity-plugin-latex-input.
>
> For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/latex-input).
## Usage
## What is it?

sanity-plugin-latex-input adds support for `latex` schema type, so it can be used in Portable Text Editor (PTE) in Sanity Studio.

![latex-input preview](assets/latex-input.png)

## Installation

```sh
npm install --save sanity-plugin-latex-input@studio-v3
```

or

```sh
yarn add sanity-plugin-latex-input@studio-v3
```
sanity install sanity-plugin-latex-input

## Usage


Import and add the plugin to your studio config in sanity.config.ts (or .js):

```ts
import { latexBlock } from "sanity-plugin-latex-input";

export default createConfig({
/* ... */

plugins: [
latexInput()
]
})
```

You may now use the type name `latex` in your schema, such as in portable text.
Expand Down Expand Up @@ -39,3 +72,29 @@ export default {
```

The Portable Text editor will render a preview of the contents with KaTeX.

## License

MIT-licensed. See LICENSE.

## Develop & test

Make sure to run `npm run build` once, then run

```bash
npm run link-watch
```

In another shell, `cd` to your test studio and run:

```bash
npx yalc add sanity-plugin-latex-input --link && yarn install
```

Now, changes in this repo will be automatically built and pushed to the studio,
triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.

### About build & watch

This plugin uses [@sanity/plugin-sdk](https://github.com/sanity-io/plugin-sdk)
with default configuration for build & watch scripts.
Binary file added assets/latex-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
}
4 changes: 4 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'**/*.{js,jsx}': ['eslint'],
'**/*.{ts,tsx}': ['eslint', () => 'tsc --noEmit'],
}
Loading

0 comments on commit 37cdfdb

Please sign in to comment.