From 35c0a0dc690f4ef83d376723003cb61d4d4b8e5a Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Mon, 30 May 2016 21:40:07 +0100 Subject: [PATCH] Use cloneWithData Change-Id: I7ffe3c7ab20d5f785a6642c8293f271f4dc08ff8 --- modules/ve-mw/dm/models/ve.dm.MWImageModel.js | 26 +++++-------------- .../dialogs/ve.ui.MWExtensionPreviewDialog.js | 3 ++- .../ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js | 9 ++----- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js index 4ce711d5a6..33a7848782 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js @@ -821,26 +821,12 @@ ve.dm.MWImageModel.prototype.getCurrentDimensions = function () { */ ve.dm.MWImageModel.prototype.getCaptionDocument = function () { if ( !this.captionDoc ) { - this.captionDoc = new ve.dm.Document( - [ - { type: 'paragraph', internal: { generated: 'wrapper' } }, - { type: '/paragraph' }, - { type: 'internalList' }, - { type: '/internalList' } - ], - // htmlDocument - this.parentDoc.getHtmlDocument(), - // parentDocument - null, - // internalList - null, - // innerWhitespace - null, - // lang - this.parentDoc.getLang(), - // dir - this.parentDoc.getDir() - ); + this.captionDoc = this.parentDoc.cloneWithData( [ + { type: 'paragraph', internal: { generated: 'wrapper' } }, + { type: '/paragraph' }, + { type: 'internalList' }, + { type: '/internalList' } + ] ); } return this.captionDoc; }; diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWExtensionPreviewDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWExtensionPreviewDialog.js index 762f118b31..149951c46e 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWExtensionPreviewDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWExtensionPreviewDialog.js @@ -55,7 +55,8 @@ ve.ui.MWExtensionPreviewDialog.prototype.getSetupProcess = function ( data ) { doc = this.selectedNode.getDocument().cloneFromRange( this.selectedNode.getOuterRange() ); } else { element = this.getNewElement(); - doc = new ve.dm.Document( [ + // We assume that WindowAction pass + doc = data.fragment.getDocument().cloneWithData( [ element, { type: '/' + element.type }, { type: 'internalList' }, diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js index 8e3529bf2b..56f8badcca 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js @@ -1271,17 +1271,12 @@ ve.ui.MWMediaDialog.prototype.resetCaption = function () { if ( this.imageModel ) { captionDocument = this.imageModel.getCaptionDocument(); } else { - captionDocument = new ve.dm.Document( [ + captionDocument = doc.cloneWithData( [ { type: 'paragraph', internal: { generated: 'wrapper' } }, { type: '/paragraph' }, { type: 'internalList' }, { type: '/internalList' } - ], - // The ve.dm.Document constructor expects - // ( data, htmlDocument, parentDocument, internalList, innerWhitespace, lang, dir ) - // as parameters. We are only interested in setting up language, hence the - // multiple 'null' values. - null, null, null, null, doc.getLang(), doc.getDir() ); + ] ); } this.store = doc.getStore();