Skip to content

Commit 7e59f78

Browse files
committed
JS-8705: update
1 parent 065bbe4 commit 7e59f78

File tree

7 files changed

+45
-9
lines changed

7 files changed

+45
-9
lines changed

CLAUDE.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,13 @@ Use the Figma MCP tools to fetch design context and screenshots from Figma files
181181
- `fileKey` is the ID after `/design/`
182182
- `nodeId` is in the `node-id` query parameter (convert `-` to `:` for the API)
183183

184-
**Example usage:**
184+
**Extract parameters from Figma URLs:**
185185
For URL `https://www.figma.com/design/uWka9aJ7IOdvHch60rIRlb/MyFile?node-id=12769-19003`:
186186
- `fileKey`: `uWka9aJ7IOdvHch60rIRlb`
187-
- `nodeId`: `12769:19003`
187+
- `nodeId`: `12769:19003`
188+
189+
**Important - Icons and Images:**
190+
- All icons and images must be stored locally in `src/img/` - do NOT use remote Figma asset URLs
191+
- When implementing designs from Figma, recreate icons as SVG files in the appropriate `src/img/icon/` subdirectory
192+
- Follow existing icon patterns (e.g., `src/img/icon/add/` for editor control button icons)
193+
- Icons typically have two variants: `name0.svg` (default state, #B6B6B6) and `name1.svg` (hover state, #252525)

src/img/icon/add/preFillName0.svg

Lines changed: 5 additions & 0 deletions
Loading

src/img/icon/add/preFillName1.svg

Lines changed: 5 additions & 0 deletions
Loading

src/json/relation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default {
144144
'type',
145145
'targetObjectType',
146146
'internalFlags',
147-
'sourceObject'
147+
'sourceObject',
148148
],
149149

150150
space: [

src/json/text.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@
618618
"editorControlLayout": "Settings",
619619
"editorControlDescription0": "Show description",
620620
"editorControlDescription1": "Hide description",
621+
"editorControlPrefillName0": "Pre-fill name",
622+
"editorControlPrefillName1": "Empty name",
621623

622624
"editorPagePasteAsHeader": "Paste as",
623625
"editorPagePasteLink": "URL",

src/scss/component/editor/controls.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
.icon.layout { background-image: url('~img/icon/add/layout0.svg'); }
2929
.icon.relation { background-image: url('~img/icon/add/relation0.svg'); }
3030
.icon.description { background-image: url('~img/icon/add/description0.svg'); }
31+
.icon.preFillName { background-image: url('~img/icon/add/preFillName0.svg'); }
3132
}
3233
.btn:hover, .btn.hover {
3334
.icon.icon { background-image: url('~img/icon/add/icon1.svg'); }
3435
.icon.addCover { background-image: url('~img/icon/add/cover1.svg'); }
3536
.icon.layout { background-image: url('~img/icon/add/layout1.svg'); }
3637
.icon.relation { background-image: url('~img/icon/add/relation1.svg'); }
3738
.icon.description { background-image: url('~img/icon/add/description1.svg'); }
39+
.icon.preFillName { background-image: url('~img/icon/add/preFillName1.svg'); }
3840
}
3941

4042
&.isDraggingOver { background: var(--color-system-drop-zone); }

src/ts/component/page/elements/head/controlButtons.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { forwardRef, useEffect, useRef, useState, useImperativeHandle } f
22
import $ from 'jquery';
33
import { observer } from 'mobx-react';
44
import { Icon } from 'Component';
5-
import { I, S, U, J, translate, analytics, focus, Renderer, Relation, Action, Onboarding, keyboard } from 'Lib';
5+
import { I, C, S, U, J, translate, analytics, focus, Renderer, Relation, Action, Onboarding, keyboard } from 'Lib';
66

77
interface Props {
88
rootId: string;
@@ -32,8 +32,10 @@ const ControlButtons = observer(forwardRef<ControlButtonsRef, Props>((props, ref
3232
const isBookmark = U.Object.isBookmarkLayout(root?.layout);
3333
const isChat = U.Object.isChatLayout(root?.layout);
3434
const isType = U.Object.isTypeLayout(root?.layout);
35-
const object = S.Detail.get(rootId, rootId, [ 'featuredRelations', 'targetObjectType', 'layoutAlign' ]);
35+
const object = S.Detail.get(rootId, rootId, [ 'featuredRelations', 'targetObjectType', 'layoutAlign', 'type', 'templateNamePrefillType' ]);
36+
const isTemplate = U.Object.isTemplateType(object.type);
3637
const hasDescription = Relation.getArrayValue(object.featuredRelations).includes('description');
38+
const prefillType = Number(object.templateNamePrefillType) || 0;
3739
const hasConflict = U.Object.hasLayoutConflict(object);
3840
const check = U.Data.checkDetails(rootId);
3941
const nodeRef = useRef(null);
@@ -68,6 +70,10 @@ const ControlButtons = observer(forwardRef<ControlButtonsRef, Props>((props, ref
6870
Action.toggleFeatureRelation(rootId, 'description');
6971
};
7072

73+
const onPrefillNameHandler = (e: any) => {
74+
C.ObjectListSetDetails([ rootId ], [ { key: 'templateNamePrefillType', value: prefillType ? 0 : 1 } ]);
75+
};
76+
7177
const onCoverHandler = (e: any) => {
7278
e.preventDefault();
7379
e.stopPropagation();
@@ -158,14 +164,15 @@ const ControlButtons = observer(forwardRef<ControlButtonsRef, Props>((props, ref
158164
});
159165
};
160166

161-
const getAllowedButtons = (): { allowedIcon: boolean, allowedLayout: boolean, allowedCover: boolean, allowedDescription: boolean } => {
167+
const getAllowedButtons = (): { allowedIcon: boolean, allowedLayout: boolean, allowedCover: boolean, allowedDescription: boolean, allowedPrefillName: boolean } => {
162168
let allowedLayout = false;
163169
let allowedIcon = false;
164170
let allowedCover = false;
165171
let allowedDescription = false;
172+
let allowedPrefillName = false;
166173

167174
if (!root) {
168-
return { allowedIcon, allowedLayout, allowedCover, allowedDescription };
175+
return { allowedIcon, allowedLayout, allowedCover, allowedDescription, allowedPrefillName };
169176
};
170177

171178
const allowedDetails = S.Block.checkFlags(rootId, rootId, [ I.RestrictionObject.Details ]);
@@ -174,6 +181,7 @@ const ControlButtons = observer(forwardRef<ControlButtonsRef, Props>((props, ref
174181
allowedIcon = allowedDetails && !isTask && !isNote && !isBookmark && !isType;
175182
allowedCover = allowedDetails && !isNote && !isType;
176183
allowedDescription = allowedDetails && !isNote;
184+
allowedPrefillName = allowedDetails && isTemplate;
177185

178186
if (isInSets && !hasConflict) {
179187
allowedLayout = false;
@@ -184,17 +192,18 @@ const ControlButtons = observer(forwardRef<ControlButtonsRef, Props>((props, ref
184192
allowedLayout = false;
185193
allowedCover = false;
186194
allowedDescription = false;
195+
allowedPrefillName = false;
187196
};
188197

189-
return { allowedIcon, allowedLayout, allowedCover, allowedDescription };
198+
return { allowedIcon, allowedLayout, allowedCover, allowedDescription, allowedPrefillName };
190199
};
191200

192201
const resize = () => {
193202
const { ww } = U.Common.getWindowDimensions();
194203
$(nodeRef.current).toggleClass('small', ww <= 900);
195204
};
196205

197-
const { allowedIcon, allowedLayout, allowedCover, allowedDescription } = getAllowedButtons();
206+
const { allowedIcon, allowedLayout, allowedCover, allowedDescription, allowedPrefillName } = getAllowedButtons();
198207

199208
useEffect(() => {
200209
if (allowedDescription) {
@@ -238,6 +247,13 @@ const ControlButtons = observer(forwardRef<ControlButtonsRef, Props>((props, ref
238247
</div>
239248
) : ''}
240249

250+
{allowedPrefillName ? (
251+
<div id="button-prefill-name" className="btn white withIcon" onClick={onPrefillNameHandler}>
252+
<Icon className="preFillName" />
253+
<div className="txt">{translate(`editorControlPrefillName${prefillType}`)}</div>
254+
</div>
255+
) : ''}
256+
241257
{allowedLayout ? (
242258
<div id="button-layout" className="btn white withIcon small" onClick={onLayoutHandler}>
243259
<Icon className="layout" />

0 commit comments

Comments
 (0)