Skip to content

Commit

Permalink
scroll issues and hard coded strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuletpol committed Feb 1, 2025
1 parent bbfe8ca commit 1686e57
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ npx grunt amd

Refer to the documentation in `libs/codemirror` for details on modifying the CodeMirror dependency.

## Credits

Thanks to CodeMirror and the awesome CodeMirror plugins developed by [Replit](https://github.com/orgs/replit/repositories?q=codemirror). All icons are obtained from FontAwesome 6 free plugins. Many thanks also to the developers of the [htmlfy](https://www.npmjs.com/package/htmlfy) npm module.

---

Enjoy coding with **Source Code Pro**!
2 changes: 1 addition & 1 deletion amd/build/viewmanager.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/viewmanager.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/viewpanel.min.js.map

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions amd/src/viewmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,18 @@ export class ViewManager {
if (!currentNode) {
// Simply set the previous scroll position if selected node is not found
const previousScroll = blackboard.scrolls[this.editor.id];
this.editor.contentWindow.scrollTo(0, previousScroll);
setTimeout(() => this.editor.contentWindow.scrollTo(0, previousScroll), 50);
} else {
// Scroll the iframe's contentWindow until the currentNode is visible
this.editor.selection.setCursorLocation(currentNode, 0);
this.editor.selection.collapse();
const iframeHeight = this.editor.container.querySelector('iframe').clientHeight;
const scrollPos = Math.max(currentNode.offsetTop - 0.5 * iframeHeight, 0);
this.editor.contentWindow.scrollTo(0, scrollPos);
currentNode.remove();
setTimeout(() => {
// Images take some time to adquire correct height
const scrollPos = Math.max(currentNode.offsetTop - 0.5 * iframeHeight, 0);
this.editor.contentWindow.scrollTo(0, scrollPos);
currentNode.remove();
}, 50);
}
this.editor.nodeChanged();
this.pendingChanges = false;
Expand Down
1 change: 1 addition & 0 deletions amd/src/viewpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class ViewPanelManager extends ViewManager {
const container = api.getContainer();
this.parentContainer = container.parentElement;
const headerButtonElements = this.parentContainer.querySelectorAll('.tox-view__header button');

// eslint-disable-next-line no-unused-vars
const [_, __, btnDescreaseFontsize, btnIncreaseFontsize, btnTheme, ___, btnAccept] = headerButtonElements;
this.domElements = {
Expand Down
3 changes: 3 additions & 0 deletions lang/ca/tiny_codepro.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
$string['linewrap'] = 'Trencar línies llargues';
$string['opendialog'] = 'Obir com a diàleg';
$string['openpanel'] = 'Obrir com a panell';
$string['opt_confuser'] = 'Configurable per usuari';
$string['opt_defdialog'] = 'Per defecte diàleg';
$string['opt_defpanel'] = 'Per defecte panell';
$string['plugin'] = 'codePro';
$string['pluginname'] = 'Source code Pro';
$string['prettify'] = 'Formata el codi';
Expand Down
3 changes: 3 additions & 0 deletions lang/en/tiny_codepro.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
$string['linewrap'] = 'Line wrap';
$string['opendialog'] = 'Open as dialog';
$string['openpanel'] = 'Open as panel';
$string['opt_confuser'] = 'User configurable';
$string['opt_defdialog'] = 'Defaults to dialog';
$string['opt_defpanel'] = 'Defaults to panel';
$string['plugin'] = 'codePro';
$string['pluginname'] = 'Source code Pro';
$string['prettify'] = 'Prettify code';
Expand Down
3 changes: 3 additions & 0 deletions lang/es/tiny_codepro.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
$string['linewrap'] = 'Romper lineas largas';
$string['opendialog'] = 'Abrir como diálogo';
$string['openpanel'] = 'Abrir como panel';
$string['opt_confuser'] = 'Configurable por usuario';
$string['opt_defdialog'] = 'Por defecto diálogo';
$string['opt_defpanel'] = 'Por defecto panel';
$string['plugin'] = 'codePro';
$string['pluginname'] = 'Source code Pro';
$string['prettify'] = 'Formatear el código';
Expand Down
9 changes: 5 additions & 4 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@
1
));

$userconf = new lang_string('opt_confuser', $pluginname);
$choices1 = [
'dialog' => 'Open as dialog',
'panel' => 'Open as panel',
'user:dialog' => 'User configurable; defaults to dialog',
'user:panel' => 'User configurable; defaults to panel',
'dialog' => new lang_string('opendialog', $pluginname),
'panel' => new lang_string('openpanel', $pluginname),
'user:dialog' => new lang_string('opt_defdialog', $pluginname) . ' + ' . $userconf,
'user:panel' => new lang_string('opt_defpanel', $pluginname) . ' + ' . $userconf,
];

$settings->add(new admin_setting_configselect(
Expand Down
3 changes: 3 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
height: 100%;
max-width: 100% !important;
}
.tiny_codepro-view__pane {
overflow: hidden;
}
/** Ensure a minimum height in pane view **/
.tox.tox-tinymce:has(.tox-view-wrap:not([aria-hidden])):has(.tiny_codepro-view__pane) {
min-height: 400px;
Expand Down

0 comments on commit 1686e57

Please sign in to comment.