mirror of
https://github.com/outline/outline.git
synced 2026-12-01 09:22:14 +03:00
fix: Locally update text value and tasks summary with multiplayer editor
This commit is contained in:
1 parent
c1f832b0a2
commit
aa90d388ef
3 files changed
+23
-11
No files matched your search
@@ -10,12 +10,12 @@ import BaseModel from "models/BaseModel";
|
||||
import User from "models/User";
|
||||
import View from "./View";
|
||||
|
||||
type SaveOptions = {
|
||||
type SaveOptions = {|
|
||||
publish?: boolean,
|
||||
done?: boolean,
|
||||
autosave?: boolean,
|
||||
lastRevision?: number,
|
||||
};
|
||||
|};
|
||||
|
||||
export default class Document extends BaseModel {
|
||||
@observable isSaving: boolean = false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
import { debounce } from "lodash";
|
||||
import { observable } from "mobx";
|
||||
import { action, observable } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { InputIcon } from "outline-icons";
|
||||
import { AllSelection } from "prosemirror-state";
|
||||
@@ -120,7 +120,12 @@ class DocumentScene extends React.Component<Props> {
|
||||
this.title = template.title;
|
||||
this.isDirty = true;
|
||||
|
||||
const { view, parser } = this.editor.current;
|
||||
const editorRef = this.editor.current;
|
||||
if (!editorRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { view, parser } = editorRef;
|
||||
view.dispatch(
|
||||
view.state.tr
|
||||
.setSelection(new AllSelection(view.state.doc))
|
||||
@@ -231,13 +236,12 @@ class DocumentScene extends React.Component<Props> {
|
||||
|
||||
document.title = title;
|
||||
document.text = text;
|
||||
document.tasks = getTasks(document.text);
|
||||
|
||||
let isNew = !document.id;
|
||||
this.isSaving = true;
|
||||
this.isPublishing = !!options.publish;
|
||||
|
||||
document.tasks = getTasks(document.text);
|
||||
|
||||
try {
|
||||
let savedDocument = document;
|
||||
if (auth.team?.features.multiplayerEditor) {
|
||||
@@ -299,13 +303,21 @@ class DocumentScene extends React.Component<Props> {
|
||||
};
|
||||
|
||||
onChange = (getEditorText) => {
|
||||
const { auth } = this.props;
|
||||
if (auth.team?.features.multiplayerEditor) {
|
||||
return;
|
||||
}
|
||||
const { document, auth } = this.props;
|
||||
|
||||
this.getEditorText = getEditorText;
|
||||
|
||||
// If the multiplayer editor is enabled then we still want to keep the local
|
||||
// text value in sync as it is used as a cache.
|
||||
if (auth.team?.features.multiplayerEditor) {
|
||||
action(() => {
|
||||
document.text = this.getEditorText();
|
||||
document.tasks = getTasks(document.text);
|
||||
})();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// document change while read only is presumed to be a checkbox edit,
|
||||
// in that case we don't delay in saving for a better user experience.
|
||||
if (this.props.readOnly) {
|
||||
|
||||
@@ -56,7 +56,7 @@ describe("provisionSubdomain", () => {
|
||||
});
|
||||
|
||||
describe("save", () => {
|
||||
it("should ot allow known features", async () => {
|
||||
it("should allow known features", async () => {
|
||||
const team = await buildTeam();
|
||||
team.features = { multiplayerEditor: true };
|
||||
|
||||
|
||||
Reference in new issue
Block a user