-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #822 from streamich/peritext-inline-formatting
Peritext basic inline formatting
- Loading branch information
Showing
19 changed files
with
308 additions
and
61 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
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,3 +1,3 @@ | ||
export {Block, IBlock} from './Block'; | ||
export {LeafBlock} from './LeafBlock'; | ||
export {Inline} from './Inline'; | ||
export * from './Inline'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
export enum DefaultRendererColors { | ||
ActiveCursor = '#07f', | ||
InactiveCursor = 'rgba(127,127,127,.7)', | ||
ActiveSelection = '#d7e9fd', | ||
|
||
/** | ||
* Derived from #d7e9fd. 80% opacity used so that | ||
* any inline formatting underneath the selection | ||
* is still visible. | ||
*/ | ||
ActiveSelection = 'rgba(196,223,253,.8)', | ||
|
||
InactiveSelection = 'rgba(127,127,127,.2)', | ||
} |
23 changes: 23 additions & 0 deletions
23
src/json-crdt-peritext-ui/plugins/minimal/RenderInline/Spoiler.tsx
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,23 @@ | ||
// biome-ignore lint: React is used for JSX | ||
import * as React from 'react'; | ||
import {rule} from 'nano-theme'; | ||
|
||
const blockClass = rule({ | ||
bg: '#222', | ||
col: 'transparent', | ||
bdrad: '2px', | ||
'&:hover': { | ||
bg: '#222', | ||
col: 'rgba(255, 255, 255, 0.2)', | ||
}, | ||
}); | ||
|
||
export interface SpoilerProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Spoiler: React.FC<SpoilerProps> = (props) => { | ||
const {children} = props; | ||
|
||
return <span className={blockClass}>{children}</span>; | ||
}; |
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
25 changes: 0 additions & 25 deletions
25
src/json-crdt-peritext-ui/plugins/toolbar/RenderInline.tsx
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
src/json-crdt-peritext-ui/plugins/toolbar/RenderInline/Code.tsx
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,41 @@ | ||
// biome-ignore lint: React is used for JSX | ||
import * as React from 'react'; | ||
import {rule, drule, theme, useTheme} from 'nano-theme'; | ||
import type {InlineAttr} from '../../../../json-crdt-extensions'; | ||
|
||
const blockClass = drule({ | ||
...theme.font.mono.mid, | ||
fz: '.9em', | ||
pdt: '.05em', | ||
pdb: '.05em', | ||
}); | ||
|
||
const startClass = rule({ | ||
borderTopLeftRadius: '.3em', | ||
borderBottomLeftRadius: '.3em', | ||
pdl: '.24em', | ||
}); | ||
|
||
const endClass = rule({ | ||
borderTopRightRadius: '.3em', | ||
borderBottomRightRadius: '.3em', | ||
pdr: '.24em', | ||
}); | ||
|
||
export interface CodeProps { | ||
attr: InlineAttr; | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Code: React.FC<CodeProps> = (props) => { | ||
const {children, attr} = props; | ||
const theme = useTheme(); | ||
const className = | ||
blockClass({ | ||
bg: theme.g(0.2, 0.1), | ||
}) + | ||
(attr.isStart() ? startClass : '') + | ||
(attr.isEnd() ? endClass : ''); | ||
|
||
return <span className={className}>{children}</span>; | ||
}; |
19 changes: 19 additions & 0 deletions
19
src/json-crdt-peritext-ui/plugins/toolbar/RenderInline/Del.tsx
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,19 @@ | ||
// biome-ignore lint: React is used for JSX | ||
import * as React from 'react'; | ||
import {rule} from 'nano-theme'; | ||
|
||
const delClass = rule({ | ||
bg: '#ffebe9', | ||
bxsh: '0 2px 0 0 #ffcecb', | ||
col: 'red', | ||
}); | ||
|
||
export interface DelProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Del: React.FC<DelProps> = (props) => { | ||
const {children} = props; | ||
|
||
return <del className={delClass}>{children}</del>; | ||
}; |
19 changes: 19 additions & 0 deletions
19
src/json-crdt-peritext-ui/plugins/toolbar/RenderInline/Ins.tsx
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,19 @@ | ||
// biome-ignore lint: React is used for JSX | ||
import * as React from 'react'; | ||
import {rule} from 'nano-theme'; | ||
|
||
const blockClass = rule({ | ||
bg: '#dafbe1', | ||
bxsh: '0 2px 0 0 #aceebb', | ||
td: 'none', | ||
}); | ||
|
||
export interface InsProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Ins: React.FC<InsProps> = (props) => { | ||
const {children} = props; | ||
|
||
return <ins className={blockClass}>{children}</ins>; | ||
}; |
Oops, something went wrong.