Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5178d1ae
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5178d1ae
编写于
7月 23, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactoring UpdateImageSize.ts for simplicity
上级
56eebb2b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
21 addition
and
32 deletion
+21
-32
extensions/emmet/src/updateImageSize.ts
extensions/emmet/src/updateImageSize.ts
+21
-32
未找到文件。
extensions/emmet/src/updateImageSize.ts
浏览文件 @
5178d1ae
...
@@ -177,27 +177,24 @@ function updateHTMLTag(editor: TextEditor, node: HtmlNode, width: number, height
...
@@ -177,27 +177,24 @@ function updateHTMLTag(editor: TextEditor, node: HtmlNode, width: number, height
const
srcAttr
=
getAttribute
(
node
,
'
src
'
);
const
srcAttr
=
getAttribute
(
node
,
'
src
'
);
const
widthAttr
=
getAttribute
(
node
,
'
width
'
);
const
widthAttr
=
getAttribute
(
node
,
'
width
'
);
const
heightAttr
=
getAttribute
(
node
,
'
height
'
);
const
heightAttr
=
getAttribute
(
node
,
'
height
'
);
const
quote
=
getAttributeQuote
(
editor
,
srcAttr
);
const
endOfAttributes
=
node
.
attributes
[
node
.
attributes
.
length
-
1
].
end
;
let
edits
:
[
Range
,
string
][]
=
[];
let
edits
:
[
Range
,
string
][]
=
[];
let
textToAdd
=
''
;
// apply changes from right to left, first for height, then for width
if
(
!
widthAttr
)
{
let
point
:
Position
;
textToAdd
+=
` width=
${
quote
}${
width
}${
quote
}
`
;
const
quote
=
getAttributeQuote
(
editor
,
widthAttr
||
heightAttr
||
srcAttr
);
}
else
{
edits
.
push
([
new
Range
(
widthAttr
.
value
.
start
,
widthAttr
.
value
.
end
),
String
(
width
)]);
}
if
(
!
heightAttr
)
{
if
(
!
heightAttr
)
{
// no `height` attribute, add it right after `width` or `src`
textToAdd
+=
` height=
${
quote
}${
height
}${
quote
}
`
;
point
=
widthAttr
?
widthAttr
.
end
:
srcAttr
.
end
;
edits
.
push
([
new
Range
(
point
,
point
),
` height=
${
quote
}${
height
}${
quote
}
`
]);
}
else
{
}
else
{
edits
.
push
([
new
Range
(
heightAttr
.
value
.
start
,
heightAttr
.
value
.
end
),
String
(
height
)]);
edits
.
push
([
new
Range
(
heightAttr
.
value
.
start
,
heightAttr
.
value
.
end
),
String
(
height
)]);
}
}
if
(
textToAdd
)
{
if
(
!
widthAttr
)
{
edits
.
push
([
new
Range
(
endOfAttributes
,
endOfAttributes
),
textToAdd
]);
// no `width` attribute, add it right before `height` or after `src`
point
=
heightAttr
?
heightAttr
.
start
:
srcAttr
.
end
;
edits
.
push
([
new
Range
(
point
,
point
),
` width=
${
quote
}${
width
}${
quote
}
`
]);
}
else
{
edits
.
push
([
new
Range
(
widthAttr
.
value
.
start
,
widthAttr
.
value
.
end
),
String
(
width
)]);
}
}
return
editor
.
edit
(
builder
=>
{
return
editor
.
edit
(
builder
=>
{
...
@@ -228,27 +225,19 @@ function updateCSSNode(editor: TextEditor, srcProp: Property, width: number, hei
...
@@ -228,27 +225,19 @@ function updateCSSNode(editor: TextEditor, srcProp: Property, width: number, hei
edits
.
push
([
new
Range
(
srcProp
.
end
,
srcProp
.
end
),
'
;
'
]);
edits
.
push
([
new
Range
(
srcProp
.
end
,
srcProp
.
end
),
'
;
'
]);
}
}
let
point
:
Position
;
let
textToAdd
=
''
;
if
(
!
heightProp
)
{
// no `height` property, add it right after `width` or source property
point
=
widthProp
?
widthProp
.
start
:
srcProp
.
end
;
edits
.
push
([
new
Range
(
point
,
point
),
`
${
before
}
height
${
separator
}${
height
}
px;`
]);
}
else
{
edits
.
push
([
new
Range
(
heightProp
.
valueToken
.
start
,
heightProp
.
valueTokenend
),
`
${
height
}
px`
]);
}
if
(
!
widthProp
)
{
if
(
!
widthProp
)
{
// no `width` attribute, add it right after `height` or source property
textToAdd
+=
`
${
before
}
width
${
separator
}${
width
}
px;`
;
if
(
heightProp
)
{
point
=
heightProp
.
previousSibling
?
heightProp
.
previousSibling
.
end
:
rule
.
contentStartToken
.
end
;
}
else
{
}
else
{
point
=
srcProp
.
end
;
edits
.
push
([
new
Range
(
widthProp
.
valueToken
.
start
,
widthProp
.
valueToken
.
end
),
`
${
width
}
px`
])
;
}
}
edits
.
push
([
new
Range
(
point
,
point
),
`
${
before
}
width
${
separator
}${
width
}
px;`
]);
if
(
!
heightProp
)
{
textToAdd
+=
`
${
before
}
height
${
separator
}${
height
}
px;`
;
}
else
{
}
else
{
edits
.
push
([
new
Range
(
widthProp
.
valueToken
.
start
,
widthProp
.
valueTokenend
),
`
${
width
}
px`
]);
edits
.
push
([
new
Range
(
heightProp
.
valueToken
.
start
,
heightProp
.
valueToken
.
end
),
`
${
height
}
px`
]);
}
if
(
textToAdd
)
{
edits
.
push
([
new
Range
(
srcProp
.
end
,
srcProp
.
end
),
textToAdd
]);
}
}
return
editor
.
edit
(
builder
=>
{
return
editor
.
edit
(
builder
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录