Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
5682b92
Page view: Add link field control
gigitux Sep 10, 2024
98c65ea
Drag and Drop: When dragging a mix of video, audio, and image blocks,…
andrewserong Sep 11, 2024
da8f874
Disallow setting grid block rows/columns to zero (#65217)
talldan Sep 11, 2024
ec58c51
Image: Adds the block controls for uploading image. (#64320)
vipul0425 Sep 11, 2024
6a60081
Fix resizing to max width in classic themes (#64819)
kevin940726 Sep 11, 2024
2f939a7
Fix image block crash (#65222)
t-hamano Sep 11, 2024
e820a6c
Merge branch 'add/@wordpress-fields' of github.com:gigitux/gutenberg …
gigitux Sep 11, 2024
20ca80f
DatePicker: better hover/focus styles (#65117)
ciampo Sep 11, 2024
5daa582
Navigator Screen: warn if path doesn't follow a URL-like scheme (#65231)
ciampo Sep 11, 2024
3d5dacd
Populate block context with inherited post type from template slug (#…
SantosGuillamot Sep 11, 2024
b276647
Remove Warning and add notice for Navigation (#63921)
AKSHAT2802 Sep 11, 2024
f8a19eb
Build: Prepare build for more script modules (#65064)
sirreal Sep 11, 2024
30def0b
Merge branch 'add/@wordpress-fields' of github.com:gigitux/gutenberg …
gigitux Sep 11, 2024
0855668
move slug field control to @wordpress/fields package
gigitux Sep 11, 2024
0c0e605
Add @wordpress/fields package (#65230)
gigitux Sep 11, 2024
e1ad8c2
Improve Tabs indicator animation and related utils (#64926)
DaniGuardiola Sep 11, 2024
f1aa523
Fix Content Only Toolbar icon focus style (#64940)
jeryj Sep 11, 2024
a15a93d
Remove colons from control labels (#65205)
mirka Sep 11, 2024
8a7df39
Fix: Moving the last page item to the the trash causes a crash. (#65236)
jorgefilipecosta Sep 11, 2024
8a74d31
Normalize block inspector controls spacing (#64526)
mirka Sep 11, 2024
d5ab90a
Bump plugin version to 19.2.0
gutenbergplugin Sep 11, 2024
e9d31c2
Update Changelog for 19.2.0
gutenbergplugin Sep 11, 2024
f073eb1
Add the spacing for horizontal and vertical for block gap on buttons …
hbhalodia Sep 12, 2024
f1403c4
Plugin: Remove 'function_exists' checks for methods with 'gutenberg' …
Mamaduka Sep 12, 2024
d649865
Scripts: Update stylelint dependency and the default config (#64828)
mikeybinns Sep 12, 2024
0e671a2
Show top level sections in List View in Zoom Out mode (#65202)
getdave Sep 12, 2024
394288f
Add __next40pxDefaultSize for files in editor 4 (#65140)
AKSHAT2802 Sep 12, 2024
a76c475
Close inserter on exiting Zoom Out to edit (#65194)
getdave Sep 12, 2024
1a60dff
Make `wordpress/fields` a private package (#65269)
oandregal Sep 12, 2024
9bdfebf
Build Plugin: Simplify and improve zip contents (#65232)
sirreal Sep 12, 2024
bc60075
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/link-…
gigitux Sep 12, 2024
f88e629
A11y: Add Script Module (#65101)
sirreal Sep 12, 2024
92661e7
Build Tooling: Correctly generate PHP files for server-side rendering…
t-hamano Sep 12, 2024
297e9ca
Form Input: Don't use `flex-direction: row-reverse` for checkbox fiel…
t-hamano Sep 12, 2024
33bdcbc
Remove babel from script-modules build (#65279)
sirreal Sep 12, 2024
3368298
Switch from UglifyJS to Terser to build the polyfill script (#65278)
jsnajdr Sep 12, 2024
0cbc7be
Fix typo in Slot Fills documentation (#65275)
greenworld Sep 12, 2024
a18d831
Add props for buttons in editor 2 (#65083)
AKSHAT2802 Sep 12, 2024
4c31695
Update: Remove unused css selectors. (#65276)
jorgefilipecosta Sep 12, 2024
67fe7b0
Add Zoom Out toggle to editor header when experiment enabled (#65183)
getdave Sep 12, 2024
eba5eb7
Block Bindings: Try gap 0 on attribute items. (#65277)
cbravobernal Sep 12, 2024
d329bfb
[Fields] Migrate store and actions from editor package to fields pack…
gigitux Sep 12, 2024
fb4ba26
Align popover alt variant styling with block toolbar (#65263)
jameskoster Sep 12, 2024
6d32f4f
BoxControl: Fix critical error when null value is passed (#65287)
t-hamano Sep 12, 2024
a895274
Add props for buttons in editor 1 (#65068)
AKSHAT2802 Sep 12, 2024
1664022
Grid: In RTL languages, the resize handles point in the opposite dire…
rohitmathur-7 Sep 13, 2024
632d8d6
Spacing control: Replace sides dropdwon with link button (#65193)
madhusudhand Sep 13, 2024
33e2fad
Styleling config: Fix stylelint config missing files for npm (#65313)
mikeybinns Sep 13, 2024
dfc28b0
Patterns: Change deprecated social icons for standard in e2e (#65312)
cbravobernal Sep 13, 2024
12660ca
DataViews: improve UX of bundled views for Pages (#65295)
oandregal Sep 13, 2024
b0abc74
Split content view with meta boxes (#64351)
stokesman Sep 13, 2024
9e88d86
Update minimum required version in PHP. (#65301)
peterwilsoncc Sep 13, 2024
257d26a
DimensionsPanel: Apply 40px default size to UI when no spacing preset…
t-hamano Sep 13, 2024
8a815ee
DataViews: Use Dropdown for views config dialog (#65314)
ntsekouras Sep 13, 2024
e102033
Block Editor: Use static access for selector in 'useZoomOutModeExit' …
Mamaduka Sep 13, 2024
1df91fb
Add: Typography styling support to the navigation submenu block. (#65…
jorgefilipecosta Sep 13, 2024
b10ca39
Editor: Use hooks instead of HoC in `BlockManager` (#65349)
t-hamano Sep 14, 2024
9f79666
Global Styles: refactor site background controls and move site global…
ramonjd Sep 16, 2024
45d33f0
Query loop / Post template: Enable post format filter (#64167)
carolinan Sep 16, 2024
ea0ea78
Put Replace in own group to give it borders (#64849)
jeryj Sep 16, 2024
d9e3075
Pass the comments query paged arg to functions (#63698)
SantosGuillamot Sep 16, 2024
38e74db
Add JSDoc block for getSectionRootClientId in block editor package (#…
colorful-tones Sep 16, 2024
4ca78cd
Fix Tabs styling in Font Library modal (#65330)
mirka Sep 16, 2024
c80fc61
Fix: Button: Replace remaining 40px default size violation [Edit Site…
hbhalodia Sep 16, 2024
edd4148
Convert EmbedPreview component to functional component (#51325)
louwie17 Sep 16, 2024
e2d7722
Update Card radius (#65053)
jameskoster Sep 16, 2024
2ac16e0
Docs: Update the content of the API version 3 section in the Block AP…
t-hamano Sep 16, 2024
c0e3ad8
Bump the react-native group across 1 directory with 2 updates (#65321)
dependabot[bot] Sep 16, 2024
788bb9e
DocumentBar: replace icon with post type label (#65170)
creativecoder Sep 17, 2024
46d898e
Global Styles: Update REST controller override method and backport ch…
Mamaduka Sep 17, 2024
d32a5b6
BoxControl: Add lint rule for 40px size prop usage (#65341)
mirka Sep 17, 2024
5b037d7
ButtonGroup: Fix story to show what the component does (#65336)
mirka Sep 17, 2024
1a23ed6
Image cropping: skip making an API request if there are no changes to…
andrewserong Sep 17, 2024
f82bc32
Add __next40pxDefaultSize for files in editor 3 (#65139)
AKSHAT2802 Sep 17, 2024
3a2f74f
Rename edit-post__fade-in-animation and unify keyframe definitions (#…
ciampo Sep 17, 2024
524516d
Add __next40pxDefaultSize for edit-widgets files (#65367)
dhruvang21 Sep 17, 2024
d95c35d
Merge branch 'trunk' of github.com:WordPress/gutenberg into add/link-…
gigitux Sep 17, 2024
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
Next Next commit
Page view: Add link field control
  • Loading branch information
gigitux committed Sep 10, 2024
commit 5682b928356f624f6ed820d066689423d08d5d88
9 changes: 8 additions & 1 deletion packages/edit-site/src/components/post-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ function PostEditForm( { postType, postId } ) {
);
const form = {
type: 'panel',
fields: [ 'title', 'status', 'date', 'author', 'comment_status' ],
fields: [
'title',
'status',
'date',
'author',
'slug',
'comment_status',
],
};
const onChange = ( edits ) => {
for ( const id of ids ) {
Expand Down
165 changes: 163 additions & 2 deletions packages/edit-site/src/components/post-fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
createInterpolateElement,
useMemo,
useState,
useCallback,
useRef,
useEffect,
} from '@wordpress/element';
import { dateI18n, getDate, getSettings } from '@wordpress/date';
import {
Expand All @@ -22,10 +25,22 @@ import {
pending,
notAllowed,
commentAuthorAvatar as authorIcon,
copySmall,
} from '@wordpress/icons';
import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalInputControl as InputControl,
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
ExternalLink,
Icon,
Button,
} from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
import { useCopyToClipboard } from '@wordpress/compose';
import { safeDecodeURIComponent } from '@wordpress/url';
import { store as noticesStore } from '@wordpress/notices';

/**
* Internal dependencies
Expand Down Expand Up @@ -175,6 +190,21 @@ function PostAuthorField( { item } ) {
);
}

function LinkField( { item } ) {
const slug = item.slug;
const originalSlug = useRef( slug );

useEffect( () => {
if ( slug && originalSlug.current === undefined ) {
originalSlug.current = slug;
}
}, [ slug ] );

const slugToDisplay = slug || originalSlug.current;

return `/${ slugToDisplay ?? '' }`;
}

function usePostFields( viewType ) {
const { records: authors, isResolving: isLoadingAuthors } =
useEntityRecords( 'root', 'user', { per_page: -1 } );
Expand Down Expand Up @@ -369,6 +399,137 @@ function usePostFields( viewType ) {
return <time>{ getFormattedDate( item.date ) }</time>;
},
},
{
label: __( 'Link' ),
id: 'slug',
getValue: ( { item } ) => item.slug,
render: LinkField,
Edit: ( { field, onChange, data } ) => {
const { id } = field;

const slug = field.getValue( { item: data } ) ?? '';
const permalinkTemplate = data.permalink_template || '';
const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
const [ prefix, suffix ] = permalinkTemplate.split(
PERMALINK_POSTNAME_REGEX
);
const permalinkPrefix = prefix;
const permalinkSuffix = suffix;
const isEditable =
PERMALINK_POSTNAME_REGEX.test( permalinkTemplate );
const originalSlug = useRef( slug );
const slugToDisplay = slug || originalSlug.current;
const permalink = isEditable
? `${ permalinkPrefix }${ slugToDisplay }${ permalinkSuffix }`
: safeDecodeURIComponent( data.link || '' );

useEffect( () => {
if ( slug && originalSlug.current === undefined ) {
originalSlug.current = slug;
}
}, [ slug ] );

const onChangeControl = useCallback(
( newValue ) =>
onChange( {
[ id ]: newValue,
} ),
[ id, onChange ]
);

const { createNotice } = useDispatch( noticesStore );

const copyButtonRef = useCopyToClipboard( permalink, () => {
createNotice(
'info',
__( 'Copied URL to clipboard.' ),
{
isDismissible: true,
type: 'snackbar',
}
);
} );

return (
<fieldset className="edit-site-dataviews-controls__slug">
{ isEditable && (
<VStack>
<VStack spacing="0px">
<span>
{ __(
'Customize the last part of the URL.'
) }
</span>
<ExternalLink
href="https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink"
target="_blank"
>
{ __( 'Learn more' ) }
</ExternalLink>
</VStack>
<InputControl
__next40pxDefaultSize
prefix={
<InputControlPrefixWrapper>
/
</InputControlPrefixWrapper>
}
suffix={
<Button
__next40pxDefaultSize
icon={ copySmall }
ref={ copyButtonRef }
label={ __( 'Copy' ) }
/>
}
label={ __( 'Link' ) }
hideLabelFromVision
value={ slug }
autoComplete="off"
spellCheck="false"
type="text"
className="edit-site-dataviews-controls__slug-input"
onChange={ ( newValue ) => {
onChangeControl( newValue );
} }
onBlur={ () => {
if ( slug === '' ) {
onChangeControl(
originalSlug.current
);
}
} }
help={
<ExternalLink
className="edit-site-dataviews-controls__slug-help"
href={ permalink }
target="_blank"
>
<span>{ permalinkPrefix }</span>
<span className="edit-site-dataviews-controls__slug-help-slug">
{ slugToDisplay }
</span>
<span className="edit-site-dataviews-controls__slug-help-suffix">
{ permalinkSuffix }
</span>
</ExternalLink>
}
/>
</VStack>
) }
{ ! isEditable && (
<ExternalLink
className="edit-site-dataviews-controls__slug-help"
href={ permalink }
target="_blank"
>
{ permalink }
</ExternalLink>
) }
</fieldset>
);
},
},
{
id: 'comment_status',
label: __( 'Discussion' ),
Expand Down
19 changes: 19 additions & 0 deletions packages/edit-site/src/components/post-fields/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.edit-site-dataviews-controls__slug {
.edit-site-dataviews-controls__slug-external-icon {
margin-left: 5ch;
}

.edit-site-dataviews-controls__slug-input
input.components-input-control__input {
padding-inline-start: 0 !important;
}

.edit-site-dataviews-controls__slug-help {
color: $gray-700;

.edit-site-dataviews-controls__slug-help-slug,
.edit-site-dataviews-controls__slug-help-suffix {
font-weight: 600;
}
}
}
1 change: 1 addition & 0 deletions packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@import "./components/style-book/style.scss";
@import "./components/editor-canvas-container/style.scss";
@import "./components/post-edit/style.scss";
@import "./components/post-fields/style.scss";
@import "./components/post-list/style.scss";
@import "./components/resizable-frame/style.scss";
@import "./hooks/push-changes-to-global-styles/style.scss";
Expand Down