mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Feat embed code (#985)
* fix: fix linux build * Merge pull request #599 from AppFlowy-IO/refactor/grid_decode_cell_data Refactor/grid decode cell data * refactor: cleaned up and added bold, italic styles * refactor: remove bold & italic styles Co-authored-by: Nathan.fooo <86001920+appflowy@users.noreply.github.com>
This commit is contained in:
parent
7b06b4c427
commit
f4cf5d0808
@ -255,6 +255,9 @@ class RichTextStyle {
|
|||||||
if (attributes.href != null) {
|
if (attributes.href != null) {
|
||||||
return Colors.lightBlue;
|
return Colors.lightBlue;
|
||||||
}
|
}
|
||||||
|
if (attributes.code) {
|
||||||
|
return Colors.lightBlue.withOpacity(0.8);
|
||||||
|
}
|
||||||
return attributes.color ?? Colors.black;
|
return attributes.color ?? Colors.black;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +265,7 @@ class RichTextStyle {
|
|||||||
if (attributes.backgroundColor != null) {
|
if (attributes.backgroundColor != null) {
|
||||||
return attributes.backgroundColor!;
|
return attributes.backgroundColor!;
|
||||||
} else if (attributes.code) {
|
} else if (attributes.code) {
|
||||||
return Colors.grey.withOpacity(0.4);
|
return Colors.blue.shade300.withOpacity(0.3);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,22 @@ List<ToolbarItem> defaultToolbarItems = [
|
|||||||
),
|
),
|
||||||
handler: (editorState, context) => formatStrikethrough(editorState),
|
handler: (editorState, context) => formatStrikethrough(editorState),
|
||||||
),
|
),
|
||||||
|
ToolbarItem(
|
||||||
|
id: 'appflowy.toolbar.code',
|
||||||
|
type: 2,
|
||||||
|
tooltipsMessage: 'Embed Code',
|
||||||
|
iconBuilder: (isHighlight) => FlowySvg(
|
||||||
|
name: 'toolbar/code',
|
||||||
|
color: isHighlight ? Colors.lightBlue : null,
|
||||||
|
),
|
||||||
|
validator: _showInTextSelection,
|
||||||
|
highlightCallback: (editorState) => _allSatisfy(
|
||||||
|
editorState,
|
||||||
|
StyleKey.code,
|
||||||
|
(value) => value == StyleKey.code,
|
||||||
|
),
|
||||||
|
handler: (editorState, context) => formatEmbedCode(editorState),
|
||||||
|
),
|
||||||
ToolbarItem(
|
ToolbarItem(
|
||||||
id: 'appflowy.toolbar.quote',
|
id: 'appflowy.toolbar.quote',
|
||||||
type: 3,
|
type: 3,
|
||||||
|
@ -139,6 +139,10 @@ bool formatStrikethrough(EditorState editorState) {
|
|||||||
return formatRichTextPartialStyle(editorState, StyleKey.strikethrough);
|
return formatRichTextPartialStyle(editorState, StyleKey.strikethrough);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool formatEmbedCode(EditorState editorState) {
|
||||||
|
return formatRichTextPartialStyle(editorState, StyleKey.code);
|
||||||
|
}
|
||||||
|
|
||||||
bool formatHighlight(EditorState editorState) {
|
bool formatHighlight(EditorState editorState) {
|
||||||
bool value = _allSatisfyInSelection(
|
bool value = _allSatisfyInSelection(
|
||||||
editorState, StyleKey.backgroundColor, defaultHighlightColor);
|
editorState, StyleKey.backgroundColor, defaultHighlightColor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user