Skip to content

Commit

Permalink
refactor(structure): Update package folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
surya darma committed May 23, 2021
1 parent 10b85c2 commit 0492f81
Show file tree
Hide file tree
Showing 36 changed files with 24 additions and 15,103 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"private": true,
"workspaces": [
"slate-string-deserialize",
"slate-paste-url-plugin",
"slate-stabilo-plugin",
"packages/*",
"playground"
]
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "slate-paste-url-plugin",
"name": "@imdbsd/slate-paste-url-plugin",
"version": "0.0.1",
"description": "Paste url and transforms into anchor element",
"main": "dist/index.js",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "slate-stabilo-plugin",
"name": "@imdbsd/slate-stabilo-plugin",
"version": "1.0.0",
"description": "slate highlighting text plugin",
"main": "dist/index.js",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "slate-string-deserialize",
"name": "@imdbsd/slate-string-deserialize",
"version": "1.0.4",
"description": "deserialize string to slate value",
"main": "dist/index.js",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion playground/.eslintcache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"/Users/temporary/Works/personal/slate-plugin/playground/src/App.tsx":"1","/Users/temporary/Works/personal/slate-plugin/playground/src/Stories/SlateStringDeserialize.tsx":"2","/Users/temporary/Works/personal/slate-plugin/playground/src/Stories/Button.tsx":"3"},{"size":556,"mtime":1609048817928,"results":"4","hashOfConfig":"5"},{"size":598,"mtime":1609049567508,"results":"6","hashOfConfig":"5"},{"size":941,"mtime":1609050074641,"results":"7","hashOfConfig":"5"},{"filePath":"8","messages":"9","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"yzs728",{"filePath":"10","messages":"11","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"12","messages":"13","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/temporary/Works/personal/slate-plugin/playground/src/App.tsx",[],"/Users/temporary/Works/personal/slate-plugin/playground/src/Stories/SlateStringDeserialize.tsx",[],"/Users/temporary/Works/personal/slate-plugin/playground/src/Stories/Button.tsx",[]]
[{"/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStabilo.stories.tsx":"1","/Users/temporary/Works/personal/slate-plugin/playground/src/SlatePasteUrl.stories.tsx":"2","/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStringDeserialize.stories.tsx":"3","/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStringDeserialize.tsx":"4","/Users/temporary/Works/personal/slate-plugin/playground/src/SlatePasteUrl.tsx":"5","/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStabilo.tsx":"6"},{"size":1961,"mtime":1621665069179,"results":"7","hashOfConfig":"8"},{"size":444,"mtime":1609567894988,"results":"9","hashOfConfig":"8"},{"size":543,"mtime":1609054016105,"results":"10","hashOfConfig":"8"},{"size":774,"mtime":1621668056590,"results":"11","hashOfConfig":"8"},{"size":2433,"mtime":1621740478535,"results":"12","hashOfConfig":"8"},{"size":1069,"mtime":1621741680646,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},"3ku3ya",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"16"},{"filePath":"23","messages":"24","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"25","usedDeprecatedRules":"16"},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStabilo.stories.tsx",[],["28","29"],"/Users/temporary/Works/personal/slate-plugin/playground/src/SlatePasteUrl.stories.tsx",[],"/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStringDeserialize.stories.tsx",[],"/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStringDeserialize.tsx",[],"/Users/temporary/Works/personal/slate-plugin/playground/src/SlatePasteUrl.tsx",["30"],"import {useState, useMemo, FC} from 'react'\nimport {createEditor, Node} from 'slate'\nimport {Slate, Editable, withReact, DefaultElement} from 'slate-react'\nimport {usePasteUrl, Options} from '@imdbsd/slate-paste-url-plugin'\n\nexport type Props = {\n defaultType?: string\n patterns?:\n | {capture: string; type?: string}\n | {capture: string; type?: string}[]\n}\n\nconst Editor: FC<Props> = (props) => {\n const options: Options = {\n defaultType: props.defaultType,\n patterns: props.patterns\n ? Array.isArray(props.patterns)\n ? props.patterns.map((pattern) => ({\n type: pattern.type,\n capture: new RegExp(pattern.capture, 'i'),\n }))\n : {\n type: props.patterns.type,\n capture: new RegExp(props.patterns.capture, 'i'),\n }\n : undefined,\n }\n const withPasteUrl = usePasteUrl(options)\n const editor = useMemo(() => withPasteUrl(withReact(createEditor())), [])\n const [value, setValue] = useState<Node[]>([\n {\n type: 'paragraph',\n children: [\n {\n text: `Slate paste url example, try block some text and paste url or github url to the blocked text.\n `,\n },\n ],\n },\n {\n type: 'paragraph',\n children: [\n {\n text:\n 'To change how the url rendered, edit the renderElement in SlatePasteUrl.tsx',\n },\n ],\n },\n ])\n\n return (\n <Slate\n editor={editor}\n value={value}\n onChange={(newValue) => setValue(newValue)}\n >\n <Editable\n renderElement={(props) => {\n switch (props.element.type) {\n case 'link': {\n return (\n <a\n href={props.element.link as string}\n style={{fontWeight: 'bold'}}\n {...props.attributes}\n >\n {props.children}\n </a>\n )\n }\n case 'github_link': {\n return (\n <a\n href={props.element.link as string}\n style={{fontWeight: 'bold', color: 'blue'}}\n {...props.attributes}\n >\n {props.children}\n </a>\n )\n }\n default: {\n return <DefaultElement {...props} />\n }\n }\n }}\n />\n </Slate>\n )\n}\n\nexport default Editor\n","/Users/temporary/Works/personal/slate-plugin/playground/src/SlateStabilo.tsx",[],{"ruleId":"31","replacedBy":"32"},{"ruleId":"33","replacedBy":"34"},{"ruleId":"35","severity":1,"message":"36","line":29,"column":73,"nodeType":"37","endLine":29,"endColumn":75,"suggestions":"38"},"no-native-reassign",["39"],"no-negated-in-lhs",["40"],"react-hooks/exhaustive-deps","React Hook useMemo has a missing dependency: 'withPasteUrl'. Either include it or remove the dependency array.","ArrayExpression",["41"],"no-global-assign","no-unsafe-negation",{"desc":"42","fix":"43"},"Update the dependencies array to be: [withPasteUrl]",{"range":"44","text":"45"},[947,949],"[withPasteUrl]"]
6 changes: 3 additions & 3 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@imdbsd/slate-paste-url-plugin": "0.0.1",
"@imdbsd/slate-stabilo-plugin": "1.0.0",
"@imdbsd/slate-string-deserialize": "1.0.4",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand All @@ -16,9 +19,6 @@
"slate": "^0.59.0",
"slate-history": "^0.59.0",
"slate-react": "^0.59.0",
"slate-paste-url-plugin": "0.0.1",
"slate-string-deserialize": "1.0.4",
"slate-stabilo-plugin": "1.0.0",
"typescript": "^4.0.3",
"web-vitals": "^0.2.4"
},
Expand Down
2 changes: 1 addition & 1 deletion playground/src/SlatePasteUrl.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useState, useMemo, FC} from 'react'
import {createEditor, Node} from 'slate'
import {Slate, Editable, withReact, DefaultElement} from 'slate-react'
import {usePasteUrl, Options} from 'slate-paste-url-plugin'
import {usePasteUrl, Options} from '@imdbsd/slate-paste-url-plugin'

export type Props = {
defaultType?: string
Expand Down
2 changes: 1 addition & 1 deletion playground/src/SlateStabilo.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useState, useMemo, FC, useRef, useEffect} from 'react'
import {createEditor, Node} from 'slate'
import {Slate, Editable, withReact} from 'slate-react'
import {decorate, renderLeaf, Highlight} from 'slate-stabilo-plugin'
import {decorate, renderLeaf, Highlight} from '@imdbsd/slate-stabilo-plugin'

export type Props = {search: Highlight; value?: Node[]}
const Editor: FC<Props> = (props) => {
Expand Down
28 changes: 14 additions & 14 deletions playground/src/SlateStringDeserialize.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { useState, useMemo, useEffect, FC } from "react";
import { createEditor, Node } from "slate";
import { Slate, Editable, withReact } from "slate-react";
import deserialize, { Options } from "slate-string-deserialize";
import {useState, useMemo, useEffect, FC} from 'react'
import {createEditor, Node} from 'slate'
import {Slate, Editable, withReact} from 'slate-react'
import deserialize, {Options} from '@imdbsd/slate-string-deserialize'

export type Props = {
value: string;
options?: Options;
};
value: string
options?: Options
}
const Editor: FC<Props> = (props) => {
const editor = useMemo(() => withReact(createEditor()), []);
const editor = useMemo(() => withReact(createEditor()), [])
const [value, setValue] = useState<Node[]>(() =>
deserialize(props.value, props.options)
);
)

useEffect(() => {
setValue(deserialize(props.value, props.options));
}, [props.value, props.options]);
setValue(deserialize(props.value, props.options))
}, [props.value, props.options])

return (
<Slate
Expand All @@ -25,7 +25,7 @@ const Editor: FC<Props> = (props) => {
>
<Editable />
</Slate>
);
};
)
}

export default Editor;
export default Editor
Loading

0 comments on commit 0492f81

Please sign in to comment.