-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for links, wysiwyg style (#45)
- add create link via pasting over selected text - add hovering links menus for viewing, updating, and clearing existing links - add inspect element on aux click (for debugging) - add more AST viewing tools to the editor (for debugging)
- Loading branch information
Showing
13 changed files
with
1,004 additions
and
438 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
|
||
import unified from "unified"; | ||
import markdown from "remark-parse"; | ||
import remarkGfm from 'remark-gfm' | ||
import { remarkToSlate, slateToRemark, mdastToSlate } from "remark-slate-transformer"; | ||
const parser = unified().use(markdown).use(remarkGfm as any) | ||
|
||
function isImageUrl(url: string) { | ||
if (!url) return false; | ||
|
||
const mdast = parser.parse(url) | ||
console.log(mdast); | ||
console.log(mdastToSlate(mdast as any)) // expects Root, parser returns "Node" (its actually a root in my case) | ||
} | ||
|
||
|
||
// const isImageUrl = url => { | ||
// if (!url) return false | ||
// if (!isUrl(url)) return false | ||
// const ext = new URL(url).pathname.split('.').pop() | ||
// return imageExtensions.includes(ext) | ||
// } | ||
// https://cdn.shopify.com/s/files/1/3106/5828/products/IMG_9385_1024x1024@2x.jpg?v=1577795595 | ||
// const imageExtensionRegex = | ||
|
||
// Copied from this repo: https://github.com/arthurvr/image-extensions | ||
// Which is an npm package that is just a json file | ||
const imageExtensions = [ | ||
"ase", | ||
"art", | ||
"bmp", | ||
"blp", | ||
"cd5", | ||
"cit", | ||
"cpt", | ||
"cr2", | ||
"cut", | ||
"dds", | ||
"dib", | ||
"djvu", | ||
"egt", | ||
"exif", | ||
"gif", | ||
"gpl", | ||
"grf", | ||
"icns", | ||
"ico", | ||
"iff", | ||
"jng", | ||
"jpeg", | ||
"jpg", | ||
"jfif", | ||
"jp2", | ||
"jps", | ||
"lbm", | ||
"max", | ||
"miff", | ||
"mng", | ||
"msp", | ||
"nitf", | ||
"ota", | ||
"pbm", | ||
"pc1", | ||
"pc2", | ||
"pc3", | ||
"pcf", | ||
"pcx", | ||
"pdn", | ||
"pgm", | ||
"PI1", | ||
"PI2", | ||
"PI3", | ||
"pict", | ||
"pct", | ||
"pnm", | ||
"pns", | ||
"ppm", | ||
"psb", | ||
"psd", | ||
"pdd", | ||
"psp", | ||
"px", | ||
"pxm", | ||
"pxr", | ||
"qfx", | ||
"raw", | ||
"rle", | ||
"sct", | ||
"sgi", | ||
"rgb", | ||
"int", | ||
"bw", | ||
"tga", | ||
"tiff", | ||
"tif", | ||
"vtf", | ||
"xbm", | ||
"xcf", | ||
"xpm", | ||
"3dv", | ||
"amf", | ||
"ai", | ||
"awg", | ||
"cgm", | ||
"cdr", | ||
"cmx", | ||
"dxf", | ||
"e2d", | ||
"egt", | ||
"eps", | ||
"fs", | ||
"gbr", | ||
"odg", | ||
"svg", | ||
"stl", | ||
"vrml", | ||
"x3d", | ||
"sxd", | ||
"v2d", | ||
"vnd", | ||
"wmf", | ||
"emf", | ||
"art", | ||
"xar", | ||
"png", | ||
"webp", | ||
"jxr", | ||
"hdp", | ||
"wdp", | ||
"cur", | ||
"ecw", | ||
"iff", | ||
"lbm", | ||
"liff", | ||
"nrrd", | ||
"pam", | ||
"pcx", | ||
"pgf", | ||
"sgi", | ||
"rgb", | ||
"rgba", | ||
"bw", | ||
"int", | ||
"inta", | ||
"sid", | ||
"ras", | ||
"sun", | ||
"tga" | ||
] |
Oops, something went wrong.