@silexlabs/silex 3.3.0 → 3.3.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,13 +21,11 @@
21
21
  *
22
22
  */
23
23
 
24
- import { Component, ComponentView } from 'grapesjs'
25
24
  import { DEV_MESSAGE } from '../constants'
26
25
  import { ClientConfig } from './config'
27
26
  import { ClientEvent } from './events'
28
27
  import { initEditor, getEditor } from './grapesjs/index'
29
28
  import { cmdPauseAutoSave } from './grapesjs/storage'
30
- import { displayedToStored, storedToDisplayed } from './assetUrl'
31
29
 
32
30
  // Expose API to calling app as window.silex
33
31
  export * from './expose'
@@ -85,42 +83,6 @@ export async function start(options = {}): Promise<void> {
85
83
  // Add default plugins
86
84
  await config.addDefaultPlugins()
87
85
 
88
- const domc = editor.DomComponents
89
- const imgType = domc.getType('image')
90
- domc.addType('image', {
91
- ...imgType,
92
- view: {
93
- ...imgType.view,
94
- onRender() {
95
- const view = this as ComponentView
96
- imgType.view.onRender && imgType.view.onRender.call(this) // call original
97
- const el = view.el
98
- const elImg = view.el as HTMLImageElement
99
- const src = this.model.getAttributes().src
100
- if (src && !src.startsWith('http')) {
101
- elImg.src = storedToDisplayed(src, config.websiteId, config.storageId)
102
- }
103
- },
104
- },
105
- model: {
106
- ...imgType.model,
107
- init() {
108
- const model = this as Component
109
- imgType.model.init && imgType.model.init.call(this) // call original
110
- // Handle changes by the AssetManager
111
- model.on('change', () => {
112
- if(model.get('src')) {
113
- const newSrc = displayedToStored(model.get('src'))
114
- if(newSrc !== model.get('src')) {
115
- model.set('src', newSrc)
116
- model.view.render()
117
- }
118
- }
119
- })
120
- },
121
- },
122
- })
123
-
124
86
  // Load the site
125
87
  try {
126
88
  editor.runCommand(cmdPauseAutoSave)
@@ -656,7 +656,7 @@ export default class GitlabConnector implements StorageConnector {
656
656
  } while (page <= totalPages)
657
657
 
658
658
  return projects
659
- .filter(p => p.name.startsWith(this.options.repoPrefix))
659
+ .filter(p => p.name.startsWith(this.options.repoPrefix) && !p.name.includes('-deleted-'))
660
660
  .map(p => ({
661
661
  websiteId: p.id,
662
662
  name: p.name.replace(this.options.repoPrefix, ''),
@@ -826,75 +826,10 @@ export default class GitlabConnector implements StorageConnector {
826
826
  await this.callApi({
827
827
  session,
828
828
  path: `api/v4/projects/${websiteId}`,
829
- method: 'DELETE'
829
+ method: 'DELETE',
830
830
  })
831
- //// Load the meta repo data
832
- //const file = await this.callApi(session, `api/v4/projects/${this.getMetaRepoPath(session)}/repository/files/${this.options.metaRepoFile}`, 'GET', null, {
833
- // ref: this.options.branch,
834
- //})
835
- //const metaRepo = JSON.parse(Buffer.from(file.content, 'base64').toString('utf8')) as MetaRepoFileContent
836
- //const data = metaRepo.websites[websiteId]
837
- //if(!data) throw new ApiError(`Website ${websiteId} not found`, 404)
838
- //// Update or create the website meta data
839
- //delete metaRepo.websites[websiteId]
840
- //// Save the meta repo data
841
- //const project = await this.callApi(session, `api/v4/projects/${this.getMetaRepoPath(session)}/repository/files/${this.options.metaRepoFile}`, 'PUT', {
842
- // branch: this.options.branch,
843
- // commit_message: `Delete meta data of ${data.meta.name} (${websiteId}) from Silex`,
844
- // content: JSON.stringify(metaRepo),
845
- //})
846
831
  }
847
832
 
848
- // async duplicateWebsite(session: GitlabSession, websiteId: string): Promise<void> {
849
- // // Get the repo meta data
850
- // const meta = await this.getWebsiteMeta(session, websiteId)
851
- // // List all the repository files
852
- // const files = await this.ls({
853
- // session,
854
- // websiteId,
855
- // recursive: true,
856
- // })
857
-
858
- // // Create a new repo
859
- // const newId = await this.createWebsite(session, {
860
- // ...meta,
861
- // name: meta.name + ' Copy ' + new Date().toISOString().replace(/T.*/, '') + ' ' + Math.random().toString(36).substring(2, 4),
862
- // })
863
- // // Upload all files
864
- // const actions: GitlabAction[] = []
865
- // for (const file of files.keys()) {
866
- // const content = await this.readFile(session, websiteId, file)
867
- // // From buffer to string
868
- // const contentStr = content.toString('base64')
869
- // const path = encodeURIComponent(file)
870
- // switch (file) {
871
- // case WEBSITE_DATA_FILE:
872
- // actions.push({
873
- // action: 'update',
874
- // file_path: path,
875
- // content: contentStr,
876
- // })
877
- // break
878
- // default:
879
- // actions.push({
880
- // action: 'create',
881
- // file_path: path,
882
- // content: contentStr,
883
- // })
884
- // }
885
- // }
886
- // // Perform a batch commit
887
- // return this.callApi({
888
- // session,
889
- // path: `api/v4/projects/${newId}/repository/commits`,
890
- // method: 'POST',
891
- // requestBody: {
892
- // branch: this.options.branch,
893
- // commit_message: 'Update website data from Silex',
894
- // actions,
895
- // },
896
- // })
897
- // }
898
833
  // Fork the repo
899
834
  async duplicateWebsite(session: GitlabSession, websiteId: string): Promise<void> {
900
835
  const meta = await this.getWebsiteMeta(session, websiteId)