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
function lex(value) { | |
const lexer = new Lexer(value) | |
let ch = "" | |
while ((ch = lexer.next())) { | |
let token = 0 | |
switch (true) { | |
// comment | |
case ch == "/" && (lexer.peek() == "/" || lexer.peek() == "*"): | |
ch = lexer.next() |
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 PropTypes from "prop-types" | |
// import useMethods from "use-methods" | |
import * as traverseDOM from "./traverseDOM" | |
import { Title } from "./Title" | |
import { useForceUpdate } from "./useForceUpdate" | |
function ContentEditable(props) { | |
const ref = React.useRef(null) |
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 methods = (state: State) => ({ | |
clearAll() { | |
return initialState | |
}, | |
focus() { | |
state.focus = true | |
}, | |
blur() { | |
state.focus = false | |
}, |
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, { useEffect, useRef } from "react" | |
import useMethods from "use-methods" | |
const setLocalStorage = (key: string, value: Object) => { | |
const json = JSON.stringify(value) | |
localStorage.setItem(key, json) | |
} | |
const getLocalStorage = (key: string) => { | |
const json = localStorage.getItem(key) |
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, useEffect, useLayoutEffect, useRef, useState } from "react" | |
import PropTypes from "prop-types" | |
import useMethods from "use-methods" | |
import { findNode, findPos, readRoot } from "./traverseDOM" | |
import { Title } from "./Title" | |
const contentEditable = { | |
contentEditable: true, | |
suppressContentEditableWarning: true, |
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, useEffect, useLayoutEffect, useRef, useState } from "react" | |
import PropTypes from "prop-types" | |
import useMethods from "use-methods" | |
import { findNode, findPos, readRoot } from "./traverseDOM" | |
import { Title } from "./Title" | |
const contentEditable = { | |
contentEditable: true, | |
suppressContentEditableWarning: true, |
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 Fragment = props => ( | |
<> | |
{["hello", "world"].map((item, index) => ( | |
<p key={index}> | |
{!item ? <br /> : item} | |
</p> | |
))} | |
</> | |
) | |
return ( |
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
let Fragment = <React.Fragment /> | |
for (const item of ["hello,", "world!"]) { | |
let El = ( | |
<p> | |
{!item ? <br /> : item} | |
</p> | |
) | |
Fragment = ( | |
<Fragment> | |
<El /> |
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
// parse("hello,\nworld!") -> | |
// | |
// <div> | |
// <p> | |
// hello, | |
// </p> | |
// <p> | |
// world! | |
// </p> | |
// </div> |