Skip to content

Commit

Permalink
fix: error in note
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Jan 7, 2024
1 parent 27f4576 commit 5663efc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/tw-whiteboard/tldraw/shapes/wikitext/WikiTextShapeUtil.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable unicorn/no-null */
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
import {
Editor,
getDefaultColorTheme,
Expand All @@ -10,7 +12,6 @@ import {
TLNoteShape,
TLOnEditEndHandler,
toDomPrecision,
useIsDarkMode,
} from '@tldraw/editor';

const NOTE_SIZE = 200;
Expand Down Expand Up @@ -77,7 +78,7 @@ export class WikiTextShapeUtil extends ShapeUtil<TLNoteShape> {
props: { color, font, size, align, text, verticalAlign },
} = shape;

const theme = getDefaultColorTheme({ isDarkMode: useIsDarkMode() });
const theme = getDefaultColorTheme({ isDarkMode: this.editor.user.getIsDarkMode() });
const adjustedColor = color === 'black' ? 'yellow' : color;

return (
Expand Down Expand Up @@ -116,7 +117,7 @@ export class WikiTextShapeUtil extends ShapeUtil<TLNoteShape> {

override toSvg(shape: TLNoteShape, context: SvgExportContext) {
// context.addExportDef(getFontDefForExport(shape.props.font));
const theme = getDefaultColorTheme({ isDarkMode: this.editor.user.isDarkMode });
const theme = getDefaultColorTheme({ isDarkMode: this.editor.user.getIsDarkMode() });
const bounds = this.editor.getShapeGeometry(shape).bounds;

const g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
Expand Down Expand Up @@ -178,7 +179,7 @@ export class WikiTextShapeUtil extends ShapeUtil<TLNoteShape> {
props: { text },
} = shape;

if (text.trimEnd() !== shape.props.text) {
if (text.trimEnd() !== text) {
this.editor.updateShapes([
{
id,
Expand All @@ -199,7 +200,7 @@ function getGrowY(editor: Editor, shape: TLNoteShape, previousGrowY = 0) {
...TEXT_PROPS,
fontFamily: FONT_FAMILIES[shape.props.font],
fontSize: LABEL_FONT_SIZES[shape.props.size],
width: NOTE_SIZE - PADDING * 2 + 'px',
maxWidth: NOTE_SIZE - PADDING * 2,
});

const nextHeight = nextTextSize.h + PADDING * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Pointing extends StateNode {
shape = {} as TLNoteShape;

override onEnter = () => {
this.wasFocusedOnEnter = !this.editor.isMenuOpen;
this.wasFocusedOnEnter = !this.editor.getIsMenuOpen();
if (this.wasFocusedOnEnter) {
this.shape = this.createShape();
}
Expand Down Expand Up @@ -56,7 +56,7 @@ export class Pointing extends StateNode {

private complete() {
if (this.wasFocusedOnEnter) {
if (this.editor.instanceState.isToolLocked) {
if (this.editor.getInstanceState().isToolLocked) {
this.parent.transition('idle', {});
} else {
this.editor.setEditingShape(this.shape.id);
Expand Down

0 comments on commit 5663efc

Please sign in to comment.