本文整理汇总了TypeScript中paperclip.getPCStartTagAttribute函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getPCStartTagAttribute函数的具体用法?TypeScript getPCStartTagAttribute怎么用?TypeScript getPCStartTagAttribute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPCStartTagAttribute函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getAllModules
export const getPreviewComponentEntries = (state: ApplicationState): AllComponentsPreviewEntry[] => {
const allModules = getAllModules(state);
const entries: AllComponentsPreviewEntry[] = [];
let currentTop = 0;
for (const module of allModules) {
if (module.type !== PCModuleType.COMPONENT) {
continue;
}
for (const component of (module as ComponentModule).components) {
// TODO - check for preview meta
for (let i = 0, {length} = component.previews; i < length; i++) {
const preview = component.previews[i];
const width = Number(getPCStartTagAttribute(preview.source, "width") || DEFAULT_COMPONENT_PREVIEW_SIZE.width);
const height = Number(getPCStartTagAttribute(preview.source, "height") || DEFAULT_COMPONENT_PREVIEW_SIZE.height);
const bounds = { left: 0, top: currentTop, right: width, bottom: currentTop + height };
entries.push({
bounds,
componentId: component.id,
previewName: preview.name || String(i),
relativeFilePath: getPublicSrcPath(module.uri, state)
});
currentTop = bounds.bottom;
}
}
}
return entries;
};
开发者ID:cryptobuks,项目名称:tandem,代码行数:35,代码来源:index.ts
示例2: getStartTag
const transpileElement = (element: PCElement | PCSelfClosingElement, context: TranspileElementContext) => {
const startTag = getStartTag(element);
const tagName = startTag.name;
const componentInfo = context.childComponentInfo[tagName];
if (tagName === "slot") {
const slotName = getPCStartTagAttribute(element, "name");
return `${ slotName ? getSlotName(slotName) : "children" }`;
}
let tagContent: string;
if (componentInfo) {
const childDep = componentInfo;
const component = getComponentFromModule(tagName, childDep.module);
const componentDepInfo = getComponentTranspileInfo(component);
tagContent = `childComponentClasses.${componentDepInfo.className}`;
} else {
tagContent = `"${tagName}"`;
}
// TODO - need to check if node is component
let content = `React.createElement(${tagContent}, ${transpileAttributes(element, context, Boolean(componentInfo))}, ` +
getElementChildNodes(element).map(node => transpileNode(node, context)).filter(Boolean).join(", ") +
`)`;
return content;
};
开发者ID:cryptobuks,项目名称:tandem,代码行数:30,代码来源:module.ts
示例3: traversePCAST
traversePCAST(root, (child) => {
if (isTag(child) && getStartTag(child as PCElement).name === "slot") {
const slotName = getPCStartTagAttribute(child as PCElement, "name");
slotNames.push(slotName ? getSlotName(getPCStartTagAttribute(child as PCElement, "name")) : "children");
}
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:6,代码来源:utils.ts
示例4:
slottedElements.forEach((element) => {
content += `"${getSlotName(getPCStartTagAttribute(element, "slot"))}": ${transpileModifiedElement(element, context)},`
});
开发者ID:cryptobuks,项目名称:tandem,代码行数:3,代码来源:module.ts
示例5: getTagHover
function getTagHover(element: PCSelfClosingElement|PCElement, range: Range, open: boolean): Hover | Promise<Hover> {
const startTag = element.type === PCExpressionType.SELF_CLOSING_ELEMENT ? (element as PCSelfClosingElement) : (element as PCElement).startTag;
const { name: tagName } = startTag;
const tagLower = tagName.toLowerCase();
if (tagLower === "preview") {
const ancestors = getAncestors(element, root);
const component = ancestors[0];
const id = getPCStartTagAttribute(component, "id");
const previewName = getPCStartTagAttribute(element, "name") || component.childNodes.indexOf(element);
if (!id) {
return NULL_HOVER;
}
const hoverFilePath = path.join(TMP_DIRECTORY, `${id.replace(/\-/g, "")}.png`);
return (async () => {
// Hack. Must save files to local FS for some reason.
try {
await new Promise((resolve, reject) => {
request({ url: `http://127.0.0.1:${devToolsPort}/components/${id}/screenshots/${previewName}/latest?maxWidth=300&maxHeight=240`, encoding: null }, (err, response, body) => {
if (err) return reject();
if (response.statusCode !== 200) {
return reject(new Error("not found"));
}
fs.writeFileSync(hoverFilePath, body);
resolve();
})
});
} catch(e) {
return {
contents: `Preview could not be loaded. `,
isTrusted: true
};
}
return {
// timestamp for cache buster
contents: `![component preview](file://${hoverFilePath}?${Date.now()})`
};
})();
}
for (const provider of tagProviders) {
let hover: Hover | null = null;
provider.collectTags((t, label) => {
if (t === tagLower) {
const tagLabel = open ? '<' + tagLower + '>' : '</' + tagLower + '>';
hover = { contents: [{ language: 'html', value: tagLabel }, MarkedString.fromPlainText(label)], range };
}
});
if (hover) {
return hover;
}
}
return NULL_HOVER;
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:65,代码来源:htmlHover.ts
注:本文中的paperclip.getPCStartTagAttribute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论