@webhandle/ckeditor-4 1.0.0

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.
@@ -0,0 +1,173 @@
1
+ import createInitializeWebhandleComponent from "@webhandle/initialize-webhandle-component/create-initialize-webhandle-component.mjs"
2
+ import ComponentManager from "@webhandle/initialize-webhandle-component/component-manager.mjs"
3
+ import path from "node:path"
4
+
5
+ const initializeWebhandleComponent = createInitializeWebhandleComponent()
6
+
7
+ initializeWebhandleComponent.componentName = '@webhandle/ckeditor-4'
8
+ initializeWebhandleComponent.componentDir = import.meta.dirname
9
+ initializeWebhandleComponent.defaultConfig = {
10
+ "publicFilesPrefix": '/' + initializeWebhandleComponent.componentName + "/files"
11
+ , "alwaysProvideResources": false
12
+ }
13
+ initializeWebhandleComponent.staticFilePath = 'public'
14
+ initializeWebhandleComponent.templatePath = 'views'
15
+
16
+
17
+ initializeWebhandleComponent.setup = async function(webhandle, config) {
18
+ let manager = new ComponentManager()
19
+ manager.config = config
20
+
21
+ let base = webhandle.projectRoot
22
+ try {
23
+ let info = webhandle.sinks.project.getFullFileInfo('node_modules/ckeditor4')
24
+ }
25
+ catch(e) {
26
+ base = initializeWebhandleComponent.componentDir
27
+ }
28
+ manager.staticPaths.push(
29
+ webhandle.addStaticDir(
30
+ path.join(base, 'node_modules/ckeditor4')
31
+ , {
32
+ urlPrefix: '/@webhandle/ckeditor-4/ck-files'
33
+ , fixedSetOfFiles: true
34
+ })
35
+ )
36
+ manager.staticPaths.push(
37
+ webhandle.addStaticDir(
38
+ path.join(base, 'node_modules/@webhandle/ckeditor-multi-widget-panel/public/ckeditor')
39
+ , {
40
+ urlPrefix: '/@webhandle/ckeditor-4/ck-files'
41
+ , fixedSetOfFiles: true
42
+ })
43
+ )
44
+ manager.staticPaths.push(
45
+ webhandle.addStaticDir(
46
+ path.join(base, 'node_modules/@dankolz/picture-ckeditor-plugin/public/ckeditor')
47
+ , {
48
+ urlPrefix: '/@webhandle/ckeditor-4/ck-files'
49
+ , fixedSetOfFiles: true
50
+ })
51
+ )
52
+ manager.staticPaths.push(
53
+ webhandle.addStaticDir(
54
+ path.join(base, 'node_modules/@dankolz/template-ckeditor-plugin/public/ckeditor')
55
+ , {
56
+ urlPrefix: '/@webhandle/ckeditor-4/ck-files'
57
+ , fixedSetOfFiles: true
58
+ })
59
+ )
60
+
61
+ manager.staticPaths.push(
62
+ webhandle.addStaticDir(
63
+ path.join(initializeWebhandleComponent.componentDir, 'public')
64
+ , {
65
+ urlPrefix: '/@webhandle/ckeditor-4/files'
66
+ , fixedSetOfFiles: true
67
+ })
68
+ )
69
+
70
+ manager.addExternalResources = function(externalResourceManager) {
71
+ externalResourceManager.provideResource({
72
+ mimeType: 'application/javascript'
73
+ , url: '/@webhandle/ckeditor-4/ck-files/ckeditor.js'
74
+ , name: 'ckeditor4'
75
+ , resourceType: 'module'
76
+ })
77
+ externalResourceManager.includeResource({
78
+ mimeType: 'application/javascript'
79
+ , url: '/@webhandle/ckeditor-4/files/js/variables.mjs'
80
+ , resourceType: 'module'
81
+ })
82
+ externalResourceManager.includeResource({
83
+ mimeType: 'application/javascript'
84
+ , url: '/@webhandle/ckeditor-4/files/js/load.mjs'
85
+ , resourceType: 'module'
86
+ })
87
+ // externalResourceManager.includeResource({
88
+ // mimeType: 'text/css'
89
+ // , url: '/@webhandle/ckeditor-4/files/styles.css'
90
+ // })
91
+ }
92
+
93
+ webhandle.addTemplate(initializeWebhandleComponent.componentName + '/addExternalResources', (data) => {
94
+ try {
95
+ let externalResourceManager = initializeWebhandleComponent.getExternalResourceManager(data)
96
+ manager.addExternalResources(externalResourceManager)
97
+ let resources = externalResourceManager.render()
98
+ return resources
99
+ }
100
+ catch(e) {
101
+ console.log(e)
102
+ }
103
+ return ""
104
+ })
105
+
106
+ // webhandle.routers.preDynamic.use((req, res, next) => {
107
+ // if(config.alwaysProvideResources || !initializeWebhandleComponent.supportsMultipleImportMaps(req)) {
108
+ // manager.addExternalResources(res.locals.externalResourceManager)
109
+ // }
110
+ // next()
111
+ // })
112
+
113
+ // manager.addExternalResources = (externalResourceManager, options) => {
114
+ // externalResourceManager.includeResource({
115
+ // mimeType: 'text/css'
116
+ // , url: config.publicFilesPrefix + '/css/styles.css'
117
+ // })
118
+
119
+ // externalResourceManager.provideResource({
120
+ // url: config.publicFilesPrefix + '/js/functionality.mjs'
121
+ // , mimeType: 'application/javascript'
122
+ // , resourceType: 'module'
123
+ // , name: initializeWebhandleComponent.componentName
124
+ // })
125
+ // }
126
+
127
+ // webhandle.addTemplate(initializeWebhandleComponent.componentName + '/addExternalResources', (data) => {
128
+ // let externalResourceManager = initializeWebhandleComponent.getExternalResourceManager(data)
129
+ // manager.addExternalResources(externalResourceManager)
130
+ // })
131
+
132
+ // webhandle.addTemplate(initializeWebhandleComponent.componentName + '/doTheThing', (data) => {
133
+ // try {
134
+ // let externalResourceManager = initializeWebhandleComponent.getExternalResourceManager(data)
135
+ // manager.addExternalResources(externalResourceManager)
136
+
137
+ // let resources = externalResourceManager.render()
138
+ // let action = `
139
+ // <script type="module">
140
+ // import { component } from "${initializeWebhandleComponent.componentName}"
141
+ // component()
142
+ // </script>`
143
+
144
+ // return resources + action
145
+ // }
146
+ // catch(e) {
147
+ // console.error(e)
148
+ // }
149
+ // })
150
+
151
+ // // Allow access to the component and style code
152
+ // let filePath = path.join(initializeWebhandleComponent.componentDir, initializeWebhandleComponent.staticFilePath)
153
+ // manager.staticPaths.push(
154
+ // webhandle.addStaticDir(
155
+ // filePath,
156
+ // {
157
+ // urlPrefix: config.publicFilesPrefix
158
+ // , fixedSetOfFiles: true
159
+ // }
160
+ // )
161
+ // )
162
+
163
+ // webhandle.addTemplateDir(
164
+ // path.join(initializeWebhandleComponent.componentDir, initializeWebhandleComponent.templatePath)
165
+ // , {
166
+ // immutable: true
167
+ // }
168
+ // )
169
+
170
+ return manager
171
+ }
172
+
173
+ export default initializeWebhandleComponent
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@webhandle/ckeditor-4",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "run-webhandle ./test.mjs"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/EmergentIdeas/webhandle-ckeditor-4.git"
12
+ },
13
+ "keywords": [],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "type": "module",
17
+ "bugs": {
18
+ "url": "https://github.com/EmergentIdeas/webhandle-ckeditor-4/issues"
19
+ },
20
+ "homepage": "https://github.com/EmergentIdeas/webhandle-ckeditor-4#readme",
21
+ "dependencies": {
22
+ "@dankolz/picture-ckeditor-plugin": "^1.0.7",
23
+ "@dankolz/template-ckeditor-plugin": "^1.0.1",
24
+ "@webhandle/ckeditor-multi-widget-panel": "^1.0.2",
25
+ "@webhandle/initialize-webhandle-component": "^1.0.4",
26
+ "ckeditor4": "4.22"
27
+ }
28
+ }
@@ -0,0 +1,64 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ __externalResourceManager.render()__
6
+
7
+
8
+ </head>
9
+
10
+ <body>
11
+
12
+ __externalResourceManager::@webhandle/ckeditor-4/addExternalResources__
13
+ <div id="editor" style="height: 500px; border: solid 1px black;">
14
+
15
+ </div>
16
+ <textarea class="ckeditor" id="teditor"></textarea>
17
+
18
+ <script type="module">
19
+ let id = 'editor'
20
+
21
+ let editorEl = document.querySelector('#' + id)
22
+ editorEl.setAttribute('contenteditable', 'true')
23
+ editorEl.classList.add('page-editor-editable')
24
+
25
+ let editorOptions = {
26
+ on: {
27
+ change: function(event) {
28
+ console.log('change')
29
+ },
30
+ blur: function( event ) {
31
+ console.log('blur')
32
+ }
33
+ }
34
+ , customConfig: '/@webhandle/ckeditor-4/files/conf/std-config.js'
35
+ }
36
+ CKEDITOR.inline(id, editorOptions)
37
+
38
+ id = 'teditor'
39
+ editorEl = document.querySelector('#' + id)
40
+ editorOptions = {
41
+ on: {
42
+ change: function(event) {
43
+ // console.log(event)
44
+ // console.log(event.editor.getData())
45
+ document.querySelector('#' + id).value = event.editor.getData()
46
+ },
47
+ blur: function( event ) {
48
+ console.log(event)
49
+ }
50
+ }
51
+ , customConfig: '/@webhandle/ckeditor-4/files/conf/std-config.js'
52
+ }
53
+ CKEDITOR.replace(id, editorOptions)
54
+ </script>
55
+
56
+
57
+
58
+
59
+
60
+ __externalResourceManager.render()__
61
+ </body>
62
+
63
+
64
+ </html>
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ CKEDITOR.editorConfig = function( config ) {
7
+ // Define changes to default configuration here.
8
+ // For complete reference see:
9
+ // http://docs.ckeditor.com/#!/api/CKEDITOR.config
10
+
11
+ // The toolbar groups arrangement, optimized for two toolbar rows.
12
+ config.toolbarGroups = [
13
+ { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
14
+ { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] },
15
+ { name: 'links' },
16
+ { name: 'insert' },
17
+ { name: 'forms' },
18
+ { name: 'tools' },
19
+ { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
20
+ { name: 'others' },
21
+ '/',
22
+ { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
23
+ { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
24
+ { name: 'styles' },
25
+ { name: 'colors' }
26
+ ];
27
+
28
+ // Remove some buttons provided by the standard plugins, which are
29
+ // not needed in the Standard(s) toolbar.
30
+ config.removeButtons = 'Underline,Subscript,Superscript';
31
+
32
+ config.removePlugins = 'image';
33
+
34
+ // Set the most common block elements.
35
+ config.format_tags = 'p;h1;h2;h3;pre';
36
+
37
+ // Simplify the dialog windows.
38
+ // config.removeDialogTabs = 'image:advanced;link:advanced';
39
+
40
+ config.disableNativeSpellChecker = false;
41
+ config.filebrowserBrowseUrl = '/webhandle-page-editor/files/browse/type/all'
42
+ config.filebrowserImageBrowseUrl = '/webhandle-page-editor/files/browse/type/image'
43
+ config.filebrowserUploadUrl = '/webhandle-page-editor/files/upload-file?action=upload'
44
+ config.allowedContent = "small h5 h6 sup sub strong em table tr td th tbody dl dt dd br hr ul ol li pre u[class](*); img[*](*){*}; a[*](*); iframe[*](*); span[*](*); div[*](*); h1[*](*); h2[*](*){*}; h3[*](*){*}; h4[*](*); p{*}[*](*); section[*](*); picture[*](*){*}; figure[*](*){*}; figcaption[*](*){*}; script[*](*){*}"
45
+ config.disallowedContent = 'img{width, height}[width, height]'
46
+
47
+ config.extraPlugins = (config.extraPlugins ? config.extraPlugins + ',' : '') + 'sourcedialog,flex-picture,template-replacement,multi-widget-panel'
48
+ // config.extraPlugins = (config.extraPlugins ? config.extraPlugins + ',' : '') + 'sourcedialog'
49
+
50
+ config.sourceAreaTabSize = 4;
51
+ config.versionCheck = false
52
+ };
53
+
54
+ CKEDITOR.on( 'instanceReady', function( ev ) {
55
+ function makeBlockStyleFormat(tag) {
56
+ ev.editor.dataProcessor.writer.setRules( tag, {
57
+ indent: true,
58
+ breakBeforeOpen: true,
59
+ breakAfterOpen: true,
60
+ breakBeforeClose: true,
61
+ breakAfterClose: true
62
+ })
63
+ }
64
+ ev.editor.dataProcessor.writer.selfClosingEnd = '/>';
65
+ ev.editor.dataProcessor.writer.indentationChars = '\t';
66
+ for(let tag of ['div', 'section', 'p', 'h1', 'h2', 'h3', 'h4', 'h5']) {
67
+ makeBlockStyleFormat(tag)
68
+ }
69
+ });
@@ -0,0 +1,2 @@
1
+ import "ckeditor4"
2
+ CKEDITOR.disableAutoInline = true
@@ -0,0 +1 @@
1
+ window.CKEDITOR_BASEPATH = '/@webhandle/ckeditor-4/ck-files/'
package/test.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import setupCKEditor from "./initialize-webhandle-component.mjs";
2
+ export default async function test(webhandle) {
3
+ webhandle.development = true
4
+
5
+ let ckManager = await setupCKEditor(webhandle)
6
+
7
+ // webhandle.routers.primary.use((req, res, next) => {
8
+ // ckManager.addExternalResources(res.locals.externalResourceManager)
9
+ // next()
10
+ // })
11
+ }