(Also see [remarkable][], the markdown parser created by the author of this cheatsheet)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const {EditorState, Selection} = require("prosemirror-state") | |
| const {MenuBarEditorView} = require("prosemirror-menu") | |
| const {DOMParser, DOMSerializer, Schema} = require("prosemirror-model") | |
| const {schema: baseSchema} = require("prosemirror-schema-basic") | |
| const {exampleSetup} = require("prosemirror-example-setup") | |
| const {keymap} = require("prosemirror-keymap") | |
| const CodeMirror = require("codemirror") | |
| require("codemirror/mode/javascript/javascript") | |
| let view, menuView, schema = new Schema({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from 'react' | |
| import ReactDOM from 'react-dom' | |
| import { EditorState } from 'prosemirror-state' | |
| import { EditorView } from 'prosemirror-view' | |
| import { Node, Schema } from 'prosemirror-model' | |
| import applyDevTools from 'prosemirror-dev-tools' | |
| import styled from 'styled-components' | |
| // Here we have the (too simple) React component which | |
| // we'll be rendering content into. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Consistent version of `useMutableSource`, Inspired by https://github.com/pmndrs/valtio/blob/master/src/useMutableSource.ts | |
| import { useEffect, useRef, useState } from 'react'; | |
| const TARGET = Symbol('target'); | |
| const GET_VERSION = Symbol('getVersion'); | |
| export type Source<TargetType extends any, VersionType extends any> = { | |
| [TARGET]: TargetType; | |
| [GET_VERSION]: (target: TargetType) => VersionType; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Skype | |
| Min: 6 | |
| Max: 32 | |
| Can contain: a-z A-Z 0-9 . , _ - | |
| Other: Must start with a letter | |
| Min: 1 | |
| Max: 15 | |
| Can contain: a-z A-Z 0-9 _ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import ReactDOM from 'react-dom' | |
| import './index.css' | |
| import { createTable } from 'react-table' | |
| type Row = { | |
| firstName: string | |
| lastName: string |
Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where each x is replaced with a random hexadecimal digit from 0 to f, and y is replaced with a random hexadecimal digit from 8 to b.
There's also @LeverOne's approach using iteration, which is one byte shorter.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as Y from 'yjs' | |
| import * as mutex from 'lib0/mutex.js' | |
| import { Observable } from 'lib0/observable.js' | |
| import PouchDB from 'pouchdb'; | |
| // This is the name of the top level Y.Map that is used to construct the main pouchDB | |
| // JSON document. | |
| const topDataYMapName = 'data'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Current Adapter Example | |
| * This is a simple adapter, some are extremely complex... | |
| * It is not immediately obvious why some code lives in the adapter and some in the foundation | |
| * The Select alone is over 700 lines of component logic... | |
| **/ | |
| MDCCheckboxFoundation({ | |
| addClass: (className) => this.root_.classList.add(className), | |
| removeClass: (className) => this.root_.classList.remove(className), | |
| setNativeControlAttr: (attr, value) => this.nativeCb_.setAttribute(attr, value), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useCallback, FunctionComponent } from 'react' | |
| import { useField } from 'payload/components/forms' | |
| import { Field } from 'payload/types' | |
| import Editor from 'rich-markdown-editor' | |
| // Make sure to never re-render the editor, since it tracks the value on its own. | |
| const MemorizedEditor = React.memo(Editor, (prev, next) => prev.id === next.id) | |
| type FieldWithPath = Field & { path?: string } |
OlderNewer