-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
334894e
commit 9fa1520
Showing
19 changed files
with
700 additions
and
283 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
Note: We have included the plugin in the same JavaScript file as the TinyMCE | ||
instance for display purposes only. Tiny recommends not maintaining the plugin | ||
with the TinyMCE instance and using the `external_plugins` option. | ||
*/ | ||
tinymce.PluginManager.add('sfPreview', (editor, url) => { | ||
const openDialog = () => editor.windowManager.open({ | ||
title: 'Preview', | ||
type: 'htmlpanel', // component type | ||
html: '<div>Html goes here</div>', | ||
body: { | ||
type: 'panel', | ||
items: [ | ||
{ | ||
type: 'input', | ||
name: 'title', | ||
label: 'Title' | ||
} | ||
] | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'cancel', | ||
text: 'Close' | ||
}, | ||
{ | ||
type: 'submit', | ||
text: 'Save', | ||
buttonType: 'primary' | ||
} | ||
], | ||
onSubmit: (api) => { | ||
const data = api.getData(); | ||
/* Insert content when the window form is submitted */ | ||
editor.insertContent('Title: ' + data.title); | ||
api.close(); | ||
} | ||
}); | ||
/* Add a button that opens a window */ | ||
editor.ui.registry.addButton('sfPreview', { | ||
icon:'preview', | ||
onAction: () => { | ||
/* Open window */ | ||
openDialog(); | ||
} | ||
}); | ||
/* Adds a menu item, which can then be included in any menu via the menu/menubar configuration */ | ||
editor.ui.registry.addMenuItem('sfPreview', { | ||
text: '预览', | ||
icon:'preview', | ||
onAction: () => { | ||
/* Open window */ | ||
openDialog(); | ||
} | ||
}); | ||
/* Return the metadata for the help plugin */ | ||
return { | ||
getMetadata: () => ({ | ||
name: 'sfPreview', | ||
url: 'https://www.runpod.cn' | ||
}) | ||
}; | ||
}); | ||
|
||
/* | ||
The following is an example of how to use the new plugin and the new | ||
toolbar button. | ||
*/ | ||
tinymce.init({ | ||
selector: 'textarea#custom-plugin', | ||
plugins: 'example help', | ||
toolbar: 'example | help' | ||
}); |
69 changes: 69 additions & 0 deletions
69
app/Plugins/Topic/resources/assets/js/editor/plugins/sfPreview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Note: We have included the plugin in the same JavaScript file as the TinyMCE | ||
instance for display purposes only. Tiny recommends not maintaining the plugin | ||
with the TinyMCE instance and using the `external_plugins` option. | ||
*/ | ||
|
||
tinymce.PluginManager.add('sfPreview', (editor, url) => { | ||
const openDialog = () => editor.windowManager.open({ | ||
title: '预览', | ||
size: "large", | ||
body: { | ||
type: 'panel', | ||
items: [ | ||
{ | ||
type: 'iframe', // component type | ||
name: 'sfPreview', // identifier | ||
sandboxed: true, | ||
transparent: true, | ||
} | ||
] | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'cancel', | ||
text: 'Close' | ||
}, | ||
], | ||
}); | ||
/* Add a button that opens a window */ | ||
editor.ui.registry.addButton('sfPreview', { | ||
icon:'preview', | ||
onAction: () => { | ||
/* Open window */ | ||
let _openDialog = openDialog(); | ||
axios.post("/topic/create/preview",{ | ||
_token:csrf_token, | ||
content:editor.getContent() | ||
}).then(r=>{ | ||
_openDialog.setData({ | ||
sfPreview:r.data | ||
}) | ||
}) | ||
} | ||
}); | ||
/* Adds a menu item, which can then be included in any menu via the menu/menubar configuration */ | ||
editor.ui.registry.addMenuItem('sfPreview', { | ||
text: '预览', | ||
icon:'preview', | ||
onAction: () => { | ||
/* Open window */ | ||
let _openDialog = openDialog(); | ||
axios.post("/topic/create/preview",{ | ||
_token:csrf_token, | ||
content:editor.getContent() | ||
}).then(r=>{ | ||
_openDialog.setData({ | ||
sfPreview:r.data | ||
}) | ||
}) | ||
} | ||
}); | ||
/* Return the metadata for the help plugin */ | ||
return { | ||
getMetadata: () => ({ | ||
name: 'sfPreview', | ||
url: 'https://www.runpod.cn' | ||
}) | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
69 changes: 69 additions & 0 deletions
69
app/Plugins/Topic/resources/package/js/editor/plugins/sfPreview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Note: We have included the plugin in the same JavaScript file as the TinyMCE | ||
instance for display purposes only. Tiny recommends not maintaining the plugin | ||
with the TinyMCE instance and using the `external_plugins` option. | ||
*/ | ||
|
||
tinymce.PluginManager.add('sfPreview', (editor, url) => { | ||
const openDialog = () => editor.windowManager.open({ | ||
title: '预览', | ||
size: "large", | ||
body: { | ||
type: 'panel', | ||
items: [ | ||
{ | ||
type: 'iframe', // component type | ||
name: 'sfPreview', // identifier | ||
sandboxed: true, | ||
transparent: true, | ||
} | ||
] | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'cancel', | ||
text: 'Close' | ||
}, | ||
], | ||
}); | ||
/* Add a button that opens a window */ | ||
editor.ui.registry.addButton('sfPreview', { | ||
icon:'preview', | ||
onAction: () => { | ||
/* Open window */ | ||
let _openDialog = openDialog(); | ||
axios.post("/topic/create/preview",{ | ||
_token:csrf_token, | ||
content:editor.getContent() | ||
}).then(r=>{ | ||
_openDialog.setData({ | ||
sfPreview:r.data | ||
}) | ||
}) | ||
} | ||
}); | ||
/* Adds a menu item, which can then be included in any menu via the menu/menubar configuration */ | ||
editor.ui.registry.addMenuItem('sfPreview', { | ||
text: '预览', | ||
icon:'preview', | ||
onAction: () => { | ||
/* Open window */ | ||
let _openDialog = openDialog(); | ||
axios.post("/topic/create/preview",{ | ||
_token:csrf_token, | ||
content:editor.getContent() | ||
}).then(r=>{ | ||
_openDialog.setData({ | ||
sfPreview:r.data | ||
}) | ||
}) | ||
} | ||
}); | ||
/* Return the metadata for the help plugin */ | ||
return { | ||
getMetadata: () => ({ | ||
name: 'sfPreview', | ||
url: 'https://www.runpod.cn' | ||
}) | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.