Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React md editor #30

Merged
merged 2 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 77 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,85 @@
name: CI
name: CI & Release
on:
- push
- pull_request
# Build on pushes to release branches
push:
branches: [main, v3]
# Build on pull requests targeting release branches
pull_request:
branches: [main, v3]
workflow_dispatch:
inputs:
release:
description: Release new version
required: true
default: false
type: boolean

jobs:
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
log-the-inputs:
name: Log inputs
runs-on: ubuntu-latest
steps:
- run: |
echo "Inputs: $INPUTS"
env:
INPUTS: ${{ toJSON(inputs) }}

build:
name: Lint & Build
runs-on: ubuntu-latest
steps:
- 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
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- run: npm ci
- run: npm run lint --if-present
- run: npm run prepublishOnly

# test:
# name: Test
# needs: build
# strategy:
# matrix:
# os: [ macos-latest, ubuntu-latest ]
# node: [ lts/*, current ]
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node }}
# cache: npm
# - run: npm ci
# - run: npm test --if-present

release:
name: Semantic release
needs: build
runs-on: ubuntu-latest
# only run if opt-in during workflow_dispatch
if: inputs.release == true
steps:
- uses: actions/checkout@v3
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run build
#- run: npm test
node-version: lts/*
cache: npm
- run: npm ci
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release --dry-run
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
19 changes: 0 additions & 19 deletions .github/workflows/npm-publish.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@sanity/semantic-release-preset",
"branches": [
{"name": "main", "channel": "studio-v3", "prerelease": "v3-studio"},
{"name": "main-post-ga"}
]
}
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@

A Markdown editor with preview for Sanity Studio.

Supports Github flavored markdown and image uploads. You can either drag image(s) into the editor or click the bottom bar to bring up a file selector. The resulting image URL(s) are inserted with a default width parameter which you can change to your liking using the [Sanity image pipeline parameters](https://www.sanity.io/docs/image-urls).
Supports Github flavored markdown and image uploads. You can either drag image(s) into the editor or click the bottom bar to bring up a file selector.
The resulting image URL(s) are inserted with a default width parameter which you can change to your liking using the [Sanity image pipeline parameters](https://www.sanity.io/docs/image-urls).

### Known issues with the current v3 version

![Markdown input](assets/markdown-input.png)
The v2 version used react-mde for editing. The current v3 version @uiw/react-md-editor. This may change before GA.

At the moment the v3 version does not have drag-and-drop image upload support.
You can still add markdown image tags, but you will have to get the image url yourself for now.

## Installation

Expand Down Expand Up @@ -74,3 +80,9 @@ with default configuration for build & watch scripts.
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
on how to run this plugin with hotreload in the studio.

### Release new version

Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-markdown/actions).
Make sure to select the main/v3 branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.
Loading