Apply strictNullChecks to src/components/views/rooms/wysiwyg_composer/* (#10653)
* update components folder * update useInitialContentpull/28788/head^2
parent
fbf3de52cd
commit
c824c4a858
|
@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { MouseEventHandler } from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { _t } from "../../../../../languageHandler";
|
import { _t } from "../../../../../languageHandler";
|
||||||
import AccessibleButton from "../../../elements/AccessibleButton";
|
import AccessibleButton, { ButtonEvent } from "../../../elements/AccessibleButton";
|
||||||
|
|
||||||
interface EditionButtonsProps {
|
interface EditionButtonsProps {
|
||||||
onCancelClick: MouseEventHandler<HTMLButtonElement>;
|
onCancelClick: (e: ButtonEvent) => void;
|
||||||
onSaveClick: MouseEventHandler<HTMLButtonElement>;
|
onSaveClick: (e: ButtonEvent) => void;
|
||||||
isSaveDisabled?: boolean;
|
isSaveDisabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,14 @@ export function parseEditorStateTransfer(
|
||||||
): string {
|
): string {
|
||||||
const partCreator = new CommandPartCreator(room, mxClient);
|
const partCreator = new CommandPartCreator(room, mxClient);
|
||||||
|
|
||||||
let parts: Part[];
|
let parts: (Part | undefined)[] = [];
|
||||||
if (editorStateTransfer.hasEditorState()) {
|
if (editorStateTransfer.hasEditorState()) {
|
||||||
// if restoring state from a previous editor,
|
// if restoring state from a previous editor,
|
||||||
// restore serialized parts from the state
|
// restore serialized parts from the state
|
||||||
parts = editorStateTransfer.getSerializedParts().map((p) => partCreator.deserializePart(p));
|
const serializedParts = editorStateTransfer.getSerializedParts();
|
||||||
|
if (serializedParts !== null) {
|
||||||
|
parts = serializedParts.map((p) => partCreator.deserializePart(p));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// otherwise, either restore serialized parts from localStorage or parse the body of the event
|
// otherwise, either restore serialized parts from localStorage or parse the body of the event
|
||||||
// TODO local storage
|
// TODO local storage
|
||||||
|
@ -59,7 +62,7 @@ export function parseEditorStateTransfer(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return parts.reduce((content, part) => content + part.text, "");
|
return parts.reduce((content, part) => content + part?.text, "");
|
||||||
// Todo local storage
|
// Todo local storage
|
||||||
// this.saveStoredEditorState();
|
// this.saveStoredEditorState();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue