Skip to content

Commit

Permalink
Merge pull request #196 from michelson/michelson/upgrade-dependencies
Browse files Browse the repository at this point in the history
Michelson/upgrade dependencies
  • Loading branch information
michelson authored Sep 10, 2021
2 parents 3d40822 + 04b3545 commit ae19d66
Show file tree
Hide file tree
Showing 24 changed files with 5,512 additions and 5,623 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
packages/**/*/package

.vercel

lerna-debug.log
93 changes: 44 additions & 49 deletions components/Live.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import Highlight, {defaultProps} from 'prism-react-renderer'
import {LiveProvider, LiveEditor, LiveError, LivePreview} from 'react-live'
import {mdx} from '@mdx-js/react'
import Dante ,{
import React from "react";
import Highlight, { defaultProps } from "prism-react-renderer";
import { LiveProvider, LiveEditor, LiveError, LivePreview } from "react-live";
import { mdx } from "@mdx-js/react";
import Dante, {
ImageBlockConfig,
EmbedBlockConfig,
VideoBlockConfig,
Expand All @@ -15,45 +15,43 @@ import Dante ,{
CodeBlockConfig,
PrismDraftDecorator,
LinkDecorator,
utils
} from '../packages/dante2/src/editor/components/Dante'
utils,
} from "../packages/dante2/src/editor/components/Dante";
// 'Dante2'
//'../packages/dante2/src/editor/components/Dante'
//'Dante2' // use Dante2 to point to the component package

import {
CustomWidgetconfig
} from '../data/customWidget'
import { CompositeDecorator } from 'draft-js'
import MultiDecorator from 'draft-js-multidecorators'
import { CustomWidgetconfig } from "../data/customWidget";
import { CompositeDecorator } from "draft-js";
import MultiDecorator from "draft-js-multidecorators";

//import {code} from './site/data/poc.js'
//import Dante from './editor/components/Dante/Dante.js'
//import {CodeBlockConfig} from './editor/components/blocks/code'
import Prism from 'prismjs'
import Prism from "prismjs";

//import {PrismDraftDecorator} from './editor/components/decorators/prism'
//import Link from './editor/components/decorators/link'
//import findEntities from './editor/utils/find_entities'

import contentData from '../data/poc.js'
import { State, Toggle } from 'react-powerplug'
import config from '../data/constants.js'
import contentData from "../data/poc.js";
import { State, Toggle } from "react-powerplug";
import config from "../data/constants.js";

function Button (){
return <p>sjsjsjsjsjsjs</p>
function Button() {
return <p>sjsjsjsjsjsjs</p>;
}
export default function Live({children, className, live, render}) {
const language = className.replace(/language-/, '')
export default function Live({ children, className, live, render }) {
const language = className.replace(/language-/, "");

if (live) {
return (
<div>
<LiveProvider
code={children.trim()}
transformCode={code => '/** @jsx mdx */' + code}
transformCode={(code) => "/** @jsx mdx */" + code}
scope={{
mdx,
mdx,
Dante,
ImageBlockConfig,
EmbedBlockConfig,
Expand All @@ -75,62 +73,59 @@ export default function Live({children, className, live, render}) {

Prism,

Button,
contentData,
State,
Button,
contentData,
State,
Toggle,
config
config,
}}
>

<div className="grid grid-cols-1 sm:grid-rows-2 gap-0 border-gray-200 border-2 rounded-md shadow-md">

<div className="grid grid-cols-1 sm:grid-rows-2--- gap-0 border-gray-200 border-2 rounded-md shadow-md">
<div className=" p-8 shadow-lg">
<LivePreview />
</div>

<div style={{
backgroundColor: 'rgb(42, 39, 52)',
color: 'rgb(154, 134, 253)',
padding: '20px'

<div
style={{
backgroundColor: "rgb(42, 39, 52)",
color: "rgb(154, 134, 253)",
padding: "20px",
}}
className="p-8 shadow-lg text-sm">
className="p-8 shadow-lg text-sm"
>
<LiveEditor />
</div>
</div>

<LiveError className="bg-red-600 text-black font-bold" />
</LiveProvider>
</div>
)
);
}

if (render) {
return (
<div style={{marginTop: '40px'}}>
<div style={{ marginTop: "40px" }}>
<LiveProvider code={children}>
<LivePreview />
</LiveProvider>
</div>
)
);
}

return (
<Highlight
{...defaultProps}
code={children.trim()}
language={language}>
{({className, style, tokens, getLineProps, getTokenProps}) => (
<pre className={className} style={{...style, padding: '20px'}}>
<Highlight {...defaultProps} code={children.trim()} language={language}>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={{ ...style, padding: "20px" }}>
{tokens.map((line, i) => (
<div key={i} {...getLineProps({line, key: i})}>
<div key={i} {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span key={key} {...getTokenProps({token, key})} />
<span key={key} {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
)
}
);
}
17 changes: 8 additions & 9 deletions components/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link'
import Link from "next/link";

export default function Index({ posts }) {
export default function Index({ posts, path }) {
return (
<div className="py-5 fixed z-10 inset-0 flex-none h-full bg-black bg-opacity-25 w-full lg:bg-white lg:static lg:h-auto lg:overflow-y-visible lg:pt-0 lg:w-60 xl:w-72 lg:block hidden">
<div className="py-5 h-full overflow-y-auto scrolling-touch lg:h-auto lg:block lg:relative lg:sticky lg:bg-transparent overflow-hidden lg:top-18 bg-white mr-24 lg:mr-0">
Expand All @@ -9,20 +9,19 @@ export default function Index({ posts }) {
</p>
<ul>
{posts.map((post) => (
<li
key={post.filePath}>
<li key={post.filePath}>
<Link
as={`/v2/posts/${post.filePath.replace(/\.mdx?$/, '')}`}
href={`/v2/posts/[slug]`}
as={`${path}/posts/${post.filePath.replace(/\.mdx?$/, "")}`}
href={`${path}/posts/[slug]`}
>
<a className="px-3 py-2 transition-colors duration-200 relative block hover:text-gray-900 text-gray-500">
{post.data.title}
</a>
</Link>
</li>
))}
</ul>
</ul>
</div>
</div>
)
}
);
}
Empty file added importer/draftjs.json
Empty file.
71 changes: 71 additions & 0 deletions importer/parser.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

require 'pry'
require 'json'
require 'active_support'
require "active_support/core_ext"


string = "hola como estas"
blocks = {
blocks: [
{"offset"=>3, "length"=>3, "style"=>"CUSTOM_COLOR_#db2929"},
{"offset"=>5, "length"=>10, "style"=>"BOLD"},
{"offset"=>5, "length"=>4, "style"=>"ITALIC"}
]
}
block_hash = ActiveSupport::HashWithIndifferentAccess.new(blocks)
ranges = block_hash[:blocks]

i = 0
r = string.split("").inject({}){|res, l| res[i]= l; i+=1 ; res }
# {0=>h, 1=>l ...}

refs = r.map{|k,v|
arr = []
ranges.each_with_index do |o, i|
range = (o[:offset]..(o[:offset]+o[:length]-1))
#puts "#{k} in #{range}"
arr << i if (range).include?(k)
end
arr
}

# [[], [], [], [0], [0], [0, 1, 2], [1, 2], [1, 2], [1, 2], [1], [1], [1], [1], [1], [1]]


groups = [{text: "", marks: []}]
current_group = 0
refs.each_with_index{|o,i|
groups[current_group][:text] << r[i].to_s
groups[current_group][:marks] = o
if refs[i+1] != refs[i]
current_group += 1
groups.push({text: "", marks: []})
end
}

def convert_ranges(range)
case range[:style]
when "BOLD" then { type: 'bold' }
when "ITALIC" then { type: 'italic' }
else
if range[:style].include?('CUSTOM_COLOR_')
color = range[:style].gsub("CUSTOM_COLOR_", "")
{
"type": "textStyle",
"attrs": {
"color": color
}
}
end
end
end

final_groups = groups.map{|o|
o.merge!( marks: o[:marks].map{|o| convert_ranges(ranges[o]) } )
o = { text: o[:text] } if o[:marks].blank?
o
}

binding.pry

Loading

0 comments on commit ae19d66

Please sign in to comment.