import { forwardRef, useEffect, useId, useRef, useState } from 'react';
import { Col } from '../components/Col';
import { Rect } from '../components/Rect';
import { Text } from '../components/Text';
import { Row } from '../components/Row';
import { SVG } from '../components/SVG';
import { Align } from '../components/Align';
import {
BBoxWithChildren,
Measure,
useBluefishLayout,
withBluefish,
withBluefishComponent,
useBluefishContext,
} from '../bluefish';
import { Ref } from '../components/Ref';
import { Group } from '../components/Group';
import { Line } from '../components/Line';
import { Arrow } from '../components/Arrow';
import { Space } from '../components/Space';
import { Connector } from '../components/Connector';
import _ from 'lodash';
import { Align2 } from '../components/Align2';
export type CharProps = {
value: string;
opId: string;
deleted: boolean;
marks: ('italic' | 'bold')[];
};
const foo = {
the: 'center',
of: 'A',
// to: 'B',
to: { the: 'center', of: 'B' },
};
export const Char = forwardRef(function Char({ value, marks, opId }: CharProps, ref: any) {
const tile = useRef(null);
const leftHandle = useRef(null);
const rightHandle = useRef(null);
const letter = useRef(null);
const opIdLabel = useRef(null);
return (
// TODO: use x and y to position the group
, ]} />
, ]} />
} centerLeft={} />
} centerRight={} />
);
});
export type MarkOpProps = {
action: string;
markType: string;
backgroundColor: string;
borderColor: string;
opId: string;
start: { opId: string };
end: { opId: string };
};
export const MarkOp: React.FC = forwardRef(function MarkOp(
{ action, markType, backgroundColor, borderColor, start, end, opId },
ref: any,
) {
const rectRef = useRef(null);
const textRef = useRef(null);
return (
{/* TODO: text measurement is broken, since the text isn't actually centered */}
{/* ...however, using a rect instead results in a properly centered component */}
{/* */}
, ]} />
, ]} />
, ]} />
{/* make a row component and a column component */}
{/* align the two components */}
// proposed API:
// (<>
//
//
// {rect}
//
//
//
// {rect}
//
//
// {rect}
// {text}
//
// >)}>
// {/* TODO: remove width */}
//
//
//
//
// {/* TODO: remove width */}
//
//
// {/* TODO: starting to think the naming is backwards. currently second arg to align mutates, but first doesn't.
// maybe I should flip them?
// Rationale: Read it as "align first to second," which implies that the first is mutated. */}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
);
});
export type PeritextProps = {
chars: CharProps[];
markOps: MarkOpProps[];
};
export const Peritext: React.FC = ({ chars, markOps, spacing }) => {
const charsRef = useRef(null);
const markOpsRef = useRef(null);
const context = useBluefishContext();
return (
);
};