Skip to content

Commit

Permalink
Merge pull request #432 from AppQuality/develop
Browse files Browse the repository at this point in the history
rework: Don't use wordwrapper
  • Loading branch information
d-beezee authored Oct 22, 2024
2 parents 824a2ae + 45173eb commit d828e40
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 36 deletions.
6 changes: 0 additions & 6 deletions src/stories/transcript/extensions/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ const DefaultActiveWrapper = ({ children }: { children: ReactNode }) => {
return <span style={{ background: "#ff0000" }}>{children}</span>;
};

const DefaultWordWrapper = ({ children }: { children: ReactNode }) => {
return <span>{children}</span>;
};

const DefaultObservationWrapper = ({
title,
color,
Expand Down Expand Up @@ -145,7 +141,6 @@ const SearchStyleWrapper = styled.span`

export interface ThemeOptions {
activeWrapper: typeof DefaultActiveWrapper;
wordWrapper: typeof DefaultWordWrapper;
observationWrapper: typeof DefaultObservationWrapper;
paragraphWrapper: typeof DefaultParagraphWrapper;
speakerWrapper: typeof DefaultSpeakerWrapper;
Expand Down Expand Up @@ -176,7 +171,6 @@ export const Theme = Extension.create<ThemeOptions, {}>({
addOptions() {
return {
activeWrapper: DefaultActiveWrapper,
wordWrapper: DefaultWordWrapper,
observationWrapper: DefaultObservationWrapper,
paragraphWrapper: DefaultParagraphWrapper,
speakerWrapper: DefaultSpeakerWrapper,
Expand Down
22 changes: 0 additions & 22 deletions src/stories/transcript/nodes/word/Component.tsx

This file was deleted.

35 changes: 27 additions & 8 deletions src/stories/transcript/nodes/word/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Node } from "@tiptap/core";
import { ReactNodeViewRenderer } from "@tiptap/react";
import { Component } from "./Component";
import { Plugin } from "@tiptap/pm/state";

export const Word = Node.create({
name: "Word",
Expand All @@ -20,13 +19,13 @@ export const Word = Node.create({
parseHTML() {
return [
{
tag: "span[data-start][data-end]",
tag: "word[data-start][data-end]",
},
];
},
renderHTML({ node }) {
return [
"span",
"word",
{
"data-start": node.attrs["data-start"],
"data-end": node.attrs["data-end"],
Expand All @@ -36,9 +35,29 @@ export const Word = Node.create({
];
},

addNodeView() {
return ReactNodeViewRenderer(Component, {
as: "span",
});
addProseMirrorPlugins() {
return [
new Plugin({
props: {
handleDOMEvents: {
click: (view, event) => {
const { target } = event;
if (
target instanceof HTMLElement &&
target.getAttribute("data-start")
) {
const dataStart = target.getAttribute("data-start");

if (!dataStart) return false;

this.editor.commands.setCurrentTime(Number(dataStart));
return true;
}
return false;
},
},
},
}),
];
},
});

0 comments on commit d828e40

Please sign in to comment.