-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into wip/johan
# Conflicts: # .yarn/install-state.gz # packages/apps/client/src/components/SplitPanel/SplitPanel.tsx
- Loading branch information
Showing
13 changed files
with
223 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/apps/client/src/CurrentRundown/CurrentRundown.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.SegmentLineList { | ||
display: grid; | ||
grid-template-columns: 1fr 3em 4em 2fr 5fr 1fr 1fr; | ||
padding: 0; | ||
margin: 0; | ||
--table-gap-size: 2px; | ||
gap: var(--table-gap-size); | ||
} | ||
|
||
.SegmentContainer { | ||
padding: 0; | ||
margin: 0; | ||
display: contents; | ||
} | ||
|
||
.SegmentIdentifier { | ||
padding: 0; | ||
margin: 0; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.LineContainer { | ||
padding: 0; | ||
margin: 0; | ||
grid-column: 2 / 8; | ||
display: grid; | ||
grid-template-columns: subgrid; | ||
grid-template-rows: auto; | ||
gap: var(--table-gap-size); | ||
} | ||
|
||
.Line { | ||
grid-column: 1 / 7; | ||
display: grid; | ||
grid-template-columns: subgrid; | ||
gap: var(--table-gap-size); | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
.LineItem { | ||
background: var(--color-dark-2); | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.LineIdentifier { | ||
--dummy: 1; | ||
} | ||
|
||
.LineType { | ||
--dumy: 1; | ||
} | ||
|
||
.LineSlug { | ||
composes: LineItem; | ||
} | ||
|
||
.LineScript { | ||
composes: LineItem; | ||
} | ||
|
||
.LineDuration { | ||
composes: LineItem; | ||
} | ||
|
||
.LineDuration2 { | ||
composes: LineItem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/apps/client/src/lib/mdExtensions/everyLineAParagraph.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Extension, CompileContext, Token } from 'mdast-util-from-markdown' | ||
import { TokenTypeMap } from 'micromark-util-types' | ||
|
||
export function everyLineAParagraph(): Extension { | ||
return { | ||
enter: { | ||
['lineEnding']: function (this: CompileContext, token: Token) { | ||
console.log(token, this) | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,88 @@ | ||
import { fromMarkdown as mdastFromMarkdown } from 'mdast-util-from-markdown' | ||
import type { Node, Parent } from 'mdast' | ||
import { fromMarkdown as mdAstFromMarkdown } from 'mdast-util-from-markdown' | ||
import { toMarkdown as mdAstToMarkdown } from 'mdast-util-to-markdown' | ||
import type { Node as MdAstNode, Parent as MdAstParent, Literal as MdAstLiteral } from 'mdast' | ||
import { Node as ProsemirrorNode } from 'prosemirror-model' | ||
import { directive } from 'micromark-extension-directive' | ||
import { directiveFromMarkdown } from 'mdast-util-directive' | ||
import { schema } from '../ScriptEditor/scriptSchema' | ||
import { directiveFromMarkdown, directiveToMarkdown } from 'mdast-util-directive' | ||
import { everyLineAParagraph } from './mdExtensions/everyLineAParagraph' | ||
|
||
export function fromMarkdown(text: string): void { | ||
const ast = mdastFromMarkdown(text, 'utf-8', { | ||
export function fromMarkdown(text: string): ProsemirrorNode[] { | ||
const ast = mdAstFromMarkdown(text, 'utf-8', { | ||
extensions: [directive()], | ||
mdastExtensions: [directiveFromMarkdown()], | ||
mdastExtensions: [everyLineAParagraph(), directiveFromMarkdown()], | ||
}) | ||
|
||
traverseNodes(ast.children) | ||
return traverseMdAstNodes(ast.children) | ||
} | ||
|
||
function traverseNodes(nodes: Node[]) { | ||
export function toMarkdown(doc: ProsemirrorNode[]): string { | ||
return mdAstToMarkdown( | ||
{ | ||
type: 'root', | ||
children: [], | ||
}, | ||
{ | ||
extensions: [directiveToMarkdown()], | ||
} | ||
) | ||
} | ||
|
||
function mdastToEditorSchemaNode(node: MdAstNode, children?: ProsemirrorNode[]): ProsemirrorNode[] { | ||
if (node.type === 'paragraph') { | ||
return [schema.node(schema.nodes.paragraph, undefined, children)] | ||
} else if (isLeafDirective(node) && node.name === 'emptyPara') { | ||
return [schema.node(schema.nodes.paragraph, undefined, [])] | ||
} else if (node.type === 'text' && isLiteral(node)) { | ||
return [schema.text(node.value)] | ||
} else if (node.type === 'strong' && children) { | ||
return children.map((child) => child.mark([...child.marks, schema.mark(schema.marks.bold)])) | ||
} else if (node.type === 'emphasis' && children) { | ||
return children.map((child) => child.mark([...child.marks, schema.mark(schema.marks.italic)])) | ||
} else if (isTextDirective(node) && node.name === 'reverse' && children) { | ||
return children.map((child) => child.mark([...child.marks, schema.mark(schema.marks.reverse)])) | ||
} else if (node.type === 'break') { | ||
return [schema.text('\n')] | ||
} else { | ||
console.warn(node) | ||
return [schema.text('[UNKNOWN]')] | ||
} | ||
} | ||
|
||
function traverseMdAstNodes(nodes: MdAstNode[]): ProsemirrorNode[] { | ||
const result: ProsemirrorNode[] = [] | ||
for (const childNode of nodes) { | ||
console.dir(childNode) | ||
if (isParent(childNode)) traverseNodes(childNode.children) | ||
let children: ProsemirrorNode[] = [] | ||
if (isParent(childNode)) { | ||
children = traverseMdAstNodes(childNode.children) | ||
} | ||
result.push(...mdastToEditorSchemaNode(childNode, children)) | ||
} | ||
|
||
return result | ||
} | ||
|
||
function isParent(node: Node): node is Parent { | ||
function isParent(node: MdAstNode): node is MdAstParent { | ||
if ('children' in node && Array.isArray(node.children)) return true | ||
return false | ||
} | ||
|
||
function isLiteral(node: MdAstNode): node is MdAstLiteral { | ||
if ('value' in node) return true | ||
return false | ||
} | ||
|
||
function isTextDirective(node: MdAstNode): node is MdAstTextDirective { | ||
if (node.type === 'textDirective' && 'name' in node) return true | ||
return false | ||
} | ||
|
||
function isLeafDirective(node: MdAstNode): node is MdAstTextDirective { | ||
if (node.type === 'leafDirective' && 'name' in node) return true | ||
return false | ||
} | ||
|
||
interface MdAstTextDirective extends MdAstNode { | ||
name: string | ||
attributes: Record<string, string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters