Skip to content

Commit

Permalink
Merge branch 'main' into feature-table-cell-vertical-align
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL authored Feb 7, 2025
2 parents e740332 + 65bf70d commit 111bc08
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/call-increment-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ on:
channel:
required: true
type: string
git-repo:
required: true
type: string
secrets:
SSH_KEY:
required: true
outputs:
version:
description: 'The new package.json version, e.g. "0.16.0"'
Expand All @@ -35,10 +29,11 @@ jobs:
version: ${{ steps.increment-version.outputs.version }}
tag-ref: ${{ steps.increment-version.outputs.tag-ref }}
latest-release: ${{ steps.latest.outputs.release }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_KEY }}
fetch-depth: 0
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
Expand All @@ -64,4 +59,3 @@ jobs:
CHANNEL: ${{ inputs.channel }}
LATEST_RELEASE: ${{ steps.latest.outputs.release }}
DRY_RUN: ${{ inputs.dry-run && '1' || '' }}
GIT_REPO: ${{ inputs.git-repo }}
3 changes: 0 additions & 3 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ jobs:
channel: nightly
increment: prerelease
dry-run: false
git-repo: '[email protected]:facebook/lexical.git'
secrets:
SSH_KEY: ${{ secrets.SSH_KEY }}
npm-release:
uses: ./.github/workflows/call-npm-publish.yml
needs: [increment-version]
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ jobs:
increment: ${{ inputs.increment }}
dry-run: false
channel: ${{ inputs.increment == 'prerelease' && 'next' || 'latest' }}
git-repo: '[email protected]:facebook/lexical.git'
secrets:
SSH_KEY: ${{ secrets.SSH_KEY }}
7 changes: 7 additions & 0 deletions packages/lexical-react/flow/LexicalLinkPlugin.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
* @flow strict
*/

type LinkAttributes = {
rel?: null | string;
target?: null | string;
title?: null | string;
};

type Props = $ReadOnly<{
validateUrl?: (url: string) => boolean,
attributes?: LinkAttributes,
}>;

declare export function LinkPlugin(props: Props): null;
11 changes: 10 additions & 1 deletion packages/lexical/src/LexicalEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
$getPreviousSelection,
$getRoot,
$getSelection,
$isDecoratorNode,
$isElementNode,
$isRangeSelection,
$isRootNode,
Expand Down Expand Up @@ -79,6 +80,7 @@ import {getActiveEditor, updateEditorSync} from './LexicalUpdates';
import {
$findMatchingParent,
$flushMutations,
$getAdjacentNode,
$getNodeByKey,
$isSelectionCapturedInDecorator,
$isTokenOrSegmented,
Expand Down Expand Up @@ -604,11 +606,18 @@ function onBeforeInput(event: InputEvent, editor: LexicalEditor): void {
const hasSelectedAllTextInNode =
selection.anchor.offset === 0 &&
selection.focus.offset === selectedNodeText.length;
const shouldLetBrowserHandleDelete =
let shouldLetBrowserHandleDelete =
IS_ANDROID_CHROME &&
isSelectionAnchorSameAsFocus &&
!hasSelectedAllTextInNode &&
selectedNodeCanInsertTextAfter;
// Check if selection is collapsed and if the previous node is a decorator node
// If so, the browser will not be able to handle the deletion
if (shouldLetBrowserHandleDelete && selection.isCollapsed()) {
shouldLetBrowserHandleDelete = !$isDecoratorNode(
$getAdjacentNode(selection.anchor, true),
);
}
if (!shouldLetBrowserHandleDelete) {
dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true);
}
Expand Down
13 changes: 13 additions & 0 deletions packages/lexical/src/LexicalSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {NodeKey} from './LexicalNode';
import type {ElementNode} from './nodes/LexicalElementNode';
import type {TextFormatType} from './nodes/LexicalTextNode';

import {IS_ANDROID_CHROME} from 'shared/environment';
import invariant from 'shared/invariant';

import {
Expand Down Expand Up @@ -2915,6 +2916,18 @@ export function updateDOMSelection(
nextFocusNode,
nextFocusOffset,
);
// When deleting text across multiple paragraphs, Chrome on Android shifts selection rightwards
// This is a workaround to restore the correct selection
if (IS_ANDROID_CHROME) {
setTimeout(() => {
domSelection.setBaseAndExtent(
nextAnchorNode,
nextAnchorOffset,
nextFocusNode,
nextFocusOffset,
);
});
}
} catch (error) {
// If we encounter an error, continue. This can sometimes
// occur with FF and there's no good reason as to why it
Expand Down
6 changes: 3 additions & 3 deletions scripts/npm/postversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const {spawn} = require('child-process-promise');

const {npm_package_version, CHANNEL, GIT_REPO, GITHUB_OUTPUT} = process.env;
const {npm_package_version, CHANNEL, GITHUB_OUTPUT} = process.env;

// Previously this script was defined directly in package.json as the
// following (in one line):
Expand All @@ -31,7 +31,6 @@ async function main() {
// CHANNEL should already be validated by increment-version which calls this (indirectly)
for (const [k, v] of Object.entries({
CHANNEL,
GIT_REPO,
npm_package_version,
})) {
if (!v) {
Expand All @@ -57,6 +56,7 @@ async function main() {
[
'git',
'tag',
'-f',
'-a',
`v${npm_package_version}`,
'-m',
Expand All @@ -77,7 +77,7 @@ async function main() {
'git',
'push',
...(process.env.DRY_RUN === '1' ? ['--dry-run'] : []),
GIT_REPO,
'origin',
...refs.map((ref) => `+${ref}`),
]);
if (GITHUB_OUTPUT) {
Expand Down

0 comments on commit 111bc08

Please sign in to comment.