Skip to content

Commit c72eb9d

Browse files
committed
only show slate editor toolbar when clicking "..."
- this also meant fixing an issue with the frame context for chatrooms
1 parent a240b1c commit c72eb9d

File tree

7 files changed

+28
-56
lines changed

7 files changed

+28
-56
lines changed

src/packages/frontend/chat/chat-log.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export function ChatLog({
218218
<>
219219
{visibleHashtags.size > 0 && (
220220
<HashtagBar
221-
style={{ margin: "5px 15px 0 15px" }}
221+
style={{ margin: "5px 15px 15px 15px" }}
222222
actions={{
223223
set_hashtag_state: (tag, state) => {
224224
actions.setHashtagState(tag, state);

src/packages/frontend/chat/chatroom.tsx

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import { FormattedMessage } from "react-intl";
1010
import { Col, Row, Well } from "@cocalc/frontend/antd-bootstrap";
1111
import {
1212
React,
13-
redux,
1413
useEditorRedux,
1514
useEffect,
1615
useRef,
1716
useState,
1817
} from "@cocalc/frontend/app-framework";
1918
import { Icon, Loading } from "@cocalc/frontend/components";
2019
import StaticMarkdown from "@cocalc/frontend/editors/slate/static-markdown";
21-
import { FrameContext } from "@cocalc/frontend/frame-editors/frame-tree/frame-context";
2220
import { hoursToTimeIntervalHuman } from "@cocalc/util/misc";
2321
import { EditorComponentProps } from "../frame-editors/frame-tree/types";
2422
import { ChatLog } from "./chat-log";
@@ -67,7 +65,6 @@ export function ChatRoom({
6765
actions,
6866
project_id,
6967
path,
70-
is_visible,
7168
font_size,
7269
desc,
7370
}: EditorComponentProps) {
@@ -368,28 +365,13 @@ export function ChatRoom({
368365
if (messages == null || input == null) {
369366
return <Loading theme={"medium"} />;
370367
}
371-
// remove frameContext once the chatroom is part of a frame tree.
372-
// we need this now, e.g., since some markdown editing components
373-
// for input assume in a frame tree, e.g., to fix
374-
// https://github.com/sagemathinc/cocalc/issues/7554
375368
return (
376-
<FrameContext.Provider
377-
value={
378-
{
379-
project_id,
380-
path,
381-
isVisible: !!is_visible,
382-
redux,
383-
} as any
384-
}
369+
<div
370+
onMouseMove={mark_as_read}
371+
onClick={mark_as_read}
372+
className="smc-vfill"
385373
>
386-
<div
387-
onMouseMove={mark_as_read}
388-
onClick={mark_as_read}
389-
className="smc-vfill"
390-
>
391-
{render_body()}
392-
</div>
393-
</FrameContext.Provider>
374+
{render_body()}
375+
</div>
394376
);
395377
}

src/packages/frontend/chat/input.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ export default function ChatInput({
205205
return intl.formatMessage(
206206
{
207207
id: "chat.input.placeholder",
208-
defaultMessage:
209-
"Type a new message ({have_llm, select, true {chat with AI or } other {}}notify a collaborator by typing @)...",
208+
defaultMessage: "Message (@mention)...",
210209
},
211210
{
212211
have_llm,

src/packages/frontend/editors/markdown-input/multimode.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const multimodeStateCache = new LRU<string, MultimodeState>({ max: 500 });
5050
const Modes = ["markdown", "editor"] as const;
5151
export type Mode = (typeof Modes)[number];
5252

53-
5453
const LOCAL_STORAGE_KEY = "markdown-editor-mode";
5554

5655
function getLocalStorageMode(): Mode | undefined {
@@ -134,7 +133,7 @@ interface Props {
134133
// refresh codemirror if this changes
135134
refresh?: any;
136135

137-
overflowEllipsis?: boolean; // if true, show "..." button popping up all menu entries
136+
overflowEllipsis?: boolean; // if true (the default!), show "..." button popping up all menu entries
138137

139138
dirtyRef?: MutableRefObject<boolean>; // a boolean react ref that gets set to true whenever document changes for any reason (client should explicitly set this back to false).
140139

@@ -176,7 +175,7 @@ export default function MultiMarkdownInput({
176175
onUndo,
177176
onUploadEnd,
178177
onUploadStart,
179-
overflowEllipsis = false,
178+
overflowEllipsis = true,
180179
placeholder,
181180
refresh,
182181
registerEditor,
@@ -287,7 +286,7 @@ export default function MultiMarkdownInput({
287286
};
288287
}, [mode]);
289288

290-
function toggleEditBarPopupver() {
289+
function toggleEditBarPopover() {
291290
setEditBarPopover(!editBarPopover);
292291
}
293292

@@ -390,7 +389,7 @@ export default function MultiMarkdownInput({
390389
onChange={(e) => {
391390
const mode = e.target.value;
392391
if (mode === "menu") {
393-
toggleEditBarPopupver();
392+
toggleEditBarPopover();
394393
} else {
395394
setMode(mode as Mode);
396395
}

src/packages/frontend/editors/slate/editable-markdown.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ interface Props {
125125
controlRef?: MutableRefObject<{
126126
moveCursorToEndOfLine: () => void;
127127
} | null>;
128+
showEditBar?: boolean;
128129
}
129130

130131
export const EditableMarkdown: React.FC<Props> = React.memo((props: Props) => {
@@ -164,6 +165,7 @@ export const EditableMarkdown: React.FC<Props> = React.memo((props: Props) => {
164165
unregisterEditor,
165166
value,
166167
controlRef,
168+
showEditBar,
167169
} = props;
168170
const { project_id, path, desc, isVisible } = useFrameContext();
169171
const isMountedRef = useIsMountedRef();
@@ -994,16 +996,18 @@ export const EditableMarkdown: React.FC<Props> = React.memo((props: Props) => {
994996
{!hidePath && (
995997
<Path is_current={is_current} path={path} project_id={project_id} />
996998
)}
997-
<EditBar
998-
Search={search.Search}
999-
isCurrent={is_current}
1000-
marks={marks}
1001-
linkURL={linkURL}
1002-
listProperties={listProperties}
1003-
editor={editor}
1004-
style={editBarStyle}
1005-
hideSearch={hideSearch}
1006-
/>
999+
{showEditBar && (
1000+
<EditBar
1001+
Search={search.Search}
1002+
isCurrent={is_current}
1003+
marks={marks}
1004+
linkURL={linkURL}
1005+
listProperties={listProperties}
1006+
editor={editor}
1007+
style={editBarStyle}
1008+
hideSearch={hideSearch}
1009+
/>
1010+
)}
10071011
<div
10081012
className={noVfill || height == "auto" ? undefined : "smc-vfill"}
10091013
style={{

src/packages/frontend/frame-editors/whiteboard-editor/elements/text.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ export default function Text(props: Props) {
3434
editBarStyle: {
3535
visibility:
3636
!props.focused || mode == "markdown" ? "hidden" : undefined,
37-
top: `${-55 - 5}px`,
38-
left: "-24px",
39-
position: "absolute",
40-
boxShadow: "1px 3px 5px #ccc",
41-
margin: "5px",
42-
minWidth: "500px",
43-
background: "white",
44-
fontFamily: "sans-serif",
45-
paddingRight: 0, // undoing a temporary hack
4637
},
4738
modeSwitchStyle: {
4839
top: "-82px",
@@ -170,7 +161,7 @@ function EditText({
170161
2 * PADDING +
171162
2 +
172163
15,
173-
MIN_HEIGHT
164+
MIN_HEIGHT,
174165
);
175166
actions.setElement({
176167
obj: { id: element.id, h: height },
@@ -208,7 +199,7 @@ function EditText({
208199
// still want to consider it focused, e.g., editing math and code
209200
// cells, and clicking a checkbox.
210201
}}
211-
value={element.str ? element.str : element.data?.initStr ?? ""}
202+
value={element.str ? element.str : (element.data?.initStr ?? "")}
212203
fontSize={element.data?.fontSize ?? DEFAULT_FONT_SIZE}
213204
onChange={() => {
214205
/* MultiMarkdownInput's onChange is debounced by default */

src/packages/frontend/frame-editors/whiteboard-editor/tools/edit-bar.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ function FontSize(props: ButtonProps) {
220220
width: "64px",
221221
fontSize: "20px",
222222
color: "#666",
223-
paddingTop: "4px",
224223
}}
225224
min={minFontSize}
226225
max={maxFontSize}
@@ -251,7 +250,6 @@ function Radius(props: ButtonProps) {
251250
width: "70px",
252251
fontSize: "20px",
253252
color: "#666",
254-
paddingTop: "4px",
255253
}}
256254
min={0}
257255
max={maxRadius}
@@ -288,7 +286,6 @@ function Opacity(props: ButtonProps) {
288286
width: "70px",
289287
fontSize: "20px",
290288
color: "#666",
291-
paddingTop: "4px",
292289
}}
293290
min={0}
294291
max={1}

0 commit comments

Comments
 (0)