Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/bump-version-on-merge-next.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bump version on merge

# Caution:
# Caution:
# the use of "pull_request_target" trigger allows to successfully
# run workflow even when triggered from a fork. The trigger grants
# access to repo's secrets and gives write permission to the runner.
Expand All @@ -17,7 +17,7 @@ jobs:
# If pull request was merged then we should check for a package version update
check-for-no-version-changing:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
actions: write
steps:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/create-a-release-draft.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Create a release draft

# Caution:
# Caution:
# the use of "pull_request_target" trigger allows to successfully
# run workflow even when triggered from a fork. The trigger grants
# access to repo's secrets and gives write permission to the runner.
Expand All @@ -17,7 +17,7 @@ jobs:
# If pull request was merged then we should check for a package version update
check-version-changing:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
actions: write
steps:
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
asset_path: dist/editorjs.umd.js
asset_name: editorjs.umd.js
asset_content_type: application/javascript

# Build and upload target Editor.js MJS build to release as artifact
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
Expand All @@ -123,7 +123,7 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/editorjs.mjs
asset_name: editorjs.mjs
asset_content_type: application/javascript
asset_content_type: application/javascript

# Send a notification message
- name: Send a message
Expand All @@ -132,4 +132,4 @@ jobs:
webhook: ${{ secrets.CODEX_BOT_WEBHOOK_FRONTEND }}
message: '🦥 [Draft release v${{ steps.package.outputs.version }}](${{ steps.create_release.outputs.html_url }}) for package [${{ steps.package.outputs.name }}](${{ steps.package.outputs.npmjs-link }}) has been created. Add changelog and publish it!'
parse_mode: 'markdown'
disable_web_page_preview: true
disable_web_page_preview: true
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
matrix:
browser: [firefox, chrome, edge]

runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [pull_request]
jobs:
lint:
name: ESlint
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-package-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
publish:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
# Checkout to target branch
- uses: actions/checkout@v4
Expand Down Expand Up @@ -62,4 +62,4 @@ jobs:
webhook: ${{ secrets.CODEX_BOT_NOTIFY_EDITORJS_PUBLIC_CHAT }}
message: '📦 [${{ steps.package.outputs.name }} ${{ steps.package.outputs.version }}](${{ env.GITHUB_LINK }}) was published'
parse_mode: 'markdown'
disable_web_page_preview: true
disable_web_page_preview: true
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 2.31.0

- `New` - Inline tools (those with `isReadOnlySupported` specified) can now be used in read-only mode
- `New` - Inline tools (those with `isReadOnlySupported` specified) shortcuts now work in read-only mode
- `Improvement` - Block manager passes target tool config to the `conversionConfig.import` method on conversion
- `Fix` - Fix selection of first block in read-only initialization with "autofocus=true"
- `Fix` - Incorrect caret position after blocks merging in Safari
Expand Down
5 changes: 4 additions & 1 deletion src/components/modules/toolbar/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,10 @@ export default class InlineToolbar extends Module<InlineToolbarNodes> {

this.popover?.activateItemByName(toolName);
},
on: this.Editor.UI.nodes.redactor,
/**
* We need to bind shortcut to the document to make it work in read-only mode
*/
on: document,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ShortcutData {
/**
* Element handler should be added for
*/
on: HTMLElement;
on: HTMLElement | Document;
}

/**
Expand Down
58 changes: 56 additions & 2 deletions test/cypress/tests/ui/InlineToolbar.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import Header from '@editorjs/header';
import type { MenuConfig } from '../../../../types/tools';
import type { InlineTool, MenuConfig } from '../../../../types/tools';
import { createEditorWithTextBlocks } from '../../support/utils/createEditorWithTextBlocks';

describe('Inline Toolbar', () => {
describe('Separators', () => {
Expand Down Expand Up @@ -174,4 +174,58 @@ describe('Inline Toolbar', () => {
.should('have.attr', 'data-item-name', 'test-tool');
});
});

describe('Shortcuts', () => {
it('should work in read-only mode', () => {
const toolSurround = cy.stub().as('toolSurround');

/* eslint-disable jsdoc/require-jsdoc */
class Marker implements InlineTool {
public static isInline = true;
public static shortcut = 'CMD+SHIFT+M';
public static isReadOnlySupported = true;
public render(): MenuConfig {
return {
icon: 'm',
title: 'Marker',
onActivate: () => {
toolSurround();
},
};
}
}
/* eslint-enable jsdoc/require-jsdoc */

createEditorWithTextBlocks([
'some text',
], {
tools: {
marker: Marker,
},
readOnly: true,
});

cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.selectText('text');

cy.wait(300);

cy.document().then((doc) => {
doc.dispatchEvent(new KeyboardEvent('keydown', {
bubbles: true,
cancelable: true,
key: 'M',
code: 'KeyM',
keyCode: 77,
which: 77,
metaKey: true,
shiftKey: true,
}));
});

cy.get('@toolSurround').should('have.been.called');
});
});
});

4 changes: 2 additions & 2 deletions test/cypress/tests/utils/popover.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ describe('Popover', () => {
.should('exist');
});

it.only('shoould support i18n in nested popover', () => {
it('shoould support i18n in nested popover', () => {
/**
*
*/
Expand Down Expand Up @@ -1076,7 +1076,7 @@ describe('Popover', () => {
.should('exist');
});

it.only('should allow to reach nested popover via keyboard', () => {
it('should allow to reach nested popover via keyboard', () => {
cy.createEditor({
tools: {
header: {
Expand Down
Loading