From b870fbe4769add75cab464791b546bad18f61af0 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 14 Mar 2022 08:54:31 +0300 Subject: [PATCH 1/4] Add code-mirror mapping for test app --- .../Volo.CmsKit.Web.Unified/abp.resourcemapping.js | 5 ++++- .../host/Volo.CmsKit.Web.Unified/package.json | 3 ++- .../cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js index 82b2d4b649..b473302023 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js @@ -7,6 +7,9 @@ module.exports = { "@libs" ], mappings: { - + "@node_modules/codemirror/lib/*.*": "@libs/codemirror/", + "@node_modules/codemirror/mode/**/*.*": "@libs/codemirror/mode/", + "@node_modules/codemirror/theme/**/*.*": "@libs/codemirror/theme/", + "@node_modules/codemirror/addon/**/*.*": "@libs/codemirror/addon/" } } \ No newline at end of file diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json index c27b4dc457..909a876b9d 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@abp/aspnetcore.mvc.ui.theme.basic": "^5.2.0-rc.1", - "@abp/cms-kit": "5.2.0-rc.1" + "@abp/cms-kit": "5.2.0-rc.1", + "@abp/codemirror": "~5.2.0-rc.1" } } \ No newline at end of file diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock index 47305a1cad..e69e2daced 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock @@ -90,6 +90,14 @@ "@abp/cms-kit.admin" "~5.2.0-rc.1" "@abp/cms-kit.public" "~5.2.0-rc.1" +"@abp/codemirror@~5.2.0-rc.1": + version "5.2.0-rc.1" + resolved "https://registry.yarnpkg.com/@abp/codemirror/-/codemirror-5.2.0-rc.1.tgz#0f06b4396056d1f3c854e67127d84781690d554f" + integrity sha512-iYl9LnHJTZFGUF/WJdGwXwTDUtfrodqr4RAEG+OBETe55yjGLmEW9cRjqgyZdX8UZvYGv9kSD3ScVUrv3woa/A== + dependencies: + "@abp/core" "~5.2.0-rc.1" + codemirror "^5.65.1" + "@abp/core@~5.2.0-rc.1": version "5.2.0-rc.1" resolved "https://registry.yarnpkg.com/@abp/core/-/core-5.2.0-rc.1.tgz#28dd4949d6b45a2a75f4b76fe0b78b9fa809755d" @@ -987,6 +995,11 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= +codemirror@^5.65.1: + version "5.65.2" + resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.65.2.tgz#5799a70cb3d706e10f60e267245e3a75205d3dd9" + integrity sha512-SZM4Zq7XEC8Fhroqe3LxbEEX1zUPWH1wMr5zxiBuiUF64iYOUH/JI88v4tBag8MiBS8B8gRv8O1pPXGYXQ4ErA== + collection-map@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/collection-map/-/collection-map-1.0.0.tgz#aea0f06f8d26c780c2b75494385544b2255af18c" From 68194d7f85b736e5834aeab6700b4c97a1dcf8d1 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 14 Mar 2022 09:08:52 +0300 Subject: [PATCH 2/4] Add style & script editor for Page Create/Update --- .../Pages/CmsKit/Pages/Create.cshtml | 9 ++++++-- .../Pages/CmsKit/Pages/Update.cshtml | 5 +++++ .../Pages/CmsKit/Pages/create.js | 22 +++++++++++++++++-- .../Pages/CmsKit/Pages/update.js | 18 +++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml index 841576e761..4671cb2ca2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Create.cshtml @@ -1,6 +1,7 @@ @page @using System.Globalization +@using Volo.Abp.AspNetCore.Mvc.UI.Packages.Codemirror @using Volo.Abp.AspNetCore.Mvc.UI.Packages.TuiEditor @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Uppy @using Volo.CmsKit.Admin.Web.Pages @@ -22,6 +23,9 @@ + + + @@ -31,6 +35,7 @@ @section styles { + } @@ -56,11 +61,11 @@ - + - + diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml index 1271502946..499ad1b633 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/Update.cshtml @@ -1,6 +1,7 @@ @page "{Id}" @using System.Globalization +@using Volo.Abp.AspNetCore.Mvc.UI.Packages.Codemirror @using Volo.Abp.AspNetCore.Mvc.UI.Packages.TuiEditor @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Uppy @using Volo.Abp.AspNetCore.Mvc.UI.Packages.Slugify @@ -23,6 +24,9 @@ + + + @@ -32,6 +36,7 @@ @section styles { + } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/create.js b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/create.js index ffe37fe5a8..1de6021a7d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/create.js +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/create.js @@ -6,22 +6,40 @@ $(function () { var $slug = $('#ViewModel_Slug'); var $buttonSubmit = $('#button-page-create'); + var scriptEditor = CodeMirror.fromTextArea(document.getElementById("ViewModel_Script"), { + mode: "javascript", + lineNumbers: true + }); + + var styleEditor = CodeMirror.fromTextArea(document.getElementById("ViewModel_Style"), { + mode: "css", + lineNumbers: true + }); + + $('.nav-tabs a').on('shown.bs.tab', function () { + scriptEditor.refresh(); + styleEditor.refresh(); + }); + $createForm.data('validator').settings.ignore = ":hidden, [contenteditable='true']:not([name]), .tui-popup-wrapper"; $createForm.on('submit', function (e) { e.preventDefault(); - + if ($createForm.valid()) { abp.ui.setBusy(); + $("#ViewModel_Style").val(styleEditor.getValue()); + $("#ViewModel_Script").val(scriptEditor.getValue()); + $createForm.ajaxSubmit({ success: function (result) { abp.notify.success(l('SuccessfullySaved')); abp.ui.clearBusy(); location.href = "../Pages"; }, - error: function(result){ + error: function (result) { abp.ui.clearBusy(); abp.notify.error(result.responseJSON.error.message); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/update.js b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/update.js index 99af38b70c..6bd90dd934 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/update.js +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/update.js @@ -7,6 +7,21 @@ $(function () { $formUpdate.data('validator').settings.ignore = ":hidden, [contenteditable='true']:not([name]), .tui-popup-wrapper"; + var scriptEditor = CodeMirror.fromTextArea(document.getElementById("ViewModel_Script"), { + mode: "javascript", + lineNumbers: true + }); + + var styleEditor = CodeMirror.fromTextArea(document.getElementById("ViewModel_Style"), { + mode: "css", + lineNumbers: true + }); + + $('.nav-tabs a').on('shown.bs.tab', function () { + scriptEditor.refresh(); + styleEditor.refresh(); + }); + $formUpdate.on('submit', function (e) { e.preventDefault(); @@ -14,6 +29,9 @@ $(function () { abp.ui.setBusy(); + $("#ViewModel_Style").val(styleEditor.getValue()); + $("#ViewModel_Script").val(scriptEditor.getValue()); + $formUpdate.ajaxSubmit({ success: function (result) { abp.notify.success(l('SuccessfullySaved')); From 880d23357af54ef7afca428dedc6bac10a089d9a Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 14 Mar 2022 09:32:21 +0300 Subject: [PATCH 3/4] Revert local changes for Volo.CmsKit.Web.Unified --- .../host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js | 4 ---- modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js index b473302023..26cdc6aad9 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/abp.resourcemapping.js @@ -7,9 +7,5 @@ module.exports = { "@libs" ], mappings: { - "@node_modules/codemirror/lib/*.*": "@libs/codemirror/", - "@node_modules/codemirror/mode/**/*.*": "@libs/codemirror/mode/", - "@node_modules/codemirror/theme/**/*.*": "@libs/codemirror/theme/", - "@node_modules/codemirror/addon/**/*.*": "@libs/codemirror/addon/" } } \ No newline at end of file diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json index 909a876b9d..c27b4dc457 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/package.json @@ -4,7 +4,6 @@ "private": true, "dependencies": { "@abp/aspnetcore.mvc.ui.theme.basic": "^5.2.0-rc.1", - "@abp/cms-kit": "5.2.0-rc.1", - "@abp/codemirror": "~5.2.0-rc.1" + "@abp/cms-kit": "5.2.0-rc.1" } } \ No newline at end of file From e40dfb586e18ac522614e0180aafbdc31a36d5b4 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 14 Mar 2022 09:33:14 +0300 Subject: [PATCH 4/4] Update yarn.lock --- .../cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock index e69e2daced..47305a1cad 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/yarn.lock @@ -90,14 +90,6 @@ "@abp/cms-kit.admin" "~5.2.0-rc.1" "@abp/cms-kit.public" "~5.2.0-rc.1" -"@abp/codemirror@~5.2.0-rc.1": - version "5.2.0-rc.1" - resolved "https://registry.yarnpkg.com/@abp/codemirror/-/codemirror-5.2.0-rc.1.tgz#0f06b4396056d1f3c854e67127d84781690d554f" - integrity sha512-iYl9LnHJTZFGUF/WJdGwXwTDUtfrodqr4RAEG+OBETe55yjGLmEW9cRjqgyZdX8UZvYGv9kSD3ScVUrv3woa/A== - dependencies: - "@abp/core" "~5.2.0-rc.1" - codemirror "^5.65.1" - "@abp/core@~5.2.0-rc.1": version "5.2.0-rc.1" resolved "https://registry.yarnpkg.com/@abp/core/-/core-5.2.0-rc.1.tgz#28dd4949d6b45a2a75f4b76fe0b78b9fa809755d" @@ -995,11 +987,6 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= -codemirror@^5.65.1: - version "5.65.2" - resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.65.2.tgz#5799a70cb3d706e10f60e267245e3a75205d3dd9" - integrity sha512-SZM4Zq7XEC8Fhroqe3LxbEEX1zUPWH1wMr5zxiBuiUF64iYOUH/JI88v4tBag8MiBS8B8gRv8O1pPXGYXQ4ErA== - collection-map@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/collection-map/-/collection-map-1.0.0.tgz#aea0f06f8d26c780c2b75494385544b2255af18c"