Skip to content

Commit

Permalink
Merge branch 'dev' into pr/desktop/fix-tinymce-ctrl-p
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator authored Mar 5, 2025
2 parents 1e0a4c1 + 7e8dee4 commit 7b901a1
Show file tree
Hide file tree
Showing 14 changed files with 404 additions and 330 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ packages/lib/commands/renderMarkup.test.js
packages/lib/commands/renderMarkup.js
packages/lib/commands/showEditorPlugin.js
packages/lib/commands/synchronize.js
packages/lib/commands/toggleAllFolders.test.js
packages/lib/commands/toggleAllFolders.js
packages/lib/commands/toggleEditorPlugin.js
packages/lib/components/EncryptionConfigScreen/utils.test.js
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ packages/lib/commands/renderMarkup.test.js
packages/lib/commands/renderMarkup.js
packages/lib/commands/showEditorPlugin.js
packages/lib/commands/synchronize.js
packages/lib/commands/toggleAllFolders.test.js
packages/lib/commands/toggleAllFolders.js
packages/lib/commands/toggleEditorPlugin.js
packages/lib/components/EncryptionConfigScreen/utils.test.js
Expand Down
25 changes: 19 additions & 6 deletions Joplin_install_and_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,22 @@ showHelp() {
}

#-----------------------------------------------------
# PARSE ARGUMENTS
# Setup Download Helper: DL
#-----------------------------------------------------
if [[ `command -v wget2` ]]; then
DL='wget2 -qO'
elif [[ `command -v wget` ]]; then
DL='wget -qO'
elif [[ `command -v curl` ]]; then
DL='curl -sLo'
else
print "${COLOR_RED}Error: wget2, wget, and curl not found. Please install one of these tools.${COLOR_RESET}"
exit 1
fi

#-----------------------------------------------------
# PARSE ARGUMENTS
#-----------------------------------------------------
optspec=":h-:"
while getopts "${optspec}" OPT; do
[ "${OPT}" = " " ] && continue
Expand Down Expand Up @@ -140,9 +153,9 @@ fi

# Get the latest version to download
if [[ "$INCLUDE_PRE_RELEASE" == true ]]; then
RELEASE_VERSION=$(wget -qO - "https://api.github.com/repos/laurent22/joplin/releases" | grep -Po '"tag_name": ?"v\K.*?(?=")' | sort -rV | head -1)
RELEASE_VERSION=$($DL - "https://api.github.com/repos/laurent22/joplin/releases" | grep -Po '"tag_name": ?"v\K.*?(?=")' | sort -rV | head -1)
else
RELEASE_VERSION=$(wget -qO - "https://api.github.com/repos/laurent22/joplin/releases/latest" | grep -Po '"tag_name": ?"v\K.*?(?=")')
RELEASE_VERSION=$($DL - "https://api.github.com/repos/laurent22/joplin/releases/latest" | grep -Po '"tag_name": ?"v\K.*?(?=")')
fi

# Check if it's in the latest version
Expand All @@ -163,8 +176,8 @@ fi
#-----------------------------------------------------
print 'Downloading Joplin...'
TEMP_DIR=$(mktemp -d)
wget -O "${TEMP_DIR}/Joplin.AppImage" "https://objects.joplinusercontent.com/v${RELEASE_VERSION}/Joplin-${RELEASE_VERSION}.AppImage?source=LinuxInstallScript&type=$DOWNLOAD_TYPE"
wget -O "${TEMP_DIR}/joplin.png" https://joplinapp.org/images/Icon512.png
$DL "${TEMP_DIR}/Joplin.AppImage" "https://objects.joplinusercontent.com/v${RELEASE_VERSION}/Joplin-${RELEASE_VERSION}.AppImage?source=LinuxInstallScript&type=$DOWNLOAD_TYPE"
$DL "${TEMP_DIR}/joplin.png" https://joplinapp.org/images/Icon512.png

#-----------------------------------------------------
print 'Installing Joplin...'
Expand Down Expand Up @@ -287,7 +300,7 @@ echo "$RELEASE_VERSION" > "${INSTALL_DIR}/VERSION"

#-----------------------------------------------------
if [[ "$SHOW_CHANGELOG" == true ]]; then
NOTES=$(wget -qO - https://api.github.com/repos/laurent22/joplin/releases/latest | grep -Po '"body": "\K.*(?=")')
NOTES=$($DL - https://api.github.com/repos/laurent22/joplin/releases/latest | grep -Po '"body": "\K.*(?=")')
print "${COLOR_BLUE}Changelog:${COLOR_RESET}\n${NOTES}"
fi

Expand Down
1 change: 1 addition & 0 deletions packages/app-desktop/gui/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ function useMenu(props: Props) {
shim.isMac() ? noItem : menuItemDic.toggleMenuBar,
menuItemDic.toggleNoteList,
menuItemDic.toggleVisiblePanes,
menuItemDic.toggleEditorPlugin,
{
label: _('Layout button sequence'),
submenu: layoutButtonSequenceMenuItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ interface CollapseExpandAllButtonProps {
}

const CollapseExpandAllButton = (props: CollapseExpandAllButtonProps) => {
// To allow it to be accessed by accessibility tools, the new folder button
// To allow it to be accessed by accessibility tools, the toggle button
// is not included in the portion of the list with role='tree'.
const icon = props.allFoldersCollapsed ? 'far fa-caret-square-right' : 'far fa-caret-square-down';
const label = props.allFoldersCollapsed ? _('Expand all notebooks') : _('Collapse all notebooks');

return <button onClick={() => onToggleAllFolders(props.allFoldersCollapsed)} className='sidebar-header-button -collapseall'>
<i
aria-label={_('Collapse / Expand all notebooks')}
aria-label={label}
role='img'
className={icon}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/app-desktop/gui/menuCommandNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function() {
'togglePerFolderSortOrder',
'toggleSideBar',
'toggleVisiblePanes',
'toggleEditorPlugin',
'toggleTabMovesFocus',
'editor.deleteLine',
'editor.duplicateLine',
Expand Down
36 changes: 36 additions & 0 deletions packages/lib/commands/toggleAllFolders.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { setupDatabase, switchClient } from '../testing/test-utils';
import { runtime } from './toggleAllFolders';
import Setting from '../models/Setting';
import { CommandContext } from '../services/CommandService';
import { defaultState } from '../reducer';

const command = runtime();

const makeContext = (): CommandContext => {
return {
state: defaultState,
dispatch: ()=>{},
};
};

describe('toggleAllFolders', () => {

beforeEach(async () => {
await setupDatabase(0);
await switchClient(0);
});

test('expanding all should expand the folders header, if previously collapsed', async () => {
Setting.setValue('folderHeaderIsExpanded', false);

// Collapsing all should leave the folder header as-is
const context = makeContext();
await command.execute(context, true);
expect(Setting.value('folderHeaderIsExpanded')).toBe(false);

// Expanding all should also expand the folder header
await command.execute(context, false);
expect(Setting.value('folderHeaderIsExpanded')).toBe(true);
});

});
5 changes: 5 additions & 0 deletions packages/lib/commands/toggleAllFolders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CommandRuntime, CommandDeclaration, CommandContext } from '../services/CommandService';
import { _ } from '../locale';
import getCanBeCollapsedFolderIds from '../models/utils/getCanBeCollapsedFolderIds';
import Setting from '../models/Setting';

export const declaration: CommandDeclaration = {
name: 'toggleAllFolders',
Expand All @@ -10,6 +11,10 @@ export const declaration: CommandDeclaration = {
export const runtime = (): CommandRuntime => {
return {
execute: async (context: CommandContext, collapseAll: boolean) => {
if (!collapseAll && !Setting.value('folderHeaderIsExpanded')) {
Setting.setValue('folderHeaderIsExpanded', true);
}

context.dispatch({
type: 'FOLDER_SET_COLLAPSED',
ids: collapseAll ? getCanBeCollapsedFolderIds(context.state.folders) : [],
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/commands/toggleEditorPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ export const runtime = (): CommandRuntime => {
});
}
},

enabledCondition: 'hasActivePluginEditor',
};
};
4 changes: 3 additions & 1 deletion packages/lib/models/Note_CustomSortOrder.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const time = require('../time').default;
const { setupDatabaseAndSynchronizer, switchClient } = require('../testing/test-utils.js');
const { setupDatabaseAndSynchronizer, switchClient, msleep } = require('../testing/test-utils.js');
const Folder = require('../models/Folder').default;
const Note = require('../models/Note').default;

Expand Down Expand Up @@ -95,6 +95,8 @@ describe('models/Note_CustomSortOrder', () => {

const timeBefore = time.unixMs();

await msleep(10);

await Note.insertNotesAt(folder1.id, [note2.id], 0);
await Note.insertNotesAt(folder1.id, [note1.id], 1);

Expand Down
2 changes: 2 additions & 0 deletions packages/lib/services/KeymapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const defaultKeymapItems = {
{ accelerator: 'Option+Cmd+S', command: 'toggleSideBar' },
{ accelerator: 'Option+Cmd+L', command: 'toggleNoteList' },
{ accelerator: 'Cmd+L', command: 'toggleVisiblePanes' },
{ accelerator: 'Option+Cmd+V', command: 'toggleEditorPlugin' },
{ accelerator: 'Cmd+0', command: 'zoomActualSize' },
{ accelerator: 'Cmd+E', command: 'toggleExternalEditing' },
{ accelerator: 'Option+Cmd+T', command: 'setTags' },
Expand Down Expand Up @@ -93,6 +94,7 @@ const defaultKeymapItems = {
{ accelerator: 'Ctrl+Shift+M', command: 'toggleMenuBar' },
{ accelerator: 'F11', command: 'toggleNoteList' },
{ accelerator: 'Ctrl+L', command: 'toggleVisiblePanes' },
{ accelerator: 'Alt+Ctrl+V', command: 'toggleEditorPlugin' },
{ accelerator: 'Ctrl+0', command: 'zoomActualSize' },
{ accelerator: 'Ctrl+E', command: 'toggleExternalEditing' },
{ accelerator: 'Ctrl+Alt+T', command: 'setTags' },
Expand Down
6 changes: 6 additions & 0 deletions packages/lib/services/commands/stateToWhenClauseContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FolderEntity, NoteEntity } from '../database/types';
import { itemIsReadOnlySync, ItemSlice } from '../../models/utils/readOnly';
import ItemChange from '../../models/ItemChange';
import { getTrashFolderId } from '../trash';
import getActivePluginEditorView from '../plugins/utils/getActivePluginEditorView';

export interface WhenClauseContextOptions {
commandFolderId?: string;
Expand Down Expand Up @@ -43,6 +44,7 @@ export interface WhenClauseContext {
oneNoteSelected: boolean;
someNotesSelected: boolean;
syncStarted: boolean;
hasActivePluginEditor: boolean;
}

export default function stateToWhenClauseContext(state: State, options: WhenClauseContextOptions = null): WhenClauseContext {
Expand All @@ -61,6 +63,8 @@ export default function stateToWhenClauseContext(state: State, options: WhenClau
const commandFolderId = options.commandFolderId || windowState.selectedFolderId;
const commandFolder: FolderEntity = commandFolderId ? BaseModel.byId(state.folders, commandFolderId) : null;

const { editorPlugin } = state.pluginService ? getActivePluginEditorView(state.pluginService.plugins) : { editorPlugin: null };

const settings = state.settings || {};

return {
Expand Down Expand Up @@ -108,5 +112,7 @@ export default function stateToWhenClauseContext(state: State, options: WhenClau
joplinServerConnected: [9, 10].includes(settings['sync.target']),
joplinCloudAccountType: settings['sync.target'] === 10 ? settings['sync.10.accountType'] : 0,
hasMultiProfiles: state.profileConfig && state.profileConfig.profiles.length > 1,

hasActivePluginEditor: !!editorPlugin,
};
}
7 changes: 5 additions & 2 deletions packages/lib/shim-init-node.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

const { shimInit } = require('./shim-init-node');
import shim from './shim';
import { setupDatabaseAndSynchronizer, supportDir } from './testing/test-utils';
import { createTempDir, setupDatabaseAndSynchronizer, supportDir } from './testing/test-utils';
import { copyFile } from 'fs-extra';

describe('shim-init-node', () => {
Expand All @@ -19,8 +19,11 @@ describe('shim-init-node', () => {
});

test('should preserve the file extension if one is provided regardless of the mime type', async () => {
const tempDir = await createTempDir();

const originalFilePath = `${supportDir}/valid_pdf_without_ext`;
const fileWithDifferentExtension = `${originalFilePath}.mscz`;
const fileWithDifferentExtension = `${tempDir}/valid_pdf.mscz`;

await copyFile(originalFilePath, fileWithDifferentExtension);

const resource = await shim.createResourceFromPath(fileWithDifferentExtension);
Expand Down
Loading

0 comments on commit 7b901a1

Please sign in to comment.