PageContainer.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. import { Container } from 'unstated';
  2. import * as entities from 'entities';
  3. import * as toastr from 'toastr';
  4. import { pagePathUtils } from '@growi/core';
  5. import loggerFactory from '~/utils/logger';
  6. import { EditorMode } from '~/stores/ui';
  7. import { toastError } from '../util/apiNotification';
  8. import {
  9. DetachCodeBlockInterceptor,
  10. RestoreCodeBlockInterceptor,
  11. } from '../util/interceptor/detach-code-blocks';
  12. import {
  13. DrawioInterceptor,
  14. } from '../util/interceptor/drawio-interceptor';
  15. const { isTrashPage } = pagePathUtils;
  16. const logger = loggerFactory('growi:services:PageContainer');
  17. /**
  18. * Service container related to Page
  19. * @extends {Container} unstated Container
  20. */
  21. export default class PageContainer extends Container {
  22. constructor(appContainer) {
  23. super();
  24. this.appContainer = appContainer;
  25. this.appContainer.registerContainer(this);
  26. this.state = {};
  27. const mainContent = document.querySelector('#content-main');
  28. if (mainContent == null) {
  29. logger.debug('#content-main element is not exists');
  30. return;
  31. }
  32. const revisionId = mainContent.getAttribute('data-page-revision-id');
  33. const path = decodeURI(mainContent.getAttribute('data-path'));
  34. this.state = {
  35. // local page data
  36. markdown: null, // will be initialized after initStateMarkdown()
  37. pageId: mainContent.getAttribute('data-page-id'),
  38. revisionId,
  39. revisionCreatedAt: +mainContent.getAttribute('data-page-revision-created'),
  40. path,
  41. tocHtml: '',
  42. seenUsers: [],
  43. seenUserIds: [],
  44. sumOfSeenUsers: [],
  45. isLiked: false,
  46. likers: [],
  47. likerIds: [],
  48. sumOfLikers: 0,
  49. createdAt: mainContent.getAttribute('data-page-created-at'),
  50. // please use useCurrentUpdatedAt instead
  51. updatedAt: mainContent.getAttribute('data-page-updated-at'),
  52. deletedAt: mainContent.getAttribute('data-page-deleted-at') || null,
  53. isUserPage: JSON.parse(mainContent.getAttribute('data-page-user')) != null,
  54. isTrashPage: isTrashPage(path),
  55. isDeleted: JSON.parse(mainContent.getAttribute('data-page-is-deleted')),
  56. isDeletable: JSON.parse(mainContent.getAttribute('data-page-is-deletable')),
  57. isNotCreatable: JSON.parse(mainContent.getAttribute('data-page-is-not-creatable')),
  58. isAbleToDeleteCompletely: JSON.parse(mainContent.getAttribute('data-page-is-able-to-delete-completely')),
  59. isPageExist: mainContent.getAttribute('data-page-id') != null,
  60. pageUser: JSON.parse(mainContent.getAttribute('data-page-user')),
  61. tags: null,
  62. hasChildren: JSON.parse(mainContent.getAttribute('data-page-has-children')),
  63. templateTagData: mainContent.getAttribute('data-template-tags') || null,
  64. shareLinksNumber: mainContent.getAttribute('data-share-links-number'),
  65. shareLinkId: JSON.parse(mainContent.getAttribute('data-share-link-id') || null),
  66. // latest(on remote) information
  67. remoteRevisionId: revisionId,
  68. remoteRevisionBody: null,
  69. remoteRevisionUpdateAt: null,
  70. revisionIdHackmdSynced: mainContent.getAttribute('data-page-revision-id-hackmd-synced') || null,
  71. lastUpdateUsername: mainContent.getAttribute('data-page-last-update-username') || null,
  72. deleteUsername: mainContent.getAttribute('data-page-delete-username') || null,
  73. pageIdOnHackmd: mainContent.getAttribute('data-page-id-on-hackmd') || null,
  74. hasDraftOnHackmd: !!mainContent.getAttribute('data-page-has-draft-on-hackmd'),
  75. isHackmdDraftUpdatingInRealtime: false,
  76. isConflictDiffModalOpen: false,
  77. };
  78. // parse creator, lastUpdateUser and revisionAuthor
  79. try {
  80. this.state.creator = JSON.parse(mainContent.getAttribute('data-page-creator'));
  81. }
  82. catch (e) {
  83. logger.warn('The data of \'data-page-creator\' is invalid', e);
  84. }
  85. try {
  86. this.state.revisionAuthor = JSON.parse(mainContent.getAttribute('data-page-revision-author'));
  87. this.state.lastUpdateUser = JSON.parse(mainContent.getAttribute('data-page-revision-author'));
  88. }
  89. catch (e) {
  90. logger.warn('The data of \'data-page-revision-author\' is invalid', e);
  91. }
  92. const { interceptorManager } = this.appContainer;
  93. interceptorManager.addInterceptor(new DetachCodeBlockInterceptor(appContainer), 10); // process as soon as possible
  94. interceptorManager.addInterceptor(new DrawioInterceptor(appContainer), 20);
  95. interceptorManager.addInterceptor(new RestoreCodeBlockInterceptor(appContainer), 900); // process as late as possible
  96. this.initStateMarkdown();
  97. this.checkAndUpdateImageUrlCached(this.state.likers);
  98. const { isSharedUser } = this.appContainer;
  99. // see https://dev.growi.org/5fabddf8bbeb1a0048bcb9e9
  100. const isAbleToGetAttachedInformationAboutPages = this.state.isPageExist && !isSharedUser;
  101. if (isAbleToGetAttachedInformationAboutPages) {
  102. // We don't retrieve bookmarks in the initial page load
  103. // as it is stored in a separate collection to like and seen user
  104. // data so it has a separate api endpoint.
  105. this.initialPageLoad();
  106. }
  107. this.setTocHtml = this.setTocHtml.bind(this);
  108. this.save = this.save.bind(this);
  109. this.checkAndUpdateImageUrlCached = this.checkAndUpdateImageUrlCached.bind(this);
  110. this.emitJoinPageRoomRequest = this.emitJoinPageRoomRequest.bind(this);
  111. this.emitJoinPageRoomRequest();
  112. this.addWebSocketEventHandlers = this.addWebSocketEventHandlers.bind(this);
  113. this.addWebSocketEventHandlers();
  114. const unlinkPageButton = document.getElementById('unlink-page-button');
  115. if (unlinkPageButton != null) {
  116. unlinkPageButton.addEventListener('click', async() => {
  117. try {
  118. const res = await this.appContainer.apiPost('/pages.unlink', { path });
  119. window.location.href = encodeURI(`${res.path}?unlinked=true`);
  120. }
  121. catch (err) {
  122. toastError(err);
  123. }
  124. });
  125. }
  126. }
  127. /**
  128. * Workaround for the mangling in production build to break constructor.name
  129. */
  130. static getClassName() {
  131. return 'PageContainer';
  132. }
  133. /**
  134. * whether to display reaction buttons
  135. * ex.) like, bookmark
  136. */
  137. get isAbleToShowPageReactionButtons() {
  138. const { isTrashPage, isPageExist } = this.state;
  139. const { isSharedUser } = this.appContainer;
  140. return (!isTrashPage && isPageExist && !isSharedUser);
  141. }
  142. /**
  143. * whether to display tag labels
  144. */
  145. get isAbleToShowTagLabel() {
  146. const { isUserPage } = this.state;
  147. const { isSharedUser } = this.appContainer;
  148. return (!isUserPage && !isSharedUser);
  149. }
  150. /**
  151. * whether to display page management
  152. * ex.) duplicate, rename
  153. */
  154. get isAbleToShowPageManagement() {
  155. const { isPageExist, isTrashPage } = this.state;
  156. const { isSharedUser } = this.appContainer;
  157. return (isPageExist && !isTrashPage && !isSharedUser);
  158. }
  159. /**
  160. * whether to display pageEditorModeManager
  161. * ex.) view, edit, hackmd
  162. */
  163. get isAbleToShowPageEditorModeManager() {
  164. const { isNotCreatable, isTrashPage } = this.state;
  165. const { isSharedUser } = this.appContainer;
  166. return (!isNotCreatable && !isTrashPage && !isSharedUser);
  167. }
  168. /**
  169. * whether to display pageAuthors
  170. * ex.) creator, lastUpdateUser
  171. */
  172. get isAbleToShowPageAuthors() {
  173. const { isPageExist, isUserPage } = this.state;
  174. return (isPageExist && !isUserPage);
  175. }
  176. /**
  177. * whether to like button
  178. * not displayed on user page
  179. */
  180. get isAbleToShowLikeButtons() {
  181. const { isUserPage } = this.state;
  182. const { isSharedUser } = this.appContainer;
  183. return (!isUserPage && !isSharedUser);
  184. }
  185. /**
  186. * whether to Empty Trash Page
  187. * not displayed when guest user and not on trash page
  188. */
  189. get isAbleToShowEmptyTrashButton() {
  190. const { currentUser } = this.appContainer;
  191. const { path, hasChildren } = this.state;
  192. return (currentUser != null && currentUser.admin && path === '/trash' && hasChildren);
  193. }
  194. /**
  195. * whether to display trash management buttons
  196. * ex.) undo, delete completly
  197. * not displayed when guest user
  198. */
  199. get isAbleToShowTrashPageManagementButtons() {
  200. const { currentUser } = this.appContainer;
  201. const { isDeleted } = this.state;
  202. return (isDeleted && currentUser != null);
  203. }
  204. /**
  205. * initialize state for markdown data
  206. */
  207. initStateMarkdown() {
  208. let pageContent = '';
  209. const rawText = document.getElementById('raw-text-original');
  210. if (rawText) {
  211. pageContent = rawText.innerHTML;
  212. }
  213. const markdown = entities.decodeHTML(pageContent);
  214. this.state.markdown = markdown;
  215. }
  216. async initialPageLoad() {
  217. {
  218. const {
  219. data: {
  220. likerIds, sumOfLikers, isLiked, seenUserIds, sumOfSeenUsers, isSeen,
  221. },
  222. } = await this.appContainer.apiv3Get('/page/info', { pageId: this.state.pageId });
  223. await this.setState({
  224. sumOfLikers,
  225. isLiked,
  226. likerIds,
  227. seenUserIds,
  228. sumOfSeenUsers,
  229. isSeen,
  230. });
  231. }
  232. await this.retrieveLikersAndSeenUsers();
  233. }
  234. async toggleLike() {
  235. {
  236. const toggledIsLiked = !this.state.isLiked;
  237. await this.appContainer.apiv3Put('/page/likes', { pageId: this.state.pageId, bool: toggledIsLiked });
  238. await this.setState(state => ({
  239. isLiked: toggledIsLiked,
  240. sumOfLikers: toggledIsLiked ? state.sumOfLikers + 1 : state.sumOfLikers - 1,
  241. likerIds: toggledIsLiked
  242. ? [...this.state.likerIds, this.appContainer.currentUserId]
  243. : state.likerIds.filter(id => id !== this.appContainer.currentUserId),
  244. }));
  245. }
  246. await this.retrieveLikersAndSeenUsers();
  247. }
  248. async retrieveLikersAndSeenUsers() {
  249. const { users } = await this.appContainer.apiGet('/users.list', { user_ids: [...this.state.likerIds, ...this.state.seenUserIds].join(',') });
  250. await this.setState({
  251. likers: users.filter(({ id }) => this.state.likerIds.includes(id)).slice(0, 15),
  252. seenUsers: users.filter(({ id }) => this.state.seenUserIds.includes(id)).slice(0, 15),
  253. });
  254. this.checkAndUpdateImageUrlCached(users);
  255. }
  256. async checkAndUpdateImageUrlCached(users) {
  257. const noImageCacheUsers = users.filter((user) => { return user.imageUrlCached == null });
  258. if (noImageCacheUsers.length === 0) {
  259. return;
  260. }
  261. const noImageCacheUserIds = noImageCacheUsers.map((user) => { return user.id });
  262. try {
  263. await this.appContainer.apiv3Put('/users/update.imageUrlCache', { userIds: noImageCacheUserIds });
  264. }
  265. catch (err) {
  266. // Error alert doesn't apear, because user don't need to notice this error.
  267. logger.error(err);
  268. }
  269. }
  270. setLatestRemotePageData(s2cMessagePageUpdated) {
  271. const newState = {
  272. remoteRevisionId: s2cMessagePageUpdated.revisionId,
  273. remoteRevisionBody: s2cMessagePageUpdated.revisionBody,
  274. remoteRevisionUpdateAt: s2cMessagePageUpdated.revisionUpdateAt,
  275. revisionIdHackmdSynced: s2cMessagePageUpdated.revisionIdHackmdSynced,
  276. // TODO // TODO remove lastUpdateUsername and refactor parts that lastUpdateUsername is used
  277. lastUpdateUsername: s2cMessagePageUpdated.lastUpdateUsername,
  278. lastUpdateUser: s2cMessagePageUpdated.remoteLastUpdateUser,
  279. };
  280. if (s2cMessagePageUpdated.hasDraftOnHackmd != null) {
  281. newState.hasDraftOnHackmd = s2cMessagePageUpdated.hasDraftOnHackmd;
  282. }
  283. this.setState(newState);
  284. }
  285. setTocHtml(tocHtml) {
  286. if (this.state.tocHtml !== tocHtml) {
  287. this.setState({ tocHtml });
  288. }
  289. }
  290. /**
  291. * save success handler
  292. * @param {object} page Page instance
  293. * @param {Array[Tag]} tags Array of Tag
  294. * @param {object} revision Revision instance
  295. */
  296. updateStateAfterSave(page, tags, revision, editorMode) {
  297. // update state of PageContainer
  298. const newState = {
  299. pageId: page._id,
  300. revisionId: revision._id,
  301. revisionCreatedAt: new Date(revision.createdAt).getTime() / 1000,
  302. remoteRevisionId: revision._id,
  303. revisionAuthor: revision.author,
  304. revisionIdHackmdSynced: page.revisionHackmdSynced,
  305. hasDraftOnHackmd: page.hasDraftOnHackmd,
  306. markdown: revision.body,
  307. createdAt: page.createdAt,
  308. updatedAt: page.updatedAt,
  309. };
  310. if (tags != null) {
  311. newState.tags = tags;
  312. }
  313. this.setState(newState);
  314. // PageEditor component
  315. const pageEditor = this.appContainer.getComponentInstance('PageEditor');
  316. if (pageEditor != null) {
  317. if (editorMode !== EditorMode.Editor) {
  318. pageEditor.updateEditorValue(newState.markdown);
  319. }
  320. }
  321. // PageEditorByHackmd component
  322. const pageEditorByHackmd = this.appContainer.getComponentInstance('PageEditorByHackmd');
  323. if (pageEditorByHackmd != null) {
  324. // reset
  325. if (editorMode !== EditorMode.HackMD) {
  326. pageEditorByHackmd.reset();
  327. }
  328. }
  329. }
  330. /**
  331. * update page meta data
  332. * @param {object} page Page instance
  333. * @param {object} revision Revision instance
  334. * @param {String[]} tags Array of Tag
  335. */
  336. updatePageMetaData(page, revision, tags) {
  337. const newState = {
  338. revisionId: revision._id,
  339. revisionCreatedAt: new Date(revision.createdAt).getTime() / 1000,
  340. remoteRevisionId: revision._id,
  341. revisionAuthor: revision.author,
  342. revisionIdHackmdSynced: page.revisionHackmdSynced,
  343. hasDraftOnHackmd: page.hasDraftOnHackmd,
  344. updatedAt: page.updatedAt,
  345. };
  346. if (tags != null) {
  347. newState.tags = tags;
  348. }
  349. this.setState(newState);
  350. }
  351. /**
  352. * Save page
  353. * @param {string} markdown
  354. * @param {object} optionsToSave
  355. * @return {object} { page: Page, tags: Tag[] }
  356. */
  357. async save(markdown, editorMode, optionsToSave = {}) {
  358. const { pageId, path } = this.state;
  359. let { revisionId } = this.state;
  360. const options = Object.assign({}, optionsToSave);
  361. if (editorMode === 'hackmd') {
  362. // set option to sync
  363. options.isSyncRevisionToHackmd = true;
  364. revisionId = this.state.revisionIdHackmdSynced;
  365. }
  366. let res;
  367. if (pageId == null) {
  368. res = await this.createPage(path, markdown, options);
  369. }
  370. else {
  371. res = await this.updatePage(pageId, revisionId, markdown, options);
  372. }
  373. this.updateStateAfterSave(res.page, res.tags, res.revision, editorMode);
  374. return res;
  375. }
  376. async saveAndReload(optionsToSave, editorMode) {
  377. if (optionsToSave == null) {
  378. const msg = '\'saveAndReload\' requires the \'optionsToSave\' param';
  379. throw new Error(msg);
  380. }
  381. if (editorMode == null) {
  382. logger.warn('\'saveAndReload\' requires the \'editorMode\' param');
  383. return;
  384. }
  385. const { pageId, path } = this.state;
  386. let { revisionId } = this.state;
  387. const options = Object.assign({}, optionsToSave);
  388. let markdown;
  389. if (editorMode === 'hackmd') {
  390. const pageEditorByHackmd = this.appContainer.getComponentInstance('PageEditorByHackmd');
  391. markdown = await pageEditorByHackmd.getMarkdown();
  392. // set option to sync
  393. options.isSyncRevisionToHackmd = true;
  394. revisionId = this.state.revisionIdHackmdSynced;
  395. }
  396. else {
  397. const pageEditor = this.appContainer.getComponentInstance('PageEditor');
  398. markdown = pageEditor.getMarkdown();
  399. }
  400. let res;
  401. if (pageId == null) {
  402. res = await this.createPage(path, markdown, options);
  403. }
  404. else {
  405. res = await this.updatePage(pageId, revisionId, markdown, options);
  406. }
  407. const editorContainer = this.appContainer.getContainer('EditorContainer');
  408. editorContainer.clearDraft(path);
  409. window.location.href = path;
  410. return res;
  411. }
  412. async createPage(pagePath, markdown, tmpParams) {
  413. const socketIoContainer = this.appContainer.getContainer('SocketIoContainer');
  414. // clone
  415. const params = Object.assign(tmpParams, {
  416. path: pagePath,
  417. body: markdown,
  418. });
  419. const res = await this.appContainer.apiv3Post('/pages/', params);
  420. const { page, tags, revision } = res.data;
  421. return { page, tags, revision };
  422. }
  423. async updatePage(pageId, revisionId, markdown, tmpParams) {
  424. const socketIoContainer = this.appContainer.getContainer('SocketIoContainer');
  425. // clone
  426. const params = Object.assign(tmpParams, {
  427. page_id: pageId,
  428. revision_id: revisionId,
  429. body: markdown,
  430. });
  431. const res = await this.appContainer.apiPost('/pages.update', params);
  432. if (!res.ok) {
  433. throw new Error(res.error);
  434. }
  435. return res;
  436. }
  437. deletePage(isRecursively, isCompletely) {
  438. const socketIoContainer = this.appContainer.getContainer('SocketIoContainer');
  439. // control flag
  440. const completely = isCompletely ? true : null;
  441. const recursively = isRecursively ? true : null;
  442. return this.appContainer.apiPost('/pages.remove', {
  443. recursively,
  444. completely,
  445. page_id: this.state.pageId,
  446. revision_id: this.state.revisionId,
  447. });
  448. }
  449. revertRemove(isRecursively) {
  450. const socketIoContainer = this.appContainer.getContainer('SocketIoContainer');
  451. // control flag
  452. const recursively = isRecursively ? true : null;
  453. return this.appContainer.apiPost('/pages.revertRemove', {
  454. recursively,
  455. page_id: this.state.pageId,
  456. });
  457. }
  458. rename(newPagePath, isRecursively, isRenameRedirect, isRemainMetadata) {
  459. const socketIoContainer = this.appContainer.getContainer('SocketIoContainer');
  460. const { pageId, revisionId, path } = this.state;
  461. return this.appContainer.apiv3Put('/pages/rename', {
  462. revisionId,
  463. pageId,
  464. isRecursively,
  465. isRenameRedirect,
  466. isRemainMetadata,
  467. newPagePath,
  468. path,
  469. });
  470. }
  471. showSuccessToastr() {
  472. toastr.success(undefined, 'Saved successfully', {
  473. closeButton: true,
  474. progressBar: true,
  475. newestOnTop: false,
  476. showDuration: '100',
  477. hideDuration: '100',
  478. timeOut: '1200',
  479. extendedTimeOut: '150',
  480. });
  481. }
  482. showErrorToastr(error) {
  483. toastr.error(error.message, 'Error occured', {
  484. closeButton: true,
  485. progressBar: true,
  486. newestOnTop: false,
  487. showDuration: '100',
  488. hideDuration: '100',
  489. timeOut: '3000',
  490. });
  491. }
  492. // request to server so the client to join a room for each page
  493. emitJoinPageRoomRequest() {
  494. const socketIoContainer = this.appContainer.getContainer('SocketIoContainer');
  495. const socket = socketIoContainer.getSocket();
  496. socket.emit('join:page', { socketId: socket.id, pageId: this.state.pageId });
  497. }
  498. addWebSocketEventHandlers() {
  499. // eslint-disable-next-line @typescript-eslint/no-this-alias
  500. const pageContainer = this;
  501. const socketIoContainer = this.appContainer.getContainer('SocketIoContainer');
  502. const socket = socketIoContainer.getSocket();
  503. socket.on('page:create', (data) => {
  504. logger.debug({ obj: data }, `websocket on 'page:create'`); // eslint-disable-line quotes
  505. // update remote page data
  506. const { s2cMessagePageUpdated } = data;
  507. if (s2cMessagePageUpdated.pageId === pageContainer.state.pageId) {
  508. pageContainer.setLatestRemotePageData(s2cMessagePageUpdated);
  509. }
  510. });
  511. socket.on('page:update', (data) => {
  512. logger.debug({ obj: data }, `websocket on 'page:update'`); // eslint-disable-line quotes
  513. // update remote page data
  514. const { s2cMessagePageUpdated } = data;
  515. if (s2cMessagePageUpdated.pageId === pageContainer.state.pageId) {
  516. pageContainer.setLatestRemotePageData(s2cMessagePageUpdated);
  517. }
  518. });
  519. socket.on('page:delete', (data) => {
  520. logger.debug({ obj: data }, `websocket on 'page:delete'`); // eslint-disable-line quotes
  521. // update remote page data
  522. const { s2cMessagePageUpdated } = data;
  523. if (s2cMessagePageUpdated.pageId === pageContainer.state.pageId) {
  524. pageContainer.setLatestRemotePageData(s2cMessagePageUpdated);
  525. }
  526. });
  527. socket.on('page:editingWithHackmd', (data) => {
  528. logger.debug({ obj: data }, `websocket on 'page:editingWithHackmd'`); // eslint-disable-line quotes
  529. // update isHackmdDraftUpdatingInRealtime
  530. const { s2cMessagePageUpdated } = data;
  531. if (s2cMessagePageUpdated.pageId === pageContainer.state.pageId) {
  532. pageContainer.setState({ isHackmdDraftUpdatingInRealtime: true });
  533. }
  534. });
  535. }
  536. /* TODO GW-325 */
  537. retrieveMyBookmarkList() {
  538. }
  539. async resolveConflict(markdown, editorMode) {
  540. const { pageId, remoteRevisionId, path } = this.state;
  541. const editorContainer = this.appContainer.getContainer('EditorContainer');
  542. const options = editorContainer.getCurrentOptionsToSave();
  543. const optionsToSave = Object.assign({}, options);
  544. const res = await this.updatePage(pageId, remoteRevisionId, markdown, optionsToSave);
  545. editorContainer.clearDraft(path);
  546. this.updateStateAfterSave(res.page, res.tags, res.revision, editorMode);
  547. editorContainer.setState({ tags: res.tags });
  548. return res;
  549. }
  550. }