- } type="text">
+ } type="text">
转调
diff --git a/src/view/Header/RightInfoBlock/index.js b/src/view/Header/RightInfoBlock/index.js
index 7869987..1ec64f4 100644
--- a/src/view/Header/RightInfoBlock/index.js
+++ b/src/view/Header/RightInfoBlock/index.js
@@ -66,7 +66,6 @@ const handleChangeAuthor = wrappedAction((index, value) => {
});
function RightInfoBlock() {
- // TODO: working
return (
{
+ state.selectedNotationKey = notation.key;
+ state.shouldNotationBlurAfterClick = false;
+ if (state.tieSourceKey) {
+ // 处理连音线
+ if (state.tieSourceKey === notation.key) {
+ state.tieSourceKey = null;
+ // NOTICE: 如果要添加其他逻辑注意这里的return
+ return;
+ }
+ const {
+ notation: sourceNotation,
+ paragraph: sourceParagraph,
+ } = findParagraphAndNotation(state.tieSourceKey);
+ if (!sourceNotation) {
+ state.tieSourceKey = null;
+ return;
+ }
+ if (sourceParagraph.notations.includes(notation)) {
+ sourceNotation.tieTo = notation.key;
+ notation.tieTo = sourceNotation.key;
+ } else {
+ message.warn("只允许相同段落的音符相连!");
+ }
+ state.tieSourceKey = null;
+ }
+ });
+
const underlineOffset = P.underlineStepOffsetY * (notation.underline | 0);
const octaveInitialOffset =
notation.octave > 0
@@ -65,7 +104,7 @@ function Notation({ offsetX, notation }) {
const renderNote = () => {
let transform;
- if (notation.note === Notes.extend) {
+ if (notation.note === notations.extend) {
// 延音符太长了缩短一点
transform = "scale(0.8, 1)";
}
@@ -83,21 +122,46 @@ function Notation({ offsetX, notation }) {
type="octave"
cx="0"
cy={octaveInitialOffset + octaveStepOffset * i}
+ fill="currentColor"
r="2"
>
));
};
+ const options = getNotationContextItems(notation, paragraph);
return (
-
- {renderPrefixSups()}
- {renderTopDecorators()}
- {renderNote()}
- {notation.dotted && (
-
- )}
- {renderOctave()}
-
+
+
+ {renderPrefixSups()}
+ {renderTopDecorators()}
+ {renderNote()}
+ {notation.dotted && (
+
+ )}
+ {renderOctave()}
+
+
);
}
diff --git a/src/view/Notation/index.module.css b/src/view/Notation/index.module.css
new file mode 100644
index 0000000..3b78966
--- /dev/null
+++ b/src/view/Notation/index.module.css
@@ -0,0 +1,3 @@
+.selectedNotation {
+ color: coral;
+}
\ No newline at end of file
diff --git a/src/view/Paragraph/index.js b/src/view/Paragraph/index.js
index 281fd44..ee1cfab 100644
--- a/src/view/Paragraph/index.js
+++ b/src/view/Paragraph/index.js
@@ -1,12 +1,17 @@
-import { useMemo } from "react";
+import { observer } from "mobx-react-lite";
+import EditableContent from "../../component/EditableContent";
import P, {
calcNotationAboveOffset,
calcNotationPrefixOffset,
calcNotationWidth,
calcParagraphAboveOffset,
- calcParagraphHeight,
+ calcParagraphContentHeight,
calcParagraphWidth,
} from "../../util/placement";
+import {
+ getParagraphMenuOptions,
+ handleSelectParagraphMenu,
+} from "../../menu/paragraph";
import Notation from "../Notation";
import Row from "../Row";
@@ -34,6 +39,7 @@ function Paragraph({ paragraph, offsetY, alignJustify }) {
return width;
};
+ // 缓存音符偏移量
const noteOffsets = notations.map((_, i) => {
return (
// 渲染音符时坐标为其中心,故偏移半个音符宽
@@ -116,10 +122,11 @@ function Paragraph({ paragraph, offsetY, alignJustify }) {
0.0062948773732605465 * x * x +
0.6378785891964498 * x -
0.6843414475200537;
- y = Math.max(Math.min(y, P.maxTieHeight), P.minTieHeight);
+ y = Math.max(Math.min(y, P.maxTieBezierOffset), P.minTieHeight);
const bezierY = offsetY - y;
return (
{
+ const height = calcParagraphContentHeight(paragraph);
+ return (
+
+
+
+ );
+ };
+
return (
+ {renderParagraphMask()}
{renderTies()}
{paragraph.notations.map((n, i) => (
-
+
))}
{renderUnderlines()}
);
}
-export default Paragraph;
+export default observer(Paragraph);
diff --git a/src/view/Text/index.js b/src/view/Text/index.js
index 4bbc7ae..24f4df3 100644
--- a/src/view/Text/index.js
+++ b/src/view/Text/index.js
@@ -16,7 +16,7 @@ export default function Text({ children, editable, ...props }) {
dominantBaseline="hanging"
stroke="none"
fontWeight="bold"
- fill="black"
+ fill="currentColor"
dangerouslySetInnerHTML={{ __html: escapeHtml(children) }}
{...props}
>
@@ -36,7 +36,7 @@ export default function Text({ children, editable, ...props }) {
dominantBaseline="hanging"
stroke="none"
fontWeight="bold"
- fill="black"
+ fill="currentColor"
{...props}
>
{children}
diff --git a/src/view/menu/editor.js b/src/view/menu/editor.js
deleted file mode 100644
index 3f6d632..0000000
--- a/src/view/menu/editor.js
+++ /dev/null
@@ -1,97 +0,0 @@
-import {
- EditOutlined,
- FileTextOutlined,
- FolderOpenOutlined,
- PlusOutlined,
- SaveOutlined,
-} from "@ant-design/icons";
-import { Menu } from "antd";
-import store from "../../store/global";
-import { go, runInWrappedAction } from "../../store/history";
-
-const { SubMenu } = Menu;
-const fileMenu = (
-
-);
-const editMenu = (
-
-);
-
-const convertMenu = (
-
-);
-
-function handleMenu({ key }) {
- switch (key) {
- case "undo":
- go(-1);
- break;
- case "redo":
- go(1);
- break;
- case "reset-title":
- runInWrappedAction(() => {
- store.title = "【歌曲名称】";
- });
- break;
- case "reset-authors":
- store.authors = [
- "【作曲者】 作曲",
- "【填词者】 填词",
- "【记谱者】 记谱",
- ];
- break;
- }
-}
-
-export { fileMenu, editMenu, convertMenu };