chore: update prettier setting

This commit is contained in:
zerosoul
2022-06-12 15:30:14 +08:00
parent 14b4678d9e
commit 516794d352
209 changed files with 2435 additions and 4588 deletions
+15 -15
View File
@@ -4,7 +4,7 @@ export const CONFIG = {
editableProps: {
spellCheck: false,
autoFocus: true,
placeholder: "Type…",
placeholder: "Type…"
},
trailingBlock: { type: ELEMENT_PARAGRAPH },
softBreak: {
@@ -13,11 +13,11 @@ export const CONFIG = {
{
hotkey: "shift+enter",
query: {
allow: [ELEMENT_IMAGE, ELEMENT_PARAGRAPH],
},
},
],
},
allow: [ELEMENT_IMAGE, ELEMENT_PARAGRAPH]
}
}
]
}
},
exitBreak: {
options: {
@@ -25,9 +25,9 @@ export const CONFIG = {
{
hotkey: "mod+enter",
query: {
allow: [ELEMENT_IMAGE, ELEMENT_PARAGRAPH],
},
},
allow: [ELEMENT_IMAGE, ELEMENT_PARAGRAPH]
}
}
// {
// hotkey: "mod+shift+enter",
// before: true,
@@ -40,14 +40,14 @@ export const CONFIG = {
// allow: KEYS_HEADING,
// },
// },
],
},
]
}
},
selectOnBackspace: {
options: {
query: {
allow: [ELEMENT_IMAGE],
},
},
},
allow: [ELEMENT_IMAGE]
}
}
}
};
+23 -39
View File
@@ -23,7 +23,7 @@ import {
// usePlateEditorRef,
// ELEMENT_IMAGE,
// useComboboxControls,
MentionCombobox,
MentionCombobox
} from "@udecode/plate";
import { createComboboxPlugin } from "@udecode/plate-combobox";
import { ReactEditor } from "slate-react";
@@ -44,7 +44,7 @@ const Plugins = ({
id = "",
placeholder = "Write some markdown...",
sendMessages,
members = [],
members = []
}) => {
// const { getMenuProps, getItemProps } = useComboboxControls();
const [context, to] = id.split("_");
@@ -57,7 +57,7 @@ const Plugins = ({
const initialProps = {
...CONFIG.editableProps,
className: "box",
placeholder,
placeholder
};
const plateEditor = getPlateEditorRef(`${TEXT_EDITOR_PREFIX}_${id}`);
useEffect(() => {
@@ -91,13 +91,7 @@ const Plugins = ({
(evt) => {
// 是否在at操作
const mentionInputs = findMentionInput(plateEditor);
if (
mentionInputs ||
evt.shiftKey ||
evt.ctrlKey ||
evt.altKey ||
evt.isComposing
) {
if (mentionInputs || evt.shiftKey || evt.ctrlKey || evt.altKey || evt.isComposing) {
return true;
}
evt.preventDefault();
@@ -107,14 +101,14 @@ const Plugins = ({
Transforms.delete(plateEditor, {
at: {
anchor: Editor.start(plateEditor, []),
focus: Editor.end(plateEditor, []),
},
focus: Editor.end(plateEditor, [])
}
});
},
{
// eventTypes: ["keydown"],
target: editableRef,
when: !cmdKey,
when: !cmdKey
}
);
useKey(
@@ -125,7 +119,7 @@ const Plugins = ({
},
{
eventTypes: ["keydown", "keyup"],
target: editableRef,
target: editableRef
}
);
const pluginArr = [
@@ -133,7 +127,7 @@ const Plugins = ({
createNodeIdPlugin(),
createSoftBreakPlugin(CONFIG.softBreak),
createTrailingBlockPlugin(CONFIG.trailingBlock),
createExitBreakPlugin(CONFIG.exitBreak),
createExitBreakPlugin(CONFIG.exitBreak)
];
const plugins = createPlugins(
enableMentions
@@ -145,17 +139,17 @@ const Plugins = ({
console.log("mention", item);
const {
text,
data: { uid },
data: { uid }
} = item;
return { value: `@${text}`, uid };
},
insertSpaceAfterMention: true,
},
}),
insertSpaceAfterMention: true
}
})
])
: pluginArr,
{
components,
components
}
);
@@ -179,20 +173,16 @@ const Plugins = ({
const { value, mentions } = getMixedText(v.children);
const prev = tmps[tmps.length - 1];
if (!prev) {
tmps.push([
{ type: "text", content: value, properties: { mentions } },
]);
tmps.push([{ type: "text", content: value, properties: { mentions } }]);
} else {
if (Array.isArray(prev)) {
tmps[tmps.length - 1].push({
type: "text",
content: value,
properties: { mentions },
properties: { mentions }
});
} else {
tmps.push([
{ type: "text", content: value, properties: { mentions } },
]);
tmps.push([{ type: "text", content: value, properties: { mentions } }]);
}
}
}
@@ -202,8 +192,8 @@ const Plugins = ({
type: "text",
content: tmp.map((t) => t.content).join("\n"),
properties: {
mentions: tmp.map((t) => t.properties?.mentions || []).flat(),
},
mentions: tmp.map((t) => t.properties?.mentions || []).flat()
}
}
: tmp;
});
@@ -229,13 +219,7 @@ const Plugins = ({
// component={StyledCombobox}
onRenderItem={({ item }) => {
console.log("wtf", item);
return (
<Contact
key={item.data.uid}
uid={item.data.uid}
interactive={false}
/>
);
return <Contact key={item.data.uid} uid={item.data.uid} interactive={false} />;
}}
items={members.map((id) => {
const data = contactData[id];
@@ -246,8 +230,8 @@ const Plugins = ({
text: name,
data: {
uid,
...rest,
},
...rest
}
};
})}
/>
@@ -273,7 +257,7 @@ export const useMixedEditor = (key) => {
};
return {
focus,
insertText,
insertText
};
};
export default Plugins;
+4 -4
View File
@@ -2,12 +2,12 @@ import {
createBasicElementsPlugin,
createImagePlugin,
createParagraphPlugin,
createSelectOnBackspacePlugin,
createSelectOnBackspacePlugin
} from "@udecode/plate";
import { CONFIG } from "./config";
const basicElements = [
createParagraphPlugin(), // paragraph element
createParagraphPlugin() // paragraph element
];
export const PLUGINS = {
@@ -16,6 +16,6 @@ export const PLUGINS = {
image: [
createBasicElementsPlugin(),
createImagePlugin(),
createSelectOnBackspacePlugin(CONFIG.selectOnBackspace),
],
createSelectOnBackspacePlugin(CONFIG.selectOnBackspace)
]
};
@@ -1,6 +1,6 @@
const nodeTypes = {
paragraph: "p",
image: "img",
image: "img"
};
export default nodeTypes;
@@ -1,13 +1,10 @@
import {
ELEMENT_PARAGRAPH,
ELEMENT_PARAGRAPH
// TElement,
} from "@udecode/plate";
// import { Text } from 'slate'
export const createElement = (
text = "",
{ type = ELEMENT_PARAGRAPH, mark } = {}
) => {
export const createElement = (text = "", { type = ELEMENT_PARAGRAPH, mark } = {}) => {
const leaf = { text };
if (mark) {
leaf[mark] = true;
@@ -15,7 +12,7 @@ export const createElement = (
return {
type,
children: [leaf],
children: [leaf]
};
};