Skip to content

Commit 08a3484

Browse files
format
1 parent cb066fd commit 08a3484

38 files changed

Lines changed: 852 additions & 817 deletions

examples/frontend/web/app.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@ ReactElement _buildTaskManager(
147147
'$apiUrl/tasks',
148148
method: 'POST',
149149
token: token,
150-
body: {
151-
'title': newTaskState.value,
152-
'description': descState.value,
153-
},
150+
body: {'title': newTaskState.value, 'description': descState.value},
154151
);
155152
result.match(
156153
onSuccess: (response) {

examples/markdown_editor/lib/src/components/editor_app.dart

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,63 +45,71 @@ ReactElement EditorApp() => createElement(
4545
onBlock: applyBlock,
4646
onLink: applyLink,
4747
onToggleMode: () {
48-
modeState.setWithUpdater((current) => switch (current) {
49-
EditorMode.wysiwyg => EditorMode.markdown,
50-
EditorMode.markdown => EditorMode.wysiwyg,
51-
});
48+
modeState.setWithUpdater(
49+
(current) => switch (current) {
50+
EditorMode.wysiwyg => EditorMode.markdown,
51+
EditorMode.markdown => EditorMode.wysiwyg,
52+
},
53+
);
5254
},
5355
);
5456

5557
final htmlContent = markdownToHtml(contentState.value);
5658
final wordCount = _countWords(contentState.value);
5759

58-
return $div(className: 'app') >> [
59-
_buildHeader(),
60-
$main(className: 'main-content') >> [
61-
$div(className: 'editor-container') >> [
62-
buildToolbar(
63-
mode: modeState.value,
64-
callbacks: callbacks,
65-
onShowLinkDialog: openLinkDialog,
66-
onSaveSelection: handleSaveSelection,
60+
return $div(className: 'app') >>
61+
[
62+
_buildHeader(),
63+
$main(className: 'main-content') >>
64+
[
65+
$div(className: 'editor-container') >>
66+
[
67+
buildToolbar(
68+
mode: modeState.value,
69+
callbacks: callbacks,
70+
onShowLinkDialog: openLinkDialog,
71+
onSaveSelection: handleSaveSelection,
72+
),
73+
_buildEditorWrapper(
74+
mode: modeState.value,
75+
content: contentState.value,
76+
htmlContent: htmlContent,
77+
onContentChange: contentState.set,
78+
),
79+
_buildStatusBar(
80+
wordCount: wordCount,
81+
mode: modeState.value,
82+
),
83+
],
84+
],
85+
_buildFooter(),
86+
buildLinkDialog(
87+
isOpen: linkDialogOpen.value,
88+
onClose: () => linkDialogOpen.set(false),
89+
initialUrl: linkUrlState.value,
90+
initialText: linkTextState.value,
91+
onInsert: (url, text) {
92+
applyLink(url, text);
93+
linkDialogOpen.set(false);
94+
},
6795
),
68-
_buildEditorWrapper(
69-
mode: modeState.value,
70-
content: contentState.value,
71-
htmlContent: htmlContent,
72-
onContentChange: contentState.set,
73-
),
74-
_buildStatusBar(wordCount: wordCount, mode: modeState.value),
75-
],
76-
],
77-
_buildFooter(),
78-
buildLinkDialog(
79-
isOpen: linkDialogOpen.value,
80-
onClose: () => linkDialogOpen.set(false),
81-
initialUrl: linkUrlState.value,
82-
initialText: linkTextState.value,
83-
onInsert: (url, text) {
84-
applyLink(url, text);
85-
linkDialogOpen.set(false);
86-
},
87-
),
88-
];
96+
];
8997
}).toJS,
9098
);
9199

92100
ReactElement _buildHeader() =>
93101
$header(className: 'header') >>
94-
($div(className: 'header-content') >> [
95-
$span(className: 'logo') >> 'Markdown Editor',
96-
]);
102+
($div(className: 'header-content') >>
103+
[$span(className: 'logo') >> 'Markdown Editor']);
97104

98105
ReactElement _buildEditorWrapper({
99106
required EditorMode mode,
100107
required String content,
101108
required String htmlContent,
102109
required void Function(String) onContentChange,
103110
}) =>
104-
$div(className: 'editor-wrapper') >> [
111+
$div(className: 'editor-wrapper') >>
112+
[
105113
switch (mode) {
106114
EditorMode.wysiwyg => buildEditorArea(
107115
htmlContent: htmlContent,
@@ -118,12 +126,14 @@ ReactElement _buildStatusBar({
118126
required int wordCount,
119127
required EditorMode mode,
120128
}) =>
121-
$div(className: 'status-bar') >> [
129+
$div(className: 'status-bar') >>
130+
[
122131
$span() >> '$wordCount words',
123-
$span() >> switch (mode) {
124-
EditorMode.wysiwyg => 'Formatted View',
125-
EditorMode.markdown => 'Markdown View',
126-
},
132+
$span() >>
133+
switch (mode) {
134+
EditorMode.wysiwyg => 'Formatted View',
135+
EditorMode.markdown => 'Markdown View',
136+
},
127137
];
128138

129139
ReactElement _buildFooter() =>

examples/markdown_editor/lib/src/components/link_dialog.dart

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -57,56 +57,64 @@ ReactElement buildLinkDialog({
5757
}
5858
}
5959

60-
return $div(className: 'dialog-overlay', onClick: onClose) >> [
61-
createElement(
62-
'div'.toJS,
63-
createProps({
64-
'className': 'dialog',
65-
'onClick': ((JSObject e) {
66-
(e['stopPropagation']! as JSFunction).callAsFunction(e);
67-
}).toJS,
68-
}),
60+
return $div(className: 'dialog-overlay', onClick: onClose) >>
6961
[
70-
$div(className: 'dialog-header') >> 'Insert Link',
71-
$div(className: 'dialog-body') >> [
72-
$div(className: 'form-group') >> [
73-
$label() >> 'URL',
74-
createElement(
75-
'input'.toJS,
76-
createProps({
77-
'type': 'url',
78-
'className': 'dialog-input',
79-
'placeholder': 'https://example.com',
80-
'value': urlState.value,
81-
'onChange': handleUrlChange.toJS,
82-
'onKeyDown': handleKeyDown.toJS,
83-
'autoFocus': true,
84-
}),
85-
),
86-
],
87-
$div(className: 'form-group') >> [
88-
$label() >> 'Display Text (optional)',
89-
createElement(
90-
'input'.toJS,
91-
createProps({
92-
'type': 'text',
93-
'className': 'dialog-input',
94-
'placeholder': 'Link text',
95-
'value': textState.value,
96-
'onChange': handleTextChange.toJS,
97-
'onKeyDown': handleKeyDown.toJS,
98-
}),
99-
),
100-
],
101-
],
102-
$div(className: 'dialog-footer') >> [
103-
$button(className: 'btn btn-secondary', onClick: onClose) >>
104-
'Cancel',
105-
$button(className: 'btn btn-primary', onClick: handleSubmit) >>
106-
'Insert',
107-
],
108-
].toJS,
109-
),
110-
];
62+
createElement(
63+
'div'.toJS,
64+
createProps({
65+
'className': 'dialog',
66+
'onClick': ((JSObject e) {
67+
(e['stopPropagation']! as JSFunction).callAsFunction(e);
68+
}).toJS,
69+
}),
70+
[
71+
$div(className: 'dialog-header') >> 'Insert Link',
72+
$div(className: 'dialog-body') >>
73+
[
74+
$div(className: 'form-group') >>
75+
[
76+
$label() >> 'URL',
77+
createElement(
78+
'input'.toJS,
79+
createProps({
80+
'type': 'url',
81+
'className': 'dialog-input',
82+
'placeholder': 'https://example.com',
83+
'value': urlState.value,
84+
'onChange': handleUrlChange.toJS,
85+
'onKeyDown': handleKeyDown.toJS,
86+
'autoFocus': true,
87+
}),
88+
),
89+
],
90+
$div(className: 'form-group') >>
91+
[
92+
$label() >> 'Display Text (optional)',
93+
createElement(
94+
'input'.toJS,
95+
createProps({
96+
'type': 'text',
97+
'className': 'dialog-input',
98+
'placeholder': 'Link text',
99+
'value': textState.value,
100+
'onChange': handleTextChange.toJS,
101+
'onKeyDown': handleKeyDown.toJS,
102+
}),
103+
),
104+
],
105+
],
106+
$div(className: 'dialog-footer') >>
107+
[
108+
$button(className: 'btn btn-secondary', onClick: onClose) >>
109+
'Cancel',
110+
$button(
111+
className: 'btn btn-primary',
112+
onClick: handleSubmit,
113+
) >>
114+
'Insert',
115+
],
116+
].toJS,
117+
),
118+
];
111119
}).toJS,
112120
);

0 commit comments

Comments
 (0)